Exemplo n.º 1
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.º 2
0
 def test_array_instance(self):
     array = mock.Mock(spec=Array)
     result = ensure_array(array)
     self.assertIs(array, result)
Exemplo n.º 3
0
def fake_array(fill_value, dtype=np.dtype('f4')):
    return mock.Mock(shape=(3, 4),
                     dtype=dtype,
                     fill_value=fill_value,
                     ndim=2,
                     spec=Array)
Exemplo n.º 4
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Biggus. If not, see <http://www.gnu.org/licenses/>.
"""Unit tests for `biggus._init._normalise_axis`."""

from __future__ import absolute_import, division, print_function
from six.moves import (filter, input, map, range, zip)  # noqa

import unittest

from biggus._init import _normalise_axis
from biggus.tests import mock

ARRAY = mock.Mock(ndim=9)


class TestNone(unittest.TestCase):
    def test(self):
        self.assertIs(_normalise_axis(None, ARRAY), None)


class TestValid(unittest.TestCase):
    def check(self, argument, expected):
        result = _normalise_axis(argument, ARRAY)
        self.assertEqual(result, expected)
        self.assertIsInstance(result, tuple)

    def test_zero(self):
        self.check(0, (0, ))
Exemplo n.º 5
0
def fake_array(fill_value, dtype=np.dtype('f4')):
    return mock.Mock(shape=mock.sentinel.SHAPE, dtype=dtype,
                     fill_value=fill_value, spec=Array)