Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1fdc2cd

Browse filesBrowse files
authored
Merge pull request #19535 from QuLogic/fix-units-old-np
Fix example's BasicUnit array conversion.
2 parents 214def5 + 3488dc7 commit 1fdc2cd
Copy full SHA for 1fdc2cd

File tree

Expand file treeCollapse file tree

2 files changed

+8
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-5
lines changed

‎.circleci/config.yml

Copy file name to clipboardExpand all lines: .circleci/config.yml
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ commands:
6767
- run:
6868
name: Install Python dependencies
6969
command: |
70-
python -m pip install --user numpy<< parameters.numpy_version >> codecov coverage
71-
python -m pip install --user -r requirements/doc/doc-requirements.txt
70+
python -m pip install --user \
71+
numpy<< parameters.numpy_version >> codecov coverage \
72+
-r requirements/doc/doc-requirements.txt
7273
7374
mpl-install:
7475
steps:

‎examples/units/basic_units.py

Copy file name to clipboardExpand all lines: examples/units/basic_units.py
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
"""
77

8+
from distutils.version import LooseVersion
89
import math
910

1011
import numpy as np
@@ -154,8 +155,9 @@ def __str__(self):
154155
def __len__(self):
155156
return len(self.value)
156157

157-
def __getitem__(self, key):
158-
return TaggedValue(self.value[key], self.unit)
158+
if LooseVersion(np.__version__) >= '1.20':
159+
def __getitem__(self, key):
160+
return TaggedValue(self.value[key], self.unit)
159161

160162
def __iter__(self):
161163
# Return a generator expression rather than use `yield`, so that
@@ -218,7 +220,7 @@ def __array_wrap__(self, array, context):
218220
return TaggedValue(array, self)
219221

220222
def __array__(self, t=None, context=None):
221-
ret = np.array([1])
223+
ret = np.array(1)
222224
if t is not None:
223225
return ret.astype(t)
224226
else:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.