示例#1
0
    def test_constructor(self):

        # missing data arg
        with assert_raises(TypeError):
            # noinspection PyArgumentList
            GenotypeDaskArray.from_array()

        # data has wrong dtype
        data = 'foo bar'
        with assert_raises(ValueError):
            GenotypeDaskArray.from_array(data)

        # data has wrong dtype
        data = np.array([4., 5., 3.7])
        with assert_raises(ValueError):
            GenotypeDaskArray.from_array(data)

        # data has wrong dimensions
        data = np.array([1, 2, 3])
        with assert_raises(ValueError):
            GenotypeDaskArray.from_array(data)

        # data has wrong dimensions
        data = np.array([[1, 2], [3, 4]])  # use HaplotypeDaskArray instead
        with assert_raises(ValueError):
            GenotypeDaskArray.from_array(data)

        # diploid data (typed)
        gd = self.setup_instance(np.array(diploid_genotype_data, dtype='i1'))
        aeq(diploid_genotype_data, gd)
        eq(np.int8, gd.dtype)

        # polyploid data (typed)
        gd = self.setup_instance(np.array(triploid_genotype_data, dtype='i1'))
        aeq(triploid_genotype_data, gd)
        eq(np.int8, gd.dtype)
    def test_constructor(self):

        # missing data arg
        with assert_raises(TypeError):
            # noinspection PyArgumentList
            GenotypeDaskArray.from_array()

        # data has wrong dtype
        data = 'foo bar'
        with assert_raises(ValueError):
            GenotypeDaskArray.from_array(data)

        # data has wrong dtype
        data = np.array([4., 5., 3.7])
        with assert_raises(ValueError):
            GenotypeDaskArray.from_array(data)

        # data has wrong dimensions
        data = np.array([1, 2, 3])
        with assert_raises(ValueError):
            GenotypeDaskArray.from_array(data)

        # data has wrong dimensions
        data = np.array([[1, 2], [3, 4]])  # use HaplotypeDaskArray instead
        with assert_raises(ValueError):
            GenotypeDaskArray.from_array(data)

        # diploid data (typed)
        gd = self.setup_instance(np.array(diploid_genotype_data, dtype='i1'))
        aeq(diploid_genotype_data, gd)
        eq(np.int8, gd.dtype)

        # polyploid data (typed)
        gd = self.setup_instance(np.array(triploid_genotype_data, dtype='i1'))
        aeq(triploid_genotype_data, gd)
        eq(np.int8, gd.dtype)
示例#3
0
 def setup_instance(self, data):
     return GenotypeDaskArray.from_array(data, chunks=(2, 2, None))
 def setup_instance(self, data):
     return GenotypeDaskArray.from_array(data, chunks=(2, 2, None))
示例#5
0
 def setup_instance(self, data, dtype=None):
     return GenotypeDaskArray.from_array(np.asarray(data, dtype=dtype),
                                         chunks=(2, 2, None))