Beispiel #1
0
 def test_Y_values(self):
     X, Y = self.X, self.Y
     Y[0, 0] = -1
     with npt.assert_raises(ValueError):
         CCA(Y, X, None, None)
     Y[0] = 0
     with npt.assert_raises(ValueError):
         CCA(Y, X, None, None)
Beispiel #2
0
 def setup(self):
     """Data from table 11.3 in Legendre & Legendre 1998
     (p. 590). Loaded results as computed with vegan 2.0-8 and
     compared with table 11.5 if also there."""
     Y = np.loadtxt(get_data_path('example3_Y'))
     X = np.loadtxt(get_data_path('example3_X'))
     self.ordination = CCA(Y, X[:, :-1],
                           ['Site0', 'Site1', 'Site2', 'Site3', 'Site4',
                            'Site5', 'Site6', 'Site7', 'Site8', 'Site9'],
                           ['Species0', 'Species1', 'Species2', 'Species3',
                            'Species4', 'Species5', 'Species6', 'Species7',
                            'Species8'])
class TestCCAResults(object):
    def setup(self):
        """Data from table 11.3 in Legendre & Legendre 1998
        (p. 590). Loaded results as computed with vegan 2.0-8 and
        compared with table 11.5 if also there."""
        Y = np.loadtxt(get_data_path("example3_Y"))
        X = np.loadtxt(get_data_path("example3_X"))
        self.ordination = CCA(
            Y,
            X[:, :-1],
            ["Site0", "Site1", "Site2", "Site3", "Site4", "Site5", "Site6", "Site7", "Site8", "Site9"],
            [
                "Species0",
                "Species1",
                "Species2",
                "Species3",
                "Species4",
                "Species5",
                "Species6",
                "Species7",
                "Species8",
            ],
        )

    def test_scaling1_species(self):
        scores = self.ordination.scores(1)

        vegan_species = np.loadtxt(get_data_path("example3_species_scaling1_from_vegan"))
        npt.assert_almost_equal(scores.species, vegan_species, decimal=6)

    def test_scaling1_site(self):
        scores = self.ordination.scores(1)

        vegan_site = np.loadtxt(get_data_path("example3_site_scaling1_from_vegan"))
        npt.assert_almost_equal(scores.site, vegan_site, decimal=4)

    def test_scaling2_species(self):
        scores = self.ordination.scores(2)

        vegan_species = np.loadtxt(get_data_path("example3_species_scaling2_from_vegan"))
        npt.assert_almost_equal(scores.species, vegan_species, decimal=5)

    def test_scaling2_site(self):
        scores = self.ordination.scores(2)

        vegan_site = np.loadtxt(get_data_path("example3_site_scaling2_from_vegan"))
        npt.assert_almost_equal(scores.site, vegan_site, decimal=4)
Beispiel #4
0
class TestCCAResults(object):
    def setup(self):
        """Data from table 11.3 in Legendre & Legendre 1998
        (p. 590). Loaded results as computed with vegan 2.0-8 and
        compared with table 11.5 if also there."""
        Y = np.loadtxt(get_data_path('example3_Y'))
        X = np.loadtxt(get_data_path('example3_X'))
        self.ordination = CCA(Y, X[:, :-1], [
            'Site0', 'Site1', 'Site2', 'Site3', 'Site4', 'Site5', 'Site6',
            'Site7', 'Site8', 'Site9'
        ], [
            'Species0', 'Species1', 'Species2', 'Species3', 'Species4',
            'Species5', 'Species6', 'Species7', 'Species8'
        ])

    def test_scaling1_species(self):
        scores = self.ordination.scores(1)

        vegan_species = np.loadtxt(
            get_data_path('example3_species_scaling1_from_vegan'))
        npt.assert_almost_equal(scores.species, vegan_species, decimal=6)

    def test_scaling1_site(self):
        scores = self.ordination.scores(1)

        vegan_site = np.loadtxt(
            get_data_path('example3_site_scaling1_from_vegan'))
        npt.assert_almost_equal(scores.site, vegan_site, decimal=4)

    def test_scaling2_species(self):
        scores = self.ordination.scores(2)

        vegan_species = np.loadtxt(
            get_data_path('example3_species_scaling2_from_vegan'))
        npt.assert_almost_equal(scores.species, vegan_species, decimal=5)

    def test_scaling2_site(self):
        scores = self.ordination.scores(2)

        vegan_site = np.loadtxt(
            get_data_path('example3_site_scaling2_from_vegan'))
        npt.assert_almost_equal(scores.site, vegan_site, decimal=4)
