@@ -961,6 +961,30 @@ public async Task AsscalarRemovedInNumpyV1_23()
961
961
Assert . AreEqual ( 143d , new NDarray < double > ( new [ ] { 143d } ) . item ( ) ) ;
962
962
}
963
963
964
+ [ TestMethod ]
965
+ public async Task IssueByMaLichtenegger ( )
966
+ {
967
+ // byte array als uint32 array
968
+ var bytes = new byte [ ] { 1 , 0 , 0 , 0 , 2 , 0 , 0 , 0 , 3 , 0 , 0 , 0 } ;
969
+ var uints = np . zeros ( new Shape ( 3 ) , np . uint32 ) ;
970
+ Console . WriteLine ( uints . repr ) ;
971
+ var ctypes = uints . PyObject . ctypes ;
972
+ long ptr = ctypes . data ;
973
+ Marshal . Copy ( bytes , 0 , new IntPtr ( ptr ) , bytes . Length ) ;
974
+ Console . WriteLine ( uints . repr ) ;
975
+ Assert . AreEqual ( "array([1, 2, 3], dtype=uint32)" , uints . repr ) ;
976
+ // byte array als float64 array
977
+ bytes = new byte [ ] { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ;
978
+ var doubles = np . zeros ( new Shape ( 2 ) , np . float64 ) ;
979
+ Console . WriteLine ( doubles . repr ) ;
980
+ ctypes = doubles . PyObject . ctypes ;
981
+ ptr = ctypes . data ;
982
+ Marshal . Copy ( bytes , 0 , new IntPtr ( ptr ) , bytes . Length ) ;
983
+ Console . WriteLine ( doubles . repr ) ;
984
+ Assert . IsTrue ( doubles [ 0 ] . asscalar < double > ( ) != 0 ) ;
985
+ Assert . IsTrue ( doubles [ 1 ] . asscalar < double > ( ) == 0 ) ;
986
+ }
987
+
964
988
// TODO: https://docs.scipy.org/doc/numpy/user/basics.indexing.html?highlight=slice#structural-indexing-tools
965
989
// TODO: https://docs.scipy.org/doc/numpy/user/basics.indexing.html?highlight=slice#assigning-values-to-indexed-arrays
966
990
// TODO: https://docs.scipy.org/doc/numpy/user/basics.indexing.html?highlight=slice#dealing-with-variable-numbers-of-indices-within-programs
0 commit comments