Skip to content

Commit 9b9d91f

Browse files
committed
More improvements.
1 parent a0cf155 commit 9b9d91f

File tree

5 files changed

+40
-35
lines changed

5 files changed

+40
-35
lines changed

docs/changelog_fragments/68.feat.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ The :class:`ncdata.NcData` objects can be indexed with the ``[]`` operation, or
33
specifed dimensions with the :meth:`~ncdata.NcData.slicer` method.
44
This is based on the new :meth:`~ncdata.utils.index_by_dimensions()` utility method
55
and :class:`~ncdata.utils.Slicer` class.
6-
See: :ref:`indexing_overview`
6+
See: :ref:`utils_indexing`

docs/details/developer_notes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ For a full docs-build:
4646

4747
.. note::
4848

49-
* the above is just for *local testing*, when required.
49+
* the above is just for **local testing**, when required.
5050
* For PRs (and releases), we also provide *automatic* builds on GitHub,
5151
via ReadTheDocs_.
5252

@@ -56,9 +56,9 @@ Release actions
5656

5757
#. Update the :ref:`change-log page <change_log>` in the details section
5858

59-
#. ensure all major changes + PRs are referenced in the :ref:`change_notes` section.
59+
#. start with ``$ towncrier build``
6060

61-
* The starting point for this is now just : ``$ towncrier build``.
61+
#. ensure all major changes + PRs are referenced in the :ref:`change_notes` section.
6262

6363
#. update the "latest version" stated in the :ref:`development_status` section
6464

docs/userdocs/user_guide/common_operations.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@ Equality Testing
126126
We implement equality operations ``==`` / ``!=`` for all the core data objects.
127127

128128
.. warning::
129-
The equality testing actually calls the :func:`ncdata.utils.dataset_differences` and
130-
:func:`ncdata.utils.variable_differences` utility functions.
129+
Equality testing for :class:`~ncdata.NcData` and :class:`~ncdata.NcVariable` actually
130+
calls the :func:`ncdata.utils.dataset_differences` and
131+
:func:`ncdata.utils.variable_differences` utilities.
131132

132133
This can be very costly if it needs to compare large data arrays.
133134

134-
If you need to avoid comparing large (and possibly lazy) arrays then you should use the
135+
If you need to avoid comparing large (and possibly lazy) arrays then you can use the
135136
:func:`ncdata.utils.dataset_differences` and
136-
:func:`ncdata.utils.variable_differences` utility functions directly.
137-
These enable you to use the provided tolerance options, such as ignoring differences in
138-
data content, or accepting that attributes are present in a different order.
137+
:func:`ncdata.utils.variable_differences` utility functions directly instead.
138+
These provide a ``check_var_data=False`` option, to ignore differences in data content.
139139

140140
See: :ref:`utils_equality`
141141

docs/userdocs/user_guide/data_objects.rst

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ However, for most operations on attributes, it is much easier to use the ``.aval
186186
property instead. This accesses *the same attributes*, but in the form of a simple
187187
"name: value" dictionary.
188188

189-
Thus for example, to fetch an attribute you would usually write just :
189+
Get attribute value
190+
^^^^^^^^^^^^^^^^^^^
191+
For example, to fetch an attribute you would usually write just :
190192

191193
.. testsetup::
192194

@@ -205,23 +207,15 @@ and **not** :
205207

206208
.. doctest:: python
207209

208-
>>> # WRONG: this reads an NcAttribute, not its value
210+
>>> # WRONG: this get the NcAttribute object, not its value
209211
>>> unit = dataset.variables["x"].attributes["units"]
210212

211-
or:
212-
213-
.. doctest:: python
214-
215-
>>> # WRONG: this gets NcAttribute.value as a character array, not a string
213+
>>> # WRONG: this returns a character array, not a string
216214
>>> unit = dataset.variables["x"].attributes["units"].value
217215

218-
or even (which is at least correct):
219-
220-
.. doctest:: python
221-
222-
>>> unit = dataset.variables["x"].attributes["units"].as_python_value()
223-
224216

217+
Set attribute value
218+
^^^^^^^^^^^^^^^^^^^
225219
Likewise, to **set** a value, you would normally just
226220

227221
.. doctest:: python
@@ -236,9 +230,11 @@ and **not**
236230
>>> dataset.variables["x"].attributes["units"].value = "K"
237231

238232

239-
Note also, that as the ``.avals`` is a dictionary, you can use standard dictionary
240-
methods such as ``update`` and ``get`` to perform other operations in a relatively
241-
natural, Pythonic way.
233+
``.avals`` as a dictionary
234+
^^^^^^^^^^^^^^^^^^^^^^^^^^
235+
Note also, that as ``.avals`` is a dictionary, you can use standard dictionary
236+
methods such as ``pop``, ``update`` and ``get`` to perform other operations in a
237+
relatively natural, Pythonic way.
242238

243239
.. doctest:: python
244240

@@ -247,6 +243,12 @@ natural, Pythonic way.
247243

248244
>>> dataset.attributes.update({"experiment": "A407", "expt_run": 704})
249245

246+
.. note::
247+
The new ``.avals`` property effectively replaces the old
248+
:meth:`~ncdata.NcData.get_attrval` and :meth:`~ncdata.NcData.set_attrval` methods,
249+
which are now deprecated and will eventually be removed.
250+
251+
250252
.. _data-constructors:
251253

252254
Core Object Constructors

docs/userdocs/user_guide/utilities.rst

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Dataset Equality Testing
1818
------------------------
1919
The functions :func:`~ncdata.utils.dataset_differences` and
2020
:func:`~ncdata.utils.variable_differences` produce a list of messages detailing all the
21-
ways in which two datasets are different.
21+
ways in which two datasets or variables are different.
2222

2323
For Example:
2424
^^^^^^^^^^^^
@@ -51,19 +51,22 @@ For Example:
5151
Dataset "x" dimension has different "unlimited" status : False != True
5252
Dataset variable "vx" shapes differ : (5,) != (2,)
5353

54-
.. note::
55-
To compare isolated variables, the subsidiary routine
56-
:func:`~ncdata.utils.variable_differences` is also provided.
54+
For a short-form test that two things are the same, you can just check that the
55+
results ``== []``.
56+
57+
By default, these functions compare **everything** about the two arguments.
58+
However, they also have multiple keywords which allow certain *types* of differences to
59+
be ignored, E.G. ``check_dims_order=False``, ``check_var_data=False``.
5760

5861
.. note::
5962
The ``==`` and ``!=`` operations on :class:`ncdata.NcData` and
60-
:class:`ncdata.NcVariable` simply call these utility functions to see if there are
61-
any differences.
63+
:class:`ncdata.NcVariable` use these utility functions to check for differences.
6264

6365
.. warning::
64-
As they lack a keyword interface, these operations have no tolerance options
65-
and check absolutely everything. This includes full data-array comparisons,
66-
which could be very costly in time or space if data arrays are large.
66+
As they lack a keyword interface, these operations provide no tolerance options,
67+
so they always check absolutely everything. Especially, they perform **full
68+
data-array comparisons**, which can have very high performance costs if data
69+
arrays are large.
6770

6871
.. _utils_indexing:
6972

0 commit comments

Comments
 (0)