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
21 changes: 5 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python_minor: [ '9', '10', '11', '12', '13' ]
python_minor: [ '9', '10', '11', '12', '13', '13t' ]
os: [ ubuntu-latest ]
# Just a single ARM worker to be sure that it works
include:
Expand Down Expand Up @@ -193,22 +193,10 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Set up Python 3.10
- name: Set up Python 3.13t
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'
python-version: '3.13t'
- name: Get minimum supported Rust version
run: echo "::set-output name=msrv::$(grep '^rust-version = ' Cargo.toml | grep -o '[0-9.]\+')"
id: get_msrv
Expand All @@ -228,4 +216,5 @@ jobs:
- name: Build
run: |
rustup default ${{ steps.get_msrv.outputs.msrv }}
maturin build --find-interpreter
maturin build -i python3.9
maturin build -i python3.13t
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

--
- Mark the module as no-GIL, which enables free-threading Python (can be built from source, not provided so far) https://github.com/light-curve/light-curve-python/pull/499

### Changed

--
- Bump both `PyO3` and `rust-numpy` to v0.24 https://github.com/light-curve/light-curve-python/pull/499

### Deprecated

Expand Down Expand Up @@ -41,7 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **Experimental Feature Breaking**: change parameter limits for Rainbow https://github.com/light-curve/light-curve-python/pull/494
- **Experimental Feature Breaking**: change parameter limits for
Rainbow https://github.com/light-curve/light-curve-python/pull/494

### Removed

Expand All @@ -50,7 +51,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Rainbow multi-band scaler didn't work with list inputs https://github.com/light-curve/light-curve-python/issues/492 https://github.com/light-curve/light-curve-python/pull/493
- Rainbow multi-band scaler didn't work with list
inputs https://github.com/light-curve/light-curve-python/issues/492 https://github.com/light-curve/light-curve-python/pull/493

## [0.10.0] 2025-01-07

Expand Down
29 changes: 15 additions & 14 deletions light-curve/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions light-curve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ mimalloc = { version = "0.1.42", features = [
"local_dynamic_tls",
], optional = true }
ndarray = { version = "0.16.1", features = ["rayon"] }
numpy = "0.23.0"
numpy = "0.24.0"
num_cpus = "1.13.0"
num-traits = "0.2"
once_cell = "1"
pyo3 = { version = "0.23.5", features = [
pyo3 = { version = "0.24.0", features = [
"extension-module",
"multiple-pymethods",
] }
Expand Down
3 changes: 3 additions & 0 deletions light-curve/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ We stopped publishing all PyPy wheels (https://github.com/light-curve/light-curv
and the PPC64le CPython glibc wheel (https://github.com/light-curve/light-curve-python/issues/479),
please feel free to open an issue if you need any of them.

[Free-threading Python](https://docs.python.org/3.13/whatsnew/3.13.html#free-threaded-cpython) is supported when built from source.
No pre-built distributions are provided so far, please comment on these issues if you need them: [PyPI binary wheel issue](https://github.com/light-curve/light-curve-python/issues/500), [conda-forge package issue](https://github.com/conda-forge/light-curve-python-feedstock/issues/11).

See [bellow](#build-from-source) for the details on how to build the package from the source code.

## Feature evaluators
Expand Down
28 changes: 26 additions & 2 deletions light-curve/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ dev = [
"black",
"ruff",
]
# cesium and iminuit don't support free-threading yet
dev-free-threading = [
"pytest",
"markdown-pytest",
"pytest-benchmark",
"pytest-subtests>=0.10",
"numpy",
"scipy",
"joblib",
"pandas",
"black",
"ruff",
]

[tool.maturin]
# It asks to use Cargo.lock to make the build reproducible
Expand Down Expand Up @@ -148,10 +161,10 @@ markers = [
[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py{39,310,311,312,313}-{base,test}
envlist = py{39,310,311,312,313,313t}-{base,test}
isolated_build = True

[testenv:py{39,310,311,312,313}-base]
[testenv:py{39,310,311,312,313,313t}-base]
change_dir = {envtmpdir}
extras =
commands =
Expand All @@ -166,6 +179,17 @@ commands =
ruff check .
set_env =
CARGO_TARGET_DIR = {tox_root}/target

[testenv:py313t-test]
extras = dev-free-threading
commands =
pytest README.md tests/ light_curve/ \
--ignore tests/test_w_bench.py \
--ignore=tests/light_curve_py/features/test_rainbow.py \
--deselect=README.md::test_rainbow_fit_example
ruff check .
set_env =
CARGO_TARGET_DIR = {tox_root}/target
"""


Expand Down
2 changes: 1 addition & 1 deletion light-curve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static GLOBAL_ALLOCATOR: MiMalloc = MiMalloc;
///
/// dm-lg(dt) maps generator is represented by `DmDt` class, while all other classes are
/// feature extractors
#[pymodule]
#[pymodule(gil_used = false)]
fn light_curve(py: Python, m: Bound<PyModule>) -> PyResult<()> {
m.add("__version__", env!("CARGO_PKG_VERSION"))?;

Expand Down
20 changes: 19 additions & 1 deletion light-curve/tests/light_curve_ext/test_feature.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
import inspect
import pickle
from concurrent.futures import ThreadPoolExecutor

import numpy as np
import pytest
Expand Down Expand Up @@ -174,7 +175,24 @@ def test_many_vs_call(feature):

call = np.stack([feature(*lc, sorted=True) for lc in lcs])
many = feature.many(lcs, sorted=True, n_jobs=2)
assert_array_equal(many, call)
assert_array_equal(call, many)

# Test with Python threads to ensure we have no problems on the free-threading CPython
with ThreadPoolExecutor(2) as pool:
futures = [pool.submit(feature, *lc, sorted=True) for lc in lcs]
call_threads = np.stack([f.result() for f in futures])
del futures
assert_array_equal(call, call_threads)

n_lcs_per_job = 4
with ThreadPoolExecutor(2) as pool:
futures = [
pool.submit(feature.many, lcs[i : i + n_lcs_per_job], sorted=True, n_jobs=2)
for i in range(0, n_lc, n_lcs_per_job)
]
many_threads = np.concatenate([f.result() for f in futures])
del futures
assert_array_equal(call, many_threads)


def test_fill_value_not_enough_observations():
Expand Down
Loading