Skip to content

Commit 695851d

Browse files
committed
Merge branch 'main' of github.com:Blosc/python-blosc2
2 parents 3ef12c5 + 3e872c5 commit 695851d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/blosc2/lazyexpr.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3121,13 +3121,16 @@ def _new_expr(cls, expression, operands, guess, out=None, where=None, ne_args=No
31213121
# substitutes with dummy operands (cheap for reductions) and
31223122
# defaults to blosc2 functions (cheap for constructors)
31233123
new_expr = _numpy_eval_expr(desliced_expr, desliced_ops, prefer_blosc=True)
3124-
_dtype = new_expr.dtype
3124+
_dtype = new_expr.dtype if hasattr(new_expr, "dtype") else np.dtype(type(new_expr))
31253125
if isinstance(new_expr, blosc2.LazyExpr):
31263126
# DO NOT restore the original expression and operands
31273127
# Instead rebase operands and restore only constructors
31283128
expression_, operands_ = conserve_functions(
31293129
_expression, _operands, new_expr.operands | local_vars
31303130
)
3131+
elif _shape == () and not _operands: # passed scalars
3132+
expression_ = "o0"
3133+
operands_ = {"o0": ne_evaluate(_expression)}
31313134
else:
31323135
# An immediate evaluation happened
31333136
# (e.g. all operands are numpy arrays or constructors)

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# LICENSE file in the root directory of this source tree)
77
#######################################################################
88
import os
9+
import sys
910

1011
import pytest
1112

@@ -14,6 +15,15 @@
1415

1516
def pytest_configure(config):
1617
blosc2.print_versions()
18+
if sys.platform != "emscripten":
19+
# Using the defaults for nthreads can be very time consuming for tests.
20+
# Fastest runtime (95 sec) for the whole test suite (Mac Mini M4 Pro)
21+
# blosc2.set_nthreads(1)
22+
# Second best runtime (101 sec), but still contained, and
23+
# actually tests multithreading.
24+
blosc2.set_nthreads(2)
25+
# This makes the worst time (242 sec)
26+
# blosc2.set_nthreads(blosc2.nthreads) # worst runtime ()
1727

1828

1929
@pytest.fixture(scope="session")

0 commit comments

Comments
 (0)