Skip to content

Commit

Permalink
Return copies of internal Orbit arrays to avoid overriding the intern…
Browse files Browse the repository at this point in the history
…al state
  • Loading branch information
jobovy committed Jan 25, 2021
1 parent 5508311 commit 8e2f41e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions galpy/orbit/Orbits.py
Expand Up @@ -1393,7 +1393,7 @@ def getOrbit(self):
2019-03-02 - Written - Bovy (UofT)
"""
return self.orbit
return self.orbit.copy()

@shapeDecorator
def getOrbit_dxdv(self):
Expand All @@ -1420,7 +1420,7 @@ def getOrbit_dxdv(self):
2019-05-21 - Written - Bovy (UofT)
"""
return self.orbit_dxdv[...,4:]
return self.orbit_dxdv[...,4:].copy()

@physical_conversion('energy')
@shapeDecorator
Expand Down Expand Up @@ -2840,7 +2840,7 @@ def time(self,*args,**kwargs):
"""
if len(args) == 0:
try:
return self.t
return self.t.copy()
except AttributeError:
return 0.
else:
Expand Down Expand Up @@ -4361,7 +4361,7 @@ def _call_internal(self,*args,**kwargs):
# Not doing hasattr in above elif, bc currently slow due to overwrite of __getattribute__
warnings.warn("You specified integration times as a Quantity, but are evaluating at times not specified as a Quantity; assuming that time given is in natural (internal) units (multiply time by unit to get output at physical time)",galpyWarning)
if t_exact_integration_times: # Common case where one wants all integrated times
return self.orbit.T
return self.orbit.T.copy()
elif isinstance(t,(int,float,numpy.number)) and hasattr(self,'t') \
and t in list(self.t):
return numpy.array(self.orbit[:,list(self.t).index(t),:]).T
Expand Down

0 comments on commit 8e2f41e

Please sign in to comment.