Skip to content

Commit

Permalink
Merge pull request #78 from LSSTDESC/issue/22/docstrings-creation
Browse files Browse the repository at this point in the history
Creation docstrings
  • Loading branch information
OliviaLynn authored Nov 21, 2023
2 parents 499c244 + 8cfc16f commit 87c9b42
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 193 deletions.
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

0 comments on commit 87c9b42

Please sign in to comment.