3
3
import numpy as np
4
4
import pytest
5
5
6
- from pandas ._config import using_string_dtype
7
-
8
- from pandas .compat import PYPY
9
-
10
6
from pandas .core .dtypes .common import (
11
7
is_dtype_equal ,
12
8
is_object_dtype ,
@@ -81,10 +77,10 @@ def test_ndarray_compat_properties(index_or_series_obj):
81
77
assert Series ([1 ]).item () == 1
82
78
83
79
84
- @pytest .mark .skipif (
85
- PYPY or using_string_dtype (),
86
- reason = "not relevant for PyPy doesn't work properly for arrow strings" ,
87
- )
80
+ # @pytest.mark.skipif(
81
+ # PYPY or using_string_dtype(),
82
+ # reason="not relevant for PyPy doesn't work properly for arrow strings",
83
+ # )
88
84
def test_memory_usage (index_or_series_memory_obj ):
89
85
obj = index_or_series_memory_obj
90
86
# Clear index caches so that len(obj) == 0 report 0 memory usage
@@ -98,7 +94,12 @@ def test_memory_usage(index_or_series_memory_obj):
98
94
res = obj .memory_usage ()
99
95
res_deep = obj .memory_usage (deep = True )
100
96
101
- is_object = is_object_dtype (obj ) or (is_ser and is_object_dtype (obj .index ))
97
+ def _is_object_dtype (obj ):
98
+ if isinstance (obj , pd .MultiIndex ):
99
+ return any (is_object_dtype (level ) for level in obj .levels )
100
+ return is_object_dtype (obj )
101
+
102
+ is_object = _is_object_dtype (obj ) or (is_ser and _is_object_dtype (obj .index ))
102
103
is_categorical = isinstance (obj .dtype , pd .CategoricalDtype ) or (
103
104
is_ser and isinstance (obj .index .dtype , pd .CategoricalDtype )
104
105
)
@@ -111,7 +112,7 @@ def test_memory_usage(index_or_series_memory_obj):
111
112
assert res_deep == res == expected
112
113
elif is_object or is_categorical or is_object_string :
113
114
# only deep will pick them up
114
- assert res_deep > res
115
+ assert res_deep > res , ( res_deep , res )
115
116
else :
116
117
assert res == res_deep
117
118
0 commit comments