Ejemplo n.º 1
0
    def test_on_empty_group(self):
        group = self.h5file.create_group('group')
        assert_raise(self.items.is_appendable_to, group,
                     "unable to open object", KeyError)

        # Create an empty items group
        self.items.create_dataset(group, 10)
        assert self.items.is_appendable_to(group)
Ejemplo n.º 2
0
    def test_raise_on_empty(self):
        Features(self.feat)
        empty1 = self.feat
        empty1.append(np.array([]))
        empty2 = [np.array([])] * 3

        for arg in [empty1, empty2]:
            assert_raise(Features, arg, "all features must be non-empty")
Ejemplo n.º 3
0
 def test_bad_format(self):
     # 3D
     assert_raise(parse_times, [randn(2, 2, 2)], '1D or 2D numpy arrays')
     # 2D with shape[1] != 2
     assert_raise(parse_times, [randn(10, 3)], 'must have 2 elements')
     assert_raise(parse_times, [randn(5, 1)], 'must have 2 elements')
     assert_raise(parse_times, [randn(2, 1)], 'must have 2 elements')
Ejemplo n.º 4
0
 def test_nto_hdf5_file(self):
     with open(self.filename, 'w') as temp:
         temp.write('This is not a HDF5 file')
     assert_raise(Writer, self.filename, 'not a HDF5 file')
Ejemplo n.º 5
0
 def test_bad(self):
     bad = self.data[2] + self.data[3]
     assert_raise(parse_dim, bad, "must have the same")
Ejemplo n.º 6
0
 def test_not_iterable(self):
     args = [self.data.append(np.array([])), 1]
     for arg in args:
         assert_raise(parse_dtype, arg, "not iterable", TypeError)
Ejemplo n.º 7
0
 def test_bad(self):
     arg = self.data
     arg[0] = arg[0].astype(int)
     assert_raise(parse_dtype, arg, "homogeneous")
Ejemplo n.º 8
0
def test_parse_dformat_bad():
    """Test the parse_dformat function."""
    msg = "is a bad features format, please choose"
    for arg in ["danse", "spark", 1, "spam"]:
        assert_raise(parse_dformat, arg, msg)
Ejemplo n.º 9
0
 def test_dim_bad(self):
     bad_feat = self.feat
     bad_feat[5] = bad_feat[5][:, :-1]
     assert_raise(parse_dim, bad_feat, "same feature dimension")
Ejemplo n.º 10
0
 def test_bad_dims(self):
     for arg in [self.t1+self.t2,
                 self.t2+self.t1,
                 self.t2+[np.array([1, 2, 3])]]:
         assert_raise(parse_times, arg, 'the same dimension')
Ejemplo n.º 11
0
 def test_init(self):
     assert_raise(Times2D, generate.times(10), 'must be 2D')
     assert Times2D(self.data).tformat == 2
Ejemplo n.º 12
0
 def test_same_items_twice(self):
     group = self.h5file.create_group('group')
     self.items.create_dataset(group, 10)
     self.items.write(group)
     assert_raise(self.items.is_appendable_to, group,
                  'more than one shared items')
Ejemplo n.º 13
0
 def test_bad(self):
     args = [[1, 1], [1, 2, 2], ['a', 'b', 'c', 'a']]
     msg = 'all items must have different names.'
     for arg in args:
         assert_raise(Items, arg, msg)