コード例 #1
0
 def test_max_supports_multiple_axes(self):
     raw = np.random.random_sample((10, 9, 8, 7))
     arr = ArrayWithUnits(raw,
                          dimensions=[
                              ContrivedDimension(10),
                              IdentityDimension(),
                              IdentityDimension(),
                              ContrivedDimension2(10)
                          ])
     result = arr.max(axis=(1, 2))
     self.assertEqual((10, 7), result.shape)
     self.assertIsInstance(result, ArrayWithUnits)
     self.assertEqual(2, len(result.dimensions))
     self.assertIsInstance(result.dimensions[0], ContrivedDimension)
     self.assertIsInstance(result.dimensions[1], ContrivedDimension2)
コード例 #2
0
 def test_max_supports_keepdims(self):
     raw = np.random.random_sample((10, 9, 8, 7))
     arr = ArrayWithUnits(raw,
                          dimensions=[
                              ContrivedDimension(10),
                              ContrivedDimension2(10),
                              ContrivedDimension(10),
                              ContrivedDimension2(10)
                          ])
     result = arr.max(axis=(1, 2), keepdims=True)
     self.assertEqual((10, 1, 1, 7), result.shape)
     self.assertIsInstance(result, ArrayWithUnits)
     self.assertEqual(4, len(result.dimensions))
     print result.dimensions
     self.assertIsInstance(result.dimensions[0], ContrivedDimension)
     self.assertIsInstance(result.dimensions[1], IdentityDimension)
     self.assertIsInstance(result.dimensions[2], IdentityDimension)
     self.assertIsInstance(result.dimensions[3], ContrivedDimension2)