Skip to content

Commit 1d4b7d1

Browse files
authored
Merge pull request #117 from knutfrode/dev
Dev
2 parents 1b0e4ce + 1014946 commit 1d4b7d1

File tree

3 files changed

+107
-43
lines changed

3 files changed

+107
-43
lines changed

docs/source/conf.py

Lines changed: 81 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,34 @@
4040
}
4141

4242
extensions = [
43+
#"sphinxcontrib.mermaid",
44+
"sphinx.ext.extlinks",
45+
"sphinx.ext.napoleon",
4346
'sphinx.ext.duration',
4447
'sphinx.ext.doctest',
4548
'sphinx.ext.autodoc',
46-
# 'autoapi.extension',
49+
'autoapi.extension',
4750
'sphinx.ext.autosummary',
4851
'sphinx_autosummary_accessors',
4952
'sphinx.ext.intersphinx',
5053
'sphinx.ext.viewcode',
5154
'sphinx.ext.mathjax',
5255
'sphinx_gallery.gen_gallery',
53-
'numpydoc',
56+
#'numpydoc',
5457
'matplotlib.sphinxext.plot_directive',
5558
]
5659

5760
intersphinx_mapping = {
5861
'python': ('https://docs.python.org/3/', None),
62+
'numpy': ('https://numpy.org/doc/stable', None),
63+
'matplotlib': ('https://matplotlib.org/stable/', None),
64+
'scipy': ('https://docs.scipy.org/doc/scipy', None),
65+
'cftime': ('https://unidata.github.io/cftime', None),
5966
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
60-
"xarray": ("https://xarray.pydata.org/en/stable/", None),
61-
"pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
67+
'xarray': ('https://xarray.pydata.org/en/stable/', None),
68+
'pandas': ("https://pandas.pydata.org/pandas-docs/stable", None),
6269
}
63-
intersphinx_disabled_domains = ['std']
70+
#intersphinx_disabled_domains = ['std']
6471

6572
templates_path = ["_templates", sphinx_autosummary_accessors.templates_path]
6673

@@ -77,16 +84,81 @@
7784
}
7885

7986
autosummary_generate = True
80-
81-
autodoc_typehints = "description"
87+
autodoc_typehints = "none"
8288
autodoc_typehints_description_target = "documented"
8389
autodoc_default_options = {
8490
"members": True,
8591
"undoc-members": True,
8692
"private-members": True,
8793
}
88-
napoleon_use_param = True
89-
napoleon_use_rtype = True
94+
95+
napoleon_google_docstring = False
96+
napoleon_numpy_docstring = True
97+
napoleon_use_param = False
98+
napoleon_use_ivar = True
99+
napoleon_use_rtype = False
100+
napoleon_preprocess_types = True
101+
napoleon_type_aliases = {
102+
# general terms
103+
"sequence": ":term:`sequence`",
104+
"iterable": ":term:`iterable`",
105+
"callable": ":py:func:`callable`",
106+
"dict_like": ":term:`dict-like <mapping>`",
107+
"dict-like": ":term:`dict-like <mapping>`",
108+
"path-like": ":term:`path-like <path-like object>`",
109+
"mapping": ":term:`mapping`",
110+
"file-like": ":term:`file-like <file-like object>`",
111+
# special terms
112+
# "same type as caller": "*same type as caller*", # does not work, yet
113+
# "same type as values": "*same type as values*", # does not work, yet
114+
# stdlib type aliases
115+
"MutableMapping": "~collections.abc.MutableMapping",
116+
"sys.stdout": ":obj:`sys.stdout`",
117+
"timedelta": "~datetime.timedelta",
118+
"string": ":class:`string <str>`",
119+
# numpy terms
120+
"array_like": ":term:`array_like`",
121+
"array-like": ":term:`array-like <array_like>`",
122+
"scalar": ":term:`scalar`",
123+
"array": ":term:`array`",
124+
"hashable": ":term:`hashable <name>`",
125+
# matplotlib terms
126+
"color-like": ":py:func:`color-like <matplotlib.colors.is_color_like>`",
127+
"matplotlib colormap name": ":doc:`matplotlib colormap name <matplotlib:gallery/color/colormap_reference>`",
128+
"matplotlib axes object": ":py:class:`matplotlib axes object <matplotlib.axes.Axes>`",
129+
"colormap": ":py:class:`colormap <matplotlib.colors.Colormap>`",
130+
# xarray terms
131+
"dim name": ":term:`dimension name <name>`",
132+
"var name": ":term:`variable name <name>`",
133+
# objects without namespace: xarray
134+
"DataArray": "~xarray.DataArray",
135+
"Dataset": "~xarray.Dataset",
136+
"Variable": "~xarray.Variable",
137+
"DataTree": "~xarray.DataTree",
138+
"DatasetGroupBy": "~xarray.core.groupby.DatasetGroupBy",
139+
"DataArrayGroupBy": "~xarray.core.groupby.DataArrayGroupBy",
140+
"Grouper": "~xarray.groupers.Grouper",
141+
"Resampler": "~xarray.groupers.Resampler",
142+
# objects without namespace: numpy
143+
"ndarray": "~numpy.ndarray",
144+
"MaskedArray": "~numpy.ma.MaskedArray",
145+
"dtype": "~numpy.dtype",
146+
"ComplexWarning": "~numpy.ComplexWarning",
147+
# objects without namespace: pandas
148+
"Index": "~pandas.Index",
149+
"MultiIndex": "~pandas.MultiIndex",
150+
"CategoricalIndex": "~pandas.CategoricalIndex",
151+
"TimedeltaIndex": "~pandas.TimedeltaIndex",
152+
"DatetimeIndex": "~pandas.DatetimeIndex",
153+
"IntervalIndex": "~pandas.IntervalIndex",
154+
"Series": "~pandas.Series",
155+
"DataFrame": "~pandas.DataFrame",
156+
"Categorical": "~pandas.Categorical",
157+
"Path": "~~pathlib.Path",
158+
# objects with abbreviated namespace (from pandas)
159+
"pd.Index": "~pandas.Index",
160+
"pd.NaT": "~pandas.NaT",
161+
}
90162

