11from PyXAB .partition .DimensionBinaryPartition import DimensionBinaryPartition
2+ from numpy .testing import assert_allclose
23import pytest
3-
4+ import copy
45
56def test_dimension_binary_partition_value_error ():
67 with pytest .raises (ValueError ):
@@ -14,17 +15,26 @@ def test_dimension_binary_partition_1D_deepen():
1415 for i in range (5 ):
1516 part .deepen ()
1617 nodelist = part .get_node_list ()
17- for node in nodelist [- 1 ]:
18- print (node .depth , node .index , node .domain , "\\ " )
19- print (part .get_root ().get_domain ())
18+ for j in range (len (nodelist [- 1 ])):
19+ assert_allclose (
20+ nodelist [- 1 ][j ].get_domain (),
21+ [[j / (2 ** (i + 1 )), (j + 1 ) / (2 ** (i + 1 ))]],
22+ )
2023
2124
2225def test_dimension_binary_partition_3D_deepen ():
23- domain = [[0 , 1 ], [10 , 50 ], [- 5 , - 10 ]]
26+ domain = [[0 , 1 ], [0 , 1 ], [0 , 1 ]]
2427 part = DimensionBinaryPartition (domain )
25-
26- for i in range (2 ):
28+ for i in range (5 ):
2729 part .deepen ()
28- nodelist = part .get_node_list ()
29- for node in nodelist [- 1 ]:
30- print (node .depth , node .index , node .domain , "\\ " )
30+ nodelist = part .get_node_list ()
31+
32+ for depth in range (part .get_depth () - 1 ):
33+ for parent in nodelist [depth ]:
34+ parent_domain = parent .get_domain ()
35+ children = parent .get_children ()
36+
37+ children_domain = []
38+ for child in children :
39+ children_domain .append (child .get_domain ())
40+ print (child .get_depth (), child .get_index (), child .get_domain (), "\\ " )
0 commit comments