Skip to content

CI: Skip numpy dev failing tests #39090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import warnings

from pandas._typing import F
from pandas.compat.numpy import is_numpy_dev

PY38 = sys.version_info >= (3, 8)
PY39 = sys.version_info >= (3, 9)
Expand Down Expand Up @@ -118,3 +119,8 @@ def get_lzma_file(lzma):
"might be required to solve this issue."
)
return lzma.LZMAFile


__all__ = [
"is_numpy_dev",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont we also need everything else currently in the namespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah probably, but not sure if we should rather do this as a follow up? If numpy fixes the bug or after we have fixed this on our site, we could simply revert this pr to avoid touching 30 files. If we do more in here, this may get tricky

]
3 changes: 3 additions & 0 deletions pandas/tests/arithmetic/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev

from pandas.core.dtypes.common import is_list_like

import pandas as pd
Expand Down Expand Up @@ -252,6 +254,7 @@ def test_compare_length_mismatch_errors(self, op, other_constructor, length):
with pytest.raises(ValueError, match="Lengths must match to compare"):
op(array, other)

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
@pytest.mark.parametrize(
"constructor, expected_type, assert_func",
[
Expand Down
5 changes: 4 additions & 1 deletion pandas/tests/base/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pytest

from pandas.compat import IS64, PYPY
from pandas.compat import IS64, PYPY, is_numpy_dev

from pandas.core.dtypes.common import is_categorical_dtype, is_object_dtype

Expand Down Expand Up @@ -116,6 +116,9 @@ def test_searchsorted(index_or_series_obj):
# See gh-14833
pytest.skip("np.searchsorted doesn't work on pd.MultiIndex")

if is_object_dtype(obj) and is_numpy_dev:
pytest.skip("GH#39089 Numpy changed dtype inference")

max_obj = max(obj, default=0)
index = np.searchsorted(obj, max_obj)
assert 0 <= index <= len(obj)
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/extension/base/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev

from pandas.core.dtypes.common import is_bool_dtype

import pandas as pd
Expand Down Expand Up @@ -392,6 +394,9 @@ def test_hash_pandas_object_works(self, data, as_frame):
b = pd.util.hash_pandas_object(data)
self.assert_equal(a, b)

@pytest.mark.xfail(
is_numpy_dev, reason="GH#39089 Numpy changed dtype inference", strict=False
)
def test_searchsorted(self, data_for_sorting, as_series):
b, c, a = data_for_sorting
arr = type(data_for_sorting)._from_sequence([a, b, c])
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/frame/apply/test_frame_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev

from pandas.core.dtypes.dtypes import CategoricalDtype

import pandas as pd
Expand Down Expand Up @@ -582,6 +584,7 @@ def test_apply_dict(self):
tm.assert_frame_equal(reduce_false, df)
tm.assert_series_equal(reduce_none, dicts)

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_applymap(self, float_frame):
applied = float_frame.applymap(lambda x: x * 2)
tm.assert_frame_equal(applied, float_frame * 2)
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/frame/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from pandas._libs import iNaT
from pandas.compat import is_numpy_dev

from pandas.core.dtypes.common import is_integer

Expand Down Expand Up @@ -254,6 +255,8 @@ def inc(x):
)
def test_setitem_same_column(self, cols, values, expected):
# GH 23239
if cols == ["C", "D", "D", "a"] and is_numpy_dev:
pytest.skip("GH#39089 Numpy changed dtype inference")
df = DataFrame([values], columns=cols)
df["a"] = df["a"]
result = df["a"].values[0]
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/frame/methods/test_drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev
from pandas.errors import PerformanceWarning

import pandas as pd
Expand Down Expand Up @@ -107,6 +108,7 @@ def test_drop_names(self):
expected = Index(["a", "b", "c"], name="first")
tm.assert_index_equal(dropped.index, expected)

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u add an issue number to all of these (open one);

we might need to backport this as well

also see if u can find a linked numpy issue - this is a breaking change and might want to have them revert this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#39089 is the open issue, you meaning this?

Yeah backport is probably useful. Linked a numpy pr in #39089

def test_drop(self):
simple = DataFrame({"A": [1, 2, 3, 4], "B": [0, 1, 2, 3]})
tm.assert_frame_equal(simple.drop("A", axis=1), simple[["B"]])
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/frame/methods/test_isin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev

import pandas as pd
from pandas import DataFrame, MultiIndex, Series
import pandas._testing as tm
Expand Down Expand Up @@ -32,6 +34,7 @@ def test_isin_empty(self, empty):
result = df.isin(empty)
tm.assert_frame_equal(result, expected)

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_isin_dict(self):
df = DataFrame({"A": ["a", "b", "c"], "B": ["a", "e", "f"]})
d = {"A": ["a"]}
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/frame/methods/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev

import pandas as pd
from pandas import DataFrame, Index, Series, Timestamp, date_range
import pandas._testing as tm
Expand Down Expand Up @@ -1508,6 +1510,7 @@ def test_replace_no_replacement_dtypes(self, dtype, value):
result = df.replace(to_replace=[None, -np.inf, np.inf], value=value)
tm.assert_frame_equal(result, df)

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
@pytest.mark.parametrize("replacement", [np.nan, 5])
def test_replace_with_duplicate_columns(self, replacement):
# GH 24798
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/frame/methods/test_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev
from pandas.errors import ParserError

import pandas as pd
Expand Down Expand Up @@ -181,6 +182,7 @@ def test_to_csv_cols_reordering(self):

tm.assert_frame_equal(df[cols], rs_c, check_names=False)

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_to_csv_new_dupe_cols(self):
import pandas as pd

Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/frame/test_nonunique_indexes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev

import pandas as pd
from pandas import DataFrame, MultiIndex, Series, date_range
import pandas._testing as tm
Expand All @@ -14,6 +16,7 @@ def check(result, expected=None):


class TestDataFrameNonuniqueIndexes:
@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_column_dups_operations(self):

# assignment
Expand Down Expand Up @@ -310,6 +313,7 @@ def test_column_dups2(self):
result = df.dropna(subset=["A", "C"], how="all")
tm.assert_frame_equal(result, expected)

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_getitem_boolean_series_with_duplicate_columns(self):
# boolean indexing
# GH 4879
Expand Down Expand Up @@ -337,6 +341,7 @@ def test_getitem_boolean_frame_with_duplicate_columns(self):
result = df[df > 6]
check(result, expected)

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_getitem_boolean_frame_unaligned_with_duplicate_columns(self):
# `df.A > 6` is a DataFrame with a different shape from df
dups = ["A", "A", "C", "D"]
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/groupby/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev
from pandas.errors import UnsupportedFunctionCall

import pandas as pd
Expand Down Expand Up @@ -1004,6 +1005,7 @@ def test_frame_describe_unstacked_format():
tm.assert_frame_equal(result, expected)


@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
@pytest.mark.filterwarnings(
"ignore:"
"indexing past lexsort depth may impact performance:"
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/groupby/test_quantile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev

import pandas as pd
from pandas import DataFrame, Index
import pandas._testing as tm
Expand Down Expand Up @@ -71,6 +73,7 @@ def test_quantile_array():
tm.assert_frame_equal(result, expected)


@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_quantile_array2():
# https://github.com/pandas-dev/pandas/pull/28085#issuecomment-524066959
df = DataFrame(
Expand Down Expand Up @@ -106,6 +109,7 @@ def test_quantile_array_no_sort():
tm.assert_frame_equal(result, expected)


@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_quantile_array_multiple_levels():
df = DataFrame(
{"A": [0, 1, 2], "B": [3, 4, 5], "c": ["a", "a", "a"], "d": ["a", "a", "b"]}
Expand Down Expand Up @@ -216,6 +220,8 @@ def test_quantile_missing_group_values_correct_results(
@pytest.mark.parametrize("q", [0.5, [0.0, 0.5, 1.0]])
def test_groupby_quantile_nullable_array(values, q):
# https://github.com/pandas-dev/pandas/issues/33136
if isinstance(q, list):
pytest.skip("GH#39089 Numpy changed dtype inference")
df = DataFrame({"a": ["x"] * 3 + ["y"] * 3, "b": values})
result = df.groupby("a")["b"].quantile(q)

Expand Down Expand Up @@ -256,6 +262,7 @@ def test_groupby_timedelta_quantile():
tm.assert_frame_equal(result, expected)


@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_columns_groupby_quantile():
# GH 33795
df = DataFrame(
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/indexes/base_class/test_indexing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev

from pandas import Index
import pandas._testing as tm

Expand All @@ -13,6 +15,7 @@ def test_get_slice_bounds_within(self, kind, side, expected):
result = index.get_slice_bound("e", kind=kind, side=side)
assert result == expected

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
@pytest.mark.parametrize("kind", ["getitem", "loc", None])
@pytest.mark.parametrize("side", ["left", "right"])
@pytest.mark.parametrize(
Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/indexes/base_class/test_where.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev

from pandas import Index
import pandas._testing as tm


class TestWhere:
@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_where_intlike_str_doesnt_cast_ints(self):
idx = Index(range(3))
mask = np.array([True, False, True])
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/indexes/categorical/test_indexing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev
from pandas.errors import InvalidIndexError

import pandas as pd
Expand Down Expand Up @@ -129,6 +130,7 @@ def test_take_invalid_kwargs(self):


class TestGetLoc:
@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_get_loc(self):
# GH 12531
cidx1 = CategoricalIndex(list("abcde"), categories=list("edabc"))
Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/indexes/interval/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev
from pandas.errors import InvalidIndexError

import pandas as pd
Expand Down Expand Up @@ -916,6 +917,9 @@ def test_searchsorted_different_argument_classes(klass):
tm.assert_numpy_array_equal(result, expected)


@pytest.mark.xfail(
is_numpy_dev, reason="GH#39089 Numpy changed dtype inference", strict=False
)
@pytest.mark.parametrize(
"arg", [[1, 2], ["a", "b"], [Timestamp("2020-01-01", tz="Europe/London")] * 2]
)
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/indexes/period/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest

from pandas._libs.tslibs.period import IncompatibleFrequency
from pandas.compat import is_numpy_dev

from pandas.core.dtypes.dtypes import PeriodDtype

Expand Down Expand Up @@ -304,6 +305,7 @@ def test_constructor_incompat_freq(self):
)
)

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_constructor_mixed(self):
idx = PeriodIndex(["2011-01", NaT, Period("2011-01", freq="M")])
exp = PeriodIndex(["2011-01", "NaT", "2011-01"], freq="M")
Expand Down
6 changes: 5 additions & 1 deletion pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest

from pandas._libs.tslib import Timestamp
from pandas.compat import IS64
from pandas.compat import IS64, is_numpy_dev
from pandas.compat.numpy import np_datetime64_compat
from pandas.util._test_decorators import async_mark

Expand Down Expand Up @@ -1358,6 +1358,7 @@ def test_slice_float_locs(self, dtype):
assert index2.slice_locs(8.5, 1.5) == (2, 6)
assert index2.slice_locs(10.5, -1) == (0, n)

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_slice_locs_dup(self):
index = Index(["a", "a", "b", "c", "d", "d"])
assert index.slice_locs("a", "d") == (0, 6)
Expand Down Expand Up @@ -1397,6 +1398,9 @@ def test_slice_locs_na_raises(self):
with pytest.raises(KeyError, match=""):
index.slice_locs(end=1.5)

@pytest.mark.xfail(
is_numpy_dev, reason="GH#39089 Numpy changed dtype inference", strict=False
)
@pytest.mark.parametrize(
"in_slice,expected",
[
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/indexes/test_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

from pandas._libs import algos as libalgos, index as libindex
from pandas.compat import is_numpy_dev

import pandas as pd
import pandas._testing as tm
Expand Down Expand Up @@ -198,6 +199,7 @@ def test_is_unique(self):
engine = self.engine_type(lambda: arr, len(arr))
assert engine.is_unique is False

@pytest.mark.xfail(is_numpy_dev, reason="GH#39089 Numpy changed dtype inference")
def test_get_loc(self):
# unique
arr = np.array(self.values, dtype=self.dtype)
Expand Down
Loading