MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / test

Function test

numpy_ml/tests/test_trees.py:43–53  ·  view source on GitHub ↗
(mine, clone)

Source from the content-addressed store, hash-verified

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

Callers 1

compare_treesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected