Skip to content

Commit

Permalink
Remove unneeded test - fix properties docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
aulemahal committed Jan 24, 2025
1 parent f46da24 commit e44aa0b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 26 deletions.
60 changes: 40 additions & 20 deletions src/xclim/sdba/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def get_measure(self):


def _mean(da: xr.DataArray, *, group: str | Grouper = "time") -> xr.DataArray:
"""Mean.
"""
Mean.
Mean over all years at the time resolution.
Expand Down Expand Up @@ -143,7 +144,8 @@ def _mean(da: xr.DataArray, *, group: str | Grouper = "time") -> xr.DataArray:


def _var(da: xr.DataArray, *, group: str | Grouper = "time") -> xr.DataArray:
"""Variance.
"""
Variance.
Variance of the variable over all years at the time resolution.
Expand Down Expand Up @@ -179,7 +181,8 @@ def _var(da: xr.DataArray, *, group: str | Grouper = "time") -> xr.DataArray:


def _std(da: xr.DataArray, *, group: str | Grouper = "time") -> xr.DataArray:
"""Standard Deviation.
"""
Standard Deviation.
Standard deviation of the variable over all years at the time resolution.
Expand Down Expand Up @@ -214,7 +217,8 @@ def _std(da: xr.DataArray, *, group: str | Grouper = "time") -> xr.DataArray:


