예제 #1
0
 def __init__(self, x, y, alt, az, leg_x_order=2, leg_y_order=2):
     self.projection = Sky2Pix_AZP()
     self.affine = AffineTransformation2D()
     self.x = x
     self.y = y
     self.alt = alt
     self.az = az
     self.x_leg = Legendre2D(leg_x_order, leg_y_order)
     self.y_leg = Legendre2D(leg_x_order, leg_y_order)
예제 #2
0
def test__fcache():
    model = OrthoPolynomialBase(x_degree=2, y_degree=2)
    with pytest.raises(NotImplementedError) as err:
        model._fcache(np.asanyarray(1), np.asanyarray(1))
    assert str(err.value) == "Subclasses should implement this"

    model = Hermite2D(x_degree=2, y_degree=2)
    assert model._fcache(np.asanyarray(1), np.asanyarray(1)) == {
        0: np.asanyarray(1),
        1: 2,
        3: np.asanyarray(1),
        4: 2,
        2: 2.0,
        5: -4.0
    }

    model = Legendre2D(x_degree=2, y_degree=2)
    assert model._fcache(np.asanyarray(1), np.asanyarray(1)) == {
        0: np.asanyarray(1),
        1: np.asanyarray(1),
        2: 1.0,
        3: np.asanyarray(1),
        4: np.asanyarray(1),
        5: 1.0
    }

    model = Chebyshev2D(x_degree=2, y_degree=2)
    assert model._fcache(np.asanyarray(1), np.asanyarray(1)) == {
        0: np.asanyarray(1),
        1: np.asanyarray(1),
        2: 1.0,
        3: np.asanyarray(1),
        4: np.asanyarray(1),
        5: 1.0
    }
예제 #3
0
def test_fit_deriv_shape_error():
    model = Hermite2D(x_degree=2, y_degree=2)
    with pytest.raises(ValueError) as err:
        model.fit_deriv(np.array([1, 2]), np.array([3, 4, 5]))
    assert str(err.value) == "x and y must have the same shape"

    model = Chebyshev2D(x_degree=2, y_degree=2)
    with pytest.raises(ValueError) as err:
        model.fit_deriv(np.array([1, 2]), np.array([3, 4, 5]))
    assert str(err.value) == "x and y must have the same shape"

    model = Legendre2D(x_degree=2, y_degree=2)
    with pytest.raises(ValueError) as err:
        model.fit_deriv(np.array([1, 2]), np.array([3, 4, 5]))
    assert str(err.value) == "x and y must have the same shape"

    model = Polynomial2D(degree=2)
    with pytest.raises(ValueError) as err:
        model.fit_deriv(np.array([1, 2]), np.array([3, 4, 5]))
    assert str(err.value) == "Expected x and y to be of equal size"