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

Creation docstrings #78

Merged
merged 3 commits into from
Nov 21, 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
36 changes: 18 additions & 18 deletions src/rail/creation/degradation/quantityCut.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class QuantityCut(Degrader):
"""Degrader that applies a cut to the given columns.

Note if a galaxy fails any of the cuts on any one of its columns, that
Note that if a galaxy fails any of the cuts on any one of its columns, that
galaxy is removed from the sample.
"""

Expand All @@ -18,33 +18,34 @@ class QuantityCut(Degrader):
config_options.update(cuts=dict)

def __init__(self, args, comm=None):
"""
Constructor

Does standard Degrader initialization and also gets defines the cuts to be applied
"""Constructor.

Performs standard Degrader initialization as well as defining the cuts
to be applied.
"""
Degrader.__init__(self, args, comm=comm)
self.cuts = None
self.set_cuts(self.config["cuts"])

def set_cuts(self, cuts: dict):
"""
"""Defines the cuts to be applied.

Parameters
----------
cuts : dict
A dictionary of cuts to make on the data.
A dictionary of cuts to make on the data

Notes
-----
The cut keys should be the names of columns you wish to make cuts on.

The cut values should be either:
- a number, which is the maximum value. I.e. if the dictionary
- a number, which is the maximum value. E.g. if the dictionary
contains "i": 25, then values of i > 25 are cut from the sample.
- an iterable, which is the range of acceptable values.
I.e. if the dictionary contains "redshift": (1.5, 2.3), then
redshifts outside that range are cut from the sample.
- an iterable, which is the range of acceptable values. E.g. if the
dictionary contains "redshift": (1.5, 2.3), then redshifts outside that
range are cut from the sample.
"""

# check that cuts is a dictionary
if not isinstance(cuts, dict): # pragma: no cover
raise TypeError("cuts must be a dictionary.")
Expand Down Expand Up @@ -82,14 +83,13 @@ def set_cuts(self, cuts: dict):
raise TypeError(bad_cut_msg)

def run(self):
"""Run method

Applies cuts
"""Applies cuts.

Notes
-----
Get the input data from the data store under this stages 'input' tag
Puts the data into the data store under this stages 'output' tag
Gets the input data from the data store under this stage's 'input' tag.

Puts the data into the data store under this stage's 'output' tag.
"""
data = self.get_data("input")

Expand All @@ -110,7 +110,7 @@ def run(self):
self.add_data("output", out_data)

def __repr__(self): # pragma: no cover
"""Pretty print this object"""
"""Pretty print this object."""
printMsg = "Degrader that applies the following cuts to a pandas DataFrame:\n"
printMsg += "{column: (min, max), ...}\n"
printMsg += self.cuts.__str__()
Expand Down
Loading
Loading