Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate
Browse files Browse the repository at this point in the history
updates:
- [github.com/PyCQA/isort: 5.13.2 → 6.0.0](PyCQA/isort@5.13.2...6.0.0)
- [github.com/codespell-project/codespell: v2.3.0 → v2.4.1](codespell-project/codespell@v2.3.0...v2.4.1)
- [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.4](astral-sh/ruff-pre-commit@v0.8.6...v0.9.4)
  • Loading branch information
pre-commit-ci[bot] authored and jobovy committed Feb 4, 2025
1 parent e0a9134 commit 332bc94
Show file tree
Hide file tree
Showing 47 changed files with 15,267 additions and 13,622 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ repos:
hooks:
- id: pycln
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
rev: 6.0.0
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/codespell-project/codespell
rev: "v2.3.0"
rev: "v2.4.1"
hooks:
- id: codespell
args: ["-L", "thisE,thise,mye,tE,te,hist,ro,sav,ccompiler,aas,floatIn,dOmin",
args: ["-L", "thisE,thise,mye,tE,te,hist,ro,sav,ccompiler,aas,floatIn,dOmin,indx",
"-x","doc/source/_static/try-galpy.js"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.4
hooks:
- id: ruff-format
2 changes: 1 addition & 1 deletion HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ v1.8.0 (2022-07-04)
- Renamed phiforce --> phitorque everywhere (including
potential.evaluatephiforces and potential.evaluateplanarphiforces), such that
the method's name actually reflect what it returns (a torque, not a force).
phiforce will be fully removed in version 1.9 and may later be re-used
phiforce will be fully removed in version 1.9 and may later be reused
for the actual phi component of the force, so switch to the new name now.

- Added code to check whether a newer version of galpy is available and, if so
Expand Down
2 changes: 1 addition & 1 deletion create_galpy_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GALPY_VERSION=1.8.0

rm -rf galpy-wheels-output
mkdir galpy-wheels-output
# Loop over the entire thing to make sure nothing gets re-used
# Loop over the entire thing to make sure nothing gets reused
for PYTHON_VERSION in "${PYTHON_VERSIONS[@]}"; do
git clone https://github.com/jobovy/galpy.git galpy-wheels
cd galpy-wheels
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Other user-facing improvements and additions are
* Renamed ``phiforce`` --> ``phitorque`` everywhere (including
``potential.evaluatephiforces`` and ``potential.evaluateplanarphiforces``), such
that the method's name actually reflect what it returns (a torque, not a force).
``phiforce`` will be fully removed in version 1.9 and may later be re-used
``phiforce`` will be fully removed in version 1.9 and may later be reused
for the actual phi component of the force, so switch to the new name now.

* Added ``SCFPotential.from_density`` to directly initialize an ``SCFPotential``
Expand Down
12 changes: 6 additions & 6 deletions galpy/actionAngle/actionAngle.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ def __init__(self, ro=None, vo=None):

def _check_consistent_units(self):
"""Internal function to check that the set of units for this object is consistent with that for the potential"""
assert physical_compatible(
self, self._pot
), "Physical conversion for the actionAngle object is not consistent with that of the Potential given to it"
assert physical_compatible(self, self._pot), (
"Physical conversion for the actionAngle object is not consistent with that of the Potential given to it"
)

def _check_consistent_units_orbitInput(self, orb):
"""Internal function to check that the set of units for this object is consistent with that for an input orbit"""
assert physical_compatible(
self, orb
), "Physical conversion for the actionAngle object is not consistent with that of the Orbit given to it"
assert physical_compatible(self, orb), (
"Physical conversion for the actionAngle object is not consistent with that of the Orbit given to it"
)

def turn_physical_off(self):
"""
Expand Down
6 changes: 3 additions & 3 deletions galpy/df/constantbetaHernquistdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def __init__(self, pot=None, beta=0, ro=None, vo=None):
-----
- 2020-07-22 - Written - Lane (UofT)
"""
assert isinstance(
pot, HernquistPotential
), "pot= must be potential.HernquistPotential"
assert isinstance(pot, HernquistPotential), (
"pot= must be potential.HernquistPotential"
)
_constantbetadf.__init__(self, pot=pot, beta=beta, ro=ro, vo=vo)
self._psi0 = -evaluatePotentials(self._pot, 0, 0, use_physical=False)
self._potInf = 0.0
Expand Down
6 changes: 3 additions & 3 deletions galpy/df/df.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def __init__(self, ro=None, vo=None):

def _check_consistent_units(self):
"""Internal function to check that the set of units for this object is consistent with that for the potential"""
assert physical_compatible(
self, self._pot
), "Physical conversion for the DF object is not consistent with that of the Potential given to it"
assert physical_compatible(self, self._pot), (
"Physical conversion for the DF object is not consistent with that of the Potential given to it"
)

def turn_physical_off(self):
"""
Expand Down
6 changes: 3 additions & 3 deletions galpy/df/isotropicHernquistdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def __init__(self, pot=None, ro=None, vo=None):
-----
- 2020-08-09 - Written - Lane (UofT)
"""
assert isinstance(
pot, HernquistPotential
), "pot= must be potential.HernquistPotential"
assert isinstance(pot, HernquistPotential), (
"pot= must be potential.HernquistPotential"
)
isotropicsphericaldf.__init__(self, pot=pot, ro=ro, vo=vo)
self._psi0 = -evaluatePotentials(self._pot, 0, 0, use_physical=False)
self._GMa = self._psi0 * self._pot.a**2.0
Expand Down
6 changes: 3 additions & 3 deletions galpy/df/isotropicPlummerdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def __init__(self, pot=None, ro=None, vo=None):
-----
- 2020-10-01 - Written - Bovy (UofT).
"""
assert isinstance(
pot, PlummerPotential
), "pot= must be potential.PlummerPotential"
assert isinstance(pot, PlummerPotential), (
"pot= must be potential.PlummerPotential"
)
isotropicsphericaldf.__init__(self, pot=pot, ro=ro, vo=vo)
self._Etildemax = pot._amp / pot._b
# /amp^4 instead of /amp^5 to make the DF that of mass density
Expand Down
8 changes: 4 additions & 4 deletions galpy/df/osipkovmerrittHernquistdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class osipkovmerrittHernquistdf(_osipkovmerrittdf):
\\beta(r) = \\frac{1}{1+r_a^2/r^2}
with :math:`r_a` the anistropy radius.
with :math:`r_a` the anisotropy radius.
"""

Expand All @@ -37,9 +37,9 @@ def __init__(self, pot=None, ra=1.4, ro=None, vo=None):
-----
- 2020-11-12 - Written - Bovy (UofT)
"""
assert isinstance(
pot, HernquistPotential
), "pot= must be potential.HernquistPotential"
assert isinstance(pot, HernquistPotential), (
"pot= must be potential.HernquistPotential"
)
_osipkovmerrittdf.__init__(self, pot=pot, ra=ra, ro=ro, vo=vo)
self._psi0 = -evaluatePotentials(self._pot, 0, 0, use_physical=False)
self._GMa = self._psi0 * self._pot.a**2.0
Expand Down
2 changes: 1 addition & 1 deletion galpy/df/osipkovmerrittNFWdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class osipkovmerrittNFWdf(_osipkovmerrittdf):
\\beta(r) = \\frac{1}{1+r_a^2/r^2}
with :math:`r_a` the anistropy radius.
with :math:`r_a` the anisotropy radius.
"""

Expand Down
2 changes: 1 addition & 1 deletion galpy/df/osipkovmerrittdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class osipkovmerrittdf(_osipkovmerrittdf):
\\beta(r) = \\frac{1}{1+r_a^2/r^2}
with :math:`r_a` the anistropy radius for arbitrary combinations of potential and density profile.
with :math:`r_a` the anisotropy radius for arbitrary combinations of potential and density profile.
"""

def __init__(
Expand Down
24 changes: 12 additions & 12 deletions galpy/df/streamspraydf.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ def __init__(
raise OSError("pot= must be set")
self._pot = flatten_potential(pot)
self._rtpot = self._pot if rtpot is None else flatten_potential(rtpot)
assert conversion.physical_compatible(
self, self._pot
), "Physical conversion for the potential is not consistent with that of the basestreamspraydf object being initialized"
assert conversion.physical_compatible(
self, self._rtpot
), "Physical conversion for the rt potential is not consistent with that of the basestreamspraydf object being initialized"
assert conversion.physical_compatible(self, self._pot), (
"Physical conversion for the potential is not consistent with that of the basestreamspraydf object being initialized"
)
assert conversion.physical_compatible(self, self._rtpot), (
"Physical conversion for the rt potential is not consistent with that of the basestreamspraydf object being initialized"
)
# Set up progenitor orbit
assert conversion.physical_compatible(
self, progenitor
), "Physical conversion for the progenitor Orbit object is not consistent with that of the basestreamspraydf object being initialized"
assert conversion.physical_compatible(self, progenitor), (
"Physical conversion for the progenitor Orbit object is not consistent with that of the basestreamspraydf object being initialized"
)
self._orig_progenitor = progenitor # Store so we can use its ro/vo/etc.
self._progenitor = progenitor()
self._progenitor.turn_physical_off()
Expand All @@ -97,9 +97,9 @@ def __init__(
self._centerpot = (
self._pot if centerpot is None else flatten_potential(centerpot)
)
assert conversion.physical_compatible(
self, self._centerpot
), "Physical conversion for the center potential is not consistent with that of the basestreamspraydf object being initialized"
assert conversion.physical_compatible(self, self._centerpot), (
"Physical conversion for the center potential is not consistent with that of the basestreamspraydf object being initialized"
)
self._center = center()
self._center.turn_physical_off()
self._center.integrate(self._progenitor_times, self._centerpot)
Expand Down
60 changes: 33 additions & 27 deletions galpy/orbit/Orbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
evaluatePotentials,
)
from ..potential import flatten as flatten_potential
from ..potential import rE, rl, toPlanarPotential
from ..potential import (
rE,
rl,
toPlanarPotential,
)
from ..potential.DissipativeForce import _isDissipative
from ..potential.Potential import _check_c
from ..util import conversion, coords, galpyWarning, galpyWarningVerbose, plot
Expand Down Expand Up @@ -816,7 +820,7 @@ def from_name(cls, *args, **kwargs):

"""
if not _APY_LOADED: # pragma: no cover
raise ImportError("astropy needs to be installed to use " "Orbit.from_name")
raise ImportError("astropy needs to be installed to use Orbit.from_name")
_load_named_objects()
_update_keys_named_objects()
# Stack coordinate-transform parameters, so they can be changed...
Expand Down Expand Up @@ -1697,7 +1701,9 @@ def integrate_SOS(
(numpy.roll(self.t, -1, axis=1) - self.t)[:, :-1]
* (numpy.roll(self._psi.T, -1, axis=0) - self._psi.T)[:-1].T
> 0.0
), "SOS integration failed (time does not monotonically increase with increasing psi)"
), (
"SOS integration failed (time does not monotonically increase with increasing psi)"
)
return None

def integrate_dxdv(
Expand Down Expand Up @@ -5624,7 +5630,7 @@ def plot(self, *args, **kwargs):
and not "yrange" in kwargs
and not kwargs.get("overplot", False)
)
labels = kwargs.pop("label", [f"Orbit {ii+1}" for ii in range(self.size)])
labels = kwargs.pop("label", [f"Orbit {ii + 1}" for ii in range(self.size)])
if self.size == 1 and isinstance(labels, str):
labels = [labels]
# Plot
Expand Down Expand Up @@ -5825,7 +5831,7 @@ def plotSOS(
and not "yrange" in kwargs
and not kwargs.get("overplot", False)
)
labels = kwargs.pop("label", [f"Orbit {ii+1}" for ii in range(self.size)])
labels = kwargs.pop("label", [f"Orbit {ii + 1}" for ii in range(self.size)])
if self.size == 1 and isinstance(labels, str):
labels = [labels]
# Plot
Expand Down Expand Up @@ -5939,7 +5945,7 @@ def _base_plotSOS(self, x, y, surface, *args, **kwargs):
and not "yrange" in kwargs
and not kwargs.get("overplot", False)
)
labels = kwargs.pop("label", [f"Orbit {ii+1}" for ii in range(self.size)])
labels = kwargs.pop("label", [f"Orbit {ii + 1}" for ii in range(self.size)])
if self.size == 1 and isinstance(labels, str):
labels = [labels]
# Plot
Expand Down Expand Up @@ -6333,7 +6339,7 @@ def animate(self, **kwargs): # pragma: no cover
names[ii], xlabels[0], ylabels[0], tlabel
),
)
traces_cumul += f""",trace{str(2*ii+1)},trace{str(2*ii+2)}"""
traces_cumul += f""",trace{str(2 * ii + 1)},trace{str(2 * ii + 2)}"""
x_data_list = """"""
y_data_list = """"""
t_data_list = """"""
Expand All @@ -6350,8 +6356,8 @@ def animate(self, **kwargs): # pragma: no cover
t_data_list += (
"""data.time.slice(trace_slice_begin,trace_slice_end), """
)
trace_num_10_list += f"""{str(2*jj*self.size + 2 * ii + 1 - 1)}, """
trace_num_20_list += f"""{str(2*jj*self.size + 2 * ii + 2 - 1)}, """
trace_num_10_list += f"""{str(2 * jj * self.size + 2 * ii + 1 - 1)}, """
trace_num_20_list += f"""{str(2 * jj * self.size + 2 * ii + 2 - 1)}, """
# Additional traces for additional plots
if len(d1s) > 1:
setup_trace2 = """
Expand Down Expand Up @@ -6397,7 +6403,9 @@ def animate(self, **kwargs): # pragma: no cover
names[0], xlabels[1], ylabels[1], tlabel
),
)
traces_cumul += f""",trace{str(2*self.size+1)},trace{str(2*self.size+2)}"""
traces_cumul += (
f""",trace{str(2 * self.size + 1)},trace{str(2 * self.size + 2)}"""
)
for ii in range(1, self.size):
setup_trace2 += """
let trace{trace_num_1}= {{
Expand Down Expand Up @@ -6445,7 +6453,7 @@ def animate(self, **kwargs): # pragma: no cover
names[ii], xlabels[1], ylabels[1], tlabel
),
)
traces_cumul += f""",trace{str(2*self.size+2*ii+1)},trace{str(2*self.size+2*ii+2)}"""
traces_cumul += f""",trace{str(2 * self.size + 2 * ii + 1)},trace{str(2 * self.size + 2 * ii + 2)}"""
else: # else for "if there is a 2nd panel"
setup_trace2 = """
let traces= [{traces_cumul}];
Expand Down Expand Up @@ -6494,7 +6502,9 @@ def animate(self, **kwargs): # pragma: no cover
names[0], xlabels[2], ylabels[2], tlabel
),
)
traces_cumul += f""",trace{str(4*self.size+1)},trace{str(4*self.size+2)}"""
traces_cumul += (
f""",trace{str(4 * self.size + 1)},trace{str(4 * self.size + 2)}"""
)
for ii in range(1, self.size):
setup_trace3 += """
let trace{trace_num_1}= {{
Expand Down Expand Up @@ -6544,7 +6554,7 @@ def animate(self, **kwargs): # pragma: no cover
names[ii], xlabels[2], ylabels[0], tlabel
),
)
traces_cumul += f""",trace{str(4*self.size+2*ii+1)},trace{str(4*self.size+2*ii+2)}"""
traces_cumul += f""",trace{str(4 * self.size + 2 * ii + 1)},trace{str(4 * self.size + 2 * ii + 2)}"""
setup_trace3 += """
let traces= [{traces_cumul}];
""".format(traces_cumul=traces_cumul)
Expand Down Expand Up @@ -7080,8 +7090,8 @@ def animate3d(self, mw_plane_bg=False, **kwargs): # pragma: no cover
if not is_kpc:
mw_bg_surface_scale /= self._ro
mw_bg_surface = f"""let mw_bg = {{
x: {json.dumps((numpy.linspace(-1, 1, 50)*mw_bg_surface_scale).tolist())},
y: {json.dumps((numpy.linspace(-1, 1, 50)*mw_bg_surface_scale).tolist())},
x: {json.dumps((numpy.linspace(-1, 1, 50) * mw_bg_surface_scale).tolist())},
y: {json.dumps((numpy.linspace(-1, 1, 50) * mw_bg_surface_scale).tolist())},
z: {json.dumps((numpy.zeros((50, 50))).tolist())},
colorscale: [[0.0,"rgba(0, 0, 0, 1)"],[0.09090909090909091,"rgba(16, 16, 16, 1)"],[0.18181818181818182,"rgba(38, 38, 38, 0.9)"],[0.2727272727272727,"rgba(59, 59, 59, 0.8)"],[0.36363636363636365,"rgba(81, 80, 80, 0.7)"],[0.45454545454545453,"rgba(102, 101, 101, 0.6)"],[0.5454545454545454,"rgba(124, 123, 122, 0.5)"],[0.6363636363636364,"rgba(146, 146, 145, 0.4)"],[0.7272727272727273,"rgba(171, 171, 170, 0.3)"],[0.8181818181818182,"rgba(197, 197, 195, 0.2)"],[0.9090909090909091,"rgba(224, 224, 223, 0.1)"],[1.0,"rgba(254, 254, 253, 0.05)"]],
surfacecolor: [
Expand Down Expand Up @@ -7188,7 +7198,7 @@ def animate3d(self, mw_plane_bg=False, **kwargs): # pragma: no cover
names[ii], xlabels[0], ylabels[0], zlabels[0], tlabel
),
)
traces_cumul += f""",trace{str(2*ii+1)},trace{str(2*ii+2)}"""
traces_cumul += f""",trace{str(2 * ii + 1)},trace{str(2 * ii + 2)}"""
x_data_list = """"""
y_data_list = """"""
z_data_list = """"""
Expand All @@ -7213,8 +7223,8 @@ def animate3d(self, mw_plane_bg=False, **kwargs): # pragma: no cover
t_data_list += (
"""data.time.slice(trace_slice_begin,trace_slice_end), """
)
trace_num_10_list += f"""{str(2*jj*self.size + 2 * ii + 1 - 1)}, """
trace_num_20_list += f"""{str(2*jj*self.size + 2 * ii + 2 - 1)}, """
trace_num_10_list += f"""{str(2 * jj * self.size + 2 * ii + 1 - 1)}, """
trace_num_20_list += f"""{str(2 * jj * self.size + 2 * ii + 2 - 1)}, """
return HTML(
"""
<style>
Expand Down Expand Up @@ -7481,9 +7491,7 @@ def _from_name_oneobject(name, obs):
# check that the necessary coordinates have been found
missing = simbad_table.mask
if any(missing["ra", "dec", "pmra", "pmdec", "rvz_radvel"][0]):
raise ValueError(
"failed to find some coordinates for {} in " "SIMBAD".format(name)
)
raise ValueError(f"failed to find some coordinates for {name} in SIMBAD")
ra, dec, pmra, pmdec, vlos = simbad_table[
"ra", "dec", "pmra", "pmdec", "rvz_radvel"
][0]
Expand Down Expand Up @@ -7512,9 +7520,7 @@ def _from_name_oneobject(name, obs):
if any(missing["RA_d", "DEC_d", "PMRA", "PMDEC", "RV_VALUE"][0]) or all(
missing["PLX_VALUE", "Distance_distance"][0]
):
raise ValueError(
"failed to find some coordinates for {} in " "SIMBAD".format(name)
)
raise ValueError(f"failed to find some coordinates for {name} in SIMBAD")
ra, dec, pmra, pmdec, vlos = simbad_table[
"RA_d", "DEC_d", "PMRA", "PMDEC", "RV_VALUE"
][0]
Expand Down Expand Up @@ -8118,6 +8124,6 @@ def _check_potential_dim(orb, pot):
def _check_consistent_units(orb, pot):
if pot is None:
return None
assert physical_compatible(
orb, pot
), "Physical conversion for the Orbit object is not consistent with that of the Potential given to it"
assert physical_compatible(orb, pot), (
"Physical conversion for the Orbit object is not consistent with that of the Potential given to it"
)
2 changes: 1 addition & 1 deletion galpy/orbit/integratePlanarOrbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ def _parse_tol(rtol, atol):


def _parse_scf_pot(p, extra_amp=1.0):
# Stand-alone parser for SCF, bc re-used
# Stand-alone parser for SCF, bc reused
isNonAxi = p.isNonAxi
pot_args = [p._a, isNonAxi]
pot_args.extend(p._Acos.shape)
Expand Down
Loading

0 comments on commit 332bc94

Please sign in to comment.