Skip to content

Replace repr() with str() when passing to axTime3.convert_time#61

Merged
jeanconn merged 3 commits intomasterfrom
new-repr
Dec 9, 2025
Merged

Replace repr() with str() when passing to axTime3.convert_time#61
jeanconn merged 3 commits intomasterfrom
new-repr

Conversation

@jeanconn
Copy link
Copy Markdown
Contributor

@jeanconn jeanconn commented Dec 3, 2025

Description

repr() was intended to get the number to as many digits as available to pass to convert_time, in modern Python using str() should be fine.

This has no impact in numpy 1.26.4 but is required for this code to work with numpy > 2 as the new repr behavior (includes the np type in the string) doesn't work with axTime3.convert . With Python > 3.1, str() should have enough digits for this code change to be non-impacting.

Interface impacts

None.

Testing

Unit tests

  • Mac
(latest) flame:chandra_time jean$ git rev-parse HEAD
0bbb3953e1d9cbd48dcbe5512085ad85f7824264
(latest) flame:chandra_time jean$ pytest
====================================================== test session starts =======================================================
platform darwin -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/jean/git/chandra_time
configfile: pytest.ini
plugins: anyio-4.7.0, timeout-2.3.1
collected 48 items                                                                                                               

chandra_time/tests/test_Time.py ................................................                                           [100%]

======================================================= 48 passed in 1.32s

And on the latest hope rc

(ska3-flight-2026.0rc4) flame:chandra_time jean$ git rev-parse HEAD
0bbb3953e1d9cbd48dcbe5512085ad85f7824264
(ska3-flight-2026.0rc4) flame:chandra_time jean$ pytest
==================================================================== test session starts ====================================================================
platform darwin -- Python 3.13.10, pytest-9.0.1, pluggy-1.6.0
rootdir: /Users/jean/git/chandra_time
configfile: pytest.ini
plugins: anyio-4.12.0, timeout-2.4.0
collected 48 items                                                                                                                                          

chandra_time/tests/test_Time.py ................................................                                                                      [100%]

==================================================================== 48 passed in 3.46

Independent check of unit tests by [REVIEWER NAME]

  • [PLATFORM]:

Functional tests

No functional testing.

@jeanconn jeanconn changed the title Force previous repr behavior Replace repr() with str() Dec 3, 2025
@jeanconn jeanconn requested a review from Copilot December 4, 2025 21:59
@jeanconn jeanconn changed the title Replace repr() with str() Replace repr() with str() when passing to axTime3.convert_time Dec 4, 2025

This comment was marked as resolved.

@jeanconn jeanconn marked this pull request as ready for review December 5, 2025 14:33
@jeanconn
Copy link
Copy Markdown
Contributor Author

jeanconn commented Dec 5, 2025

It looks like there are a few more repr() calls in Time.py, but that they are working on values that have already been explicitly converted to Python floats. So we can update those to str() or not - they look to be non-impacting for numpy 2.

@jeanconn jeanconn merged commit 792f75e into master Dec 9, 2025
7 checks passed
@jeanconn jeanconn deleted the new-repr branch December 9, 2025 16:02
This was referenced Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants