Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
warn when dimension list matches multiples
This commit treats matches with dimension lists
(such as CFDecoder.x) different than the
coordinates or axis attribute.
  • Loading branch information
Chilipp committed Apr 7, 2020
commit 93a6bc91e7fa1487d15386425212f544e0fad737
15 changes: 11 additions & 4 deletions psyplot/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,19 +917,26 @@ def get_variable_by_axis(self, var, axis, coords=None):
if not coord_names:
return
ret = []
matched = []
for coord in map(lambda dim: coords[dim], filter(
lambda dim: dim in coords, chain(
coord_names, var.dims))):
# check for the axis attribute or whether the coordinate is in the
# list of possible coordinate names
if coord.name not in (c.name for c in ret):
if coord.name in getattr(self, axis):
ret.clear()
ret.append(coord)
break
matched.append(coord)
elif coord.attrs.get('axis', '').lower() == axis:
ret.append(coord)
if ret:
if matched:
if len(matched) > 1:
warn("Found multiple matches for %s coordinate in the "
"coordinates: %s. I use %s" % (
axis, ', '.join([c.name for c in matched]),
matched[0].name),
PsyPlotRuntimeWarning)
return matched[0]
elif ret:
return None if len(ret) > 1 else ret[0]
# If the coordinates attribute is specified but the coordinate
# variables themselves have no 'axis' attribute, we interpret the
Expand Down