Skip to content

Commit

Permalink
Merge pull request #72 from mhvk/fix-dtype-setting
Browse files Browse the repository at this point in the history
Ensure that inout arguments are properly accounted for twice
  • Loading branch information
mhvk authored Apr 24, 2021
2 parents e2a3345 + c9f5d45 commit ec071b1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
8 changes: 7 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
1.7.3 (unreleased)
==================

- Fixed a bug that caused the output of ``rx``, ``ry``, and ``rz`` to be
boolean rather than float. [gh-72]

1.7.2 (25/01/2021)
====================
==================

- Bundled liberfa version update to v1.7.2.
- The classproperty decorator is now thread-safe
Expand Down
11 changes: 10 additions & 1 deletion erfa/tests/test_erfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest
import numpy as np
from numpy.testing import assert_array_equal
from numpy.testing import assert_array_equal, assert_array_almost_equal

import erfa
from erfa.tests.helper import catch_warnings
Expand Down Expand Up @@ -235,6 +235,15 @@ def test_vector_inouts():
np.testing.assert_allclose(res3, [expected]*4)


def test_rz():
# This failed on MacOS (gh-68) because the types were not set correctly.
r = erfa.rz(np.deg2rad(60.), np.eye(3))
assert_array_almost_equal(r, np.array(
[[0.5, 0.8660254, 0.],
[-0.8660254, 0.5, 0.],
[0., 0., 1.]]))


def test_pv_in():
jd1 = 2456165.5
jd2 = 0.401182685
Expand Down
7 changes: 6 additions & 1 deletion erfa/ufunc.c.templ
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,12 @@ PyMODINIT_FUNC PyInit_ufunc(void)
as these do not get copied */ #}
{%- for func in funcs %}
{%- if not func.user_dtype %}
static char types_{{ func.pyname }}[{{ func.args_by_inout('in|inout|out|ret|stat')|count }}] = { {{ func.args_by_inout('in|inout|out|ret|stat')|map(attribute='npy_type')|join(', ') }} };
static char types_{{ func.pyname }}[{{ func.args_by_inout('in|inout')|count
+ func.args_by_inout('inout|out|ret|stat')|count }}] = {
{%- for arg in func.args_by_inout('in|inout') %}{{ arg.npy_type }}, {% endfor %}
{%- for arg in func.args_by_inout('inout|out|ret|stat') -%}
{%- if loop.index > 1 %}, {% endif %}{{ arg.npy_type }}{%- endfor -%}
};
static PyUFuncGenericFunction funcs_{{ func.pyname }}[1] = { &ufunc_loop_{{ func.pyname }} };
{%- endif %}
{%- endfor %}
Expand Down

0 comments on commit ec071b1

Please sign in to comment.