-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error creating string ND array #50
Comments
Yeah, DateTime and String can't simply be marshalled into Python like Integers or Floats, so I left support for them out for now. I'll look into it. Hope it is not too complicated. |
Gotcha, that's what I was thinking but wanted to make sure. Thanks for the quick response. |
with a little modification an array of strings is already working: [TestMethod]
public void StringArray()
{
//>>> a = numpy.array(['apples', 'foobar', 'cowboy'])
//>>> a[2] = 'bananas'
//>>> a
//array(['apples', 'foobar', 'banana'],
// dtype = '|S6')
var a = np.array(new string[]{"apples", "foobar", "cowboy"});
Assert.AreEqual("array(['apples', 'foobar', 'cowboy'], dtype='<U6')", a.repr);
// todo: a[2]="banana";
a.self.SetItem(new PyInt(2), new PyString("banana"));
Assert.AreEqual("array(['apples', 'foobar', 'banana'], dtype='<U6')", a.repr);
//>>> a = numpy.array(['apples', 'foobar', 'cowboy'], dtype = object)
//>>> a
//array([apples, foobar, cowboy], dtype = object)
//>>> a[2] = 'bananas'
//>>> a
//array([apples, foobar, bananas], dtype = object)
a = np.array(new string[] { "apples", "foobar", "cowboy" }, dtype:np.object_);
Assert.AreEqual("array(['apples', 'foobar', 'cowboy'], dtype=object)", a.repr);
// todo: a[2]="banana";
a.self.SetItem(new PyInt(2), new PyString("banana"));
Assert.AreEqual("array(['apples', 'foobar', 'banana'], dtype=object)", a.repr);
} is that enough for your use case? |
in any case, I released the change as v21 to nuget |
Awesome, that works for me! That was fast too 👍 |
@henon I wouldn't suppose any workarounds exist to getting something like this to work?
|
@amine-aboufirass I created a separate issue for your request: #119 |
Hi,
I'm trying to create an NDarray to store DateTime values from a normal C# array. When I try to create the NDarray I get the following error: Can not convert type of given object to dtype: System.String[].
When I try to make a NDarray<float> it works fine, but for NDarray<DateTime> and NDarray<string> this error occurs. Is there something I am doing wrong here or are these types not supported? Thanks for the help!
The text was updated successfully, but these errors were encountered: