Пример #1
0
 def test_convert_for_dictarray(self):
     """successfully delegates when constructed from a DictArray"""
     a = numpy.identity(3, int)
     b = DictArrayTemplate("abc", "ABC").wrap(a)
     vals, row_keys, col_keys = convert_for_dictarray(b)
     got = DictArrayTemplate(row_keys, col_keys).wrap(vals)
     self.assertEqual(got.array.tolist(), b.array.tolist())
     # the wrap method creates a new array
     self.assertIsNot(got.array, b.array)
Пример #2
0
 def test_convert_for_dictarray(self):
     """convert_for_dictarray correctly delegates"""
     b = DictArrayTemplate("abc", "ABC").wrap(self.a)
     data_types = (
         [[245, 599]],
         dict(a=dict(b=4, c=5)),
         {("a", "b"): 4, ("a", "c"): 5},
         dict(a=0, b=35, c=45),
         b,
     )
     for data in data_types:
         vals, row_keys, col_keys = convert_for_dictarray(data)
         _ = DictArrayTemplate(row_keys, col_keys).wrap(vals)