From 76c538f9c2e52064daa9727bc400b3b0181e7f2f Mon Sep 17 00:00:00 2001 From: Dmitry Chigarev Date: Wed, 16 Aug 2023 12:16:40 +0000 Subject: [PATCH] Avoid columns computation on 'df.columns =' Signed-off-by: Dmitry Chigarev --- modin/core/dataframe/pandas/dataframe/dataframe.py | 1 + modin/pandas/dataframe.py | 3 ++- setup.cfg | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modin/core/dataframe/pandas/dataframe/dataframe.py b/modin/core/dataframe/pandas/dataframe/dataframe.py index 191349defbc..849e411164f 100644 --- a/modin/core/dataframe/pandas/dataframe/dataframe.py +++ b/modin/core/dataframe/pandas/dataframe/dataframe.py @@ -639,6 +639,7 @@ def _compute_axis_labels_and_lengths(self, axis: int, partitions=None): List of int Size of partitions alongside specified `axis`. """ + if partitions is None: partitions = self._partitions new_index, internal_idx = self._partition_mgr_cls.get_indices(axis, partitions) diff --git a/modin/pandas/dataframe.py b/modin/pandas/dataframe.py index e3a307773ec..3e62d1ce789 100644 --- a/modin/pandas/dataframe.py +++ b/modin/pandas/dataframe.py @@ -2401,7 +2401,8 @@ def __setattr__(self, key, value): # before it appears in __dict__. if key in ("_query_compiler", "_siblings", "_cache") or key in self.__dict__: pass - elif key in self and key not in dir(self): + # we have to check for the key in `dir(self)` first in order not to trigger columns computation + elif key not in dir(self) and key in self: self.__setitem__(key, value) # Note: return immediately so we don't keep this `key` as dataframe state. # `__getattr__` will return the columns not present in `dir(self)`, so we do not need diff --git a/setup.cfg b/setup.cfg index 2a9bbd5f8eb..82f10d0aa38 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,7 +12,7 @@ tag_prefix = parentdir_prefix = modin- [tool:pytest] -addopts = --disable-pytest-warnings --cov-config=setup.cfg --cov=modin --cov-append --cov-report= +addopts = --disable-pytest-warnings xfail_strict=true markers = xfail_executions