-
Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathtest_created__example.py
86 lines (64 loc) · 2.26 KB
/
test_created__example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import datetime
import numpy as np
from optimus.tests.base import TestBase
from optimus.helpers.json import json_encoding
from optimus.helpers.functions import deep_sort, df_dicts_equal, results_equal
def Timestamp(t):
return datetime.datetime.strptime(t, "%Y-%m-%d %H:%M:%S")
NaT = np.datetime64('NaT')
nan = float("nan")
inf = float("inf")
class TestExamplePandas(TestBase):
config = {'engine': 'pandas'}
dict = {('name', 'object'): ['Optimus', 'Bumblebee', 'Eject'], ('age (M)', 'int64'): [5, 5, 5]}
maxDiff = None
def test_cols_upper_multiple(self):
df = self.df.copy()
result = df.cols.upper(cols=['name', 'age (M)'])
result = result.to_dict()
expected = {'name': ['OPTIMUS', 'BUMBLEBEE', 'EJECT'], 'age (M)': ['5', '5', '5']}
self.assertEqual(json_encoding(result), json_encoding(expected))
def test_cols_upper_single(self):
df = self.df.copy()
result = df.cols.upper(cols=['name'])
expected = self.create_dataframe(data={('name', 'object'): ['OPTIMUS', 'BUMBLEBEE', 'EJECT'], ('age (M)', 'int64'): [5, 5, 5]}, force_data_types=True)
self.assertTrue(result.equals(expected, decimal=True, assertion=True))
class TestExampleDask(TestExamplePandas):
config = {'engine': 'dask', 'n_partitions': 1}
class TestExamplePartitionDask(TestExamplePandas):
config = {'engine': 'dask', 'n_partitions': 2}
try:
import cudf # pyright: reportMissingImports=false
except:
pass
else:
class TestExampleCUDF(TestExamplePandas):
config = {'engine': 'cudf'}
try:
import dask_cudf # pyright: reportMissingImports=false
except:
pass
else:
class TestExampleDC(TestExamplePandas):
config = {'engine': 'dask_cudf', 'n_partitions': 1}
try:
import dask_cudf # pyright: reportMissingImports=false
except:
pass
else:
class TestExamplePartitionDC(TestExamplePandas):
config = {'engine': 'dask_cudf', 'n_partitions': 2}
try:
import pyspark # pyright: reportMissingImports=false
except:
pass
else:
class TestExampleSpark(TestExamplePandas):
config = {'engine': 'spark'}
try:
import vaex # pyright: reportMissingImports=false
except:
pass
else:
class TestExampleVaex(TestExamplePandas):
config = {'engine': 'vaex'}