From b66358ddcef18d37be8835898880e3948838b60d Mon Sep 17 00:00:00 2001 From: aresnow Date: Mon, 19 Dec 2022 14:18:50 +0800 Subject: [PATCH] Revert changes caused by Pandas as it was fixed in https://github.com/pandas-dev/pandas/pull/49053 --- mars/dataframe/reduction/all.py | 2 +- mars/dataframe/reduction/any.py | 2 +- .../reduction/tests/test_reduction_execution.py | 9 --------- mars/tensor/indexing/fill_diagonal.py | 6 ++---- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/mars/dataframe/reduction/all.py b/mars/dataframe/reduction/all.py index 65b8ae25de..6b575187be 100644 --- a/mars/dataframe/reduction/all.py +++ b/mars/dataframe/reduction/all.py @@ -71,7 +71,7 @@ def tile(cls, op): def __call__(self, df): if self.axis is None and isinstance(df, DATAFRAME_TYPE): - return self.new_scalar([df], np.bool) + return self.new_scalar([df], np.dtype("bool")) else: return super().__call__(df) diff --git a/mars/dataframe/reduction/any.py b/mars/dataframe/reduction/any.py index 10e9c0ea50..da7a670a67 100644 --- a/mars/dataframe/reduction/any.py +++ b/mars/dataframe/reduction/any.py @@ -71,7 +71,7 @@ def tile(cls, op): def __call__(self, df): if self.axis is None and isinstance(df, DATAFRAME_TYPE): - return self.new_scalar([df], np.bool) + return self.new_scalar([df], np.dtype("bool")) else: return super().__call__(df) diff --git a/mars/dataframe/reduction/tests/test_reduction_execution.py b/mars/dataframe/reduction/tests/test_reduction_execution.py index 9990a1ae1b..e91a616339 100644 --- a/mars/dataframe/reduction/tests/test_reduction_execution.py +++ b/mars/dataframe/reduction/tests/test_reduction_execution.py @@ -42,18 +42,9 @@ def check_ref_counts(): yield - import functools import gc - # In https://github.com/pandas-dev/pandas/pull/48023, pandas cache current frame in this PR - # which leads to failure of decref mechanism. gc.collect() - wrappers = [ - a for a in gc.get_objects() if isinstance(a, functools._lru_cache_wrapper) - ] - - for wrapper in wrappers: - wrapper.cache_clear() sess = get_default_session() assert len(sess._get_ref_counts()) == 0 diff --git a/mars/tensor/indexing/fill_diagonal.py b/mars/tensor/indexing/fill_diagonal.py index 459baf86a6..733517d047 100644 --- a/mars/tensor/indexing/fill_diagonal.py +++ b/mars/tensor/indexing/fill_diagonal.py @@ -184,10 +184,8 @@ def _tile_nd(cls, op, val): # if more than 3d, we will rechunk the tensor into square chunk # on the diagonal direction in_tensor = op.input - nsplits = np.array(in_tensor.nsplits) - if not np.issubdtype(nsplits.dtype, np.integer) or not np.all( - np.diff(nsplits, axis=1) == 0 - ): + nsplits = [tuple(np.array(split)) for split in in_tensor.nsplits] + if set(nsplits) != 1: # need rechunk nsplit = decide_unify_split(*in_tensor.nsplits) in_tensor = yield from recursive_tile(