Open lintao185 opened 4 months ago
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?
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.
Is this conversion correct?
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;
}``
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;
}