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

Make docstrings consistent with numpydoc format #701

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 16 additions & 16 deletions tardis/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def read_hdf5_data(fname, dset_name):
Returns
-------

data : `~astropy.table.Table`
data : `astropy.table.Table`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backticks are unnecessary. This applies to all other instances, I won't comment them separately.

returns the respective
"""

Expand Down Expand Up @@ -88,7 +88,7 @@ def read_basic_atom_data(fname=None):
Returns
-------

data : `~astropy.table.Table`
data : `astropy.table.Table`
table with fields z[1], symbol, mass[u]
"""

Expand All @@ -110,7 +110,7 @@ def read_ionization_data(fname=None):
Returns
-------

data : `~astropy.table.Table`
data : `astropy.table.Table`
table with fields z[1], ion[1], ionization_energy[eV]
.. note:: energy from unionized atoms to once-ionized atoms ion = 1, for once ionized
to twice ionized ion=2, etc.
Expand All @@ -135,7 +135,7 @@ def read_levels_data(fname=None):
Returns
-------

data : `~astropy.table.Table`
data : `astropy.table.Table`
table with fields z[1], ion[1], level_number, energy, g, metastable
"""

Expand Down Expand Up @@ -167,7 +167,7 @@ def read_lines_data(fname=None):
Returns
-------

data : `~astropy.table.Table`
data : `astropy.table.Table`
table with fields wavelength, atomic_number, ion_number, f_ul, f_lu, level_id_lower, level_id_upper.
"""

Expand Down Expand Up @@ -261,26 +261,26 @@ class AtomData(object):
Parameters
----------

basic_atom_data : `~astropy.table.Table`
basic_atom_data : `astropy.table.Table`
containing the basic atom data: z, symbol, and mass

ionization_data : ~astropy.table.Table
ionization_data : `astropy.table.Table`
containing the ionization data: z, ion, and ionization energy
::important to note here is that ion describes the final ion state
e.g. H I - H II is described with ion=2

levels : ~astropy.table.Table
levels : `astropy.table.Table`
containing the levels data: z, ion, level_number, energy, g

lines : ~astropy.table.Table
lines : `astropy.table.Table`
containing the lines data: wavelength, z, ion, levels_number_lower,
levels_number_upper, f_lu, f_ul

macro_atom_data : tuple of ~astropy.table.Table
default ~None, a tuple of the macro-atom data and macro-atom references
macro_atom_data : tuple of `astropy.table.Table`
default: None, a tuple of the macro-atom data and macro-atom references

zeta_data : ~dict of interpolation objects
default ~None
zeta_data : dict of interpolation objects
default: None

"""

Expand Down Expand Up @@ -459,13 +459,13 @@ def prepare_atom_data(self, selected_atomic_numbers, line_interaction_type='scat
Parameters
----------

selected_atoms : `~set`
selected_atoms : `set`
set of selected atom numbers, e.g. set([14, 26])

line_interaction_type : `~str`
line_interaction_type : `str`
can be 'scatter', 'downbranch' or 'macroatom'

max_ion_number : `~int`
max_ion_number : `int`
maximum ion number to be included in the calculation

"""
Expand Down
4 changes: 2 additions & 2 deletions tardis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def run_tardis(config, atom_data=None):
Parameters
----------

config: ~str or ~dict
config: `str` or `dict`
filename of configuration yaml file or dictionary

atom_data: ~str or ~tardis.atomic.AtomData
atom_data: `str` or `tardis.atomic.AtomData`
if atom_data is a string it is interpreted as a path to a file storing
the atomic data. Atomic data to use for this TARDIS simulation. If set to None, the
atomic data will be loaded according to keywords set in the configuration
Expand Down
14 changes: 7 additions & 7 deletions tardis/io/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def parse_convergence_section(convergence_section_dict):
Parameters
----------

convergence_section_dict: ~dict
convergence_section_dict: dict
dictionary
"""

Expand Down Expand Up @@ -57,7 +57,7 @@ class ConfigurationNameSpace(dict):
Parameters
----------

config_dict: ~dict
config_dict: dict
configuration dictionary

Returns
Expand Down Expand Up @@ -95,7 +95,7 @@ def from_config_dict(cls, config_dict):
Parameters
----------

config_dict : ~dict
config_dict : dict
dictionary of a raw unvalidated config file


Expand Down Expand Up @@ -149,7 +149,7 @@ def get_config_item(self, config_item_string):
Parameters
----------

config_item_string: ~str
config_item_string: str
string of shape 'section1.sectionb.param1'
"""
config_item_path = config_item_string.split('.')
Expand Down Expand Up @@ -177,7 +177,7 @@ def set_config_item(self, config_item_string, value):
Parameters
----------

config_item_string: ~str
config_item_string: str
string of shape 'section1.sectionb.param1'

value:
Expand Down Expand Up @@ -239,10 +239,10 @@ def from_config_dict(cls, config_dict, validate=True, config_dirname=''):
Parameters
----------

config_dict : ~dict
config_dict : dict
dictionary of a raw unvalidated config file

validate: ~bool
validate: bool
Turn validation on or off.

Returns
Expand Down
26 changes: 13 additions & 13 deletions tardis/io/model_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ def read_density_file(filename, filetype):
Parameters
----------

filename: ~str
filename: str
filename or path of the density file

filetype: ~str
filetype: str
type of the density file

Returns
-------
time_of_model: ~astropy.units.Quantity
time_of_model: astropy.units.Quantity
time at which the model is valid

