| 41 | mine = mine.root |
| 42 | |
| 43 | def test(mine, clone): |
| 44 | if isinstance(clone, Node) and isinstance(mine, Node): |
| 45 | assert mine.feature == clone.feature, "Node {} not equal".format(depth) |
| 46 | np.testing.assert_allclose(mine.threshold, clone.threshold) |
| 47 | test(mine.left, clone.left, depth + 1) |
| 48 | test(mine.right, clone.right, depth + 1) |
| 49 | elif isinstance(clone, Leaf) and isinstance(mine, Leaf): |
| 50 | np.testing.assert_allclose(mine.value, clone.value) |
| 51 | return |
| 52 | else: |
| 53 | raise ValueError("Nodes at depth {} are not equal".format(depth)) |
| 54 | |
| 55 | depth = 0 |
| 56 | ok = True |