-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor stats modules to allow inheritance (#4)
* refactor stats modules to allow inheritance * updates after arviz-base and recent releases * add histogram and more flexibility in make_ufunc * add documentation start * update datatree accessor * prepare release
- Loading branch information
1 parent
a40917b
commit fdc4eb5
Showing
33 changed files
with
2,399 additions
and
4,875 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
html[data-theme="light"] { | ||
--pst-color-primary: rgb(11 117 145); | ||
--pst-color-secondary: rgb(238 144 64); | ||
} | ||
|
||
html[data-theme="dark"] { | ||
--pst-color-primary: rgb(0 192 191); | ||
--pst-color-secondary: rgb(238 144 64); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="sd-d-flex-row sd-align-major-spaced sd-align-minor-center"> | ||
<a href="https://arviz-base.readthedocs.io"><div class="sd-fs-6 sd-font-weight-lighter sd-text-muted">BASE</div></a> | ||
<a href="{{ pathto(root_doc) }}"><div class="sd-fs-3 sd-font-weight-bold sd-text-primary">STATS</div></a> | ||
<a href="https://arviz-plots.readthedocs.io"><div class="sd-fs-6 sd-font-weight-lighter sd-text-muted">PLOTS</div></a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,90 @@ | ||
# API reference | ||
|
||
## Accessors | ||
Currently, using accessors is the recommended way to call functions from `arviz_stats`. | ||
|
||
### Dataset accessors | ||
|
||
```{eval-rst} | ||
.. autosummary:: | ||
:toctree: generated/ | ||
:template: autosummary/accessor_attribute.rst | ||
xarray.Dataset.azstats.ds | ||
.. autosummary:: | ||
:toctree: generated/ | ||
:template: autosummary/accessor_method.rst | ||
xarray.Dataset.azstats.filter_vars | ||
xarray.Dataset.azstats.eti | ||
xarray.Dataset.azstats.hdi | ||
xarray.Dataset.azstats.ess | ||
xarray.Dataset.azstats.rhat | ||
xarray.Dataset.azstats.mcse | ||
xarray.Dataset.azstats.kde | ||
xarray.Dataset.azstats.histogram | ||
xarray.Dataset.azstats.ecdf | ||
``` | ||
|
||
|
||
|
||
## DataArray facing functions | ||
|
||
### Base submodule | ||
|
||
```{eval-rst} | ||
.. autosummary:: | ||
:toctree: generated/ | ||
arviz_base.convert_to_dataset | ||
arviz_base.convert_to_datatree | ||
arviz_base.dict_to_dataset | ||
arviz_base.extract | ||
arviz_base.generate_dims_coords | ||
arviz_base.make_attrs | ||
arviz_stats.base.dataarray_stats.eti | ||
arviz_stats.base.dataarray_stats.hdi | ||
arviz_stats.base.dataarray_stats.ess | ||
arviz_stats.base.dataarray_stats.rhat | ||
arviz_stats.base.dataarray_stats.mcse | ||
arviz_stats.base.dataarray_stats.histogram | ||
arviz_stats.base.dataarray_stats.kde | ||
``` | ||
|
||
### Numba submodule | ||
The numba accelerated computations are available as the same methods | ||
but of the `arviz_stats.numba.dataarray_stats` class. | ||
Both their API and implementation is the same as for the base module, | ||
the only difference being that one calls `arviz_stats.base.array_stats` | ||
for array facing functions whereas the other one calls `arviz_stats.numba.array_stats`. | ||
|
||
Implementation differences are thus documented below, at the array facing classes. | ||
|
||
|
||
## Array facing functions | ||
|
||
## Example datasets | ||
### Base submodule | ||
|
||
```{eval-rst} | ||
.. autosummary:: | ||
:toctree: generated/ | ||
arviz_base.load_arviz_data | ||
arviz_base.list_datasets | ||
arviz_base.get_data_home | ||
arviz_base.clear_data_home | ||
arviz_stats.base.array_stats.eti | ||
arviz_stats.base.array_stats.hdi | ||
arviz_stats.base.array_stats.ess | ||
arviz_stats.base.array_stats.rhat | ||
arviz_stats.base.array_stats.mcse | ||
arviz_stats.base.array_stats.get_bins | ||
arviz_stats.base.array_stats.histogram | ||
arviz_stats.base.array_stats.kde | ||
``` | ||
|
||
## Configuration | ||
### Numba submodule | ||
Some functions are accelerated internally without changes to the public API, | ||
others are purely inherited from the base backend, and a last group is partially | ||
or completely reimplemented. This last group is documented here: | ||
|
||
```{eval-rst} | ||
.. autosummary:: | ||
:toctree: generated/ | ||
arviz_base.rc_context | ||
arviz_stats.numba.array_stats.quantile | ||
arviz_stats.numba.array_stats.histogram | ||
arviz_stats.numba.array_stats.kde | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Architecture | ||
Currently `arviz_stats` has some top level general functionality, and then submodules | ||
that take care of the actual computations. Submodules can be completely independent or | ||
build on top of one another. | ||
|
||
## Top level functionality | ||
This includes the accessors for dataarray, Dataset and Datatree objects, | ||
the dispatcher mechanism and some general dataclasses and utilities like `ELPDData`. | ||
|
||
## Computation submodules | ||
Computation submodules are structured into two main classes: an array facing class and a dataarray facing class. All submodules should in principle have both available. | ||
|
||
The array facing class takes array_like inputs, and aims to have an API similar to NumPy/SciPy. | ||
It can be used independently of the dataarray class (to the point of not needing to have | ||
`arviz_base` nor `xarray` installed) but it is (consequently) lower level interface. | ||
There are more required arguments, no `rcParams` integration... | ||
|
||
To make integration with the dataarray facing class easier, all functions should take | ||
`axes` (or equivalent arguments) which should allow either integers or sequences of axes | ||
for the functions to work over. | ||
It is also imperative that whenever new axes are added to an array, | ||
these are added as ending dimensions. | ||
|
||
The dataarray facing class, builds on top of the array facing one, and takes | ||
{class}`~xarray.DataArray` inputs aiming to have a more xarray-like API. | ||
As the array facing class API is defined and should be common between submodules, | ||
that means that this class can very often be limited to an instance of the base array facing class. | ||
|
||
|
||
### Base (aka numpy+scipy) | ||
This is the core backend which should have most functionality available and that defines | ||
the general API for both array and dataarray facing classes. | ||
|
||
### Numba | ||
The numba submodule builds on top of the base submodule, using numba to both | ||
accelerate computations and generate better behaved ufuncs, ensuring compatibility | ||
with Dask for example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
# pylint: disable=wildcard-import | ||
"""Statistical computation and diagnostics for ArviZ.""" | ||
from .utils import * | ||
from .accessors import * | ||
|
||
try: | ||
from arviz_stats.utils import * | ||
from arviz_stats.accessors import * | ||
except ModuleNotFoundError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
"""ArviZ version.""" | ||
__version__ = "0.1.0" | ||
__version__ = "0.2.0" |
Oops, something went wrong.