Skip to content

Commit

Permalink
Update docstring as per numpy style format
Browse files Browse the repository at this point in the history
  • Loading branch information
Sakshamgupta90 committed Aug 7, 2024
1 parent 5c974e6 commit 4d8285e
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 172 deletions.
40 changes: 24 additions & 16 deletions ioos_qc/argo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ def pressure_increasing_test(inp):
Ref: ARGO QC Manual: 8. Pressure increasing test
Args
----
inp: Pressure values as a numeric numpy array or a list of numbers.
Parameters
----------
inp
Pressure values as a numeric numpy array or a list of numbers.
Returns
-------
flag_arr
A masked array of flag values equal in size to that of the input.
"""
Expand Down Expand Up @@ -68,25 +70,31 @@ def speed_test(
Missing and masked data is flagged as UNKNOWN.
If this test fails, it typically means that either a position or time is bad data,
or that a platform is mislabeled.
or that a platform is mislabeled.
Ref: ARGO QC Manual: 5. Impossible speed test
Args
----
lon: Longitudes as a numeric numpy array or a list of numbers.
lat: Latitudes as a numeric numpy array or a list of numbers.
tinp: Time data as a sequence of datetime objects compatible with pandas DatetimeIndex.
This includes numpy datetime64, python datetime objects and pandas Timestamp object.
ie. pd.DatetimeIndex([datetime.utcnow(), np.datetime64(), pd.Timestamp.now()]
If anything else is passed in the format is assumed to be seconds since the unix epoch.
suspect_threshold: A float value representing a speed, in meters per second.
Speeds exceeding this will be flagged as SUSPECT.
fail_threshold: A float value representing a speed, in meters per second.
Speeds exceeding this will be flagged as FAIL.
Parameters
----------
lon
Longitudes as a numeric numpy array or a list of numbers.
lat
Latitudes as a numeric numpy array or a list of numbers.
tinp
Time data as a sequence of datetime objects compatible with pandas DatetimeIndex.
This includes numpy datetime64, python datetime objects and pandas Timestamp object.
ie. pd.DatetimeIndex([datetime.utcnow(), np.datetime64(), pd.Timestamp.now()])
If anything else is passed in the format is assumed to be seconds since the unix epoch.
suspect_threshold
A float value representing a speed, in meters per second.
Speeds exceeding this will be flagged as SUSPECT.
fail_threshold
A float value representing a speed, in meters per second.
Speeds exceeding this will be flagged as FAIL.
Returns
-------
flag_arr
A masked array of flag values equal in size to that of the input.
"""
Expand Down
29 changes: 16 additions & 13 deletions ioos_qc/axds.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,25 @@ def valid_range_test(
treated as inclusive and the second span valid is treated as exclusive. To change this
behavior you can use the parameters `start_inclusive` and `end_inclusive`.
Args
----
inp (Sequence[any]): Data as a sequence of objects compatible with the fail_span objects
fail_span (Tuple[any, any]): 2-tuple range which to flag outside data as FAIL. Objects
should be of equal format to that of the inp parameter as they will be checked for
equality without type conversion.
dtype (np.dtype): Optional. If your data is not already numpy-typed you can specify its
dtype here.
start_inclusive (bool): Optional. If the starting span value should be inclusive (True) or
exclusive (False).
end_inclusive (bool): Optional. If the ending span value should be inclusive (True) or
exclusive (False).
Parameters
----------
inp (Sequence[any])
Data as a sequence of objects compatible with the fail_span objects
fail_span (Tuple[any, any])
2-tuple range which to flag outside data as FAIL. Objects
should be of equal format to that of the inp parameter as they will be checked for
equality without type conversion.
dtype (np.dtype)
Optional. If your data is not already numpy-typed you can specify its dtype here.
start_inclusive (bool)
Optional. If the starting span value should be inclusive (True) or exclusive (False).
end_inclusive (bool)
Optional. If the ending span value should be inclusive (True) or exclusive (False).
Returns
-------
np.ma.core.MaskedArray: A masked array of flag values equal in size to that of the input.
np.ma.core.MaskedArray
A masked array of flag values equal in size to that of the input.
"""
# Numpy array inputs
Expand Down
56 changes: 34 additions & 22 deletions ioos_qc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Attributes
----------
tw (namedtuple): The TimeWindow namedtuple definition
tw (namedtuple)
The TimeWindow namedtuple definition
"""

Expand Down Expand Up @@ -182,9 +183,10 @@ def run(self, **passedkwargs):
def extract_calls(source) -> List[Call]:
"""Extracts call objects from a source object.
Args
----
source ([any]): The source of Call objects, this can be a:
Parameters
----------
source ([any]):
The source of Call objects, this can be a:
* Call object
* list of Call objects
* list of objects with the 'calls' attribute
Expand All @@ -193,7 +195,8 @@ def extract_calls(source) -> List[Call]:
Returns
-------
List[Call]: List of extracted Call objects
List[Call]
List of extracted Call objects
"""
if isinstance(source, Call):
Expand Down Expand Up @@ -234,9 +237,10 @@ def __init__(
version=None,
default_stream_key="_stream",
) -> None:
"""Args
----
source: The QC configuration representation in one of the following formats:
"""Parameters
----------
source:
The QC configuration representation in one of the following formats:
python dict or odict
JSON/YAML filepath (str or Path object)
JSON/YAML str
Expand Down Expand Up @@ -349,9 +353,10 @@ def add(self, source) -> None:
types of objects accepted as the source parameter. The changes the internal .calls
attribute and returns None.
Args
----
source ([any]): The source of Call objects, this can be a:
Parameters
----------
source ([any])
The source of Call objects, this can be a:
* Call object
* list of Call objects
* list of objects with the 'calls' attribute
Expand Down Expand Up @@ -391,10 +396,14 @@ class ContextConfig:
Attributes
----------
config (odict): dict representation of the parsed ContextConfig source
region (GeometryCollection): A `shapely` object representing the valid geographic region
window (namedtuple): A TimeWindow object representing the valid time period
streams (odict): dict representation of the parsed Config objects
config (odict)
dict representation of the parsed ContextConfig source
region (GeometryCollection)
A `shapely` object representing the valid geographic region
window (namedtuple)
A TimeWindow object representing the valid time period
streams (odict)
dict representation of the parsed Config objects
"""

Expand Down Expand Up @@ -489,9 +498,10 @@ def add(self, source) -> None:
types of objects accepted as the source parameter. The changes the internal .calls
attribute and returns None.
Args
----
source ([any]): The source of Call objects, this can be a:
Parameters
----------
source ([any])
The source of Call objects, this can be a:
* Call object
* list of Call objects
* list of objects with the 'calls' attribute
Expand Down Expand Up @@ -522,17 +532,19 @@ def __init__(self, source, default_stream_key="_stream") -> None:
stream. This just sets up a stream with the name passed in as the "default_stream_key"
parameter.
Args
----
source: The QC configuration representation in one of the following formats:
Parameters
----------
source
The QC configuration representation in one of the following formats:
python dict or odict
JSON/YAML filepath (str or Path object)
JSON/YAML str
JSON/YAML StringIO
netCDF4/xarray filepath
netCDF4/xarray Dataset
list of Call objects
default_stream_key: The internal name of the stream, defaults to "_stream"
default_stream_key
The internal name of the stream, defaults to "_stream"
"""
warnings.warn(
Expand Down
33 changes: 20 additions & 13 deletions ioos_qc/config_creator/config_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,14 @@ def __str__(self) -> str:
class QcVariableConfig(dict):
"""Used to generate a QcConfig for a specific variable.
Args
----
path_or_dict: QcVariableConfig configuration, one of the following formats:
Parameters
----------
path_or_dict
QcVariableConfig configuration, one of the following formats:
python dict
JSON filepath (str or Path object)
schema: JSON schema for QcVariable
schema
JSON schema for QcVariable
"""

Expand Down Expand Up @@ -255,12 +257,15 @@ class QcConfigCreator:
Arguments
---------
creator_config (QcCreatorConfig): Configuration for datasets and variables used to create qc_config.
creator_config (QcCreatorConfig)
Configuration for datasets and variables used to create qc_config.
Attributes
----------
allowed_stats (list): Specific statistics allowed to be used to configure each test.
allowed_operators (list): Operators allowed to used to configure each test.
allowed_stats (list)
Specific statistics allowed to be used to configure each test.
allowed_operators (list)
Operators allowed to used to configure each test.
"""

Expand All @@ -272,13 +277,15 @@ def __init__(self, creator_config) -> None:
def create_config(self, variable_config):
"""Create QARTOD QC config given QcVariableConfig.
Args
----
variable_config (QcVariableConfig): Config for variable to be quality controlled
Parameters
----------
variable_config (QcVariableConfig)
Config for variable to be quality controlled
Returns
-------
qc_config (dict): Config for ioos_qc
qc_config (dict)
Config for ioos_qc
"""
stats = self._get_stats(variable_config)
Expand Down Expand Up @@ -307,8 +314,8 @@ def _determine_dataset_years(self):
Notes
-----
- Each dataset is from a unique climatology or source,
so the monthly files have different years.
- Each dataset is from a unique climatology or source,
so the monthly files have different years.
"""
years = {}
Expand Down
Loading

0 comments on commit 4d8285e

Please sign in to comment.