Skip to content

Commit

Permalink
TST: troubleshoot npdev build (#31594)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Feb 3, 2020
1 parent cf8c680 commit 27f365d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from pandas._config import get_option

from pandas._libs import lib, properties, reshape, tslibs
from pandas._libs.index import validate_numeric_casting
from pandas._typing import Label
from pandas.compat.numpy import function as nv
from pandas.util._decorators import Appender, Substitution
Expand Down Expand Up @@ -1022,7 +1023,7 @@ def __setitem__(self, key, value):
def _set_with_engine(self, key, value):
# fails with AttributeError for IntervalIndex
loc = self.index._engine.get_loc(key)
libindex.validate_numeric_casting(self.dtype, value)
validate_numeric_casting(self.dtype, value)
self._values[loc] = value

def _set_with(self, key, value):
Expand Down Expand Up @@ -1105,7 +1106,7 @@ def _set_value(self, label, value, takeable: bool = False):
self._values[label] = value
else:
loc = self.index.get_loc(label)
libindex.validate_numeric_casting(self.dtype, value)
validate_numeric_casting(self.dtype, value)
self._values[loc] = value
except KeyError:

Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/dtypes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,8 @@ def test__get_dtype(input_param, result):
)
def test__get_dtype_fails(input_param, expected_error_message):
# python objects
# 2020-02-02 npdev changed error message
expected_error_message += f"|Cannot interpret '{input_param}' as a data type"
with pytest.raises(TypeError, match=expected_error_message):
com._get_dtype(input_param)

Expand Down
7 changes: 6 additions & 1 deletion pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def test_equality_invalid(self, dtype):
assert not is_dtype_equal(dtype, np.int64)

def test_numpy_informed(self, dtype):
with pytest.raises(TypeError, match="data type not understood"):
# npdev 2020-02-02 changed from "data type not understood" to
# "Cannot interpret 'foo' as a data type"
msg = "|".join(
["data type not understood", "Cannot interpret '.*' as a data type"]
)
with pytest.raises(TypeError, match=msg):
np.dtype(dtype)

assert not dtype == np.str_
Expand Down

0 comments on commit 27f365d

Please sign in to comment.