Beispiel #5
0
class TestCCAResults(object):
    def setup(self):
        """Data from table 11.3 in Legendre & Legendre 1998
        (p. 590). Loaded results as computed with vegan 2.0-8 and
        compared with table 11.5 if also there."""
        Y = np.loadtxt(get_data_path('example3_Y'))
        X = np.loadtxt(get_data_path('example3_X'))
        self.ordination = CCA(Y, X[:, :-1],
                              ['Site0', 'Site1', 'Site2', 'Site3', 'Site4',
                               'Site5', 'Site6', 'Site7', 'Site8', 'Site9'],
                              ['Species0', 'Species1', 'Species2', 'Species3',
                               'Species4', 'Species5', 'Species6', 'Species7',
                               'Species8'])

    def test_scaling1_species(self):
        scores = self.ordination.scores(1)

        vegan_species = np.loadtxt(get_data_path(
            'example3_species_scaling1_from_vegan'))
        npt.assert_almost_equal(scores.species, vegan_species, decimal=6)

    def test_scaling1_site(self):
        scores = self.ordination.scores(1)

        vegan_site = np.loadtxt(get_data_path(
            'example3_site_scaling1_from_vegan'))
        npt.assert_almost_equal(scores.site, vegan_site, decimal=4)

    def test_scaling2_species(self):
        scores = self.ordination.scores(2)

        vegan_species = np.loadtxt(get_data_path(
            'example3_species_scaling2_from_vegan'))
        npt.assert_almost_equal(scores.species, vegan_species, decimal=5)

    def test_scaling2_site(self):
        scores = self.ordination.scores(2)

        vegan_site = np.loadtxt(get_data_path(
            'example3_site_scaling2_from_vegan'))
        npt.assert_almost_equal(scores.site, vegan_site, decimal=4)
Beispiel #6
0
 def setup(self):
     """Data from table 11.3 in Legendre & Legendre 1998
     (p. 590). Loaded results as computed with vegan 2.0-8 and
     compared with table 11.5 if also there."""
     Y = np.loadtxt(get_data_path('example3_Y'))
     X = np.loadtxt(get_data_path('example3_X'))
     self.ordination = CCA(Y, X[:, :-1],
                           ['Site0', 'Site1', 'Site2', 'Site3', 'Site4',
                            'Site5', 'Site6', 'Site7', 'Site8', 'Site9'],
                           ['Species0', 'Species1', 'Species2', 'Species3',
                            'Species4', 'Species5', 'Species6', 'Species7',
                            'Species8'])
 def setup(self):
     """Data from table 11.3 in Legendre & Legendre 1998
     (p. 590). Loaded results as computed with vegan 2.0-8 and
     compared with table 11.5 if also there."""
     Y = np.loadtxt(get_data_path("example3_Y"))
     X = np.loadtxt(get_data_path("example3_X"))
     self.ordination = CCA(
         Y,
         X[:, :-1],
         ["Site0", "Site1", "Site2", "Site3", "Site4", "Site5", "Site6", "Site7", "Site8", "Site9"],
         [
             "Species0",
             "Species1",
             "Species2",
             "Species3",
             "Species4",
             "Species5",
             "Species6",
             "Species7",
             "Species8",
         ],
     )
Beispiel #8
0
 def test_shape(self):
     X, Y = self.X, self.Y
     with npt.assert_raises(ValueError):
         CCA(Y, X[:-1], None, None)