Skip to content

Commit

Permalink
Move test, sort whatsnew
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaFicarelli committed Apr 24, 2024
1 parent 50322fe commit 2b42ea0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ Performance improvements
- Performance improvement in :meth:`Index.take` when ``indices`` is a full range indexer from zero to length of index (:issue:`56806`)
- Performance improvement in :meth:`Index.to_frame` returning a :class:`RangeIndex` columns of a :class:`Index` when possible. (:issue:`58018`)
- Performance improvement in :meth:`MultiIndex.equals` for equal length indexes (:issue:`56990`)
- Performance improvement in :meth:`MultiIndex.memory_usage` to ignore the index engine when it isn't already cached. (:issue:`58385`)
- Performance improvement in :meth:`RangeIndex.__getitem__` with a boolean mask or integers returning a :class:`RangeIndex` instead of a :class:`Index` when possible. (:issue:`57588`)
- Performance improvement in :meth:`RangeIndex.append` when appending the same index (:issue:`57252`)
- Performance improvement in :meth:`RangeIndex.argmin` and :meth:`RangeIndex.argmax` (:issue:`57823`)
Expand All @@ -345,7 +346,6 @@ Performance improvements
- Performance improvement in ``DataFrameGroupBy.__len__`` and ``SeriesGroupBy.__len__`` (:issue:`57595`)
- Performance improvement in indexing operations for string dtypes (:issue:`56997`)
- Performance improvement in unary methods on a :class:`RangeIndex` returning a :class:`RangeIndex` instead of a :class:`Index` when possible. (:issue:`57825`)
- Performance improvement in :meth:`MultiIndex.memory_usage` to ignore the index engine when it isn't already cached. (:issue:`58385`)

.. ---------------------------------------------------------------------------
.. _whatsnew_300.bug_fixes:
Expand Down
25 changes: 0 additions & 25 deletions pandas/tests/base/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,31 +142,6 @@ def test_memory_usage_components_narrow_series(any_real_numpy_dtype):
assert total_usage == non_index_usage + index_usage


def test_memory_usage_doesnt_trigger_engine(index):
index._cache.clear()
assert "_engine" not in index._cache

res_without_engine = index.memory_usage()
assert "_engine" not in index._cache

# explicitly load and cache the engine
_ = index._engine
assert "_engine" in index._cache

res_with_engine = index.memory_usage()

# the engine doesn't affect the result even when initialized with values, because
# index._engine.sizeof() doesn't consider the content of index._engine.values
assert res_with_engine == res_without_engine

if len(index) == 0:
assert res_without_engine == 0
assert res_with_engine == 0
else:
assert res_without_engine > 0
assert res_with_engine > 0


def test_searchsorted(request, index_or_series_obj):
# numpy.searchsorted calls obj.searchsorted under the hood.
# See gh-12238
Expand Down
24 changes: 24 additions & 0 deletions pandas/tests/indexes/test_old_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,30 @@ def test_memory_usage(self, index):
if index.inferred_type == "object":
assert result3 > result2

def test_memory_usage_doesnt_trigger_engine(self, index):
index._cache.clear()
assert "_engine" not in index._cache

res_without_engine = index.memory_usage()
assert "_engine" not in index._cache

# explicitly load and cache the engine
_ = index._engine
assert "_engine" in index._cache

res_with_engine = index.memory_usage()

# the empty engine doesn't affect the result even when initialized with values,
# because engine.sizeof() doesn't consider the content of engine.values
assert res_with_engine == res_without_engine

if len(index) == 0:
assert res_without_engine == 0
assert res_with_engine == 0
else:
assert res_without_engine > 0
assert res_with_engine > 0

def test_argsort(self, index):
if isinstance(index, CategoricalIndex):
pytest.skip(f"{type(self).__name__} separately tested")
Expand Down

0 comments on commit 2b42ea0

Please sign in to comment.