def test_constructor(self): # missing data arg with assert_raises(TypeError): # noinspection PyArgumentList HaplotypeDaskArray.from_array() # data has wrong dtype data = 'foo bar' with assert_raises(ValueError): HaplotypeDaskArray.from_array(data) # data has wrong dtype data = np.array([4., 5., 3.7]) with assert_raises(ValueError): HaplotypeDaskArray.from_array(data) # data has wrong dimensions data = np.array([1, 2, 3]) with assert_raises(ValueError): HaplotypeDaskArray.from_array(data) # data has wrong dimensions data = np.array([[[1, 2], [3, 4]]]) # use GenotypeDaskArray instead with assert_raises(ValueError): HaplotypeDaskArray.from_array(data) # valid data (typed) hd = self.setup_instance(np.array(haplotype_data, dtype='i1')) aeq(haplotype_data, hd) eq(np.int8, hd.dtype)
def setup_instance(self, data): return HaplotypeDaskArray.from_array(data, chunks=(2, 2))
def setup_instance(self, data, dtype=None): return HaplotypeDaskArray.from_array(np.asarray(data, dtype=dtype), chunks=(2, 2))