-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
easier chopping/slicing operations on Data (#1078)
* Update _data.py refactor chop chop works still * remove type hint python 3.6 has different method than 3.7+ * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update _data.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update _data.py * Update _data.py * refactor * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update _data.py * Update _data.py * Update CHANGELOG.md * Update _data.py * cleanup * string2identifier filter for operators * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor axis identifiers * Update _data.py stage for getitem slicing * Data.__getitem__ * Update _data.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * codeql * string2identifier fix retain usual behavior but optional kwargs to change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update _utilities.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * move operator_to_identifier * Update _data.py * chop, at fix parsing of coordinates * fix Data.at * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update _utilities.py * Update _utilities.py * Update CHANGELOG.md * Update _utilities.py * Update _data.py move axis creation to _from_slice method * first test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add test * cleanup * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * 3.7+ type hints * Update WrightTools/data/_data.py Co-authored-by: Kyle Sunden <git@ksunden.space> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Kyle Sunden <git@ksunden.space>
- Loading branch information
1 parent
45c1efe
commit bc6f240
Showing
5 changed files
with
196 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#! /usr/bin/env python3 | ||
"""Test at.""" | ||
|
||
|
||
# --- import ------------------------------------------------------------------------------------- | ||
|
||
|
||
import WrightTools as wt | ||
from WrightTools import datasets | ||
|
||
|
||
# --- tests -------------------------------------------------------------------------------------- | ||
|
||
|
||
def test_3D_to_1D(): | ||
data = wt.open(datasets.wt5.v1p0p1_MoS2_TrEE_movie) | ||
sliced = data.at(d2=[-50, "fs"], w2=[700, "nm"]) | ||
assert sliced.axis_expressions == ("w1=wm",) | ||
sliced = data.at(w1__e__wm=[605, "nm"], w2=[700, "nm"]) | ||
assert sliced.axis_expressions == ("d2",) | ||
data.close() | ||
sliced.close() | ||
|
||
|
||
def test_chop_equivalence(): | ||
data = wt.open(datasets.wt5.v1p0p1_MoS2_TrEE_movie) | ||
at_data = data.at(d2=[-50, "fs"], w2=[700, "nm"]) | ||
chop_data = data.chop("w1=wm", at={"d2": [-50, "fs"], "w2": [700, "nm"]})[0] | ||
assert at_data.shape == chop_data.shape | ||
assert at_data.axis_expressions == chop_data.axis_expressions | ||
|
||
|
||
if __name__ == "__main__": | ||
test_3D_to_1D() | ||
test_chop_equivalence() |