Skip to content

Commit 755679c

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into intervalarray
2 parents 8735b58 + 5686313 commit 755679c

File tree

7 files changed

+103
-11
lines changed

7 files changed

+103
-11
lines changed

LICENSES/HAVEN_LICENSE

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
1-
YEAR: 2013-2016
2-
COPYRIGHT HOLDER: Hadley Wickham; RStudio; and Evan Miller
1+
# MIT License
2+
3+
Copyright (c) 2019 Hadley Wickham; RStudio; and Evan Miller
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

doc/source/whatsnew/v1.0.3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
.. _whatsnew_103:
33

4-
What's new in 1.0.3 (March ??, 2020)
4+
What's new in 1.0.3 (March 17, 2020)
55
------------------------------------
66

77
These are the changes in pandas 1.0.3. See :ref:`release` for a full changelog

doc/source/whatsnew/v1.1.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ Other
401401
- Bug in :meth:`DataFrame.to_records` incorrectly losing timezone information in timezone-aware ``datetime64`` columns (:issue:`32535`)
402402
- Fixed :func:`pandas.testing.assert_series_equal` to correctly raise if left object is a different subclass with ``check_series_type=True`` (:issue:`32670`).
403403
- :meth:`IntegerArray.astype` now supports ``datetime64`` dtype (:issue:32538`)
404+
- Fixed bug in :func:`pandas.testing.assert_series_equal` where dtypes were checked for ``Interval`` and ``ExtensionArray`` operands when ``check_dtype`` was ``False`` (:issue:`32747`)
404405

405406
.. ---------------------------------------------------------------------------
406407

pandas/_testing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ def assert_series_equal(
11601160
f"is not equal to {right._values}."
11611161
)
11621162
raise AssertionError(msg)
1163-
elif is_interval_dtype(left.dtype) or is_interval_dtype(right.dtype):
1163+
elif is_interval_dtype(left.dtype) and is_interval_dtype(right.dtype):
11641164
assert_interval_array_equal(left.array, right.array)
11651165
elif is_categorical_dtype(left.dtype) or is_categorical_dtype(right.dtype):
11661166
_testing.assert_almost_equal(
@@ -1170,7 +1170,7 @@ def assert_series_equal(
11701170
check_dtype=check_dtype,
11711171
obj=str(obj),
11721172
)
1173-
elif is_extension_array_dtype(left.dtype) or is_extension_array_dtype(right.dtype):
1173+
elif is_extension_array_dtype(left.dtype) and is_extension_array_dtype(right.dtype):
11741174
assert_extension_array_equal(left._values, right._values)
11751175
elif needs_i8_conversion(left.dtype) or needs_i8_conversion(right.dtype):
11761176
# DatetimeArray or TimedeltaArray

pandas/core/internals/managers.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -825,17 +825,15 @@ def as_array(self, transpose: bool = False) -> np.ndarray:
825825
arr = np.empty(self.shape, dtype=float)
826826
return arr.transpose() if transpose else arr
827827

828-
mgr = self
829-
830-
if self._is_single_block and mgr.blocks[0].is_datetimetz:
828+
if self._is_single_block and self.blocks[0].is_datetimetz:
831829
# TODO(Block.get_values): Make DatetimeTZBlock.get_values
832830
# always be object dtype. Some callers seem to want the
833831
# DatetimeArray (previously DTI)
834-
arr = mgr.blocks[0].get_values(dtype=object)
832+
arr = self.blocks[0].get_values(dtype=object)
835833
elif self._is_single_block or not self.is_mixed_type:
836-
arr = np.asarray(mgr.blocks[0].get_values())
834+
arr = np.asarray(self.blocks[0].get_values())
837835
else:
838-
arr = mgr._interleave()
836+
arr = self._interleave()
839837

840838
return arr.transpose() if transpose else arr
841839

pandas/tests/util/test_assert_frame_equal.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22

3+
import pandas as pd
34
from pandas import DataFrame
45
import pandas._testing as tm
56

@@ -218,3 +219,41 @@ def test_frame_equal_unicode(df1, df2, msg, by_blocks_fixture, obj_fixture):
218219
msg = msg.format(obj=obj_fixture)
219220
with pytest.raises(AssertionError, match=msg):
220221
tm.assert_frame_equal(df1, df2, by_blocks=by_blocks_fixture, obj=obj_fixture)
222+
223+
224+
def test_assert_frame_equal_extension_dtype_mismatch():
225+
# https://github.com/pandas-dev/pandas/issues/32747
226+
left = DataFrame({"a": [1, 2, 3]}, dtype="Int64")
227+
right = left.astype(int)
228+
229+
msg = (
230+
"Attributes of DataFrame\\.iloc\\[:, 0\\] "
231+
'\\(column name="a"\\) are different\n\n'
232+
'Attribute "dtype" are different\n'
233+
"\\[left\\]: Int64\n"
234+
"\\[right\\]: int[32|64]"
235+
)
236+
237+
tm.assert_frame_equal(left, right, check_dtype=False)
238+
239+
with pytest.raises(AssertionError, match=msg):
240+
tm.assert_frame_equal(left, right, check_dtype=True)
241+
242+
243+
def test_assert_frame_equal_interval_dtype_mismatch():
244+
# https://github.com/pandas-dev/pandas/issues/32747
245+
left = DataFrame({"a": [pd.Interval(0, 1)]}, dtype="interval")
246+
right = left.astype(object)
247+
248+
msg = (
249+
"Attributes of DataFrame\\.iloc\\[:, 0\\] "
250+
'\\(column name="a"\\) are different\n\n'
251+
'Attribute "dtype" are different\n'
252+
"\\[left\\]: interval\\[int64\\]\n"
253+
"\\[right\\]: object"
254+
)
255+
256+
tm.assert_frame_equal(left, right, check_dtype=False)
257+
258+
with pytest.raises(AssertionError, match=msg):
259+
tm.assert_frame_equal(left, right, check_dtype=True)

pandas/tests/util/test_assert_series_equal.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22

3+
import pandas as pd
34
from pandas import Categorical, DataFrame, Series
45
import pandas._testing as tm
56

@@ -196,6 +197,40 @@ def test_series_equal_categorical_mismatch(check_categorical):
196197
_assert_series_equal_both(s1, s2, check_categorical=check_categorical)
197198

198199

200+
def test_assert_series_equal_extension_dtype_mismatch():
201+
# https://github.com/pandas-dev/pandas/issues/32747
202+
left = Series(pd.array([1, 2, 3], dtype="Int64"))
203+
right = left.astype(int)
204+
205+
msg = """Attributes of Series are different
206+
207+
Attribute "dtype" are different
208+
\\[left\\]: Int64
209+
\\[right\\]: int[32|64]"""
210+
211+
tm.assert_series_equal(left, right, check_dtype=False)
212+
213+
with pytest.raises(AssertionError, match=msg):
214+
tm.assert_series_equal(left, right, check_dtype=True)
215+
216+
217+
def test_assert_series_equal_interval_dtype_mismatch():
218+
# https://github.com/pandas-dev/pandas/issues/32747
219+
left = Series([pd.Interval(0, 1)], dtype="interval")
220+
right = left.astype(object)
221+
222+
msg = """Attributes of Series are different
223+
224+
Attribute "dtype" are different
225+
\\[left\\]: interval\\[int64\\]
226+
\\[right\\]: object"""
227+
228+
tm.assert_series_equal(left, right, check_dtype=False)
229+
230+
with pytest.raises(AssertionError, match=msg):
231+
tm.assert_series_equal(left, right, check_dtype=True)
232+
233+
199234
def test_series_equal_series_type():
200235
class MySeries(Series):
201236
pass

0 commit comments

Comments
 (0)