8000 Implement array cast from integer to double · Issue #293 · SciSharp/NumSharp · GitHub
[go: up one dir, main page]

Skip to content

Implement array cast from integer to double #293

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

Closed
Plankton555 opened this issue Jun 26, 2019 · 5 comments
Closed

Implement array cast from integer to double #293

Plankton555 opened this issue Jun 26, 2019 · 5 comments

Comments

@Plankton555
Copy link
Contributor

(Sorry for opening so many issues recently, I'm just reporting the problems I am running into while actually trying to port real-world code from Python to C#. I really appreciate the effort you do to implement a C# version of NumPy.)

Description
Unable to cast an integer array to a double array. System.NotImplementedException: '_ChangeTypeOfArray from Int32 to Double'

Minimum example

static void Main(string[] args)
{
    NDArray mat = np.arange(4).astype(typeof(double)).reshape(2, 2); // throws exception
}

Expected result
The array mat should contain the corresponding values, but casted to double ({0.0, 1.0, 2.0, 3.0}).

@Nucs
Copy link
Member
Nucs commented Jun 26, 2019

This is fixed in an ongoing work on my local branch.
I'll refer to this issue and close it once I finish my work and merge to master.

@Plankton555
Copy link
Contributor Author

Nice, good to hear!

@Plankton555
Copy link
Contributor Author

Would this problem also explain why I get an exception with the following code, or is it a separate problem?

static void Main(string[] args)
{
    NDArray output = np.zeros(5);
    double newValDouble = 2;
    int newValInt = 4;
    output[3] = newValDouble; // This works fine
    output[4] = newValInt; // throws System.NullReferenceException

    Debug.WriteLine($"output: {output}");
}

That is, assigning an integer to an array containing doubles (as initialized from np.zeros) causes an exception.

@henon
Copy link
Contributor
henon commented Jun 27, 2019

(Sorry for opening so many issues recently,
[...]

@Plankton555 Never feel sorry. Thank you for opening the issues, by doing that you are contributing to the library in a way!

@henon
Copy link
Contributor
henon commented Jun 29, 2019

(Sorry for polluting this thread, have no other way of contacting Plankton)

@Plankton555: Could you try run your ported script against https://github.com/SciSharp/Numpy.NET ? I'd love to know if there are any issues.

@Nucs Nucs closed this as completed in f5c021d Jul 1, 2019
Plankton555 pushed a commit to Plankton555/NumSharp that referenced this issue Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0