Exemplo n.º 1
0
 def test_large(self):
     # Source data: 3 MB
     array = self._small_array()
     target = _WriteCounter(array.shape)
     with mock.patch('biggus._init.MAX_CHUNK_SIZE', 4096):
         biggus.save([array], [target])
     self.assertTrue(target.all_written())
Exemplo n.º 2
0
 def test(self):
     # If we switch evaluation engine, does it get used?
     array = _Aggregation(biggus.ConstantArray(3, 2), None, None, None, None, {})
     return_value = (mock.sentinel.result,)
     engine = mock.Mock(**{"ndarrays.return_value": return_value})
     with mock.patch("biggus.engine", engine):
         result = array.ndarray()
     self.assertIs(result, mock.sentinel.result)
Exemplo n.º 3
0
 def test(self):
     # If we switch evaluation engine, does it get used?
     array = biggus._Aggregation(biggus.ConstantArray(3, 2), None, None,
                                 None, None, {})
     return_value = (mock.sentinel.result,)
     engine = mock.Mock(**{'ndarrays.return_value': return_value})
     with mock.patch('biggus.engine', engine):
         result = array.ndarray()
     self.assertIs(result, mock.sentinel.result)
Exemplo n.º 4
0
 def _test_flow(self, axis):
     data = np.arange(3 * 4 * 5, dtype='f4').reshape(3, 4, 5)
     array = biggus.NumpyArrayAdapter(data)
     mean = biggus.mean(array, axis=axis)
     # Artificially constrain the chunk size to eight bytes to
     # ensure biggus is stepping across axes in the correct
     # order.
     with mock.patch('biggus._init.MAX_CHUNK_SIZE', 8):
         op_result, = biggus.ndarrays([mean])
     np_result = np.mean(data, axis=axis)
     np.testing.assert_array_almost_equal(op_result, np_result)
Exemplo n.º 5
0
 def test_updates_all_override_name(self):
     with mock.patch('biggus._init.__all__', []) as tmp_all:
         _ufunc_wrapper(np.exp, 'foo')
     self.assertEqual(tmp_all, ['foo'])
Exemplo n.º 6
0
 def test_updates_all_default_name(self):
     with mock.patch('biggus._init.__all__', []) as tmp_all:
         _ufunc_wrapper(np.exp)
     self.assertEqual(tmp_all, ['exp'])
Exemplo n.º 7
0
 def test_updates_all_override_name(self):
     with mock.patch('biggus._init.__all__', []) as tmp_all:
         _ufunc_wrapper(np.exp, 'foo')
     self.assertEqual(tmp_all, ['foo'])
Exemplo n.º 8
0
 def test_updates_all_default_name(self):
     with mock.patch('biggus._init.__all__', []) as tmp_all:
         _ufunc_wrapper(np.exp)
     self.assertEqual(tmp_all, ['exp'])