Skip to content

Commit 04532cf

Browse files
committed
Use latest miniexpr and _global_linear_idx -> _flat_idx
1 parent 69dfe81 commit 04532cf

6 files changed

Lines changed: 11 additions & 11 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ endif()
6363

6464
FetchContent_Declare(miniexpr
6565
GIT_REPOSITORY https://github.com/Blosc/miniexpr.git
66-
GIT_TAG af37741a3344604e21d5572e9b216117d0db8768
66+
GIT_TAG 320240a849e185c84114501200052bfeb8d66f2b
6767
# SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../miniexpr
6868
)
6969
FetchContent_MakeAvailable(miniexpr)

bench/ndarray/linear-constructor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
@blosc2.dsl_kernel
1919
def kernel_ramp(start):
20-
return start + _global_linear_idx # noqa: F821 # DSL index/shape symbols resolved by miniexpr
20+
return start + _flat_idx # noqa: F821 # DSL index/shape symbols resolved by miniexpr
2121

2222
t0 = time()
2323
npa = np.arange(np.prod(shape), dtype=dtype).reshape(shape)

bench/ndarray/sum-linear-idx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#######################################################################
77

88
# Compare reduction performance on DSL kernels.
9-
# This uses the special _global_linear_idx var.
9+
# This uses the special _flat_idx var.
1010

1111
from time import time
1212
import numpy as np
@@ -19,7 +19,7 @@
1919
@blosc2.dsl_kernel
2020
def kernel_ramp():
2121
# return _i0 * _n1 + _i1 # noqa: F821 # DSL index/shape symbols resolved by miniexpr
22-
return _global_linear_idx # noqa: F821 # DSL index/shape symbols resolved by miniexpr
22+
return _flat_idx # noqa: F821 # DSL index/shape symbols resolved by miniexpr
2323

2424
print(kernel_ramp.dsl_source)
2525
a = blosc2.lazyudf(kernel_ramp, (), dtype=dtype, shape=shape)

src/blosc2/dsl_kernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def _numeric_literal_value(node):
191191
and isinstance(node.operand.value, int | float | bool)
192192
):
193193
value = node.operand.value
194-
return +value if isinstance(node.op, ast.UAdd) else -value
194+
return value if isinstance(node.op, ast.UAdd) else -value
195195
return None
196196

197197
for node in ast.walk(tree):

src/blosc2/ndarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5408,7 +5408,7 @@ def arange_fill(inputs, output, offset):
54085408

54095409
@blosc2.dsl_kernel
54105410
def kernel_ramp(start, step):
5411-
return start + _global_linear_idx * step # noqa: F821 # DSL index/shape symbols resolved by miniexpr
5411+
return start + _flat_idx * step # noqa: F821 # DSL index/shape symbols resolved by miniexpr
54125412

54135413
if step is None: # not array-api compliant but for backwards compatibility
54145414
step = 1
@@ -5513,7 +5513,7 @@ def linspace_fill(inputs, output, offset):
55135513

55145514
@blosc2.dsl_kernel
55155515
def kernel_ramp(start, step):
5516-
return float(start) + _global_linear_idx * float(step) # noqa: F821 # DSL index/shape symbols resolved by miniexpr
5516+
return float(start) + _flat_idx * float(step) # noqa: F821 # DSL index/shape symbols resolved by miniexpr
55175517

55185518
if shape is None:
55195519
if num is None:

tests/ndarray/test_dsl_kernels.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ def kernel_scalar_start_step(start, step):
122122
@blosc2.dsl_kernel
123123
def kernel_scalar_start_stop_nitems(start, stop, nitems):
124124
step = (stop - start) / nitems
125-
return start + _global_linear_idx * step # noqa: F821 # DSL index/shape symbols resolved by miniexpr
125+
return start + _flat_idx * step # noqa: F821 # DSL index/shape symbols resolved by miniexpr
126126

127127

128128
@blosc2.dsl_kernel
129129
def kernel_scalar_start_stop_nitems_float_cast(start, stop, nitems):
130130
step = (float(stop) - float(start)) / float(nitems)
131-
return float(start) + _global_linear_idx * step # noqa: F821 # DSL index/shape symbols resolved by miniexpr
131+
return float(start) + _flat_idx * step # noqa: F821 # DSL index/shape symbols resolved by miniexpr
132132

133133

134134
@blosc2.dsl_kernel
@@ -591,7 +591,7 @@ def test_dsl_kernel_float_cast_with_negative_scalar_param():
591591
np.testing.assert_allclose(res[...], expected, rtol=1e-6, atol=1e-6)
592592

593593

594-
def test_dsl_kernel_float_cast_with_global_linear_idx_no_segfault_subprocess():
594+
def test_dsl_kernel_float_cast_with_flat_idx_no_segfault_subprocess():
595595
if blosc2.IS_WASM:
596596
pytest.skip("subprocess is not supported on emscripten/wasm32")
597597

@@ -603,7 +603,7 @@ def test_dsl_kernel_float_cast_with_global_linear_idx_no_segfault_subprocess():
603603
@blosc2.dsl_kernel
604604
def kernel(start, stop, nitems):
605605
step = (float(stop) - float(start)) / float(nitems)
606-
return float(start) + _global_linear_idx * step # noqa: F821
606+
return float(start) + _flat_idx * step # noqa: F821
607607
608608
shape = (10, 100)
609609
arr = blosc2.lazyudf(kernel, (-10, 10, 999), dtype=np.float32, shape=shape).compute()

0 commit comments

Comments
 (0)