Exemple #1
0
 def test_complex_series_fail(self):
     import pandas as pd
     for x in "a", 0, pd.DataFrame(), pd.DataFrame(0,
                                                   index=["r0", "r1"],
                                                   columns=["c0", "c1"]):
         with self.assertRaises(TypeError):
             util.check_type(x, type_=pd.Series)
Exemple #2
0
 def test_complex_series_succ_direct(self):
     import pandas as pd
     for x in "a", 0, pd.DataFrame(), pd.DataFrame(0,
                                                   index=["r0", "r1"],
                                                   columns=["c0", "c1"]):
         self.assertIs(util.check_type(x, type_=pd.Series, check_not=True),
                       x)
Exemple #3
0
 def test_int_series_succ_direct(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_type(x, type_=int, check_dtype=True,
                             check_not=True), x)
Exemple #4
0
 def test_primitive_int_succ_direct(self):
     for x in "a", 3.14, (0, 1), [0, 1]:
         self.assertEqual(util.check_type(x, type_=int, check_not=True), x)
Exemple #5
0
 def test_primitive_int_fail_direct(self):
     for x in -128, -2, -1, 0, 1, 2, 172:
         with self.assertRaises(TypeError):
             util.check_type(x, type_=int, check_not=True)
Exemple #6
0
 def test_multi_fail(self):
     types = {str, float, tuple, list}
     x = 0
     with self.assertRaises(TypeError):
         util.check_type(x, type_=types)
Exemple #7
0
 def test_multi_succ(self):
     types = {str, float, tuple, list}
     for x in "a", 3.14, (0, 1), [0, 1]:
         self.assertEqual(util.check_type(x, type_=types), x)
Exemple #8
0
 def test_int_df_succ_direct(self):
     import pandas as pd
     x = pd.DataFrame({"c0": {"r0": 0, "r1": 1}, "c1": {"r0": 2, "r1": 3.}})
     self.assertIs(
         util.check_type(x, type_=int, check_dtype=True, check_not=True), x)
Exemple #9
0
 def test_primitive_int_fail(self):
     for x in "a", 3.14, (0, 1), [0, 1]:
         with self.assertRaises(TypeError):
             util.check_type(x, type_=int)
Exemple #10
0
 def test_int_series_fail_direct(self):
     import pandas as pd
     x = pd.Series([0, 1])
     with self.assertRaises(TypeError):
         util.check_type(x, type_=int, check_dtype=True, check_not=True)
Exemple #11
0
 def test_int_list_succ_direct(self):
     import pandas as pd
     for x in ["a", "b"], [3.14, 2.71], [0, 0.]:
         self.assertEqual(
             util.check_type(x, type_=int, check_dtype=True,
                             check_not=True), x)
Exemple #12
0
 def test_int_list_fail_direct(self):
     x = [0, 1]
     with self.assertRaises(TypeError):
         util.check_type(x, type_=int, check_dtype=True, check_not=True)
Exemple #13
0
 def test_int_tuple_succ_direct(self):
     import pandas as pd
     for x in ("a", "b"), (3.14, 2.71), (0, 0.):
         self.assertEqual(
             util.check_type(x, type_=int, check_dtype=True,
                             check_not=True), x)
Exemple #14
0
 def test_complex_series_succ(self):
     import pandas as pd
     for x in pd.Series(dtype=object), pd.Series([0, 1]):
         # pd.Series.__equals__() tests elementwise equality, we want to test identity
         self.assertIs(util.check_type(x, type_=pd.Series), x)
Exemple #15
0
 def test_complex_series_fail_direct(self):
     import pandas as pd
     for x in pd.Series(dtype=object), pd.Series([0, 1]):
         with self.assertRaises(TypeError):
             util.check_type(x, type_=pd.Series, check_not=True)
Exemple #16
0
 def test_primitive_int_succ(self):
     for x in -128, -2, -1, 0, 1, 2, 172:
         self.assertEqual(util.check_type(x, type_=int), x)
Exemple #17
0
 def test_int_df_fail_direct(self):
     import pandas as pd
     x = pd.DataFrame({"c0": {"r0": 0, "r1": 1}, "c1": {"r0": 2, "r1": 3}})
     with self.assertRaises(TypeError):
         util.check_type(x, type_=int, check_dtype=True, check_not=True)
Exemple #18
0
 def test_multi_fail_direct(self):
     types = [str, float, tuple, list]
     for x in "a", 3.14, (0, 1), [0, 1]:
         with self.assertRaises(TypeError):
             util.check_type(x, type_=types, check_not=True)
Exemple #19
0
 def test_multi_succ_direct(self):
     types = {str, float, tuple, list}
     x = 0
     self.assertEqual(util.check_type(x, type_=types, check_not=True), x)