Skip to content

Commit 2dbcdbb

Browse files
committed
Docs and input type fixes
1 parent 49f89d1 commit 2dbcdbb

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/earthkit/meteo/stats/array/distributions.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,24 @@ def fit(cls, sample, axis):
2727

2828
@abc.abstractmethod
2929
def cdf(self, x):
30-
"""Evaluate the continuous distribution function."""
30+
"""Evaluate the cumulative distribution function (CDF)."""
3131

3232
@abc.abstractmethod
3333
def ppf(self, x):
34-
"""Evaluate the inverse CDF (percent point function)."""
34+
"""Evaluate the percent point function (PPF; inverse CDF)."""
3535

3636

3737
# Temporary drop-in replacement for scipy.stats.lmoment from scipy v0.15
3838
def _lmoment(sample, order=(1, 2), axis=0):
39-
"""Compute first 2 L-moments of dataset along first axis."""
39+
"""Compute first 2 L-moments of a dataset along the first axis."""
4040
if len(order) != 2 or order[0] != 1 or order[1] != 2:
4141
raise NotImplementedError
4242
if axis != 0:
4343
raise NotImplementedError
4444

4545
nmoments = 3
4646

47+
sample = np.asarray(sample)
4748
# At least four values needed to make a sample L-moments estimation
4849
nvalues, *rest_shape = sample.shape
4950
if nvalues < 4:
@@ -137,7 +138,7 @@ def ndim(self):
137138
return self.mu.ndim
138139

139140
def cdf(self, x):
140-
"""Evaluate the cumulative distribution function.
141+
"""Evaluate the cumulative distribution function (CDF).
141142
142143
Parameters
143144
----------
@@ -154,7 +155,7 @@ def cdf(self, x):
154155
return 1.0 - np.exp(-np.exp((self.mu - x) / self.sigma))
155156

156157
def ppf(self, p):
157-
"""Evaluate the inverse cumulative distribution function.
158+
"""Evaluate the percent point function (PPF; inverse CDF).
158159
159160
Parameters
160161
----------

src/earthkit/meteo/stats/array/extreme_values.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class MaximumStatistics:
1414
"""Recurrence statistics for a sample of maximum values.
1515
16-
All statistics are computed based on a fitted continuous probability
16+
All statistics are computed from a fitted continuous probability
1717
distribution. Results will only be meaningful if this fitted distribution
1818
is representative of the sample statistics.
1919
@@ -31,7 +31,7 @@ class MaximumStatistics:
3131
Temporal frequency of the input data. Used to scale return periods.
3232
Defaults to 1, i.e., no scaling applied. Note: when supplying a numpy
3333
timedelta64, the unit carries over to return periods.
34-
dist:
34+
dist: ContinuousDistribution
3535
Continuous probability distribution fitted to the input data.
3636
"""
3737

@@ -51,7 +51,7 @@ def freq(self):
5151
return self._freq
5252

5353
def probability_of_threshold(self, threshold):
54-
"""Probability of exceeding the threshold.
54+
"""Probability of threshold exceedance.
5555
5656
Parameters
5757
----------
@@ -67,7 +67,7 @@ def probability_of_threshold(self, threshold):
6767
return self.dist.cdf(threshold)
6868

6969
def return_period_of_threshold(self, threshold):
70-
"""Return period of exceeding the threshold.
70+
"""Return period of threshold exceedance.
7171
7272
Parameters
7373
----------

0 commit comments

Comments
 (0)