Пример #1
0
    def test_spearman(self):
        """Test the spearman function with valid input."""
        # One vector has no ties.
        exp = 0.3719581
        obs = spearman(self.a, self.b)
        np.testing.assert_allclose(obs, exp)

        # Both vectors have no ties.
        exp = 0.2969697
        obs = spearman(self.b, self.c)
        np.testing.assert_allclose(obs, exp)

        # Both vectors have ties.
        exp = 0.388381
        obs = spearman(self.a, self.r)
        np.testing.assert_allclose(obs, exp)

        exp = -0.17575757575757578
        obs = spearman(self.data1, self.data2)
        np.testing.assert_allclose(obs, exp)
Пример #2
0
    def test_spearman(self):
        """Test the spearman function with valid input."""
        # One vector has no ties.
        exp = 0.3719581
        obs = spearman(self.a, self.b)
        np.testing.assert_allclose(obs, exp)

        # Both vectors have no ties.
        exp = 0.2969697
        obs = spearman(self.b, self.c)
        np.testing.assert_allclose(obs, exp)

        # Both vectors have ties.
        exp = 0.388381
        obs = spearman(self.a, self.r)
        np.testing.assert_allclose(obs, exp)

        exp = -0.17575757575757578
        obs = spearman(self.data1, self.data2)
        np.testing.assert_allclose(obs, exp)
Пример #3
0
 def test_spearman_ranked(self):
     """Test the spearman function with a vector that is already ranked."""
     exp = 0.2969697
     obs = spearman(self.b_ranked, self.c_ranked)
     np.testing.assert_allclose(obs, exp)
Пример #4
0
 def test_spearman_no_variation(self):
     """Test the spearman function with a vector having no variation."""
     exp = 0.0
     obs = spearman([1, 1, 1], [1, 2, 3])
     np.testing.assert_allclose(obs, exp)
Пример #5
0
 def test_spearman_ranked(self):
     """Test the spearman function with a vector that is already ranked."""
     exp = 0.2969697
     obs = spearman(self.b_ranked, self.c_ranked)
     np.testing.assert_allclose(obs, exp)
Пример #6
0
 def test_spearman_no_variation(self):
     """Test the spearman function with a vector having no variation."""
     exp = 0.0
     obs = spearman([1, 1, 1], [1, 2, 3])
     np.testing.assert_allclose(obs, exp)