Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
build_date = datetime.utcfromtimestamp(
int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
)
copyright = f"2011{build_date.year}, {author}"
copyright = f"2011-{build_date.year}, {author}"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -123,7 +123,7 @@
# Output file base name for HTML help builder.
htmlhelp_basename = project + 'doc'

# A dictionary of values to pass into the template engines context for all pages.
# A dictionary of values to pass into the template engine's context for all pages.
html_context = {
'to_be_indexed': ['stable', 'latest']
}
Expand Down
69 changes: 36 additions & 33 deletions erfa/tests/test_erfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,40 +60,43 @@ def test_version_with_embedded_liberfa():
assert erfa.__version__.startswith(erfa.version.erfa_version)


def test_erfa_wrapper():
"""
Runs a set of tests that mostly make sure vectorization is
working as expected
"""
@pytest.mark.parametrize(
("ra", "dec", "jd", "shape"),
[
pytest.param(0.0, 0.0, 2456855.5, (), id="scalar"),
pytest.param(
0.0, 0.0, np.linspace(2456855.5, 2456856.5, 5), (5,), id="simple array"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look like the original one
Do I miss something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the arrays smaller because I didn't see the point in forcing the tests to run with larger arrays, but the tests are still checking that the output shape is correct. I did also change the range of jd values to shorten setup, but that shouldn't matter because with or without my patch the asserts here only care about the shape of the outputs, not about the values within.

),
pytest.param(
np.linspace(0.0, np.pi * 2.0, 5)[:, None, None],
np.linspace(-np.pi / 2.0, np.pi / 2.0, 4)[:, None],
np.linspace(2456855.5, 2456856.5, 3),
(5, 4, 3),
id="broadcasting",
),
],
)
def test_atco13_shape(ra, dec, jd, shape):
assert (
erfa.atco13(
ra, dec, 0, 0, 0, 0, jd, 0, 0, 0, np.pi / 4, 0, 0, 0, 1014, 0, 0, 0.5
).aob.shape
== shape
)


jd = np.linspace(2456855.5, 2456855.5+1.0/24.0/60.0, 60*2+1)
ra = np.linspace(0.0, np.pi*2.0, 5)
dec = np.linspace(-np.pi/2.0, np.pi/2.0, 4)

aob, zob, hob, dob, rob, eo = erfa.atco13(
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, jd,
0.0, 0.0, 0.0, np.pi/4.0, 0.0, 0.0, 0.0, 1014.0, 0.0, 0.0, 0.5)
assert aob.shape == (121,)

aob, zob, hob, dob, rob, eo = erfa.atco13(
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, jd[0],
0.0, 0.0, 0.0, np.pi/4.0, 0.0, 0.0, 0.0, 1014.0, 0.0, 0.0, 0.5)
assert aob.shape == ()

aob, zob, hob, dob, rob, eo = erfa.atco13(
ra[:, None, None], dec[None, :, None], 0.0, 0.0, 0.0, 0.0, jd[None, None, :],
0.0, 0.0, 0.0, np.pi/4.0, 0.0, 0.0, 0.0, 1014.0, 0.0, 0.0, 0.5)
(aob.shape) == (5, 4, 121)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no assert here, so this was a useless comparison. The Ruff rule B015 (useless-comparison) would guard against mistakes like that, but we haven't turned on the B rules yet.


iy, im, id, ihmsf = erfa.d2dtf("UTC", 3, jd, 0.0)
assert iy.shape == (121,)
assert ihmsf.shape == (121,)
assert ihmsf.dtype == erfa.dt_hmsf

iy, im, id, ihmsf = erfa.d2dtf("UTC", 3, jd[0], 0.0)
assert iy.shape == ()
assert ihmsf.shape == ()
assert ihmsf.dtype == erfa.dt_hmsf
@pytest.mark.parametrize(
("jd", "shape"),
[
pytest.param(2456855.5, (), id="scalar"),
pytest.param([2456855.5, 2456855.75, 2456856.25], (3,), id="array"),
],
)
def test_d2dtf_shape(jd, shape):
result = erfa.d2dtf("UTC", 3, jd, 0.0)
assert result.iy.shape == shape
assert result.ihmsf.shape == shape
assert result.ihmsf.dtype == erfa.dt_hmsf


def test_angle_ops():
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ extend-select = [
"PT",
"PTH",
"RET",
"RUF",
"S101",
"SIM",
"UP",
Expand Down
Loading