diff --git a/.circleci/config.yml b/.circleci/config.yml index 838e11c84b37..e70b1befe053 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -67,8 +67,9 @@ commands: - run: name: Install Python dependencies command: | - python -m pip install --user numpy<< parameters.numpy_version >> codecov coverage - python -m pip install --user -r requirements/doc/doc-requirements.txt + python -m pip install --user \ + numpy<< parameters.numpy_version >> codecov coverage \ + -r requirements/doc/doc-requirements.txt mpl-install: steps: diff --git a/examples/units/basic_units.py b/examples/units/basic_units.py index 0e62db1233e6..727b538ec183 100644 --- a/examples/units/basic_units.py +++ b/examples/units/basic_units.py @@ -5,6 +5,7 @@ """ +from distutils.version import LooseVersion import math import numpy as np @@ -154,8 +155,9 @@ def __str__(self): def __len__(self): return len(self.value) - def __getitem__(self, key): - return TaggedValue(self.value[key], self.unit) + if LooseVersion(np.__version__) >= '1.20': + def __getitem__(self, key): + return TaggedValue(self.value[key], self.unit) def __iter__(self): # Return a generator expression rather than use `yield`, so that @@ -218,7 +220,7 @@ def __array_wrap__(self, array, context): return TaggedValue(array, self) def __array__(self, t=None, context=None): - ret = np.array([1]) + ret = np.array(1) if t is not None: return ret.astype(t) else: