Skip to content

Commit ca8c775

Browse files
fix numpy issue
1 parent c2a1339 commit ca8c775

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/test_value_array.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from packaging.version import Version
1516
import numpy as np
1617
import pytest
1718
from tunits.core import raw_WithUnit, raw_UnitArray
@@ -92,9 +93,16 @@ def test_repr() -> None:
9293
assert repr(km ** (2 / 3.0) * [-1] / kg**3 * s) == "ValueArray(array([-1.]), 'km^(2/3)*s/kg^3')"
9394

9495
# Numpy abbreviation is allowed.
95-
assert repr(list(range(50000)) * km) == (
96-
"LengthArray(array([ 0, 1, " "2, ..., 49997, 49998, 49999]), 'km')"
97-
)
96+
if Version(np.__version__) >= Version('2.2'):
97+
expected_repr = (
98+
"LengthArray(array([ 0, 1, "
99+
"2, ..., 49997, 49998, 49999], shape=(50000,)), 'km')"
100+
)
101+
else:
102+
expected_repr = (
103+
"LengthArray(array([ 0, 1, " "2, ..., 49997, 49998, 49999]), 'km')"
104+
)
105+
assert repr(list(range(50000)) * km) == expected_repr
98106

99107
# Fallback case.
100108
v: ValueArray = raw_WithUnit(

0 commit comments

Comments
 (0)