Beispiel #1
0
 def test_int_series_fail_wrapped(self):
     import pandas as pd
     x = pd.Series([0, 1])
     with self.assertRaises(TypeError):
         util.check_dtype(x, type_=int, check_not=True)
Beispiel #2
0
 def test_int_series_succ_wrapped(self):
     import pandas as pd
     for x in pd.Series(["a", "b"]), pd.Series([3.14,
                                                2.71]), pd.Series([0, 0.]):
         self.assertIs(util.check_dtype(x, type_=int, check_not=True), x)
Beispiel #3
0
 def test_int_list_fail_wrapped(self):
     x = [0, 1]
     with self.assertRaises(TypeError):
         util.check_dtype(x, type_=int, check_not=True)
Beispiel #4
0
 def test_int_list_succ_wrapped(self):
     import pandas as pd
     for x in ["a", "b"], [3.14, 2.71], [0, 0.]:
         self.assertEqual(util.check_dtype(x, type_=int, check_not=True), x)
Beispiel #5
0
 def test_multi_fail_wrapped(self):
     types = {int, str}
     x = ["a", 0]
     with self.assertRaises(TypeError):
         util.check_dtype(x, type_=types)
Beispiel #6
0
 def test_int_tuple_succ_wrapped(self):
     import pandas as pd
     for x in ("a", "b"), (3.14, 2.71), (0, 0.):
         self.assertEqual(util.check_dtype(x, type_=int, check_not=True), x)
Beispiel #7
0
 def test_int_df_succ(self):
     import pandas as pd
     x = pd.DataFrame({"c0": {"r0": 0, "r1": 1}, "c1": {"r0": 2, "r1": 3}})
     self.assertIs(util.check_dtype(x, type_=int), x)
Beispiel #8
0
 def test_int_tuple_succ(self):
     x = (0, 1)
     self.assertEqual(util.check_dtype(x, type_=int), x)
Beispiel #9
0
 def test_int_series_succ(self):
     import pandas as pd
     x = pd.Series([0, 1])
     self.assertIs(util.check_dtype(x, type_=int), x)
Beispiel #10
0
 def test_int_series_fail(self):
     import pandas as pd
     for x in pd.Series(["a", "b"]), pd.Series([3.14,
                                                2.71]), pd.Series([0, 0.]):
         with self.assertRaises(TypeError):
             util.check_dtype(x, type_=int)
Beispiel #11
0
 def test_int_list_fail(self):
     import pandas as pd
     for x in ["a", "b"], [3.14, 2.71], [0, 0.]:
         with self.assertRaises(TypeError):
             util.check_dtype(x, type_=int)
Beispiel #12
0
 def test_int_list_succ(self):
     x = [0, 1]
     self.assertEqual(util.check_dtype(x, type_=int), x)
Beispiel #13
0
 def test_int_tuple_fail(self):
     import pandas as pd
     for x in ("a", "b"), (3.14, 2.71), (0, 0.):
         with self.assertRaises(TypeError):
             util.check_dtype(x, type_=int)
Beispiel #14
0
 def test_int_df_fail_wrapped(self):
     import pandas as pd
     x = pd.DataFrame({"c0": {"r0": 0, "r1": 1}, "c1": {"r0": 2, "r1": 3}})
     with self.assertRaises(TypeError):
         util.check_dtype(x, type_=int, check_not=True)
Beispiel #15
0
 def test_multi_succ_wrapped(self):
     types = {int, str}
     for x in ["a", "b"], [0, 1]:
         self.assertEqual(util.check_dtype(x, type_=types), x)
Beispiel #16
0
 def test_int_df_succ_wrapped(self):
     import pandas as pd
     x = pd.DataFrame({"c0": {"r0": 0, "r1": 1}, "c1": {"r0": 2, "r1": 3.}})
     self.assertIs(util.check_dtype(x, type_=int, check_not=True), x)
Beispiel #17
0
 def test_non_collection_fail(self):
     # `str` is arguably a collection type but certainly not a collection of ints
     for x in "a", 0, 3.14:
         with self.assertRaises(TypeError):
             util.check_dtype(x, type_=int)