From 08931b5ca5b1b0f69d452df5fc2e0c38dfab01be Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Wed, 16 Jul 2025 22:20:29 -0700 Subject: [PATCH 01/10] move to pyproject.toml --- pyproject.toml | 34 ++++++++++++++++++++++++ setup.py | 72 +++++++++----------------------------------------- 2 files changed, 46 insertions(+), 60 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..065ad9b2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,34 @@ +[build-system] +requires = [ + "setuptools", + "numpy", + "cython", +] +build-backend = "setuptools.build_meta" + +[project] +name = "orbitize" +dynamic = ["version"] +dependencies = [ + "numpy", + "astropy>=4", + "scipy", + "emcee>=3", + "ptemcee_for_orbitize", + "matplotlib", + "corner", + "h5py", + "deprecation", + "pytest", + "pandas", + "pyerfa", + "astroquery", + "rebound", + "dynesty" +] + +[tool.setuptools.dynamic] +version = {attr = "orbitize.__version__"} + +[tool.setuptools.packages] +find = {} \ No newline at end of file diff --git a/setup.py b/setup.py index 8c25739f..291589f4 100644 --- a/setup.py +++ b/setup.py @@ -1,70 +1,22 @@ -from setuptools import setup, find_packages, Extension -import numpy, sys -import re - -USE_C_KEPLER_MODULE = 1 -if "--disable-cython" in sys.argv: - sys.argv.remove("--disable-cython") - USE_C_KEPLER_MODULE = 0 -else: - try: - from Cython.Build import cythonize - except: - print("Error: Importing cython build environment failed") - USE_C_KEPLER_MODULE = 0 - - -# auto-updating version code stolen from RadVel -def get_property(prop, project): - result = re.search( - r'{}\s*=\s*[\'"]([^\'"]*)[\'"]'.format(prop), - open(project + "/__init__.py").read(), - ) - return result.group(1) - - -def get_requires(): - reqs = [] - for line in open("requirements.txt", "r").readlines(): - reqs.append(line) - return reqs +from setuptools import setup, Extension +import numpy +from Cython.Build import cythonize def get_extensions(): extensions = [] - if USE_C_KEPLER_MODULE: - extensions = cythonize( - [ - Extension( - "orbitize._kepler", - ["orbitize/_kepler.pyx"], - include_dirs=[numpy.get_include()], - ) - ] - ) + extensions = cythonize( + [ + Extension( + "orbitize._kepler", + ["orbitize/_kepler.pyx"], + include_dirs=[numpy.get_include()], + ) + ] + ) return extensions setup( - name="orbitize", - version=get_property("__version__", "orbitize"), - description="orbitize! Turns imaging data into orbits", - url="https://github.com/sblunt/orbitize", - author="", - author_email="", - license="BSD", - packages=find_packages(), - package_data={"": ["kernels/*.cu"]}, ext_modules=get_extensions(), - include_dirs=[numpy.get_include()], - include_package_data=True, - zip_safe=False, - classifiers=[ - "Intended Audience :: Science/Research", - "Topic :: Scientific/Engineering :: Astronomy", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python :: 3.6", - ], - keywords="Orbits Astronomy Astrometry", - install_requires=get_requires(), ) From 5ded5bfa016a5222eee71772553d6c69cc2f21a4 Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Thu, 17 Jul 2025 08:12:56 -0700 Subject: [PATCH 02/10] fixing joss compile action --- .github/workflows/joss-compile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/joss-compile.yml b/.github/workflows/joss-compile.yml index eecf0d13..3504eab1 100644 --- a/.github/workflows/joss-compile.yml +++ b/.github/workflows/joss-compile.yml @@ -14,7 +14,7 @@ jobs: # This should be the path to the paper within your repo. paper-path: paper/paper.md - name: Upload - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: paper # This is the output path where Pandoc will write the compiled From f19a6aaa16f850bea5fb2ca15f064c677ea46f87 Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Thu, 17 Jul 2025 08:24:05 -0700 Subject: [PATCH 03/10] not installing deps via reqs.text in ci action since it should now happen in pyproject.toml --- .github/workflows/python-package.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b6407ac0..25bfd5eb 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -29,7 +29,6 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install flake8 pytest pytest-cov - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From f0370c1bcbbf67473e7b0f55b16c015888888893 Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Thu, 17 Jul 2025 08:28:52 -0700 Subject: [PATCH 04/10] don't halt execution for unused variable --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 25bfd5eb..5a7c8afb 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -32,7 +32,7 @@ jobs: - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --count --select=E9,F63,F7,F82 --extend-ignore=F824 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest From d8ff41bda88c49191f9fbab5a92fce857243e5e9 Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Thu, 17 Jul 2025 08:41:07 -0700 Subject: [PATCH 05/10] jk I do need reqs.txt teehee --- .github/workflows/python-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 5a7c8afb..2e767c39 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -29,6 +29,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install flake8 pytest pytest-cov + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From 9edfa81d38ca6b3f16e5dc81016fec72ebb28c2a Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Thu, 17 Jul 2025 08:41:32 -0700 Subject: [PATCH 06/10] multithread correctly on macs --- tests/test_nested_sampler.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/test_nested_sampler.py b/tests/test_nested_sampler.py index a6130c35..fe276f42 100644 --- a/tests/test_nested_sampler.py +++ b/tests/test_nested_sampler.py @@ -6,6 +6,7 @@ import numpy as np import pytest from orbitize.system import generate_synthetic_data +import sys def test_nested_sampler(): @@ -24,29 +25,34 @@ def test_nested_sampler(): ecc = 0.5 # initialize orbitize `System` object - sys = system.System(1, data_table, mtot, plx) - lab = sys.param_idx + mySys = system.System(1, data_table, mtot, plx) + lab = mySys.param_idx ecc = 0.5 # eccentricity # set all parameters except eccentricity to fixed values (same as used to generate data) - sys.sys_priors[lab["inc1"]] = np.pi / 4 - sys.sys_priors[lab["sma1"]] = sma - sys.sys_priors[lab["aop1"]] = np.pi / 4 - sys.sys_priors[lab["pan1"]] = np.pi / 4 - sys.sys_priors[lab["tau1"]] = 0.8 - sys.sys_priors[lab["plx"]] = plx - sys.sys_priors[lab["mtot"]] = mtot + mySys.sys_priors[lab["inc1"]] = np.pi / 4 + mySys.sys_priors[lab["sma1"]] = sma + mySys.sys_priors[lab["aop1"]] = np.pi / 4 + mySys.sys_priors[lab["pan1"]] = np.pi / 4 + mySys.sys_priors[lab["tau1"]] = 0.8 + mySys.sys_priors[lab["plx"]] = plx + mySys.sys_priors[lab["mtot"]] = mtot + + start_method="fork" + if sys.platform == "darwin": + start_method="spawn" # run both static & dynamic nested samplers - mysampler = sampler.NestedSampler(sys) - _ = mysampler.run_sampler(bound="multi", pfrac=0.95, static=False, num_threads=8) + mysampler = sampler.NestedSampler(mySys) + _ = mysampler.run_sampler(bound="multi", pfrac=0.95, static=False, start_method=start_method, num_threads=8) print("Finished first run!") dynamic_eccentricities = mysampler.results.post[:, lab["ecc1"]] assert np.median(dynamic_eccentricities) == pytest.approx(ecc, abs=0.1) - _ = mysampler.run_sampler(bound="multi", static=True, num_threads=8) + + _ = mysampler.run_sampler(bound="multi", static=True, start_method=start_method, num_threads=8) print("Finished second run!") static_eccentricities = mysampler.results.post[:, lab["ecc1"]] From fb89f81c9d006e97a4dd25ec8445ea6ae4d578e2 Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Thu, 17 Jul 2025 08:43:17 -0700 Subject: [PATCH 07/10] remove upper lim on docutils --- requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index e56e4de7..81bb6acd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,5 @@ pytest pandas pyerfa astroquery -sphinx>=6 -docutils<0.17 rebound dynesty From d209561bb4ea5b0f64a8f20f2de8f5db66b60dc2 Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Thu, 17 Jul 2025 10:40:26 -0700 Subject: [PATCH 08/10] fix xyz shape bug; tutorials should now pass --- orbitize/system.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/orbitize/system.py b/orbitize/system.py index 1da30d3f..2ad41130 100644 --- a/orbitize/system.py +++ b/orbitize/system.py @@ -554,9 +554,15 @@ def compute_all_orbits(self, params_arr, epochs=None, comp_rebound=False): deoff = dec_kepler + dec_perturb if self.fitting_basis == "XYZ": + # Find and filter out unbound orbits - bad_orbits = np.where(np.logical_or(ecc >= 1.0, ecc < 0.0))[0] - if bad_orbits.size != 0: + bad_orbits = [] + if isinstance(ecc, float): + if ecc >= 1.0 or ecc < 0.0: + bad_orbits = [0] + else: + bad_orbits = np.where(np.logical_or(ecc >= 1.0, ecc < 0.0))[0] + if len(bad_orbits) > 0: raoff[:, :, bad_orbits] = np.inf deoff[:, :, bad_orbits] = np.inf vz[:, :, bad_orbits] = np.inf From 514cf0d776251467999914d9e917a89e4cb269ec Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Fri, 18 Jul 2025 10:24:56 -0700 Subject: [PATCH 09/10] increment version --- orbitize/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orbitize/__init__.py b/orbitize/__init__.py index 1eff7b10..e5de575a 100644 --- a/orbitize/__init__.py +++ b/orbitize/__init__.py @@ -1,6 +1,6 @@ import os -__version__ = "3.1.0" +__version__ = "3.2.0" # set Python env variable to keep track of example data dir orbitize_dir = os.path.dirname(__file__) From 2e17664c4ed83dd25ee9a5694c328cdde7fc53a4 Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Fri, 18 Jul 2025 10:26:04 -0700 Subject: [PATCH 10/10] update changelog --- docs/index.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index 7f3c82ff..f38657d5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -55,6 +55,10 @@ User Guide: Changelog: ++++++++++ +**3.2.0 (2025-7-18)** + +- modernize install: setup.py -> pyproject.toml (@sblunt) + **3.1.0 (2024-9-09)** - JOSS paper published! (@sblunt et al)