Skip to content

Commit af8a3e2

Browse files
committed
add any, all
1 parent ca3ce7e commit af8a3e2

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

pixi.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ name = "pint-array"
1010
description = "Pint quantities with array API standard arrays."
1111
readme = "README.md"
1212
dynamic = ["version"]
13-
requires-python = ">=3.9"
13+
requires-python = ">=3.10"
1414

1515
[project.urls]
1616
Homepage = "https://github.com/lucascolley/pint-array"

src/pint_array/__init__.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
Pint interoperability with array API standard arrays.
66
"""
77

8-
from __future__ import annotations
9-
108
import importlib
119
import sys
1210
import textwrap
@@ -328,6 +326,24 @@ def prod(x, /, *args, axis=None, **kwargs):
328326

329327
mod.prod = prod
330328

329+
for func_str in (
330+
"any",
331+
"all",
332+
):
333+
334+
def func(x, /, *args, func_str=func_str, **kwargs):
335+
x = asarray(x)
336+
magnitude = xp.asarray(x.magnitude, copy=True)
337+
if x._is_multiplicative:
338+
xp_func = getattr(xp, func_str)
339+
magnitude = xp_func(magnitude, *args, **kwargs)
340+
return ArrayUnitQuantity(magnitude, None)
341+
342+
msg = "Boolean value of Quantity with offset unit is ambiguous."
343+
raise ValueError(msg)
344+
345+
setattr(mod, func_str, func)
346+
331347
# "mul": product of all units in `all_args`
332348
# - "delta": `first_input_units`, unless non-multiplicative,
333349
# which uses delta version

0 commit comments

Comments
 (0)