Skip to content

Commit

Permalink
Merge pull request #56 from khaeru/release/1.9.2
Browse files Browse the repository at this point in the history
Release v1.9.2
  • Loading branch information
khaeru committed Mar 3, 2022
2 parents ca4c4c0 + 6c71eae commit 81f1ead
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
8 changes: 6 additions & 2 deletions doc/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ What's new
:backlinks: none
:depth: 1

Next release
============
.. Next release
.. ============
v1.9.2 (2022-03-03)
===================

- Silence :func:`collect_units` when units are explicitly `""`, rather than :obj:`None` (:pull:`56`).
- Add explicit implementations of :meth:`~.object.__radd__`, :meth:`~.object.__rmul__`, :meth:`~.object.__rsub__` and :meth:`~.object.__rtruediv__` for e.g. ``4.2 * Quantity(...)`` (:pull:`55`)
- Improve typing of :meth:`.Quantity.shift` (:pull:`55`)

Expand Down
13 changes: 11 additions & 2 deletions genno/core/attrseries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import warnings
from functools import partial
from typing import Any, Hashable, Iterable, List, Mapping, Union

Expand Down Expand Up @@ -366,8 +367,16 @@ def sel(self, indexers=None, drop=False, **indexers_kwargs):
# Maybe unpack an xarray DataArray indexers, for pandas
idx.append(i.data if isinstance(i, xr.DataArray) else i)

# Select
data = self.loc[tuple(idx)]
# Silence a warning from pandas ≥1.4 that may be spurious
# FIXME investigate, adjust the code, remove the filter
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
".*indexing on a MultiIndex with a nested sequence.*",
FutureWarning,
)
# Select
data = self.loc[tuple(idx)]

# Only drop if not returning a scalar value
if not np.isscalar(data):
Expand Down
2 changes: 1 addition & 1 deletion genno/core/quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _collect_attrs(data, attrs_arg, kwargs):

# Store the "units" keyword argument as an attr
units = kwargs.pop("units", None)
if units:
if units is not None:
new_attrs["_unit"] = pint.Unit(units)

return new_attrs
Expand Down
2 changes: 1 addition & 1 deletion genno/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def collect_units(*args):

for arg in args:
unit = arg.attrs.get("_unit")
if not unit:
if unit is None:
log.debug(f"{arg} lacks units; assume dimensionless")
unit = registry.dimensionless

Expand Down

0 comments on commit 81f1ead

Please sign in to comment.