def test_CentreTransform_caching(make_random_data):
# Generate an initial set of data
x, mu, std = make_random_data
# Apply the CentreTransform to the first dataset to preserve the mean
x_copy = x.copy()
center_transformer = CentreTransform()
center_transformer(x_copy)
# Now apply the center transform to a matrix that has been translated
x_translated = x + 3.0 * mu
x_expected = x_translated - mu
x_produced = center_transformer(x_translated)
# Check that the transformer used the mean mu instead of the translated
# mean which was 3 * mu in this case above
assert np.array_equal(x_expected, x_produced)
评论列表
文章目录