def test_construction_from_string_error_subtype(self, string): # this is an invalid subtype msg = ("Incorrectly formatted string passed to constructor. " r"Valid formats include Interval or Interval\[dtype\] " "where dtype is numeric, datetime, or timedelta") with pytest.raises(TypeError, match=msg): IntervalDtype.construct_from_string(string)
def test_construction_from_string_errors(self, string): if isinstance(string, string_types): error, msg = ValueError, 'could not construct IntervalDtype' else: error, msg = TypeError, 'a string needs to be passed, got type' with tm.assert_raises_regex(error, msg): IntervalDtype.construct_from_string(string)
def test_construction_from_string_error_subtype(self, string): # this is an invalid subtype msg = ("Incorrectly formatted string passed to constructor. " r"Valid formats include Interval or Interval\[dtype\] " "where dtype is numeric, datetime, or timedelta") with pytest.raises(TypeError, match=msg): IntervalDtype.construct_from_string(string)
def test_construction_from_string_errors(self, string): if isinstance(string, string_types): error, msg = ValueError, 'could not construct IntervalDtype' else: error, msg = TypeError, 'a string needs to be passed, got type' with tm.assert_raises_regex(error, msg): IntervalDtype.construct_from_string(string)
def test_construction_from_string(self): result = IntervalDtype('interval[int64]') self.assertTrue(is_dtype_equal(self.dtype, result)) result = IntervalDtype.construct_from_string('interval[int64]') self.assertTrue(is_dtype_equal(self.dtype, result)) with pytest.raises(TypeError): IntervalDtype.construct_from_string('foo') with pytest.raises(TypeError): IntervalDtype.construct_from_string('interval[foo]') with pytest.raises(TypeError): IntervalDtype.construct_from_string('foo[int64]')
def test_construction_from_string(self): result = IntervalDtype('interval[int64]') self.assertTrue(is_dtype_equal(self.dtype, result)) result = IntervalDtype.construct_from_string('interval[int64]') self.assertTrue(is_dtype_equal(self.dtype, result)) with tm.assertRaises(TypeError): IntervalDtype.construct_from_string('foo') with tm.assertRaises(TypeError): IntervalDtype.construct_from_string('interval[foo]') with tm.assertRaises(TypeError): IntervalDtype.construct_from_string('foo[int64]')
def test_construction_from_string(self): result = IntervalDtype('interval[int64]') assert is_dtype_equal(self.dtype, result) result = IntervalDtype.construct_from_string('interval[int64]') assert is_dtype_equal(self.dtype, result) with pytest.raises(TypeError): IntervalDtype.construct_from_string('foo') with pytest.raises(TypeError): IntervalDtype.construct_from_string('interval[foo]') with pytest.raises(TypeError): IntervalDtype.construct_from_string('foo[int64]')
def test_construction_from_string_errors(self, string): # these are invalid entirely msg = "a string needs to be passed, got type" with pytest.raises(TypeError, match=msg): IntervalDtype.construct_from_string(string)
def test_construction_from_string_error_subtype(self, string): # this is an invalid subtype msg = 'could not construct IntervalDtype' with pytest.raises(TypeError, match=msg): IntervalDtype.construct_from_string(string)
def test_construction_from_string(self): result = IntervalDtype('interval[int64]') assert is_dtype_equal(self.dtype, result) result = IntervalDtype.construct_from_string('interval[int64]') assert is_dtype_equal(self.dtype, result)
def test_construction_from_string_errors(self, string): # these are invalid entirely msg = 'a string needs to be passed, got type' with tm.assert_raises_regex(TypeError, msg): IntervalDtype.construct_from_string(string)
def test_construction_from_string(self, dtype): result = IntervalDtype("interval[int64]") assert is_dtype_equal(dtype, result) result = IntervalDtype.construct_from_string("interval[int64]") assert is_dtype_equal(dtype, result)
def test_construction_from_string_error_subtype(self, string): # this is an invalid subtype msg = 'could not construct IntervalDtype' with tm.assert_raises_regex(TypeError, msg): IntervalDtype.construct_from_string(string)
def test_construction_from_string_errors(self, string): # these are invalid entirely msg = 'a string needs to be passed, got type' with tm.assert_raises_regex(TypeError, msg): IntervalDtype.construct_from_string(string)
def dtype(self): """Return the dtype object of the underlying data""" return IntervalDtype.construct_from_string(str(self.left.dtype))
def test_construction_from_string(self): result = IntervalDtype('interval[int64]') assert is_dtype_equal(self.dtype, result) result = IntervalDtype.construct_from_string('interval[int64]') assert is_dtype_equal(self.dtype, result)
def test_construction_from_string_errors(self, string): # these are invalid entirely msg = f"'construct_from_string' expects a string, got {type(string)}" with pytest.raises(TypeError, match=re.escape(msg)): IntervalDtype.construct_from_string(string)
def dtype(self): return IntervalDtype.construct_from_string(str(self.left.dtype))
def test_construction_from_string_errors(self, string): # these are invalid entirely msg = 'a string needs to be passed, got type' with pytest.raises(TypeError, match=msg): IntervalDtype.construct_from_string(string)
def test_construction_from_string_error_subtype(self, string): # this is an invalid subtype msg = 'could not construct IntervalDtype' with tm.assert_raises_regex(TypeError, msg): IntervalDtype.construct_from_string(string)
def test_construction_from_string_error_subtype(self, string): # this is an invalid subtype msg = 'could not construct IntervalDtype' with pytest.raises(TypeError, match=msg): IntervalDtype.construct_from_string(string)
def dtype(self): return IntervalDtype.construct_from_string(str(self.left.dtype))
def dtype(self): """Return the dtype object of the underlying data""" return IntervalDtype.construct_from_string(str(self.left.dtype))