-
Notifications
You must be signed in to change notification settings - Fork 72
/
__init__.py
85 lines (74 loc) · 2.29 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# pylint: disable=missing-docstring,import-outside-toplevel
# Import functions/classes to make the public API
from . import datasets
from . import version
from .coordinates import (
scatter_points,
grid_coordinates,
inside,
block_split,
rolling_window,
expanding_window,
profile_coordinates,
get_region,
pad_region,
longitude_continuity,
)
from .mask import distance_mask, convexhull_mask
from .utils import variance_to_weights, maxabs, grid_to_table, make_xarray_grid
from .io import load_surfer
from .distances import median_distance
from .blockreduce import BlockReduce, BlockMean
from .scipygridder import ScipyGridder
from .trend import Trend
from .chain import Chain
from .spline import Spline, SplineCV
from .model_selection import (
cross_val_score,
train_test_split,
BlockShuffleSplit,
BlockKFold,
)
from .vector import Vector, VectorSpline2D
from .projections import project_region, project_grid
# Get the version number through setuptools-scm
__version__ = version.version
def test(doctest=True, verbose=True, coverage=False, figures=True):
"""
Run the test suite.
Uses `py.test <http://pytest.org/>`__ to discover and run the tests.
Parameters
----------
doctest : bool
If ``True``, will run the doctests as well (code examples that start
with a ``>>>`` in the docs).
verbose : bool
If ``True``, will print extra information during the test run.
coverage : bool
If ``True``, will run test coverage analysis on the code as well.
Requires ``pytest-cov``.
figures : bool
If ``True``, will test generated figures against saved baseline
figures. Requires ``pytest-mpl`` and ``matplotlib``.
Raises
------
AssertionError
If pytest returns a non-zero error code indicating that some tests have
failed.
"""
import pytest
package = __name__
args = []
if verbose:
args.append("-vv")
if coverage:
args.append("--cov={}".format(package))
args.append("--cov-report=term-missing")
if doctest:
args.append("--doctest-modules")
if figures:
args.append("--mpl")
args.append("--pyargs")
args.append(package)
status = pytest.main(args)
assert status == 0, "Some tests have failed."