From 8c0f22fb4d935d0054bed54efee19e5626bf4637 Mon Sep 17 00:00:00 2001 From: Anne Archibald Date: Sun, 25 Feb 2024 15:02:05 +0000 Subject: [PATCH] Enforce python3.12 and fix syntaxwarnings --- src/pint/derived_quantities.py | 42 ++++++++++++++++------------------ src/pint/output/publish.py | 6 ++--- tox.ini | 1 + 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/pint/derived_quantities.py b/src/pint/derived_quantities.py index 104b73d8d..d8cb66390 100644 --- a/src/pint/derived_quantities.py +++ b/src/pint/derived_quantities.py @@ -34,7 +34,7 @@ p=[u.Hz, u.s], pd=[u.Hz / u.s, u.s / u.s], pdd=[u.Hz / u.s**2, u.s / u.s**2] ) def p_to_f(p, pd, pdd=None): - """Converts P, Pdot to F, Fdot (or vice versa) + r"""Converts P, Pdot to F, Fdot (or vice versa) Convert period, period derivative and period second derivative (if supplied) to the equivalent frequency counterparts. @@ -81,7 +81,7 @@ def p_to_f(p, pd, pdd=None): pdorfderr=[u.Hz / u.s, u.s / u.s], ) def pferrs(porf, porferr, pdorfd=None, pdorfderr=None): - """Convert P, Pdot to F, Fdot with uncertainties (or vice versa). + r"""Convert P, Pdot to F, Fdot with uncertainties (or vice versa). Calculate the period or frequency errors and the Pdot or fdot errors from the opposite ones. @@ -129,7 +129,7 @@ def pferrs(porf, porferr, pdorfd=None, pdorfderr=None): @u.quantity_input(fo=u.Hz) def pulsar_age(f: u.Hz, fdot: u.Hz / u.s, n=3, fo=1e99 * u.Hz): - """Compute pulsar characteristic age + r"""Compute pulsar characteristic age Return the age of a pulsar given the spin frequency and frequency derivative. By default, the characteristic age @@ -172,7 +172,7 @@ def pulsar_age(f: u.Hz, fdot: u.Hz / u.s, n=3, fo=1e99 * u.Hz): @u.quantity_input(I=u.g * u.cm**2) def pulsar_edot(f: u.Hz, fdot: u.Hz / u.s, I=1.0e45 * u.g * u.cm**2): - """Compute pulsar spindown energy loss rate + r"""Compute pulsar spindown energy loss rate Return the pulsar `Edot` (:math:`\dot E`, in erg/s) given the spin frequency `f` and frequency derivative `fdot`. The NS moment of inertia is assumed to be @@ -208,7 +208,7 @@ def pulsar_edot(f: u.Hz, fdot: u.Hz / u.s, I=1.0e45 * u.g * u.cm**2): @u.quantity_input def pulsar_B(f: u.Hz, fdot: u.Hz / u.s): - """Compute pulsar surface magnetic field + r"""Compute pulsar surface magnetic field Return the estimated pulsar surface magnetic field strength given the spin frequency and frequency derivative. @@ -243,7 +243,7 @@ def pulsar_B(f: u.Hz, fdot: u.Hz / u.s): @u.quantity_input def pulsar_B_lightcyl(f: u.Hz, fdot: u.Hz / u.s): - """Compute pulsar magnetic field at the light cylinder + r"""Compute pulsar magnetic field at the light cylinder Return the estimated pulsar magnetic field strength at the light cylinder given the spin frequency and @@ -285,7 +285,7 @@ def pulsar_B_lightcyl(f: u.Hz, fdot: u.Hz / u.s): @u.quantity_input def mass_funct(pb: u.d, x: u.cm): - """Compute binary mass function from period and semi-major axis + r"""Compute binary mass function from period and semi-major axis Can handle scalar or array inputs. @@ -326,7 +326,7 @@ def mass_funct(pb: u.d, x: u.cm): @u.quantity_input def mass_funct2(mp: u.Msun, mc: u.Msun, i: u.deg): - """Compute binary mass function from masses and inclination + r"""Compute binary mass function from masses and inclination Can handle scalar or array inputs. @@ -371,7 +371,7 @@ def mass_funct2(mp: u.Msun, mc: u.Msun, i: u.deg): @u.quantity_input def pulsar_mass(pb: u.d, x: u.cm, mc: u.Msun, i: u.deg): - """Compute pulsar mass from orbital parameters + r"""Compute pulsar mass from orbital parameters Return the pulsar mass (in solar mass units) for a binary. Can handle scalar or array inputs. @@ -438,7 +438,7 @@ def pulsar_mass(pb: u.d, x: u.cm, mc: u.Msun, i: u.deg): @u.quantity_input(inc=u.deg, mpsr=u.solMass) def companion_mass(pb: u.d, x: u.cm, i=60.0 * u.deg, mp=1.4 * u.solMass): - """Commpute the companion mass from the orbital parameters + r"""Commpute the companion mass from the orbital parameters Compute companion mass for a binary system from orbital mechanics, not Shapiro delay. @@ -542,7 +542,7 @@ def companion_mass(pb: u.d, x: u.cm, i=60.0 * u.deg, mp=1.4 * u.solMass): @u.quantity_input def pbdot(mp: u.Msun, mc: u.Msun, pb: u.d, e: u.dimensionless_unscaled): - """Post-Keplerian orbital decay pbdot, assuming general relativity. + r"""Post-Keplerian orbital decay pbdot, assuming general relativity. pbdot (:math:`\dot P_B`) is the change in the binary orbital period due to emission of gravitational waves. @@ -605,7 +605,7 @@ def pbdot(mp: u.Msun, mc: u.Msun, pb: u.d, e: u.dimensionless_unscaled): @u.quantity_input def gamma(mp: u.Msun, mc: u.Msun, pb: u.d, e: u.dimensionless_unscaled): - """Post-Keplerian time dilation and gravitational redshift gamma, assuming general relativity. + r"""Post-Keplerian time dilation and gravitational redshift gamma, assuming general relativity. gamma (:math:`\gamma`) is the amplitude of the modification in arrival times caused by the varying gravitational redshift of the companion and time dilation in an elliptical orbit. The time delay is @@ -661,7 +661,7 @@ def gamma(mp: u.Msun, mc: u.Msun, pb: u.d, e: u.dimensionless_unscaled): @u.quantity_input def omdot(mp: u.Msun, mc: u.Msun, pb: u.d, e: u.dimensionless_unscaled): - """Post-Keplerian longitude of periastron precession rate omdot, assuming general relativity. + r"""Post-Keplerian longitude of periastron precession rate omdot, assuming general relativity. omdot (:math:`\dot \omega`) is the relativistic advance of periastron. Can handle scalar or array inputs. @@ -716,7 +716,7 @@ def omdot(mp: u.Msun, mc: u.Msun, pb: u.d, e: u.dimensionless_unscaled): @u.quantity_input def sini(mp: u.Msun, mc: u.Msun, pb: u.d, x: u.cm): - """Post-Keplerian sine of inclination, assuming general relativity. + r"""Post-Keplerian sine of inclination, assuming general relativity. Can handle scalar or array inputs. @@ -916,14 +916,12 @@ def omdot_to_mtot(omdot: u.deg / u.yr, pb: u.d, e: u.dimensionless_unscaled): """ return ( ( - ( - omdot - / ( - 3 - * (const.G / const.c**3) ** (2.0 / 3) - * (pb / (2 * np.pi)) ** (-5.0 / 3) - * (1 - e**2) ** (-1) - ) + omdot + / ( + 3 + * (const.G / const.c**3) ** (2.0 / 3) + * (pb / (2 * np.pi)) ** (-5.0 / 3) + * (1 - e**2) ** (-1) ) ) ** (3.0 / 2) diff --git a/src/pint/output/publish.py b/src/pint/output/publish.py index 2cb82b0ac..e6380eb1f 100644 --- a/src/pint/output/publish.py +++ b/src/pint/output/publish.py @@ -259,7 +259,7 @@ def publish( ) tex.write("\\hline\n") - tex.write("\multicolumn{2}{c}{Measured Quantities} \\\\ \n") + tex.write("\\multicolumn{2}{c}{Measured Quantities} \\\\ \n") tex.write("\\hline\n") for fp in model.free_params: param = getattr(model, fp) @@ -273,7 +273,7 @@ def publish( tex.write("\\hline\n") if include_set_params: - tex.write("\multicolumn{2}{c}{Set Quantities} \\\\ \n") + tex.write("\\multicolumn{2}{c}{Set Quantities} \\\\ \n") tex.write("\\hline\n") for p in model.params: param = getattr(model, p) @@ -303,7 +303,7 @@ def publish( and getattr(model, p).quantity is not None ] if len(derived_params) > 0: - tex.write("\multicolumn{2}{c}{Derived Quantities} \\\\ \n") + tex.write("\\multicolumn{2}{c}{Derived Quantities} \\\\ \n") tex.write("\\hline\n") for param in derived_params: tex.write(publish_param(param)) diff --git a/tox.ini b/tox.ini index 67d010f84..5b18d6ba0 100644 --- a/tox.ini +++ b/tox.ini @@ -140,6 +140,7 @@ commands = black --check src tests examples [testenv:mypy] changedir = . description = use mypy +basepython = python3.12 deps = mypy==1.8.0 GitPython