11from __future__ import annotations
22
3- import re
4- from typing import TYPE_CHECKING , Any
3+ from typing import TYPE_CHECKING
54
65import numpy as np
76import pytest
3231
3332
3433import zarr .api .asynchronous
35- from zarr .core .buffer .core import ScalarWrapper
3634
3735if TYPE_CHECKING :
3836 import types
@@ -44,54 +42,6 @@ def test_nd_array_like(xp: types.ModuleType) -> None:
4442 assert isinstance (ary , NDArrayLike )
4543
4644
47- @pytest .mark .parametrize ("value" , [1 , 1.4 , "a" , b"a" , np .array (1 ), False , True ])
48- def test_scalar_wrapper (value : Any ) -> None :
49- x = ScalarWrapper (value )
50- assert x == value
51- assert value == x
52- assert x == x [()]
53- assert x .view (str ) == x
54- assert x .copy () == x
55- assert x .transpose () == x
56- assert x .ravel () == x
57- assert x .all () == bool (value )
58- if isinstance (value , (int , float )):
59- assert - x == - value
60- assert abs (x ) == abs (value )
61- assert int (x ) == int (value )
62- assert float (x ) == float (value )
63- assert complex (x ) == complex (value )
64- assert x + 1 == value + 1
65- assert x - 1 == value - 1
66- assert x * 2 == value * 2
67- assert x / 2 == value / 2
68- assert x // 2 == value // 2
69- assert x % 2 == value % 2
70- assert x ** 2 == value ** 2
71- assert x == value
72- assert x != value + 1
73- assert bool (x ) == bool (value )
74- assert hash (x ) == hash (value )
75- assert str (x ) == str (value )
76- assert format (x , "" ) == format (value , "" )
77- x .fill (2 )
78- x [()] += 1
79- assert x == 3
80- elif isinstance (value , str ):
81- assert str (x ) == value
82- with pytest .raises (TypeError , match = re .escape ("bad operand type for abs(): 'str'" )):
83- abs (x )
84-
85- with pytest .raises (ValueError , match = "Cannot reshape scalar to non-scalar shape." ):
86- x .reshape ((1 , 2 ))
87- with pytest .raises (IndexError , match = "Invalid index for scalar." ):
88- x [10 ] = value
89- with pytest .raises (IndexError , match = "Invalid index for scalar." ):
90- x [10 ]
91- with pytest .raises (TypeError , match = re .escape ("len() of unsized object." )):
92- len (x )
93-
94-
9545@pytest .mark .asyncio
9646async def test_async_array_prototype () -> None :
9747 """Test the use of a custom buffer prototype"""
0 commit comments