Skip to content

Commit

Permalink
Fix kldiv docstring (#1409)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* Fixes a malformed docstring

### Does this PR introduce a breaking change?

No.
  • Loading branch information
Zeitsperre committed Jun 30, 2023
2 parents aab7a4c + 6460cb9 commit 8118625
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ New features and enhancements
* Added ``ensembles.hawkins_sutton`` method to partition the uncertainty sources in a climate projection ensemble. (:issue:`771`, :pull:`1262`).
* New function ``xclim.core.calendar.convert_doy`` to transform day-of-year data between calendars. Also accessible from ``convert_calendar`` with ``doy=True``. (:issue:`1283`, :pull:`1406`).

Bug fixes
^^^^^^^^^
* Fix `kldiv` docstring so the math formula renders to HTML. (:issue:`1408`, :pull:`1409`).

Internal changes
^^^^^^^^^^^^^^^^
* Tolerance thresholds for error in ``test_stats::test_fit`` have been relaxed to allow for more variation in the results. Previously untested ``*_moving_yearly_window`` functions are now tested. (:issue:`1400`, :pull:`1402`).
Expand Down
7 changes: 5 additions & 2 deletions xclim/analog.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,13 @@ def kldiv(
) -> float | Sequence[float]:
r"""Compute the Kullback-Leibler divergence between two multivariate samples.
.. math
The formula to compute the K-L divergence from samples is given by:
.. math::
D(P||Q) = \frac{d}{n} \sum_i^n \log\left\{\frac{r_k(x_i)}{s_k(x_i)}\right\} + \log\left\{\frac{m}{n-1}\right\}
where :math:`r_k(x_i)` and :math:`s_k(x_i)` are, respectively, the euclidean distance to the kth neighbour of
where :math:`r_k(x_i)` and :math:`s_k(x_i)` are, respectively, the Euclidean distance to the kth neighbour of
:math:`x_i` in the x array (excepting :math:`x_i`) and in the y array. This method is scale-dependent.
Parameters
Expand Down

0 comments on commit 8118625

Please sign in to comment.