Example #1
0
    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)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
 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]')
Example #6
0
 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]')
Example #7
0
 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]')
Example #8
0
    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)
Example #9
0
    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)
Example #10
0
 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)
Example #11
0
    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)
Example #12
0
 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)
Example #13
0
    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)
Example #14
0
    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)
Example #15
0
 def dtype(self):
     """Return the dtype object of the underlying data"""
     return IntervalDtype.construct_from_string(str(self.left.dtype))
Example #16
0
 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)
Example #17
0
    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)
Example #18
0
 def dtype(self):
     return IntervalDtype.construct_from_string(str(self.left.dtype))
Example #19
0
    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)
Example #20
0
    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)
Example #21
0
    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)
Example #22
0
 def dtype(self):
     return IntervalDtype.construct_from_string(str(self.left.dtype))
Example #23
0
 def dtype(self):
     """Return the dtype object of the underlying data"""
     return IntervalDtype.construct_from_string(str(self.left.dtype))