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)
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)
def test_int_list_fail_wrapped(self): x = [0, 1] with self.assertRaises(TypeError): util.check_dtype(x, type_=int, check_not=True)
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)
def test_multi_fail_wrapped(self): types = {int, str} x = ["a", 0] with self.assertRaises(TypeError): util.check_dtype(x, type_=types)
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)
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)
def test_int_tuple_succ(self): x = (0, 1) self.assertEqual(util.check_dtype(x, type_=int), x)
def test_int_series_succ(self): import pandas as pd x = pd.Series([0, 1]) self.assertIs(util.check_dtype(x, type_=int), x)
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)
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)
def test_int_list_succ(self): x = [0, 1] self.assertEqual(util.check_dtype(x, type_=int), x)
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)
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)
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)
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)
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)