Skip to content

Commit

Permalink
Merge branch 'main' into add-index-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian authored Jul 17, 2023
2 parents 618a2c7 + 647376d commit fdbe0c8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pypi-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
path: dist
- name: Publish package to TestPyPI
if: github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@v1.8.7
uses: pypa/gh-action-pypi-publish@v1.8.8
with:
repository_url: https://test.pypi.org/legacy/
verbose: true
Expand All @@ -111,6 +111,6 @@ jobs:
name: releases
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@v1.8.7
uses: pypa/gh-action-pypi-publish@v1.8.8
with:
verbose: true
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Documentation
Internal Changes
~~~~~~~~~~~~~~~~

- :py:func:`as_variable` now consistently includes the variable name in any exceptions
raised. (:pull:`7995`). By `Peter Hill <https://github.com/ZedThree>`_

.. _whats-new.2023.07.0:

Expand Down
10 changes: 4 additions & 6 deletions xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,15 @@ def as_variable(obj, name=None) -> Variable | IndexVariable:
elif isinstance(obj, tuple):
if isinstance(obj[1], DataArray):
raise TypeError(
"Using a DataArray object to construct a variable is"
f"Variable {name!r}: Using a DataArray object to construct a variable is"
" ambiguous, please extract the data using the .data property."
)
try:
obj = Variable(*obj)
except (TypeError, ValueError) as error:
# use .format() instead of % because it handles tuples consistently
raise error.__class__(
"Could not convert tuple of form "
"(dims, data[, attrs, encoding]): "
"{} to Variable.".format(obj)
f"Variable {name!r}: Could not convert tuple of form "
f"(dims, data[, attrs, encoding]): {obj} to Variable."
)
elif utils.is_scalar(obj):
obj = Variable([], obj)
Expand All @@ -154,7 +152,7 @@ def as_variable(obj, name=None) -> Variable | IndexVariable:
obj = Variable(name, data, fastpath=True)
else:
raise TypeError(
"unable to convert object into a variable without an "
f"Variable {name!r}: unable to convert object into a variable without an "
f"explicit list of dimensions: {obj!r}"
)

Expand Down

0 comments on commit fdbe0c8

Please sign in to comment.