Skip to content

Commit 3fa730d

Browse files
authored
Merge pull request matplotlib#29616 from timhoffm/fix-units
FIX: Fix unit example so that we can unpin numpy<2.1
2 parents 3f91524 + 2c087c1 commit 3fa730d

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ commands:
9898
parameters:
9999
numpy_version:
100100
type: string
101-
default: "~=2.0.0"
101+
default: ""
102102
steps:
103103
- run:
104104
name: Install Python dependencies

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies:
1818
- kiwisolver>=1.3.1
1919
- pybind11>=2.13.2
2020
- meson-python>=0.13.1
21-
- numpy<2.1
21+
- numpy
2222
- pillow>=9
2323
- pkg-config
2424
- pygobject

galleries/examples/units/basic_units.py

+5
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ def get_unit(self):
193193

194194

195195
class BasicUnit:
196+
# numpy scalars convert eager and np.float64(2) * BasicUnit('cm')
197+
# would thus return a numpy scalar. To avoid this, we increase the
198+
# priority of the BasicUnit.
199+
__array_priority__ = np.float64(0).__array_priority__ + 1
200+
196201
def __init__(self, name, fullname=None):
197202
self.name = name
198203
if fullname is None:

0 commit comments

Comments
 (0)