Skip to content

Commit 1b540ce

Browse files
committed
(tests) added tests for the scaling table/dict calculations based on a slightly more complex test (7 design components in 4 component elemental space)
1 parent f2dc1e4 commit 1b540ce

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

tests/coreUtils.nim

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,47 @@ suite "Small real elemental space scaling table test":
7070
test "Scaling for " & $key & " -> " & twoHotEdgePrintout(key, components) & " matches reference (" & $referenceTable[key] & ")":
7171
check almostEqual(value, referenceTable[key])
7272

73+
suite "Larger integer elemental space scaling table test":
74+
const
75+
components: seq[seq[float]] = @[
76+
@[1, 0, 0, 0], # A
77+
@[0.99, 0.01, 0, 0], # A99 B1
78+
@[0, 1, 0, 0], # B
79+
@[0, 0, 0.5, 0.5], # C50 D50
80+
@[0, 0, 1, 0], # C
81+
@[0.5, 0, 0, 0.5], # A50 D50
82+
@[0.25, 0.25, 0.25, 0.25] # A25 B25 C25 D25
83+
]
84+
referenceTable: Table[seq[int], float] = {
85+
@[0, 0, 0, 0, 1, 0, 1]: 0.75,
86+
@[1, 0, 1, 0, 0, 0, 0]: 1.0,
87+
@[0, 0, 1, 0, 1, 0, 0]: 1.0,
88+
@[0, 0, 0, 1, 1, 0, 0]: 0.5,
89+
@[0, 1, 0, 0, 0, 1, 0]: 0.5,
90+
@[1, 0, 0, 0, 1, 0, 0]: 1.0,
91+
@[0, 1, 1, 0, 0, 0, 0]: 0.99,
92+
@[0, 0, 1, 1, 0, 0, 0]: 1.0,
93+
@[0, 0, 0, 0, 1, 1, 0]: 1.0,
94+
@[0, 0, 0, 1, 0, 1, 0]: 0.5,
95+
@[0, 0, 0, 1, 0, 0, 1]: 0.5,
96+
@[0, 0, 0, 0, 0, 1, 1]: 0.5,
97+
@[1, 1, 0, 0, 0, 0, 0]: 0.01,
98+
@[1, 0, 0, 1, 0, 0, 0]: 1.0,
99+
@[0, 0, 1, 0, 0, 1, 0]: 1.0,
100+
@[0, 1, 0, 0, 1, 0, 0]: 1.0,
101+
@[0, 1, 0, 0, 0, 0, 1]: 0.74,
102+
@[0, 0, 1, 0, 0, 0, 1]: 0.75,
103+
@[1, 0, 0, 0, 0, 1, 0]: 0.5,
104+
@[0, 1, 0, 1, 0, 0, 0]: 1.0,
105+
@[1, 0, 0, 0, 0, 0, 1]: 0.75
106+
}.toTable
107+
108+
let testTable = nimplex.elemental_space_scaling_table(components)
109+
echo testTable
110+
for key, value in testTable.pairs:
111+
test "Scaling for " & $key & " -> " & twoHotEdgePrintout(key, components) & " matches reference (" & $referenceTable[key] & ")":
112+
check almostEqual(value, referenceTable[key])
113+
73114
echo "***** CORE UTILS BENCHMARK RESULTS *****"
74115
let t1 = cpuTime()
75116
echo "Time:\n" & $initDuration(milliseconds = ((t1 - t0)*1e3).int) & "\n"

0 commit comments

Comments
 (0)