File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -766,7 +766,7 @@ def convert_to_slice(expression):
766
766
k = expression [i :].find ("]" ) # start checking from after [
767
767
slice_convert = expression [i : i + k + 1 ] # include [ and ]
768
768
slicer = eval (f"np.s_{ slice_convert } " )
769
- slicer = (slicer ,) if isinstance (slicer , slice ) else slicer # standardise to tuple
769
+ slicer = (slicer ,) if not isinstance (slicer , tuple ) else slicer # standardise to tuple
770
770
if any (isinstance (el , str ) for el in slicer ): # handle fields
771
771
raise ValueError ("Cannot handle fields for slicing lazy expressions." )
772
772
slicer = str (slicer )
Original file line number Diff line number Diff line change @@ -452,10 +452,19 @@ def test_slicebrackets_lazy():
452
452
res = a [10 :15 ] + 1
453
453
np .testing .assert_allclose (newarr , res [:3 ])
454
454
455
+ # Test other cases
455
456
arr = blosc2 .lazyexpr ("anarr[10:15, 2:9] + 1" , {"anarr" : a })
456
457
newarr = arr .compute ()
457
458
np .testing .assert_allclose (newarr [:], a [10 :15 , 2 :9 ] + 1 )
458
459
459
460
arr = blosc2 .lazyexpr ("anarr[10:15][2:9] + 1" , {"anarr" : a })
460
461
newarr = arr .compute ()
461
462
np .testing .assert_allclose (newarr [:], a [10 :15 ][2 :9 ] + 1 )
463
+
464
+ arr = blosc2 .lazyexpr ("anarr[10] + 1" , {"anarr" : a })
465
+ newarr = arr .compute ()
466
+ np .testing .assert_allclose (newarr [:], a [10 ] + 1 )
467
+
468
+ arr = blosc2 .lazyexpr ("anarr[10, 1] + 1" , {"anarr" : a })
469
+ newarr = arr [:]
470
+ np .testing .assert_allclose (newarr , a [10 , 1 ] + 1 )
You can’t perform that action at this time.
0 commit comments