Skip to content

Commit e7980e6

Browse files
committed
Re-arrange some functions within planarForce, planarDissipativeForce, and planarPotential to better use inheritance and have a clearer structure
1 parent 92964e1 commit e7980e6

3 files changed

Lines changed: 24 additions & 42 deletions

File tree

galpy/potential/planarDissipativeForce.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,6 @@ def Rforce(self, R, phi=0.0, t=0.0, v=None):
6161
"""
6262
return self._Rforce_nodecorator(R, phi=phi, t=t, v=v)
6363

64-
def _Rforce_nodecorator(self, R, phi=0.0, t=0.0, v=None):
65-
# Separate, so it can be used during orbit integration
66-
try:
67-
return self._amp * self._Rforce(R, phi=phi, t=t, v=v)
68-
except AttributeError: # pragma: no cover
69-
from .Potential import PotentialError
70-
71-
raise PotentialError(
72-
"'_Rforce' function not implemented for this planarDissipativeForce"
73-
)
74-
7564
@potential_physical_input
7665
@physical_conversion("force", pop=True)
7766
def phitorque(self, R, phi=0.0, t=0.0, v=None):
@@ -101,19 +90,6 @@ def phitorque(self, R, phi=0.0, t=0.0, v=None):
10190
"""
10291
return self._phitorque_nodecorator(R, phi=phi, t=t, v=v)
10392

104-
def _phitorque_nodecorator(self, R, phi=0.0, t=0.0, v=None):
105-
# Separate, so it can be used during orbit integration
106-
try:
107-
return self._amp * self._phitorque(R, phi=phi, t=t, v=v)
108-
except AttributeError: # pragma: no cover
109-
if self.isNonAxi:
110-
from .Potential import PotentialError
111-
112-
raise PotentialError(
113-
"'_phitorque' function not implemented for this DissipativeForce"
114-
)
115-
return 0.0
116-
11793

11894
class planarDissipativeForceFromFullDissipativeForce(planarDissipativeForce):
11995
"""Class that represents a planar dissipative force derived from a 3D dissipative force"""

galpy/potential/planarForce.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,27 @@ def turn_physical_on(self, ro=None, vo=None):
197197
if not vo is None:
198198
self._vo = vo
199199
return None
200+
201+
def _Rforce_nodecorator(self, R, phi=0.0, t=0.0, **kwargs):
202+
# Separate, so it can be used during orbit integration
203+
try:
204+
return self._amp * self._Rforce(R, phi=phi, t=t, **kwargs)
205+
except AttributeError: # pragma: no cover
206+
from .Potential import PotentialError
207+
208+
raise PotentialError(
209+
"'_Rforce' function not implemented for this planarDissipativeForce"
210+
)
211+
212+
def _phitorque_nodecorator(self, R, phi=0.0, t=0.0, **kwargs):
213+
# Separate, so it can be used during orbit integration
214+
try:
215+
return self._amp * self._phitorque(R, phi=phi, t=t, **kwargs)
216+
except AttributeError: # pragma: no cover
217+
if self.isNonAxi:
218+
from .Potential import PotentialError
219+
220+
raise PotentialError(
221+
"'_phitorque' function not implemented for this DissipativeForce"
222+
)
223+
return 0.0

galpy/potential/planarPotential.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,6 @@ def Rforce(self, R, phi=0.0, t=0.0):
113113
"""
114114
return self._Rforce_nodecorator(R, phi=phi, t=t)
115115

116-
def _Rforce_nodecorator(self, R, phi=0.0, t=0.0):
117-
# Separate, so it can be used during orbit integration
118-
try:
119-
return self._amp * self._Rforce(R, phi=phi, t=t)
120-
except AttributeError: # pragma: no cover
121-
raise PotentialError(
122-
"'_Rforce' function not implemented for this potential"
123-
)
124-
125116
@potential_physical_input
126117
@physical_conversion("energy", pop=True)
127118
def phitorque(self, R, phi=0.0, t=0.0):
@@ -149,15 +140,6 @@ def phitorque(self, R, phi=0.0, t=0.0):
149140
"""
150141
return self._phitorque_nodecorator(R, phi=phi, t=t)
151142

152-
def _phitorque_nodecorator(self, R, phi=0.0, t=0.0):
153-
# Separate, so it can be used during orbit integration
154-
try:
155-
return self._amp * self._phitorque(R, phi=phi, t=t)
156-
except AttributeError: # pragma: no cover
157-
raise PotentialError(
158-
"'_phitorque' function not implemented for this potential"
159-
)
160-
161143
@potential_physical_input
162144
@physical_conversion("forcederivative", pop=True)
163145
def R2deriv(self, R, phi=0.0, t=0.0):

0 commit comments

Comments
 (0)