@@ -351,14 +351,14 @@ public void ndarray_masking1()
351
351
" [[15, 16, 17, 18, 19],\n " +
352
352
" [20, 21, 22, 23, 24],\n " +
353
353
" [25, 26, 27, 28, 29]]])" ,
354
- x . repr ) ;
354
+ x . repr ) ;
355
355
var b = np . array ( new [ , ] { { true , true , false } , { false , true , true } } ) ;
356
356
Assert . AreEqual (
357
357
"array([[ 0, 1, 2, 3, 4],\n " +
358
358
" [ 5, 6, 7, 8, 9],\n " +
359
359
" [20, 21, 22, 23, 24],\n " +
360
360
" [25, 26, 27, 28, 29]])" ,
361
- x [ b ] . repr ) ;
361
+ x [ b ] . repr ) ;
362
362
}
363
363
364
364
[ TestMethod ]
@@ -641,12 +641,11 @@ public void ComplexNumbers()
641
641
public void IssueByXlient ( )
642
642
{
643
643
var points = new Point [ ] { new Point ( 0 , 0 ) , new Point ( 17 , 4 ) , new Point ( 2 , 22 ) , new Point ( 10 , 7 ) , } ;
644
- int [ , ] Pts = new int [ , ]
645
- {
646
- { points [ 0 ] . X , points [ 0 ] . Y } ,
647
- { points [ 1 ] . X , points [ 1 ] . Y } ,
648
- { points [ 2 ] . X , points [ 2 ] . Y } ,
649
- { points [ 3 ] . X , points [ 3 ] . Y }
644
+ int [ , ] Pts = new int [ , ] {
645
+ { points [ 0 ] . X , points [ 0 ] . Y } ,
646
+ { points [ 1 ] . X , points [ 1 ] . Y } ,
647
+ { points [ 2 ] . X , points [ 2 ] . Y } ,
648
+ { points [ 3 ] . X , points [ 3 ] . Y }
650
649
} ;
651
650
652
651
// exception here / deadlock
@@ -674,7 +673,7 @@ public void IssueByVolgaone()
674
673
Assert . AreEqual ( "1,2,3" , string . Join ( "," , row0Data ) ) ;
675
674
var col1 = n [ ":,1" ] ; //extract 1st column - NDarray is [2 5 8] as expected
676
675
Assert . AreEqual ( "array([2., 5., 8.], dtype=float32)" , col1 . repr ) ;
677
- var col1Data = col1 . GetData ( ) ; //this is wrong - {2,3,4}
676
+ var col1Data = col1 . GetData ( ) ; //this is wrong - {2,3,4}
678
677
Assert . AreEqual ( "2,5,8" , string . Join ( "," , col1Data ) ) ;
679
678
}
680
679
@@ -951,8 +950,8 @@ public async Task IssueByMrCOrrupted()
951
950
np . savez_compressed ( filename , null , arrays ) ;
952
951
var archive = np . load ( filename ) ;
953
952
Console . WriteLine ( archive . repr ) ;
954
- var a = new NDarray ( archive . PyObject [ "a" ] ) ;
955
- var b = new NDarray ( archive . PyObject [ "b" ] ) ;
953
+ var a = new NDarray ( archive . PyObject [ "a" ] ) ;
954
+ var b = new NDarray ( archive . PyObject [ "b" ] ) ;
956
955
Console . WriteLine ( a . repr ) ;
957
956
Console . WriteLine ( b . repr ) ;
958
957
Assert . AreEqual ( "array([[0, 1, 2],\n [3, 4, 5]])" , a . repr ) ;
@@ -962,8 +961,8 @@ public async Task IssueByMrCOrrupted()
962
961
[ TestMethod ]
963
962
public async Task AsscalarRemovedInNumpyV1_23 ( )
964
963
{
965
- Assert . AreEqual ( 143 , new NDarray < int > ( new int [ ] { 143 } ) . asscalar < int > ( ) ) ;
966
- Assert . AreEqual ( 143d , new NDarray < double > ( new [ ] { 143d } ) . asscalar < double > ( ) ) ;
964
+ Assert . AreEqual ( 143 , new NDarray < int > ( new int [ ] { 143 } ) . asscalar < int > ( ) ) ;
965
+ Assert . AreEqual ( 143d , new NDarray < double > ( new [ ] { 143d } ) . asscalar < double > ( ) ) ;
967
966
Assert . AreEqual ( 143d , new NDarray < double > ( new [ ] { 143d } ) . item ( ) ) ;
968
967
}
969
968
@@ -972,7 +971,7 @@ public async Task IssueByMaLichtenegger()
972
971
{
973
972
// byte array als uint32 array
974
973
var bytes = new byte [ ] { 1 , 0 , 0 , 0 , 2 , 0 , 0 , 0 , 3 , 0 , 0 , 0 } ;
975
- var uints = np . zeros ( new Shape ( 3 ) , np . uint32 ) ;
974
+ var uints = np . zeros ( new Shape ( 3 ) , np . uint32 ) ;
976
975
Console . WriteLine ( uints . repr ) ;
977
976
var ctypes = uints . PyObject . ctypes ;
978
977
long ptr = ctypes . data ;
@@ -1030,15 +1029,15 @@ public async Task F16Workaround()
1030
1029
1031
1030
// these bytes in binary notation correspond to f16 numbers 1, -1 and 65504 (float16 max value)
1032
1031
// note, the bytes are in reversed order to the bits shown above
1033
- var bytes = new byte [ ] {
1032
+ var bytes = new byte [ ] {
1034
1033
0b00000000 , 0b00111100 , // 1
1035
1034
0b00000000 , 0b10111100 , // -1
1036
1035
0b11111111 , 0b01111011 , // 65504
1037
1036
} ;
1038
1037
var floats = np . zeros ( new Shape ( 3 ) , np . float16 ) ;
1039
1038
Console . WriteLine ( floats . repr ) ;
1040
1039
// note, the using prevents a mem-leak with ctypes
1041
- using ( var ctypes = floats . PyObject . ctypes ) {
1040
+ using ( var ctypes = floats . PyObject . ctypes ) {
1042
1041
long ptr = ctypes . data ;
1043
1042
Marshal . Copy ( bytes , 0 , new IntPtr ( ptr ) , bytes . Length ) ;
1044
1043
}
@@ -1093,8 +1092,31 @@ public async Task IssueByTimiil()
1093
1092
[ -4.5-2.59807621j, 117. +0.j , -4.5+2.59807621j],
1094
1093
[ 0. +0.j , -13.5+7.79422863j, 0. +0.j ]]])" . Replace ( "\r " , "" ) , fft_img . repr ) ;
1095
1094
}
1096
- // TODO: https://docs.scipy.org/doc/numpy/user/basics.indexing.html?highlight=slice#structural-indexing-tools
1097
- // TODO: https://docs.scipy.org/doc/numpy/user/basics.indexing.html?highlight=slice#assigning-values-to-indexed-arrays
1098
- // TODO: https://docs.scipy.org/doc/numpy/user/basics.indexing.html?highlight=slice#dealing-with-variable-numbers-of-indices-within-programs
1095
+
1096
+ [ TestMethod ]
1097
+ public void IssueByPandath ( )
1098
+ {
1099
+ //>>> grid = np.array([[1, 2, 3, 0, 0, 4], [5, 6, 7, 0, 0, 8]])
1100
+ //>>> xs, ys = np.where(grid == 0)
1101
+ //>>> xs
1102
+ //array([0, 0, 1, 1], dtype = int64)
1103
+ //>>> ys
1104
+ //array([3, 4, 3, 4], dtype = int64)
1105
+
1106
+ var grid = np . array ( new [ , ] { { 1 , 2 , 3 , 0 , 0 , 4 } , { 5 , 6 , 7 , 0 , 0 , 8 } } ) ;
1107
+ var result = np . where ( grid . equals ( 0 ) ) ;
1108
+ Console . WriteLine ( result [ 0 ] . repr ) ;
1109
+ Console . WriteLine ( result [ 1 ] . repr ) ;
1110
+ Assert . AreEqual ( "array([0, 0, 1, 1], dtype=int64)" , result [ 0 ] . repr ) ;
1111
+ Assert . AreEqual ( "array([3, 4, 3, 4], dtype=int64)" , result [ 1 ] . repr ) ;
1112
+ }
1099
1113
}
1114
+
1115
+
1116
+
1117
+
1118
+ // TODO: https://docs.scipy.org/doc/numpy/user/basics.indexing.html?highlight=slice#structural-indexing-tools
1119
+ // TODO: https://docs.scipy.org/doc/numpy/user/basics.indexing.html?highlight=slice#assigning-values-to-indexed-arrays
1120
+ // TODO: https://docs.scipy.org/doc/numpy/user/basics.indexing.html?highlight=slice#dealing-with-variable-numbers-of-indices-within-programs
1121
+
1100
1122
}
0 commit comments