Skip to content

Commit

Permalink
Merge pull request #1040 from wright-group/map_variable
Browse files Browse the repository at this point in the history
map_variable:  ignore filepath
  • Loading branch information
kameyer226 committed Dec 6, 2021
2 parents 8d54b65 + ba86708 commit 0e3099b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Fixed
- `artists._parse_limits` now recognizes channel `null` for signed data limits.
- fixed bug where `Data.map_variable` did not interpolate on `yaqc-cmds` type Data

## [3.4.2]

Expand Down
2 changes: 1 addition & 1 deletion WrightTools/_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def __getitem__(self, key):
def __new__(cls, *args, **kwargs):
"""New object formation handler."""
# extract
filepath = args[0] if len(args) > 0 else kwargs.get("filepath", None)
filepath = args[0] if len(args) > 0 else kwargs.pop("filepath", None)
parent = args[1] if len(args) > 1 else kwargs.get("parent", None)
natural_name = args[2] if len(args) > 2 else kwargs.get("name", cls.class_name.lower())
edit_local = args[3] if len(args) > 3 else kwargs.pop("edit_local", False)
Expand Down
10 changes: 9 additions & 1 deletion WrightTools/data/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,15 @@ def map_variable(
else:
points = wt_units.converter(points, input_units, variable.units)
# construct new data object
special = ["name", "axes", "constants", "channel_names", "variable_names"]
special = [
"name",
"axes",
"constants",
"channel_names",
"variable_names",
"filepath",
"edit_local",
]
kwargs = {k: v for k, v in self.attrs.items() if k not in special}
if name is None:
name = "{0}_{1}_mapped".format(self.natural_name, variable.natural_name)
Expand Down
20 changes: 20 additions & 0 deletions tests/data/map_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


import numpy as np
import pytest

import WrightTools as wt
from WrightTools import datasets
Expand Down Expand Up @@ -34,9 +35,28 @@ def test_int():
data.close()


def test_excess_data_kwarg_1D():
p = datasets.wt5.v1p0p0_perovskite_TA
data = wt.open(p).chop("w2", at={"w1=wm": [1.6, "eV"], "d2": [0, "fs"]})[0]
mapped = data.map_variable("w2", 11)
assert mapped.w2.size == 11
data.close()


@pytest.mark.skip("It's a long test")
def test_v1p0p0():
p = datasets.wt5.v1p0p0_perovskite_TA
data = wt.open(p)
mapped = data.map_variable("w2", 2)
assert mapped.w2.size == 2
data.close()


# --- run -----------------------------------------------------------------------------------------


if __name__ == "__main__":
test_array()
test_int()
test_excess_data_kwarg_1D()
test_v1p0p0()

0 comments on commit 0e3099b

Please sign in to comment.