@@ -26,7 +26,7 @@ def test_to_numpy():
26
26
tm .assert_numpy_array_equal (result , expected )
27
27
28
28
29
- def test_setitem ():
29
+ def test_setitem_series ():
30
30
ser = pd .Series ([1 , 2 , 3 ])
31
31
ser .array [0 ] = 10
32
32
expected = pd .Series ([10 , 2 , 3 ])
@@ -99,6 +99,46 @@ def test_series_constructor_with_astype():
99
99
tm .assert_series_equal (result , expected )
100
100
101
101
102
+ @pytest .fixture (params = [
103
+ np .array (['a' , 'b' ], dtype = object ),
104
+ np .array ([0 , 1 ], dtype = float ),
105
+ np .array ([0 , 1 ], dtype = int ),
106
+ np .array ([0 , 1 + 2j ], dtype = complex ),
107
+ np .array ([True , False ], dtype = bool ),
108
+ np .array ([0 , 1 ], dtype = 'datetime64[ns]' ),
109
+ np .array ([0 , 1 ], dtype = 'timedelta64[ns]' ),
110
+ ])
111
+ def any_numpy_array (request ):
112
+ """Parametrized fixture for NumPy arrays with different dtypes.
113
+
114
+ This excludes string and bytes.
115
+ """
116
+ return request .param
117
+
118
+
119
+ def test_constructor_copy ():
120
+ arr = np .array ([0 , 1 ])
121
+ result = PandasArray (arr , copy = True )
122
+
123
+ assert np .shares_memory (result ._ndarray , arr ) is False
124
+
125
+
126
+ def test_constructor_with_data (any_numpy_array ):
127
+ nparr = any_numpy_array
128
+ arr = PandasArray (nparr )
129
+ assert arr .dtype .numpy_dtype == nparr .dtype
130
+
131
+
132
+ def test_setitem (any_numpy_array ):
133
+ nparr = any_numpy_array
134
+ arr = PandasArray (nparr , copy = True )
135
+
136
+ arr [0 ] = arr [1 ]
137
+ nparr [0 ] = nparr [1 ]
138
+
139
+ tm .assert_numpy_array_equal (arr .to_numpy (), nparr )
140
+
141
+
102
142
@pytest .mark .parametrize ('dtype, expected' , [
103
143
('bool' , True ),
104
144
('int' , True ),
@@ -114,3 +154,20 @@ def test_series_constructor_with_astype():
114
154
def test_is_numeric (dtype , expected ):
115
155
dtype = PandasDtype (dtype )
116
156
assert dtype ._is_numeric is expected
157
+
158
+
159
+ @pytest .mark .parametrize ('dtype, expected' , [
160
+ ('bool' , True ),
161
+ ('int' , False ),
162
+ ('uint' , False ),
163
+ ('float' , False ),
164
+ ('complex' , False ),
165
+ ('str' , False ),
166
+ ('bytes' , False ),
167
+ ('datetime64[ns]' , False ),
168
+ ('object' , False ),
169
+ ('void' , False )
170
+ ])
171
+ def test_is_boolean (dtype , expected ):
172
+ dtype = PandasDtype (dtype )
173
+ assert dtype ._is_boolean is expected
0 commit comments