예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
 def setup_instance(self, data):
     return HaplotypeDaskArray.from_array(data, chunks=(2, 2))
예제 #4
0
 def setup_instance(self, data):
     return HaplotypeDaskArray.from_array(data, chunks=(2, 2))
예제 #5
0
 def setup_instance(self, data, dtype=None):
     return HaplotypeDaskArray.from_array(np.asarray(data, dtype=dtype),
                                          chunks=(2, 2))