Skip to content

Commit

Permalink
Fix recognition of non-contigous input data
Browse files Browse the repository at this point in the history
  • Loading branch information
mhvk committed Oct 19, 2023
1 parent 1903739 commit fe7cb00
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion erfa/tests/test_erfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,19 @@ def test_float32_input():
xyz = np.array([[1, 0, 0], [0.9, 0.1, 0]])
out64 = erfa.p2s(xyz)
out32 = erfa.p2s(xyz.astype('f4'))
np.testing.assert_allclose(out32, out64, rtol=1.e-5)
assert_allclose(out32, out64, rtol=1.e-5)


def test_non_contiguous_matrix():
# Regression test for gh-123 (astropy gh-15503)
matrix = np.array([[1, 0, 0, 5],
[0, 1, 0, 6],
[0, 0, 1, 7]], dtype='float')[:, :3]
vector = np.array([1., 2., 3.])
assert_array_equal(matrix, np.eye(3))
conv = erfa.rxp(matrix, vector)
assert_array_equal(matrix @ vector, vector)
assert_array_equal(conv, vector)


class TestAstromNotInplace:
Expand Down
2 changes: 1 addition & 1 deletion erfa/ufunc.c.templ
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static inline void copy_to_eraLDBODY(char *ptr, npy_intp s, npy_intp n,
note: one can only have 1 or 2 dimensions */ #}
{%- if arg.ndim == 2 %}
int copy_{{ arg_name
}} = (is_{{ arg_name }}1 != sizeof({{ arg.ctype }}) &&
}} = (is_{{ arg_name }}1 != sizeof({{ arg.ctype }}) ||
is_{{ arg_name }}0 != {{ arg.shape[1] }} * sizeof({{ arg.ctype }}));
{%- else %}
int copy_{{ arg_name }} = (is_{{ arg_name }}0 != sizeof({{ arg.ctype }}));
Expand Down

0 comments on commit fe7cb00

Please sign in to comment.