velocity: ~np.ndarray
velocity: np.ndarray
the array containing the velocities

unscaled_mean_densities: ~np.ndarray
unscaled_mean_densities: np.ndarray
the array containing the densities

"""
Expand Down Expand Up @@ -69,10 +69,10 @@ def read_abundances_file(abundance_filename, abundance_filetype,
Parameters
----------

abundance_filename: ~str
abundance_filename: str
filename or path of the density file

abundance_filetype: ~str
abundance_filetype: str
type of the density file

inner_boundary_index: int
Expand Down Expand Up @@ -117,10 +117,10 @@ def read_simple_ascii_density(fname):
Returns
-------

time_of_model: ~astropy.units.Quantity
time_of_model: astropy.units.Quantity
time at which the model is valid

data: ~pandas.DataFrame
data: pandas.DataFrame
data frame containing index, velocity (in km/s) and density
"""

Expand Down Expand Up @@ -155,10 +155,10 @@ def read_artis_density(fname):
Returns
-------

time_of_model: ~astropy.units.Quantity
time_of_model: astropy.units.Quantity
time at which the model is valid

data: ~pandas.DataFrame
data: pandas.DataFrame
data frame containing index, velocity (in km/s) and density
"""

Expand Down Expand Up @@ -200,10 +200,10 @@ def read_simple_ascii_abundances(fname):
Returns
-------

index: ~np.ndarray
index: np.ndarray
containing the indices

abundances: ~pandas.DataFrame
abundances: pandas.DataFrame
data frame containing index, element1 - element30 and columns according to the shells
"""
data = np.loadtxt(fname)
Expand Down
28 changes: 14 additions & 14 deletions tardis/model/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ def calculate_power_law_density(velocities, velocity_0, rho_0, exponent):
Parameters
----------

velocities : ~astropy.Quantity
velocities : astropy.Quantity
Array like velocity profile
velocity_0 : ~astropy.Quantity
velocity_0 : astropy.Quantity
reference velocity
rho_0 : ~astropy.Quantity
rho_0 : astropy.Quantity
reference density
exponent : ~float
exponent : float
exponent used in the powerlaw

Returns
-------

densities : ~astropy.Quantity
densities : astropy.Quantity

"""
densities = rho_0 * np.power((velocities / velocity_0), exponent)
Expand All @@ -115,17 +115,17 @@ def calculate_exponential_density(velocities, velocity_0, rho_0):
Parameters
----------

velocities : ~astropy.Quantity
velocities : astropy.Quantity
Array like velocity profile
velocity_0 : ~astropy.Quantity
velocity_0 : astropy.Quantity
reference velocity
rho_0 : ~astropy.Quantity
rho_0 : astropy.Quantity
reference density

Returns
-------

densities : ~astropy.Quantity
densities : astropy.Quantity

"""
densities = rho_0 * np.exp(-(velocities / velocity_0))
Expand All @@ -137,19 +137,19 @@ def calculate_density_after_time(densities, time_0, time_explosion):
scale the density from an initial time of the model to the
time of the explosion by ^-3

Parameters:
Parameters
-----------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a small thing but keep the dashes matching in length the title (i.e. remove one here). There are other instances too.


densities: ~astropy.units.Quantity
densities: astropy.units.Quantity
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the space before the : consistent. There are other instances of this too.

densities

time_0: ~astropy.units.Quantity
time_0: astropy.units.Quantity
time of the model

time_explosion: ~astropy.units.Quantity
time_explosion: astropy.units.Quantity
time to be scaled to

Returns:
Returns
--------

scaled_density
Expand Down
12 changes: 6 additions & 6 deletions tardis/montecarlo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _initialize_estimator_arrays(self, no_of_shells, tau_sobolev_shape):
Parameters
----------

model: ~Radial1DModel
model: Radial1DModel
"""

#Estimators
Expand Down Expand Up @@ -272,16 +272,16 @@ def calculate_radiationfield_properties(self):
Parameters
----------

nubar_estimator : ~np.ndarray (float)
nubar_estimator : np.ndarray (float)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found out that PyCharm suggests np.ndarray[float]. Check the link for more info. Would be nice to also fix any other instances that match the table in the link


j_estimator : ~np.ndarray (float)
j_estimator : np.ndarray (float)

Returns
-------

t_rad : ~astropy.units.Quantity (float)
t_rad : astropy.units.Quantity (float)

w : ~numpy.ndarray (float)
w : numpy.ndarray (float)

"""

Expand Down Expand Up @@ -371,4 +371,4 @@ def from_config(cls, config):
enable_reflective_inner_boundary=config.montecarlo.enable_reflective_inner_boundary,
inner_boundary_albedo=config.montecarlo.inner_boundary_albedo,
line_interaction_type=config.plasma.line_interaction_type,
distance=config.supernova.get('distance', None))
distance=config.supernova.get('distance', None))
8 changes: 4 additions & 4 deletions tardis/montecarlo/packet_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ def create_packet_nus(self, T, no_of_packets):

Parameters
----------
T : ~float
T : float
temperature
no_of_packets: ~int
no_of_packets: int

Returns
-------

: ~numpy.ndarray
: numpy.ndarray
array of frequencies
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation here is wrong, also no need for the leading : if there is no name for the return value but only a type. There are more similar instances.


Expand Down Expand Up @@ -75,4 +75,4 @@ def create_packets(self, T, no_of_packets):
mus = self.create_packet_mus(no_of_packets)
energies = self.create_packet_energies(no_of_packets)

return nus, mus, energies
return nus, mus, energies
Loading