def test_orients_correct_if_other_is_projection(self): arr = randn(10, 2) # Flip arr left-right, rotate 90 deg counter clockwise, and translate other = np.fliplr(arr) other = np.dot(other, np.array([[0, -1], [1, 0]])) other += np.array([10, -5]) other = Projection(DataFrame(other)) oriented = Projection(DataFrame(arr)).orient_to(other) diff = (oriented.coords.values - other.coords.values).sum() self.assertAlmostEqual(0, diff)
def test_raises_error_if_dupes_in_other_index(self): index = list(range(9)) + [4] a = Projection(DataFrame(randn(10, 2))) b = Projection(DataFrame(randn(10, 2), index=index)) with self.assertRaises(ValueError): a._get_samples_shared_with(b)
def test_raises_error_if_no_shared_idx(self): a = Projection(DataFrame(randn(10, 2), index=range(0, 10))) b = Projection(DataFrame(randn(10, 2), index=range(10, 20))) with self.assertRaises(ValueError): a._get_samples_shared_with(b)
def test_orients_on_subset_returns_full_data(self): a = Projection(DataFrame(randn(10, 2))) b = Projection(DataFrame(randn(10, 2))) oriented = a.orient_to(b, index=range(4)) self.assertEqual(10, len(oriented.coords.index))
def test_returns_projection(self): a = Projection(DataFrame(randn(10, 2))) b = Projection(DataFrame(randn(10, 2))) self.assertIsInstance(a.orient_to(b), Projection)
def test_raises_error_if_other_is_array_wrong_shape(self): a = Projection(DataFrame(randn(10, 2))) with self.assertRaises(ValueError): a._get_samples_shared_with(randn(11, 2))
def test_raises_error_if_elements_in_index_not_in_other(self): a = Projection(DataFrame(randn(10, 2))) b = Projection(DataFrame(randn(10, 2), index=range(5, 15))) with self.assertRaises(ValueError): a._get_samples_shared_with(b, index=[4])
def test_raises_error_if_dupes_in_index_arg(self): a = Projection(DataFrame(randn(10, 2))) b = Projection(DataFrame(randn(10, 2))) with self.assertRaises(ValueError): a._get_samples_shared_with(b, index=[1, 1])