Skip to content

Migrate Fortran to Numba and general upgrades#94

Merged
krischer merged 25 commits intomainfrom
krischer/upgrade
Jul 8, 2025
Merged

Migrate Fortran to Numba and general upgrades#94
krischer merged 25 commits intomainfrom
krischer/upgrade

Conversation

@krischer
Copy link
Owner

@krischer krischer commented Jul 7, 2025

This MR does a few things:

  • Convert the Fortran code to Numba code. This has the big advantage of not needing a Fortran compiler anymore, meaning it is much easier to install, especially on Windows. It should just be installeable with pip now on most systems.
  • Modernize the infrastructure by moving from setup.py -> pyproject.toml.
  • Moving from flake8 to ruff.
  • Modernize whatever else needed fixing so it runs with the latest version of all dependencies.
  • Target Python versions are currently Python 3.12 and 3.13 on Windows, Linux, and macOS.
  • Migrated from travis + codecov to github actions.
  • Upgrading the UI to pyside6 - there are some issues on ARM macs though but that seems to be some incompatibility between pyside6 and pyqtgraph.

@rmodrak
Copy link

rmodrak commented Jul 7, 2025

No longer getting float128 errors. Thank you!

@rmodrak
Copy link

rmodrak commented Jul 7, 2025

Installs successfully for me using pip install git+https://github.com/krischer/instaseis.git@krischer/upgrade.

@krischer krischer requested a review from Copilot July 7, 2025 21:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces Fortran-based routines with Numba implementations, updates project tooling, and modernizes code to run under Python 3.12/3.13 with latest dependencies.

  • Introduce Numba-compiled modules (spectral_basis.py, sem_derivatives.py) to remove Fortran dependencies.
  • Migrate packaging to pyproject.toml, switch linting from Flake8 to Ruff, and update CI to GitHub Actions.
  • Update Tornado fixtures and server code to use asyncio event loops and PySide6 for the UI.

Reviewed Changes

Copilot reviewed 78 out of 139 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/tornado_testing_fixtures.py Updated I/O loop fixture to use asyncio loops and clear them
tests/conftest.py Refactored xdist support, renamed test data directory path
src/instaseis/spectral_basis.py Added Numba jitted 2D Lagrange interpolation replacing Fortran
src/instaseis/rotations.py Switched tensor rotation routines from np.float128 to float64
src/instaseis/server/routes/__init__.py Set custom AnyThreadEventLoopPolicy for Tornado threading
Comments suppressed due to low confidence (1)

src/instaseis/rotations.py:72

  • Switching from np.float128 to np.float64 reduces numeric precision and may introduce subtle errors in rotation calculations. If quad precision was necessary for stability, consider retaining np.float128 or documenting and testing the impact of this downsizing.
    R = np.require(R, dtype=np.float64)  # NOQA

Copy link

@larsgeb larsgeb left a comment

Choose a reason for hiding this comment

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

This is great, thanks for making Instaseis easier to use!

I had no problems doing a pip install of Instaseis (without any compilation headaches). Tests ran well. On a MacOS ARM system.

The addition of modern tooling like Ruff is also very welcome. How about adding this to the tests dependencies so the local dev environment can also run this out of the box?

Not sure what is typical for projects like this, but maybe the license files deserves a bump in year? Or would you say it is linked only to the original year? This was a decent amount of work and it should be clear that the project is still maintained.

Good to maybe add an issue with a deadline in two years to raise the minimum Python version beyond 3.11.

@krischer
Copy link
Owner Author

krischer commented Jul 8, 2025

Thanks @larsgeb for the suggestions! All are implemented!

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.

4 participants