예제 #1
0
    def test_exception_split_gt_1(self, l):
        with raises(ValueError):
            age.split_element(1, 5)

        l.check(('gnome.array_types.ArrayType',
                 'ERROR',
                 "'num' to split into must be at least 2"))
예제 #2
0
    def test_split_element_clone_values(self, num):
        ''' as an example age should get cloned upon split '''
        # use an object of ArrayType (base) instance
        vals = age.initialize(10)
        vals[:] = np.arange(0, 100, 10)
        split_into = num
        ix = 5
        split_elems = age.split_element(split_into, vals[ix])
        assert split_elems.dtype == vals.dtype
        assert np.all(split_elems[:] == vals[ix])
        assert len(split_elems) == split_into
        new_vals = self._replace_le_after_split(vals, ix, split_elems)

        assert np.all(new_vals[ix:ix + split_into] == new_vals[ix])
        assert np.all(new_vals[:ix] == vals[:ix])
        assert np.all(new_vals[ix + split_into:] == vals[ix + 1:])
        assert len(new_vals) == len(vals) + num - 1
예제 #3
0
    def test_split_element_clone_values(self, num):
        ''' as an example age should get cloned upon split '''
        # use an object of ArrayType (base) instance
        vals = age.initialize(10)
        vals[:] = np.arange(0, 100, 10)
        split_into = num
        ix = 5
        split_elems = age.split_element(split_into, vals[ix])
        assert split_elems.dtype == vals.dtype
        assert np.all(split_elems[:] == vals[ix])
        assert len(split_elems) == split_into
        new_vals = self._replace_le_after_split(vals, ix, split_elems)

        assert np.all(new_vals[ix:ix + split_into] == new_vals[ix])
        assert np.all(new_vals[:ix] == vals[:ix])
        assert np.all(new_vals[ix + split_into:] == vals[ix + 1:])
        assert len(new_vals) == len(vals) + num - 1
예제 #4
0
    def test_exception_split_gt_1(self, l):
        with raises(ValueError):
            age.split_element(1, 5)

        l.check(('gnome.array_types.ArrayType', 'ERROR',
                 "'num' to split into must be at least 2"))