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):
766766 k = expression [i :].find ("]" ) # start checking from after [
767767 slice_convert = expression [i : i + k + 1 ] # include [ and ]
768768 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
770770 if any (isinstance (el , str ) for el in slicer ): # handle fields
771771 raise ValueError ("Cannot handle fields for slicing lazy expressions." )
772772 slicer = str (slicer )
Original file line number Diff line number Diff line change @@ -452,10 +452,19 @@ def test_slicebrackets_lazy():
452452 res = a [10 :15 ] + 1
453453 np .testing .assert_allclose (newarr , res [:3 ])
454454
455+ # Test other cases
455456 arr = blosc2 .lazyexpr ("anarr[10:15, 2:9] + 1" , {"anarr" : a })
456457 newarr = arr .compute ()
457458 np .testing .assert_allclose (newarr [:], a [10 :15 , 2 :9 ] + 1 )
458459
459460 arr = blosc2 .lazyexpr ("anarr[10:15][2:9] + 1" , {"anarr" : a })
460461 newarr = arr .compute ()
461462 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