91163
# numpydoc_show_class_members = False
92164
# Report warnings for all validation checks except the ones listed after "all"

trajan/traj.py

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -593,33 +593,33 @@ def seltime(self, t0=None, t1=None) -> xr.Dataset:
593593

594594

595595
@abstractmethod
596-
def skill(self, other, method='liu-weissberg', **kwargs) -> xr.DataArray:
596+
def skill(self, other, method='liu-weissberg', **kwargs) -> xr.Dataset:
597597
"""
598598
Compare the skill score between this trajectory and `other`.
599599
600600
Parameters
601601
----------
602602
603-
other: Another trajectory dataset.
603+
other : Dataset
604+
Another trajectory dataset.
604605
605-
method: skill-score method, currently only liu-weissberg. See :mod:`trajan.skill`.
606+
method : str
607+
skill-score method, currently only liu-weissberg.
606608
607-
**kwargs: passed on to the skill-score method.
609+
**kwargs :
610+
Passed on to the skill-score method.
608611
609612
Returns
610613
-------
611614
612-
skill: The skill-score in the same dimensions as this dataset.
615+
skill : :class:`xarray.Dataset`
616+
The skill-score in the same dimensions as this dataset.
613617
614-
.. note::
615-
616-
The datasets must be sampled (or have observations) at approximately the same timesteps. Consider using :meth:`trajan.traj2d.gridtime` to interpolate one of the datasets to the other.
617-
618-
619-
.. note::
620-
621-
The datasets must have the same number of trajectories. If you wish to compare a single trajectory to many others, duplicate it along the trajectory dimension to match the trajectory dimension of the other. See further down for an example.
618+
Notes
619+
-----
620+
The datasets must be sampled (or have observations) at approximately the same timesteps. Consider using :meth:`gridtime` to interpolate one of the datasets to the other.
622621
622+
The datasets must have the same number of trajectories. If you wish to compare a single trajectory to many others, duplicate it along the trajectory dimension to match the trajectory dimension of the other. See further down for an example.
623623
624624
Examples
625625
--------
@@ -634,37 +634,29 @@ def skill(self, other, method='liu-weissberg', **kwargs) -> xr.DataArray:
634634
>>> other = other.traj.gridtime(ds.time)
635635
>>> skill = ds.traj.skill(other)
636636
637-
>>> print(skill)
638-
<xarray.DataArray 'Skill-score' (trajectory: 2)> Size: 8B
637+
>>> skill
638+
<xarray.DataArray 'Skillscore' (trajectory: 2)> Size: 8B
639639
array([1., 1.], dtype=float32)
640640
Coordinates:
641641
* trajectory (trajectory) int64 16B 0 1
642642
Attributes:
643643
method: liu-weissberg
644644
645-
646645
If you need to broadcast a dataset with a single drifter to one with many you can use `xarray.broadcast` or `xarray.Dataset.broadcast_like`:
647646
648647
.. note::
649648
650649
If the other dataset has any other dimensions, on any other variables, you need to exclude those when broadcasting.
651650
652-
.. testcode::
653-
654-
b0 = ds.isel(trajectory=0) # `b0` now only has a single drifter (no trajectory dimension)
655-
656-
b0 = b0.broadcast_like(ds)
657-
skill = b0.traj.skill(ds)
658-
659-
print(skill)
660-
661-
.. testoutput::
662-
663-
<xarray.DataArray 'Skill-score' (trajectory: 2)>
664-
array([1. , 0.60894716], dtype=float32)
665-
Coordinates:
666-
* trajectory (trajectory) int64 0 1
667-
Attributes:
668-
method: liu-weissberg
651+
>>> b0 = ds.isel(trajectory=0) # `b0` now only has a single drifter (no trajectory dimension)
652+
>>> b0 = b0.broadcast_like(ds)
653+
>>> skill = b0.traj.skill(ds)
669654
655+
>>> skill
656+
<xarray.DataArray 'Skillscore' (trajectory: 2)> Size: 8B
657+
array([1. , 0.608058], dtype=float32)
658+
Coordinates:
659+
* trajectory (trajectory) int64 16B 0 1
660+
Attributes:
661+
method: liu-weissberg
670662
"""

trajan/traj1d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def skill(self, other, method='liu-weissberg', **kwargs):
122122
raise ValueError(f"Unknown skill-score method: {method}.")
123123

124124
return xr.DataArray(s,
125-
name='Skill-score',
125+
name='Skillscore',
126126
coords={'trajectory': self.ds.trajectory},
127127
attrs={'method': method})
128128

0 commit comments

Comments
 (0)