def test_dict_to_numpy_array2(self): d = {"a": {"a": 1, "b": 2}, "b": {"a": 10, "b": 20}} mapping = {"a": 1, "b": 0} a = dict_to_numpy_array2(d, mapping=mapping) np.testing.assert_allclose(a, np.array([[20, 10], [2, 1]])) a = dict_to_numpy_array2(d) np.testing.assert_allclose(a.sum(), 33)
def test_dict_to_numpy_array2(self): d = {'a': {'a': 1, 'b': 2}, 'b': {'a': 10, 'b': 20}} mapping = {'a': 1, 'b': 0} a = dict_to_numpy_array2(d, mapping=mapping) assert_allclose(a, numpy.array([[20, 10], [2, 1]])) a = dict_to_numpy_array2(d) assert_allclose(a.sum(), 33)
def test_dict_to_numpy_array_a(self): d = {"a": {"a": 1, "b": 2}, "b": {"a": 10, "b": 20}} mapping = {"a": 0, "b": 1} a = dict_to_numpy_array(d, mapping=mapping) assert_allclose(a, numpy.array([[1, 2], [10, 20]])) mapping = {"a": 1, "b": 0} a = dict_to_numpy_array(d, mapping=mapping) assert_allclose(a, numpy.array([[20, 10], [2, 1]])) a = dict_to_numpy_array2(d) assert_allclose(a.sum(), 33)