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 diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b6407ac0..2e767c39 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -33,7 +33,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 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) 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__) 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 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/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 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(), ) 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"]]