This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinmobiliaria.py
154 lines (149 loc) · 10.3 KB
/
inmobiliaria.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
from utils import place_floors, value_floors, chart_floors
def test(n, f, tests, type_=None):
success = failed = 0
for inputs_, output_ in tests:
try:
if type_ == 'img':
assert sum(sum(chanels) for chanels in ImageChops.difference(f(*inputs_), Image.open(output_)).getdata()) < 10
elif type_ == 'gif':
images = f(*inputs_)
gif = Image.open(output_)
n0 = 0
i0 = i1 = 0
while i0 < gif.n_frames and i1 < len(images):
gif.seek(i0)
diff = None
while diff is None and i0 < gif.n_frames:
try:
diff = sum(sum(chanels) for chanels in ImageChops.difference(images[i1], gif).getdata())
except ValueError:
i0 +=1
gif.seek(i0)
while diff > 10 and i1 < len(images):
diff = sum(sum(chanels) for chanels in ImageChops.difference(images[i1], gif).getdata())
i1 += 1
n0 += 1
i0 +=1
i1 += 1
assert n0 > 0.9 * gif.n_frames
elif type_ == 'bar3d':
fig = f(*inputs_)
ax = fig.get_axes()[0]
n0 = 0
for child in ax.get_children():
if isinstance(child, Poly3DCollection):
vec = tuple(tuple(round(v, 3) for v in row) for row in child._vec)
ofc = tuple(tuple(round(v, 3) for v in row) for row in child._original_facecolor)
if (vec, ofc) in output_:
n0 += 1
assert n0 == len(output_)
else:
assert f(*inputs_) == output_
success += 1
except AssertionError:
failed += 1
print(f"TEST {n}: {success} exitosos y {failed} erróneos")
tests1 = [
(([[0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9]], 5), [[3, 2, 0], [0, 0, 0], [0, 0, 0]]),
(([[0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1]], 5), [[1, 0, 0, 0], [1, 1, 0, 0], [1, 1, 0, 0]])
]
tests2 = [
(([[0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9]], 5),
[[[9000000.0, 1800000.0, 270000.0], [8000000.0, 1600000.0, 0], [0, 0, 0]], [[0, 0, 0], [0, 0, 0], [0, 0, 0]], [[0, 0, 0], [0, 0, 0], [0, 0, 0]]]),
(([[0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1]], 5),
[[[9000000.0], [0], [0], [0]], [[9000000.0], [9000000.0], [0], [0]], [[9000000.0], [9000000.0], [0], [0]]])
]
tests3 = [
(([[0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9]], 5),
{((
(-0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5),
(-0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5),
(1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0, 1.0, 1.0, 2.0, 2.0, 1.0, 1.0, 1.0, 2.0, 2.0),
(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.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, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)),
(
(0.425, 0.071, 0.0, 1.0),
(0.611, 0.102, 0.0, 1.0),
(0.704, 0.117, 0.0, 1.0),
(0.332, 0.055, 0.0, 1.0),
(0.704, 0.117, 0.0, 1.0),
(0.332, 0.055, 0.0, 1.0),
(0.425, 0.071, 0.0, 1.0),
(0.611, 0.102, 0.0, 1.0),
(0.704, 0.117, 0.0, 1.0),
(0.332, 0.055, 0.0, 1.0),
(0.704, 0.117, 0.0, 1.0),
(0.332, 0.055, 0.0, 1.0))),
((
(-0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5),
(-0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, 1.5, 0.5, 0.5, 1.5, 1.5, 0.5, 1.5, 1.5, 0.5),
(-1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, -1.0, 0.0, 0.0, -1.0, -1.0, -1.0, 0.0, 0.0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, 1.0, 1.0, 1.0, 1.0, 1.0)),
(
(0.0, 0.496, 0.0, 1.0),
(0.0, 0.713, 0.0, 1.0),
(0.0, 0.821, 0.0, 1.0),
(0.0, 0.387, 0.0, 1.0),
(0.0, 0.821, 0.0, 1.0),
(0.0, 0.387, 0.0, 1.0),
(0.0, 0.496, 0.0, 1.0),
(0.0, 0.713, 0.0, 1.0),
(0.0, 0.821, 0.0, 1.0),
(0.0, 0.387, 0.0, 1.0),
(0.0, 0.821, 0.0, 1.0),
(0.0, 0.387, 0.0, 1.0),
(0.0, 0.496, 0.0, 1.0),
(0.0, 0.713, 0.0, 1.0),
(0.0, 0.821, 0.0, 1.0),
(0.0, 0.387, 0.0, 1.0),
(0.0, 0.821, 0.0, 1.0),
(0.0, 0.387, 0.0, 1.0),
(0.0, 0.496, 0.0, 1.0),
(0.0, 0.713, 0.0, 1.0),
(0.0, 0.821, 0.0, 1.0),
(0.0, 0.387, 0.0, 1.0),
(0.0, 0.821, 0.0, 1.0),
(0.0, 0.387, 0.0, 1.0),
(0.0, 0.496, 0.0, 1.0),
(0.0, 0.713, 0.0, 1.0),
(0.0, 0.821, 0.0, 1.0),
(0.0, 0.387, 0.0, 1.0),
(0.0, 0.821, 0.0, 1.0),
(0.0, 0.387, 0.0, 1.0)))
})
]
test(1, place_floors, tests1)
test(2, value_floors, tests2)
test(3, chart_floors, tests3, 'bar3d')