Skip to content

Modernize the code a little - #45

Merged
timj merged 53 commits into
masterfrom
u/timj/modernize
Feb 19, 2026
Merged

timj merged 53 commits into
masterfrom
u/timj/modernize

Conversation

@timj

@timj timj commented Aug 19, 2024 •

Copy link
Copy Markdown
Member
  • Supports python 3.13 and numpy 2

  • Starts dropping python 2 and pyfits support.

  • The libyaml detection does work if you have installed into /usr

  • The ZoomMap test failure was caused by pytest running tests in a different order.

  • Fixed a bug in options handling since constructing an ast object with options= simply didn't work.

  • Fixed the HatAttrString warning from python 3.13

  • Updated AST to v9.3.0 (which had a couple of bugs I needed to patch locally)

  • Added support for SplineMap

  • Changed version handling to pick up version from git tag.

  • Added GitHub action that should upload to PyPI when tag is pushed.

Original error reports

The libyaml detection doesn't seem to work (and doesn't work on the master branch with python 3.11) and there is a test failure on master even before this work:

======================================================================
FAIL: test_ZoomMap (__main__.TestAst.test_ZoomMap)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/timj/work/starlink-pyast/starlink/ast/test/test.py", line 180, in test_ZoomMap
    self.assertEqual(zoommap.Nobject, 1, str(zoommap))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 3 != 1 :  Begin ZoomMap 	# Zoom about the origin
    Nin = 1 	# Number of input coordinates
 IsA Mapping 	# Mapping between coordinate systems
    Zoom = 1.2 	# Zoom factor
 End ZoomMap

With python 3.13 there is a new warning:

starlink/ast/test/test.py::TestAst::test_MyChannel
  /Users/timj/work/tmp/py13/lib/python3.13/site-packages/_pytest/unraisableexception.py:85: PytestUnraisableExceptionWarning: Exception ignored in PyObject_HasAttrString(); consider using PyObject_HasAttrStringWithError(), PyObject_GetOptionalAttrString() or PyObject_GetAttrString(): None
  
  Traceback (most recent call last):
    File "/Users/timj/work/starlink-pyast/starlink/ast/test/test.py", line 950, in test_MyChannel
      channel = starlink.Ast.Channel(ss, ss)
  TypeError: The supplied 'source' object does not have an 'astsource' method and is not a sequence.

@timj

timj commented Aug 19, 2024

Copy link
Copy Markdown
Member Author

I also ran black and isort on the code and did some automated updates with ruff. Also use context managers for open().

I'l fix the travis and move it to GitHub actions.

timj added 4 commits February 11, 2026 10:21
Pytest can run the tests in alphabetical order such that when the
test runs there might be some dangling python objects associated
with previous tests. Run the garbage collection to ensure that
the ZoomMap test starts with a clean slate.
@timj
timj force-pushed the u/timj/modernize branch 3 times, most recently from 55449f2 to 41f2280 Compare February 11, 2026 21:40
timj added 11 commits February 12, 2026 12:21
This required:

* Some shenanigans to make sure that the support tools can be
  imported by setup.py when running in the sandbox.
* setuptools-scm now creates a version .h file to allow the version
  to be embedded in the C code.

The latter means that version numbering is now achieved by
tagging rather than editing Ast.c
This prevents some tools warning that the package name might
be confused by a source directory name.
@timj

timj commented Feb 19, 2026

Copy link
Copy Markdown
Member Author

Version 4.0.0 uploaded to PyPI via GitHub Action. This includes the building of wheels for easy pip install (but without the YAML support).

@timj
timj merged commit be92415 into master Feb 19, 2026
21 checks passed
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.

1 participant