Skip to content

Commit

Permalink
CI: Add unwanted pattern check (pandas-dev#37298)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsaxton authored Oct 21, 2020
1 parent 6430d53 commit 021d831
Show file tree
Hide file tree
Showing 119 changed files with 1,522 additions and 1,619 deletions.
2 changes: 2 additions & 0 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
MSG='Check for inconsistent use of pandas namespace in tests' ; echo $MSG
check_namespace "Series"
RET=$(($RET + $?))
check_namespace "DataFrame"
RET=$(($RET + $?))
echo $MSG "DONE"
fi

Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/arithmetic/test_timedelta64.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,14 +722,14 @@ def test_timedelta_ops_with_missing_values(self):

sn = pd.to_timedelta(Series([pd.NaT], dtype="m8[ns]"))

df1 = pd.DataFrame(["00:00:01"]).apply(pd.to_timedelta)
df2 = pd.DataFrame(["00:00:02"]).apply(pd.to_timedelta)
df1 = DataFrame(["00:00:01"]).apply(pd.to_timedelta)
df2 = DataFrame(["00:00:02"]).apply(pd.to_timedelta)
with pytest.raises(TypeError, match=msg):
# Passing datetime64-dtype data to TimedeltaIndex is no longer
# supported GH#29794
pd.DataFrame([pd.NaT]).apply(pd.to_timedelta)
DataFrame([pd.NaT]).apply(pd.to_timedelta)

dfn = pd.DataFrame([pd.NaT.value]).apply(pd.to_timedelta)
dfn = DataFrame([pd.NaT.value]).apply(pd.to_timedelta)

scalar1 = pd.to_timedelta("00:00:01")
scalar2 = pd.to_timedelta("00:00:02")
Expand Down
24 changes: 12 additions & 12 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def test_unary_in_array(self):
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
def test_float_comparison_bin_op(self, dtype):
# GH 16363
df = pd.DataFrame({"x": np.array([0], dtype=dtype)})
df = DataFrame({"x": np.array([0], dtype=dtype)})
res = df.eval("x < -0.1")
assert res.values == np.array([False])

Expand Down Expand Up @@ -734,7 +734,7 @@ def test_float_truncation(self):
expected = np.float64(exp)
assert result == expected

df = pd.DataFrame({"A": [1000000000.0009, 1000000000.0011, 1000000000.0015]})
df = DataFrame({"A": [1000000000.0009, 1000000000.0011, 1000000000.0015]})
cutoff = 1000000000.0006
result = df.query(f"A < {cutoff:.4f}")
assert result.empty
Expand All @@ -751,12 +751,12 @@ def test_float_truncation(self):

def test_disallow_python_keywords(self):
# GH 18221
df = pd.DataFrame([[0, 0, 0]], columns=["foo", "bar", "class"])
df = DataFrame([[0, 0, 0]], columns=["foo", "bar", "class"])
msg = "Python keyword not valid identifier in numexpr query"
with pytest.raises(SyntaxError, match=msg):
df.query("class == 0")

df = pd.DataFrame()
df = DataFrame()
df.index.name = "lambda"
with pytest.raises(SyntaxError, match=msg):
df.query("lambda == 0")
Expand Down Expand Up @@ -1366,7 +1366,7 @@ def assignment_not_inplace(self):

def test_multi_line_expression(self):
# GH 11149
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
expected = df.copy()

expected["c"] = expected["a"] + expected["b"]
Expand Down Expand Up @@ -1403,7 +1403,7 @@ def test_multi_line_expression(self):

def test_multi_line_expression_not_inplace(self):
# GH 11149
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
expected = df.copy()

expected["c"] = expected["a"] + expected["b"]
Expand All @@ -1428,7 +1428,7 @@ def test_multi_line_expression_not_inplace(self):

def test_multi_line_expression_local_variable(self):
# GH 15342
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
expected = df.copy()

local_var = 7
Expand All @@ -1446,7 +1446,7 @@ def test_multi_line_expression_local_variable(self):

def test_multi_line_expression_callable_local_variable(self):
# 26426
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})

def local_func(a, b):
return b
Expand All @@ -1466,7 +1466,7 @@ def local_func(a, b):

def test_multi_line_expression_callable_local_variable_with_kwargs(self):
# 26426
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})

def local_func(a, b):
return b
Expand All @@ -1486,7 +1486,7 @@ def local_func(a, b):

def test_assignment_in_query(self):
# GH 8664
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
df_orig = df.copy()
msg = "cannot assign without a target object"
with pytest.raises(ValueError, match=msg):
Expand All @@ -1495,7 +1495,7 @@ def test_assignment_in_query(self):

def test_query_inplace(self):
# see gh-11149
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
expected = df.copy()
expected = expected[expected["a"] == 2]
df.query("a == 2", inplace=True)
Expand Down Expand Up @@ -2052,7 +2052,7 @@ def test_truediv_deprecated(engine, parser):


def test_negate_lt_eq_le(engine, parser):
df = pd.DataFrame([[0, 10], [1, 20]], columns=["cat", "count"])
df = DataFrame([[0, 10], [1, 20]], columns=["cat", "count"])
expected = df[~(df.cat > 0)]

result = df.query("~(cat > 0)", engine=engine, parser=parser)
Expand Down
Loading

0 comments on commit 021d831

Please sign in to comment.