You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How would I transpose the below code chunk to C#? I'm trying to convert the following python code to be used in C#. The point of this function is to parse a binary file's data into a collection of defined objects.
dtype = np.dtype([
("reading_1", np.float64),
("reading_2", np.float32),
("reading_3", np.float64)
# and so on
])
...
# file is a binary file of the structured data defined above
datachunks = np.fromfile(file, dtype)
# do things with arrays of reading_1, reading_2, reading_3 from datachunks
My roadblock right now is that I do not know how to write the 'dtype' segment in C#. I have tried to declare a struct of my own and using it as a parameter for np.fromfile, which I know will not work because np.fromfile requires a Dtype.
[StructLayout(LayoutKind.Sequential)]
public struct ReadingData
{
public double reading_1;
public float reading_2;
public double reading_1;
}
...
NDArray datachunks = np.fromfile(filename, ReadingData);
// syntax error as ReadingData is not a dtype
I can't find any examples on writing a dtype struct in SciSharp's C# Numpy, so I am stumped.
The text was updated successfully, but these errors were encountered:
I am pretty sure what you are trying to do is not supported, at least the way you are doing it. I would need a minimal python snippet that creates a small file and then reads it back in, you know, just a few numbers in each reading. From that I can try to come up with an equivalent in Numpy.NET.
How would I transpose the below code chunk to C#? I'm trying to convert the following python code to be used in C#. The point of this function is to parse a binary file's data into a collection of defined objects.
My roadblock right now is that I do not know how to write the 'dtype' segment in C#. I have tried to declare a struct of my own and using it as a parameter for np.fromfile, which I know will not work because np.fromfile requires a Dtype.
I can't find any examples on writing a dtype struct in SciSharp's C# Numpy, so I am stumped.
The text was updated successfully, but these errors were encountered: