Skip to content
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

This error shouldn't be happening, right? #65

Open
lintao185 opened this issue May 31, 2024 · 5 comments
Open

This error shouldn't be happening, right? #65

lintao185 opened this issue May 31, 2024 · 5 comments

Comments

@lintao185
Copy link

image

@KevinBaselinesw
Copy link
Collaborator

can you send a small sample of code that produces this error?

It definitely should not be happening inside the numpydotnet library. The statement you show has two * operations. Is the error being thrown on your line? or inside Numpydotnet?

@lintao185
Copy link
Author

   var t = np.ceil(np.array(new double[,] { { 1.0, 3.0 }, { 1.0, 3.0 } }) ).astype(np.Int32);
   var t1 = np.ceil(np.array(new double[][] {new double[] { 1.0, 3.0 }, new double[] { 1.0, 3.0 } }) ).astype(np.Int32);

It seems that cross arrays are not supported.

@lintao185
Copy link
Author

image
Is this conversion correct?

@KevinBaselinesw
Copy link
Collaborator

I think the issue is that np.ceil does not know how to convert k2 which is an object array. I think what you want to do is use the form in k1 to get a multi-dimensional array.

     [TestMethod]
        public void test_lintao185_3()
        {
            var k1 = np.array(new double[,] { { 1.0, 3.0 }, { 1.0, 3.0 } });
            var k2 = np.array(new double[][] { new double[] { 1.0, 3.0 }, new double[] { 1.0, 3.0 } }); <--creates object array

            var t1 = np.ceil(k1);
            var t2 = np.ceil(k2);

            return;


        }``

@KevinBaselinesw
Copy link
Collaborator

Your screen shot code does not compile for me. I have tried it using .net 8.

I find it helpful to break up complex statements into smaller steps to see what each is doing. See what I did below.
Perhaps you can find the problem by debugging that way.

    [TestMethod]
        public void test_lintao185_4()
        {

            var step1 = Enumerable.Range(0, 1).Select(int x => new List<double> { 1, 1 });

            var ndarray? step2 = np.concatenate(step1);

            var step3 = step2.Select(List<double> x => np.array(x));

            var step4 = step3.astype(np.Float32);

            ////////////////////////////////////

            var step5 = shapes.Select(List<double> x => np.array(x));
            var step6 = step5.ToArray();
            var step7 = step6.astype(np.Float32);


            return;


        }

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

2 participants