コード例 #1
0
ファイル: test_bioenv.py プロジェクト: nbresnick/scikit-bio
 def test_scale_single_column(self):
     df = pd.DataFrame([[1], [0], [2]], index=['A', 'B', 'C'],
                       columns=['foo'])
     exp = pd.DataFrame([[0.0], [-1.0], [1.0]], index=['A', 'B', 'C'],
                        columns=['foo'])
     obs = _scale(df)
     assert_frame_equal(obs, exp)
コード例 #2
0
ファイル: test_bioenv.py プロジェクト: sriki18/scikit-bio
 def test_scale_single_column(self):
     df = pd.DataFrame([[1], [0], [2]],
                       index=['A', 'B', 'C'],
                       columns=['foo'])
     exp = pd.DataFrame([[0.0], [-1.0], [1.0]],
                        index=['A', 'B', 'C'],
                        columns=['foo'])
     obs = _scale(df)
     assert_frame_equal(obs, exp)
コード例 #3
0
ファイル: test_bioenv.py プロジェクト: sriki18/scikit-bio
 def test_scale_multiple_columns(self):
     # Floats and ints, including positives and negatives.
     df = pd.DataFrame(
         [[7.0, 400, -1], [8.0, 530, -5], [7.5, 450, 1], [8.5, 810, -4]],
         index=['A', 'B', 'C', 'D'],
         columns=['pH', 'Elevation', 'negatives'])
     exp = pd.DataFrame([[-1.161895, -0.805979, 0.453921],
                         [0.387298, -0.095625, -0.998625],
                         [-0.387298, -0.532766, 1.180194],
                         [1.161895, 1.434369, -0.635489]],
                        index=['A', 'B', 'C', 'D'],
                        columns=['pH', 'Elevation', 'negatives'])
     obs = _scale(df)
     assert_frame_equal(obs, exp)
コード例 #4
0
ファイル: test_bioenv.py プロジェクト: nbresnick/scikit-bio
 def test_scale_multiple_columns(self):
     # Floats and ints, including positives and negatives.
     df = pd.DataFrame([[7.0, 400, -1],
                        [8.0, 530, -5],
                        [7.5, 450, 1],
                        [8.5, 810, -4]],
                       index=['A', 'B', 'C', 'D'],
                       columns=['pH', 'Elevation', 'negatives'])
     exp = pd.DataFrame([[-1.161895, -0.805979, 0.453921],
                         [0.387298, -0.095625, -0.998625],
                         [-0.387298, -0.532766, 1.180194],
                         [1.161895, 1.434369, -0.635489]],
                        index=['A', 'B', 'C', 'D'],
                        columns=['pH', 'Elevation', 'negatives'])
     obs = _scale(df)
     assert_frame_equal(obs, exp)
コード例 #5
0
ファイル: test_bioenv.py プロジェクト: nbresnick/scikit-bio
 def test_scale_no_variance(self):
     df = pd.DataFrame([[-7.0, -1.2], [6.2, -1.2], [2.9, -1.2]],
                       index=['A', 'B', 'C'], columns=['foo', 'bar'])
     with self.assertRaises(ValueError):
         _scale(df)
コード例 #6
0
ファイル: test_bioenv.py プロジェクト: sriki18/scikit-bio
 def test_scale_no_variance(self):
     df = pd.DataFrame([[-7.0, -1.2], [6.2, -1.2], [2.9, -1.2]],
                       index=['A', 'B', 'C'],
                       columns=['foo', 'bar'])
     with self.assertRaises(ValueError):
         _scale(df)