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

Convert all docstrings to numpy-style format #608

Merged
merged 20 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
21fef51
Start on generating numpy docstrings
jobovy May 15, 2023
fba7507
More numpy docstrings for potential models
jobovy May 17, 2023
fa6d6e8
Add :orphan: directive to avoid sphinx warning
jobovy May 19, 2023
86f1757
Replace all Orbit docstrings with numpy-docstring-style versions and …
jobovy May 20, 2023
a78bd48
numpy-style docstrings for Potential methods
jobovy May 29, 2023
d89e319
Numpy docstrings for new bruteSOS Orbit functions
jobovy Jun 20, 2023
c2aa542
numpy-style docstrings for Potential functions
jobovy Jul 25, 2023
af34dd2
Fix surface density code (erroneously removed before...)
jobovy Jul 25, 2023
6fb7fd4
numpy-style docstrings for remaining potential methods and functions …
jobovy Jul 27, 2023
61e3462
numpy-style docstrings for potential classes
jobovy Sep 8, 2023
190f874
Numpy-style docstrings for actionAngle functions and methods
jobovy Sep 13, 2023
c8125be
Numpy-style docstrings for DF functions and methods
jobovy Oct 2, 2023
0a33030
Numpy-style docstrings for the util module
jobovy Oct 19, 2023
e890271
numpy-style docstrings for more Orbit functions
jobovy Oct 20, 2023
b041386
numpy-style docstrings for the snapshot module
jobovy Oct 20, 2023
5dfb780
Add numpy-style docstrings to HISTORY
jobovy Oct 20, 2023
0cddf87
Small fixes to a bunch of errors in the numpy-style docstring conversion
jobovy Oct 20, 2023
9aa72f2
array_like --> numpy.ndarray
jobovy Oct 20, 2023
4513170
Fix weird quituplication of a function
jobovy Oct 20, 2023
44e0980
Hopefully final tweaks to numpy-style docstrings
jobovy Oct 24, 2023
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
2 changes: 2 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ v1.9.1 (expected around 2023-11-01)
and solarmotion (#595). Useful when sampling over the uncertainty in the solar
parameters.

- Converted all docstrings to numpy-style format with the help of GitHub Copilot.

v1.9.0 (2023-07-02)
===================

Expand Down
1 change: 1 addition & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.mathjax",
"sphinx.ext.ifconfig",
"sphinx.ext.linkcode",
Expand Down
2 changes: 1 addition & 1 deletion doc/source/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ galpy.util.config
Configuration module

.. toctree::
:maxdepth: 2
:maxdepth: 1

setro <configsetro.rst>
setvo <configsetvo.rst>
2 changes: 1 addition & 1 deletion doc/source/reference/coords.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Various coordinate transformation routines with fairly
self-explanatory names:

.. toctree::
:maxdepth: 2
:maxdepth: 1

cov_dvrpmllbb_to_vxyz <coordscovdvrpmllbbtovxyz.rst>
cov_galcenrect_to_galcencyl <coordscovgalcenrectgalcencyl.rst>
Expand Down
2 changes: 1 addition & 1 deletion doc/source/reference/plot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ galpy.util.plot
Various plotting routines:

.. toctree::
:maxdepth: 2
:maxdepth: 1

dens2d <plotdens2d.rst>
end_print <plotendprint.rst>
Expand Down
2 changes: 2 additions & 0 deletions doc/source/reference/potentialellipsoidal.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan:

.. _ellipsoidal:

Ellipsoidal potentials
Expand Down
2 changes: 2 additions & 0 deletions doc/source/reference/potentialspherical.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan:

.. _sphericalpot:

Spherical potentials
Expand Down
279 changes: 109 additions & 170 deletions galpy/actionAngle/actionAngle.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ class actionAngle(metaclass=MetaActionAngle):

def __init__(self, ro=None, vo=None):
"""
NAME:
__init__
PURPOSE:
initialize an actionAngle object
INPUT:
ro= (None) distance scale
vo= (None) velocity scale
OUTPUT:
HISTORY:
2016-02-18 - Written - Bovy (UofT)
Initialize an actionAngle object.

Parameters
----------
ro : float or Quantity, optional
Distance scale for translation into internal units (default from configuration file).
vo : float or Quantity, optional
Velocity scale for translation into internal units (default from configuration file).

Notes
-----
- 2016-02-18 - Written - Bovy (UofT)
"""
# Parse ro and vo
if ro is None:
Expand Down Expand Up @@ -88,57 +90,31 @@ def _check_consistent_units_orbitInput(self, orb):

def turn_physical_off(self):
"""
NAME:

turn_physical_off

PURPOSE:

turn off automatic returning of outputs in physical units

INPUT:

(none)

OUTPUT:

(none)

HISTORY:

2017-06-05 - Written - Bovy (UofT)
Turn off automatic returning of outputs in physical units.

Notes
------
- 2017-06-05 - Written - Bovy (UofT)
"""
self._roSet = False
self._voSet = False
return None

def turn_physical_on(self, ro=None, vo=None):
"""
NAME:

turn_physical_on

PURPOSE:

turn on automatic returning of outputs in physical units

INPUT:

ro= reference distance (kpc; can be Quantity)

vo= reference velocity (km/s; can be Quantity)

OUTPUT:

(none)

HISTORY:

2016-06-05 - Written - Bovy (UofT)

2020-04-22 - Don't turn on a parameter when it is False - Bovy (UofT)

Turn on automatic returning of outputs in physical units.

Parameters
----------
ro : float or Quantity, optional
Distance scale for translation into internal units (default from configuration file).
vo : float or Quantity, optional
Velocity scale for translation into internal units (default from configuration file).

Notes
-----
- 2016-06-05 - Written - Bovy (UofT)
- 2020-04-22 - Don't turn on a parameter when it is False - Bovy (UofT)
"""
if not ro is False:
self._roSet = True
Expand All @@ -153,16 +129,6 @@ def turn_physical_on(self, ro=None, vo=None):
return None

def _parse_eval_args(self, *args, **kwargs):
"""
NAME:
_parse_eval_args
PURPOSE:
Internal function to parse the arguments given for an action/frequency/angle evaluation
INPUT:
OUTPUT:
HISTORY:
2010-07-11 - Written - Bovy (NYU)
"""
if len(args) == 5: # R,vR.vT, z, vz
R, vR, vT, z, vz = args
self._eval_R = R
Expand Down Expand Up @@ -210,34 +176,27 @@ def _parse_eval_args(self, *args, **kwargs):
@physical_conversion_actionAngle("__call__", pop=True)
def __call__(self, *args, **kwargs):
"""
NAME:

__call__

PURPOSE:

evaluate the actions (jr,lz,jz)

INPUT:

Either:

a) R,vR,vT,z,vz[,phi]:

1) floats: phase-space value for single object (phi is optional) (each can be a Quantity)

2) numpy.ndarray: [N] phase-space values for N objects (each can be a Quantity)

b) Orbit instance: initial condition used if that's it, orbit(t) if there is a time given as well as the second argument

OUTPUT:

(jr,lz,jz)

HISTORY:

2014-01-03 - Written for top level - Bovy (IAS)

Evaluate the actions (jr,lz,jz)

Parameters
----------
*args : tuple
Either:
a) R,vR,vT,z,vz[,phi]:
1) floats: phase-space value for single object (phi is optional) (each can be a Quantity)
2) numpy.ndarray: [N] phase-space values for N objects (each can be a Quantity)
b) Orbit instance: initial condition used if that's it, orbit(t) if there is a time given as well as the second argument
**kwargs : dict
Any other keyword arguments are passed to the _evaluate method.

Returns
-------
tuple
(jr,lz,jz)

Notes
-----
- 2014-01-03 - Written for top level - Bovy (IAS)
"""
try:
return self._evaluate(*args, **kwargs)
Expand All @@ -250,33 +209,27 @@ def __call__(self, *args, **kwargs):
@physical_conversion_actionAngle("actionsFreqs", pop=True)
def actionsFreqs(self, *args, **kwargs):
"""
NAME:

actionsFreqs

PURPOSE:

evaluate the actions and frequencies (jr,lz,jz,Omegar,Omegaphi,Omegaz)

INPUT:

Either:

a) R,vR,vT,z,vz[,phi]:

1) floats: phase-space value for single object (phi is optional) (each can be a Quantity)

2) numpy.ndarray: [N] phase-space values for N objects (each can be a Quantity)

b) Orbit instance: initial condition used if that's it, orbit(t) if there is a time given as well as the second argument

OUTPUT:

Evaluate the actions and frequencies (jr,lz,jz,Omegar,Omegaphi,Omegaz)

Parameters
----------
*args : tuple
Either:
a) R,vR,vT,z,vz[,phi]:
1) floats: phase-space value for single object (phi is optional) (each can be a Quantity)
2) numpy.ndarray: [N] phase-space values for N objects (each can be a Quantity)
b) Orbit instance: initial condition used if that's it, orbit(t) if there is a time given as well as the second argument
**kwargs : dict
Any other keyword arguments are passed to the _actionsFreqs method.

Returns
-------
tuple
(jr,lz,jz,Omegar,Omegaphi,Omegaz)

HISTORY:

2014-01-03 - Written for top level - Bovy (IAS)
Notes
-----
- 2014-01-03 - Written for top level - Bovy (IAS)

"""
try:
Expand All @@ -290,34 +243,27 @@ def actionsFreqs(self, *args, **kwargs):
@physical_conversion_actionAngle("actionsFreqsAngles", pop=True)
def actionsFreqsAngles(self, *args, **kwargs):
"""
NAME:

actionsFreqsAngles

PURPOSE:

evaluate the actions, frequencies, and angles (jr,lz,jz,Omegar,Omegaphi,Omegaz,angler,anglephi,anglez)

INPUT:

Either:

a) R,vR,vT,z,vz,phi:

1) floats: phase-space value for single object (phi is optional) (each can be a Quantity)

2) numpy.ndarray: [N] phase-space values for N objects (each can be a Quantity)

b) Orbit instance: initial condition used if that's it, orbit(t) if there is a time given as well as the second argument

OUTPUT:

Evaluate the actions, frequencies, and angles (jr,lz,jz,Omegar,Omegaphi,Omegaz,angler,anglephi,anglez)

Parameters
----------
*args : tuple
Either:
a) R,vR,vT,z,vz,phi:
1) floats: phase-space value for single object (phi is optional) (each can be a Quantity)
2) numpy.ndarray: [N] phase-space values for N objects (each can be a Quantity)
b) Orbit instance: initial condition used if that's it, orbit(t) if there is a time given as well as the second argument
**kwargs : dict
Additional keyword arguments to be passed to _actionsFreqsAngles method.

Returns
-------
tuple
(jr,lz,jz,Omegar,Omegaphi,Omegaz,angler,anglephi,anglez)

HISTORY:

2014-01-03 - Written for top level - Bovy (IAS)

Notes
-----
- 2014-01-03 - Written for top level - Bovy (IAS)
"""
try:
return self._actionsFreqsAngles(*args, **kwargs)
Expand All @@ -330,34 +276,27 @@ def actionsFreqsAngles(self, *args, **kwargs):
@physical_conversion_actionAngle("EccZmaxRperiRap", pop=True)
def EccZmaxRperiRap(self, *args, **kwargs):
"""
NAME:

EccZmaxRperiRap

PURPOSE:

evaluate the eccentricity, maximum height above the plane, peri- and apocenter

INPUT:

Either:

a) R,vR,vT,z,vz[,phi]:

1) floats: phase-space value for single object (phi is optional) (each can be a Quantity)

2) numpy.ndarray: [N] phase-space values for N objects (each can be a Quantity)

b) Orbit instance: initial condition used if that's it, orbit(t) if there is a time given as well as the second argument

OUTPUT:

(e,zmax,rperi,rap)

HISTORY:

2017-12-12 - Written - Bovy (UofT)

Evaluate the eccentricity, maximum height above the plane, peri- and apocenter.

Parameters
----------
*args : tuple
Either:
a) R,vR,vT,z,vz,phi:
1) floats: phase-space value for single object (phi is optional) (each can be a Quantity)
2) numpy.ndarray: [N] phase-space values for N objects (each can be a Quantity)
b) Orbit instance: initial condition used if that's it, orbit(t) if there is a time given as well as the second argument
**kwargs : dict
A dictionary of keyword arguments.

Returns
-------
tuple
(eccentricity, maximum height above the plane, peri-, and apocenter)

Notes
-----
- 2017-12-12 - Written - Bovy (UofT)
"""
try:
return self._EccZmaxRperiRap(*args, **kwargs)
Expand Down
Loading