Skip to content

Commit

Permalink
Update _join.py (#1108)
Browse files Browse the repository at this point in the history
* Update _join.py

Added error message for multidimensional axes. This checks all data objects. I thought that would be of use given that one may have to define 1D versions of variable axes for all objects, and could make a mistake in one but not all of the 'datas' to be joined. Open to discussion.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update _join.py

Updated changelog, used a more specific wt_exception

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
DLafayetteII and pre-commit-ci[bot] committed Dec 10, 2022
1 parent aec5990 commit dcec4e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
## [Unreleased]

## Changed
- data.join now has MultidimensionalAxisError exception message
- `Axis`: space character ("\s") in expressions are culled.
- fixed `interact2D` bug: channel/axes can now be specified with non-zero index arguments

Expand Down
6 changes: 6 additions & 0 deletions WrightTools/data/_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def join(
for d in datas[1:]:
if d.axis_expressions != axis_expressions:
raise wt_exceptions.ValueError("Joined data must have same axis_expressions")
for a in d.axes:
if a.variables[0][:].squeeze().ndim > 1:
raise wt_exceptions.MultidimensionalAxisError(a.natural_name, "join")

variable_names &= set(d.variable_names)
channel_names &= set(d.channel_names)
variable_names = list(variable_names)
Expand All @@ -103,6 +107,8 @@ def join(
for a in datas[0].axes:
if len(a.variables) > 1:
raise wt_exceptions.ValueError("Applied transform must have single variable axes")
if a.variables[0][:].squeeze().ndim > 1:
raise wt_exceptions.MultidimensionalAxisError(a.natural_name, "join")
for v in a.variables:
axis_variable_names.append(v.natural_name)
axis_variable_units.append(v.units)
Expand Down

0 comments on commit dcec4e2

Please sign in to comment.