def _skewness(da: xr.DataArray, *, group: str | Grouper = "time") -> xr.DataArray:
"""Skewness.
"""
Skewness.
Skewness of the distribution of the variable over all years at the time resolution.
Expand Down Expand Up @@ -256,7 +260,8 @@ def _skewness(da: xr.DataArray, *, group: str | Grouper = "time") -> xr.DataArra
def _quantile(
da: xr.DataArray, *, q: float = 0.98, group: str | Grouper = "time"
) -> xr.DataArray:
"""Quantile.
"""
Quantile.
Returns the quantile q of the distribution of the variable over all years at the time resolution.
Expand Down Expand Up @@ -299,7 +304,8 @@ def _spell_length_distribution(
group: str | Grouper = "time",
resample_before_rl: bool = True,
) -> xr.DataArray:
"""Spell length distribution.
"""
Spell length distribution.
Statistic of spell length distribution when the variable respects a condition (defined by an operation, a method and
a threshold).
Expand Down Expand Up @@ -419,7 +425,8 @@ def _threshold_count(
stat_resample: str | None = None,
group: str | Grouper = "time",
) -> xr.DataArray:
r"""Correlation between two variables.
r"""
Correlation between two variables.
Spearman or Pearson correlation coefficient between two variables at the time resolution.
Expand Down Expand Up @@ -476,7 +483,8 @@ def _threshold_count(
def _acf(
da: xr.DataArray, *, lag: int = 1, group: str | Grouper = "time.season"
) -> xr.DataArray:
"""Autocorrelation.
"""
Autocorrelation.
Autocorrelation with a lag over a time resolution and averaged over all years.
Expand Down Expand Up @@ -546,7 +554,8 @@ def _annual_cycle(
window: int = 31,
group: str | Grouper = "time",
) -> xr.DataArray:
r"""Annual cycle statistics.
r"""
Annual cycle statistics.
A daily climatology is calculated and optionally smoothed with a (circular) moving average.
The requested statistic is returned.
Expand Down Expand Up @@ -673,7 +682,8 @@ def _annual_statistic(
window: int = 31,
group: str | Grouper = "time",
):
"""Annual range statistics.
"""
Annual range statistics.
Compute a statistic on each year of data and return the interannual average. This is similar
to the annual cycle, but with the statistic and average operations inverted.
Expand Down Expand Up @@ -750,7 +760,8 @@ def _corr_btw_var(
group: str | Grouper = "time",
output: str = "correlation",
) -> xr.DataArray:
r"""Correlation between two variables.
r"""
Correlation between two variables.
Spearman or Pearson correlation coefficient between two variables at the time resolution.
Expand Down Expand Up @@ -833,7 +844,8 @@ def _bivariate_spell_length_distribution(
group: str | Grouper = "time",
resample_before_rl: bool = True,
) -> xr.DataArray:
"""Spell length distribution with bivariate condition.
"""
Spell length distribution with bivariate condition.
Statistic of spell length distribution when two variables respect individual conditions (defined by an operation, a method,
and a threshold).
Expand Down Expand Up @@ -983,7 +995,8 @@ def _bivariate_threshold_count(
stat_resample: str | None = None,
group: str | Grouper = "time",
) -> xr.DataArray:
"""Count the number of time steps where two variables respect given conditions.
"""
Count the number of time steps where two variables respect given conditions.
Statistic of number of time steps when two variables respect individual conditions (defined by an operation, a method,
and a threshold).
Expand Down Expand Up @@ -1066,7 +1079,8 @@ def _relative_frequency(
thresh: str = "1 mm d-1",
group: str | Grouper = "time",
) -> xr.DataArray:
"""Relative Frequency.
"""
Relative Frequency.
Relative Frequency of days with variable respecting a condition (defined by an operation and a threshold) at the
time resolution. The relative frequency is the number of days that satisfy the condition divided by the total number
Expand Down Expand Up @@ -1127,7 +1141,8 @@ def _transition_probability(
thresh: str = "1 mm d-1",
group: str | Grouper = "time",
) -> xr.DataArray:
"""Transition probability.
"""
Transition probability.
Probability of transition from the initial state to the final state. The states are
booleans comparing the value of the day to the threshold with the operator.
Expand Down Expand Up @@ -1182,7 +1197,8 @@ def _trend(
group: str | Grouper = "time",
output: str = "slope",
) -> xr.DataArray:
"""Linear Trend.
"""
Linear Trend.
The data is averaged over each time resolution and the inter-annual trend is returned.
This function will rechunk along the grouping dimension.
Expand Down Expand Up @@ -1250,7 +1266,8 @@ def _return_value(
method: str = "ML",
group: str | Grouper = "time",
) -> xr.DataArray:
r"""Return value.
r"""
Return value.
Return the value corresponding to a return period. On average, the return value will be exceeded
(or not exceed for op='min') every return period (e.g. 20 years). The return value is computed by first extracting
Expand Down Expand Up @@ -1304,7 +1321,8 @@ def _spatial_correlogram(
group: str = "time",
method: int = 1,
):
"""Spatial correlogram.
"""
Spatial correlogram.
Compute the pairwise spatial correlations (Spearman) and averages them based on the pairwise distances.
This collapses the spatial and temporal dimensions and returns a distance bins dimension.
Expand Down Expand Up @@ -1404,7 +1422,8 @@ def _decorrelation_length(
bins: int = 100,
group: xr.Coordinate | str | None = "time", # FIXME: this needs to be clarified
):
"""Decorrelation length.
"""
Decorrelation length.
Distance from a grid cell where the correlation with its neighbours goes below the threshold.
A correlogram is calculated for each grid cell following the method from
Expand Down Expand Up @@ -1540,7 +1559,8 @@ def _bin_corr(_corr, _distance):


def first_eof():
"""EOF Statistical Property (function removed).
"""
EOF Statistical Property (function removed).
Warnings
--------
Expand Down
7 changes: 1 addition & 6 deletions tests/test_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def func(data: xr.DataArray, thresh: str = "0 degC", freq: str = "YS"): # noqa
return data

doc = [
"The title",
" The title",
"",
" The abstract",
"",
Expand Down Expand Up @@ -776,11 +776,6 @@ def func(data: xr.DataArray, thresh: str = "0 degC", freq: str = "YS"): # noqa
d["identifier"] = "bad_indi"
d["module"] = "test"

bad_doc = doc[:12] + [" extra: bool", " Woupsi"] + doc[12:]
func.__doc__ = "\n".join(bad_doc)
with pytest.raises(ValueError, match="Malformed docstring"):
Daily(**d)

func.__doc__ = "\n".join(doc)
d["parameters"] = {}
d["parameters"]["thresh"] = "1 degK"
Expand Down

0 comments on commit e44aa0b

Please sign in to comment.