-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_model_generation.py
executable file
·89 lines (73 loc) · 2.6 KB
/
test_model_generation.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
87
88
89
#!/usr/bin/env python3
# Purpose: Unit tests Pandas to FBX
# Usage:
# source env/bin/activate
# python3 -m unittest discover .
import os
from pathlib import Path
import pandas as pd
import unittest
import config
import render
# Config
logger = config.get_logger()
# Constants
source_filepath = Path('./examples/plotly-gpl-data/3d-scatter.csv')
source_x_column = 'x1'
source_y_column = 'y1'
source_z_column = 'z1'
# source_filepath = Path('./examples/cs.du.edu/leut-MDdata-5k.rect.normal.ascii.csv')
# source_x_column = 'x1'
# source_y_column = 'y4'
# source_z_column = 'z1'
# source_filepath = Path('./examples/ml.ics.uci.edu/winequality-red.csv')
# source_x_column = 'chlorides'
# source_y_column = 'sulphates'
# source_z_column = 'density'
obj_filepath = Path('./examples/cube.obj')
output_path = './output'
# Data builders
def load_dataframe():
df = pd.read_csv(filepath_or_buffer=str(source_filepath))
return df
# Tests
class TestAggregation(unittest.TestCase):
def setUp(self):
logger.debug("Set-up")
if not os.path.exists(output_path):
os.makedirs(output_path)
def tearDown(self):
logger.debug("Tear-down")
def test_to_logging(self):
df = load_dataframe()
assert len(df)
render.to_logging(df,
z_column=source_z_column,
x_column=source_x_column,
y_column=source_y_column)
def test_to_3d_scatter(self):
visualisation_type = 'scatter_plot_3d'
file_type = '.png'
output_filepath = Path(output_path, visualisation_type).with_suffix(file_type)
df = load_dataframe()
assert len(df) > 0
render.to_3dscatter(df,
z_column=source_z_column,
x_column=source_x_column,
y_column=source_y_column,
output_filepath=output_filepath)
assert output_filepath.exists()
def test_generate_simple_object(self):
visualisation_type = 'scatter_plot_3d_object'
file_type = '.obj'
output_filepath = Path(output_path, visualisation_type).with_suffix(file_type)
df = load_dataframe()
assert len(df) > 0
render.to_3dscatter_3dobject(df,
z_column=source_z_column,
x_column=source_x_column,
y_column=source_y_column,
output_filepath=output_filepath)
assert output_filepath.exists()
if __name__ == '__main__':
unittest.main()