Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated features in v1.9 #585

Merged
merged 1 commit into from
Jun 17, 2023
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
8 changes: 8 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ v1.9.0 (XXXX-XX-XX)

- Don't fail when writing a (fixed) configuration file, instead just warn.

- Removed the deprecated galpy.util.bovy_coords, galpy.util.bovy_plot, and
galpy.util.bovy_conversion modules. These were replaced by galpy.util.coords,
galpy.util.plot, and galpy.util.conversion in v1.7.

- Removed the deprecated phiforce method from potentials and the accompanying
evaluatephiforces and evaluateplanarphiforces potential functions. These were replaced
by phitorque, evaluatephitorques, and evaluateplanarphitorques in v1.8.0.

- Switched to using Python 3.11 as the default Python version in the test suite.

v1.8.3 (2023-03-27)
Expand Down
17 changes: 0 additions & 17 deletions galpy/potential/Potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import os
import os.path
import pickle
import warnings
from functools import wraps

import numpy
Expand Down Expand Up @@ -762,13 +761,6 @@ def normalize(self, norm):
"""
self._amp *= norm / numpy.fabs(self.Rforce(1.0, 0.0, use_physical=False))

def phiforce(self, R, z, phi=0.0, t=0.0):
warnings.warn(
"phiforce has been renamed phitorque, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component",
FutureWarning,
)
return self.phitorque(R, z, phi=phi, t=t)

@potential_physical_input
@physical_conversion("energy", pop=True)
def phitorque(self, R, z, phi=0.0, t=0.0):
Expand Down Expand Up @@ -2405,15 +2397,6 @@ def _evaluateRforces(Pot, R, z, phi=None, t=0.0, v=None):
)


@potential_positional_arg
def evaluatephiforces(Pot, R, z, phi=None, t=0.0, v=None):
warnings.warn(
"evaluatephiforces has been renamed evaluatephitorques, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component",
FutureWarning,
)
return evaluatephitorques(Pot, R, z, phi=phi, t=t, v=v)


@potential_positional_arg
@potential_physical_input
@physical_conversion("energy", pop=True)
Expand Down
2 changes: 0 additions & 2 deletions galpy/potential/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
mass = Potential.mass
evaluateRforces = Potential.evaluateRforces
evaluatephitorques = Potential.evaluatephitorques
evaluatephiforces = Potential.evaluatephiforces
evaluatezforces = Potential.evaluatezforces
evaluaterforces = Potential.evaluaterforces
evaluateR2derivs = Potential.evaluateR2derivs
Expand Down Expand Up @@ -108,7 +107,6 @@
evaluateplanarRforces = planarPotential.evaluateplanarRforces
evaluateplanarR2derivs = planarPotential.evaluateplanarR2derivs
evaluateplanarphitorques = planarPotential.evaluateplanarphitorques
evaluateplanarphiforces = planarPotential.evaluateplanarphiforces
evaluatelinearPotentials = linearPotential.evaluatelinearPotentials
evaluatelinearForces = linearPotential.evaluatelinearForces
PotentialError = Potential.PotentialError
Expand Down
17 changes: 0 additions & 17 deletions galpy/potential/planarPotential.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import pickle
import warnings

import numpy
from scipy import integrate
Expand Down Expand Up @@ -126,13 +125,6 @@ def _Rforce_nodecorator(self, R, phi=0.0, t=0.0):
"'_Rforce' function not implemented for this potential"
)

def phiforce(self, R, phi=0.0, t=0.0):
warnings.warn(
"phiforce has been renamed phitorque, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component",
FutureWarning,
)
return self.phitorque(R, phi=phi, t=t)

@potential_physical_input
@physical_conversion("energy", pop=True)
def phitorque(self, R, phi=0.0, t=0.0):
Expand Down Expand Up @@ -1049,15 +1041,6 @@ def _evaluateplanarRforces(Pot, R, phi=None, t=0.0, v=None):
)


@potential_positional_arg
def evaluateplanarphiforces(Pot, R, phi=None, t=0.0, v=None):
warnings.warn(
"evaluateplanarphiforces has been renamed evaluateplanarphitorques, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component",
FutureWarning,
)
return evaluateplanarphitorques(Pot, R, phi=phi, t=t, v=None)


@potential_positional_arg
@potential_physical_input
@physical_conversion("energy", pop=True)
Expand Down
20 changes: 0 additions & 20 deletions galpy/util/bovy_conversion.py

This file was deleted.

10 changes: 0 additions & 10 deletions galpy/util/bovy_coords.py

This file was deleted.

18 changes: 0 additions & 18 deletions galpy/util/bovy_plot.py

This file was deleted.

91 changes: 48 additions & 43 deletions tests/test_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -7313,11 +7313,11 @@ def test_phiforce_deprecation():
# Check that we've removed phiforce in the correct version
from packaging.version import parse as parse_version

deprecation_version = parse_version("1.9")
deprecation_version = parse_version("1.8.3")
from galpy import __version__ as galpy_version

galpy_version = parse_version(galpy_version)
should_be_removed = galpy_version >= deprecation_version
should_be_removed = galpy_version > deprecation_version
# Now test
lp = potential.LogarithmicHaloPotential()
# Method
Expand All @@ -7335,15 +7335,17 @@ def test_phiforce_deprecation():
raise AssertionError(
"phiforce not removed when it was supposed to be removed"
)
raisedWarning = False
for wa in w:
raisedWarning = (
str(wa.message)
== "phiforce has been renamed phitorque, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component"
)
if raisedWarning:
break
assert raisedWarning, "phiforce deprecation did not raise the expected warning"
raisedWarning = False
for wa in w:
raisedWarning = (
str(wa.message)
== "phiforce has been renamed phitorque, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component"
)
if raisedWarning:
break
assert (
raisedWarning
), "phiforce deprecation did not raise the expected warning"
# Function
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", FutureWarning)
Expand All @@ -7359,15 +7361,17 @@ def test_phiforce_deprecation():
raise AssertionError(
"phiforce not removed when it was supposed to be removed"
)
raisedWarning = False
for wa in w:
raisedWarning = (
str(wa.message)
== "evaluatephiforces has been renamed evaluatephitorques, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component"
)
if raisedWarning:
break
assert raisedWarning, "phiforce deprecation did not raise the expected warning"
raisedWarning = False
for wa in w:
raisedWarning = (
str(wa.message)
== "evaluatephiforces has been renamed evaluatephitorques, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component"
)
if raisedWarning:
break
assert (
raisedWarning
), "phiforce deprecation did not raise the expected warning"


def test_phiforce_deprecation_2d():
Expand All @@ -7377,11 +7381,11 @@ def test_phiforce_deprecation_2d():
# Check that we've removed phiforce in the correct version
from packaging.version import parse as parse_version

deprecation_version = parse_version("1.9")
deprecation_version = parse_version("1.8.3")
from galpy import __version__ as galpy_version

galpy_version = parse_version(galpy_version)
should_be_removed = galpy_version >= deprecation_version
should_be_removed = galpy_version > deprecation_version
# Now test
lp = potential.LogarithmicHaloPotential().toPlanar()
# Method
Expand All @@ -7399,15 +7403,17 @@ def test_phiforce_deprecation_2d():
raise AssertionError(
"phiforce not removed when it was supposed to be removed"
)
raisedWarning = False
for wa in w:
raisedWarning = (
str(wa.message)
== "phiforce has been renamed phitorque, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component"
)
if raisedWarning:
break
assert raisedWarning, "phiforce deprecation did not raise the expected warning"
raisedWarning = False
for wa in w:
raisedWarning = (
str(wa.message)
== "phiforce has been renamed phitorque, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component"
)
if raisedWarning:
break
assert (
raisedWarning
), "phiforce deprecation did not raise the expected warning"
# Function
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", FutureWarning)
Expand All @@ -7423,15 +7429,17 @@ def test_phiforce_deprecation_2d():
raise AssertionError(
"phiforce not removed when it was supposed to be removed"
)
raisedWarning = False
for wa in w:
raisedWarning = (
str(wa.message)
== "evaluateplanarphiforces has been renamed evaluateplanarphitorques, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component"
)
if raisedWarning:
break
assert raisedWarning, "phiforce deprecation did not raise the expected warning"
raisedWarning = False
for wa in w:
raisedWarning = (
str(wa.message)
== "evaluateplanarphiforces has been renamed evaluateplanarphitorques, because it has always really been a torque (per unit mass); please switch to the new method name, because the old name will be removed in v1.9 and may be re-used for the actual phi force component"
)
if raisedWarning:
break
assert (
raisedWarning
), "phiforce deprecation did not raise the expected warning"


# Test that Pot is required to be a positional argument for Potential functions
Expand Down Expand Up @@ -7468,9 +7476,6 @@ def test_potential_Pot_is_positional():
func(Pot=MWPotential2014, R=1.0)
assert "required positional argument: 'Pot'" in excinfo.value.args[0]
# Special cases
with pytest.raises(TypeError) as excinfo:
potential.evaluatephiforces(Pot=MWPotential2014, R=1.0, z=0.0)
assert "required positional argument: 'Pot'" in excinfo.value.args[0]
with pytest.raises(TypeError) as excinfo:
potential.lindbladR(Pot=MWPotential2014, OmegaP=1.0)
assert "required positional argument: 'Pot'" in excinfo.value.args[0]
Expand Down