From 927c5263f880b989af99bdbcf86f32fabfd066b4 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Fri, 7 Jul 2023 13:20:28 -0500 Subject: [PATCH 01/27] working example --- WrightTools/data/_channel.py | 11 +++++++++ WrightTools/data/_data.py | 43 ++++++++++++++++++++++++++--------- WrightTools/data/_variable.py | 9 ++++++++ tests/data/chop.py | 16 +++++++++++++ 4 files changed, 68 insertions(+), 11 deletions(-) diff --git a/WrightTools/data/_channel.py b/WrightTools/data/_channel.py index c495c487c..9e06e61b6 100644 --- a/WrightTools/data/_channel.py +++ b/WrightTools/data/_channel.py @@ -225,3 +225,14 @@ def trim(self, neighborhood, method="ztest", factor=3, replace="nan", verbose=Tr if verbose: print("%i outliers removed" % len(outliers)) return outliers + + def _to_dict(self): + out = {} + out["name"] = self.natural_name + out["values"] = self[:] + out["units"] = self.units + out["label"] = self.label + out["signed"] = self.signed + out.update(self.attrs) + return out + diff --git a/WrightTools/data/_data.py b/WrightTools/data/_data.py index 86d496d31..04f6b4048 100644 --- a/WrightTools/data/_data.py +++ b/WrightTools/data/_data.py @@ -360,6 +360,36 @@ def at(self, parent=None, name=None, **at) -> Data: idx = self._at_to_slice(**at) return self._from_slice(idx, name=name, parent=parent) + def drop(self): + """cull variables and channels that have non-trivial shape where the broadcast axes have shape 1. + similar to chop + + Parameters + ---------- + ... + """ + joint_shape = wt_kit.joint_shape(*[ai[:] for ai in self.axes]) + cull_dims = [j == 1 for j in joint_shape] + sl = [0 if cull else slice(None) for cull in cull_dims] + matches_broadcast_axes = lambda a: all( + [a.shape[i] == 1 for i in range(self.ndim) if cull_dims[i]] + ) + + new = Data() + + for v in filter(matches_broadcast_axes, self.variables): + kwargs = v._to_dict() + kwargs["values"] = v[sl] + new.create_variable(**kwargs) + + for c in filter(matches_broadcast_axes, self.channels): + kwargs = c._to_dict() + kwargs["values"] = c[sl] + new.create_channel(**kwargs) + + new.transform(*self.axis_expressions) + return new + def chop(self, *args, at=None, parent=None, verbose=True) -> wt_collection.Collection: """Divide the dataset into its lower-dimensionality components. @@ -509,21 +539,12 @@ def _from_slice(self, idx, name=None, parent=None) -> Data: out = parent.create_data(name=name) for v in self.variables: - kwargs = {} - kwargs["name"] = v.natural_name + kwargs = v._to_dict() kwargs["values"] = v[idx] - kwargs["units"] = v.units - kwargs["label"] = v.label - kwargs.update(v.attrs) out.create_variable(**kwargs) for c in self.channels: - kwargs = {} - kwargs["name"] = c.natural_name + kwargs = c._to_dict() kwargs["values"] = c[idx] - kwargs["units"] = c.units - kwargs["label"] = c.label - kwargs["signed"] = c.signed - kwargs.update(c.attrs) out.create_channel(**kwargs) new_axes = [a.expression for a in self.axes if a[idx].size > 1] diff --git a/WrightTools/data/_variable.py b/WrightTools/data/_variable.py index f5ebe5d42..2d139a56b 100644 --- a/WrightTools/data/_variable.py +++ b/WrightTools/data/_variable.py @@ -50,3 +50,12 @@ def label(self) -> str: @label.setter def label(self, label): self.attrs["label"] = label + + def _to_dict(self): + out = {} + out["name"] = self.natural_name + out["values"] = self[:] + out["units"] = self.units + out["label"] = self.label + out.update(self.attrs) + return out diff --git a/tests/data/chop.py b/tests/data/chop.py index e01c02382..d86e1a33e 100755 --- a/tests/data/chop.py +++ b/tests/data/chop.py @@ -205,6 +205,21 @@ def test_non_spanning_axes(): c.close() +def test_drop_kwarg(): + d = wt.Data(name="test") + d.create_variable("x", values=np.arange(5)[:, None, None]) + d.create_variable("y", values=np.arange(4)[None, :, None]) + d.create_variable("redundant_array", values=np.tile(np.arange(3), (5, 4, 1))) + + d.create_channel("keep", values=d.x[:] + d.y[:]) + d.create_channel("throw_away", values=np.zeros((5,4,3))) + + d.transform("x", "y") + d = d.drop() # make sure it runs error free + assert d.ndim == 2 + assert d.shape == (5,4) + + # --- run ----------------------------------------------------------------------------------------- @@ -219,3 +234,4 @@ def test_non_spanning_axes(): test_3D_to_2D_signed() test_3D_to_2D_units() test_parent() + test_drop_kwarg() From cbe41b0c63d84cb63c72a61c23e96da47c495dcc Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Fri, 7 Jul 2023 13:55:01 -0500 Subject: [PATCH 02/27] drop -> squeeze --- CHANGELOG.md | 1 + WrightTools/data/_data.py | 39 ++++++++++++++++++++++++++++++++++----- tests/data/chop.py | 16 ---------------- tests/data/squeeze.py | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 tests/data/squeeze.py diff --git a/CHANGELOG.md b/CHANGELOG.md index d8cc7dd1d..20a588da6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Added - `Data.translate_to_txt`: serialize channels and variables and write as a text file. +- `Data.squeeze`: squeezing the data object to the shape of the axes. ## [3.4.6] diff --git a/WrightTools/data/_data.py b/WrightTools/data/_data.py index 04f6b4048..4cb92e820 100644 --- a/WrightTools/data/_data.py +++ b/WrightTools/data/_data.py @@ -360,14 +360,45 @@ def at(self, parent=None, name=None, **at) -> Data: idx = self._at_to_slice(**at) return self._from_slice(idx, name=name, parent=parent) - def drop(self): - """cull variables and channels that have non-trivial shape where the broadcast axes have shape 1. - similar to chop + def squeeze(self, name=None, parent=None): + """Reduce the data to the dimensionality of the (non-trivial) span of the axes. + i.e. if the joint shape of the axes has an array dimension with length 1, this + array dimension is squeezed. + + channels and variables that span beyond the axes are omitted. Parameters ---------- + name : string (optional) + name of the new Data. + parent : WrightTools Collection instance (optional) + Collection to place the new "chop" collection within. Default is + None (new parent). + + Returns + ------- + out : wt.Data + new data object. The new data object has dimensions + + Examples + -------- + >>> ... + + See also + -------- + Data.chop: Divide the dataset into its lower-dimensionality components. ... """ + new = Data(name=name, parent=parent) + + attrs = { + k:v for k,v in self.attrs.items() + if k not in ["axes", "channel_names", "constants", "name", "source", "item_names", "variable_names"] + } + new.attrs.update(attrs) + + # TODO: deal with constants? establish new constants? + joint_shape = wt_kit.joint_shape(*[ai[:] for ai in self.axes]) cull_dims = [j == 1 for j in joint_shape] sl = [0 if cull else slice(None) for cull in cull_dims] @@ -375,8 +406,6 @@ def drop(self): [a.shape[i] == 1 for i in range(self.ndim) if cull_dims[i]] ) - new = Data() - for v in filter(matches_broadcast_axes, self.variables): kwargs = v._to_dict() kwargs["values"] = v[sl] diff --git a/tests/data/chop.py b/tests/data/chop.py index d86e1a33e..e01c02382 100755 --- a/tests/data/chop.py +++ b/tests/data/chop.py @@ -205,21 +205,6 @@ def test_non_spanning_axes(): c.close() -def test_drop_kwarg(): - d = wt.Data(name="test") - d.create_variable("x", values=np.arange(5)[:, None, None]) - d.create_variable("y", values=np.arange(4)[None, :, None]) - d.create_variable("redundant_array", values=np.tile(np.arange(3), (5, 4, 1))) - - d.create_channel("keep", values=d.x[:] + d.y[:]) - d.create_channel("throw_away", values=np.zeros((5,4,3))) - - d.transform("x", "y") - d = d.drop() # make sure it runs error free - assert d.ndim == 2 - assert d.shape == (5,4) - - # --- run ----------------------------------------------------------------------------------------- @@ -234,4 +219,3 @@ def test_drop_kwarg(): test_3D_to_2D_signed() test_3D_to_2D_units() test_parent() - test_drop_kwarg() diff --git a/tests/data/squeeze.py b/tests/data/squeeze.py new file mode 100644 index 000000000..9e5865752 --- /dev/null +++ b/tests/data/squeeze.py @@ -0,0 +1,32 @@ +#! /usr/bin/env python3 +"""Test chop.""" + + +# --- import ------------------------------------------------------------------------------------- + + +import numpy as np +import WrightTools as wt +from WrightTools import datasets + + +# --- tests -------------------------------------------------------------------------------------- + + +def test_squeeze(): + d = wt.Data(name="test") + d.create_variable("x", values=np.arange(5)[:, None, None]) + d.create_variable("y", values=np.arange(4)[None, :, None]) + d.create_variable("redundant_array", values=np.tile(np.arange(3), (5, 4, 1))) + + d.create_channel("keep", values=d.x[:] + d.y[:]) + d.create_channel("throw_away", values=np.zeros((5,4,3))) + + d.transform("x", "y") + d = d.squeeze() # make sure it runs error free + assert d.ndim == 2 + assert d.shape == (5,4) + + +if __name__ == "__main__": + test_squeeze() From 853db5f2ce83902e05dc83b2aff5ea51515e917b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 7 Jul 2023 18:58:00 +0000 Subject: [PATCH 03/27] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- WrightTools/data/_channel.py | 1 - WrightTools/data/_data.py | 24 +++++++++++++++++------- tests/data/squeeze.py | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/WrightTools/data/_channel.py b/WrightTools/data/_channel.py index 9e06e61b6..8a12b2bc3 100644 --- a/WrightTools/data/_channel.py +++ b/WrightTools/data/_channel.py @@ -235,4 +235,3 @@ def _to_dict(self): out["signed"] = self.signed out.update(self.attrs) return out - diff --git a/WrightTools/data/_data.py b/WrightTools/data/_data.py index 4cb92e820..efc0fcca3 100644 --- a/WrightTools/data/_data.py +++ b/WrightTools/data/_data.py @@ -362,7 +362,7 @@ def at(self, parent=None, name=None, **at) -> Data: def squeeze(self, name=None, parent=None): """Reduce the data to the dimensionality of the (non-trivial) span of the axes. - i.e. if the joint shape of the axes has an array dimension with length 1, this + i.e. if the joint shape of the axes has an array dimension with length 1, this array dimension is squeezed. channels and variables that span beyond the axes are omitted. @@ -378,7 +378,7 @@ def squeeze(self, name=None, parent=None): Returns ------- out : wt.Data - new data object. The new data object has dimensions + new data object. The new data object has dimensions Examples -------- @@ -386,17 +386,27 @@ def squeeze(self, name=None, parent=None): See also -------- - Data.chop: Divide the dataset into its lower-dimensionality components. + Data.chop: Divide the dataset into its lower-dimensionality components. ... """ new = Data(name=name, parent=parent) attrs = { - k:v for k,v in self.attrs.items() - if k not in ["axes", "channel_names", "constants", "name", "source", "item_names", "variable_names"] + k: v + for k, v in self.attrs.items() + if k + not in [ + "axes", + "channel_names", + "constants", + "name", + "source", + "item_names", + "variable_names", + ] } new.attrs.update(attrs) - + # TODO: deal with constants? establish new constants? joint_shape = wt_kit.joint_shape(*[ai[:] for ai in self.axes]) @@ -416,7 +426,7 @@ def squeeze(self, name=None, parent=None): kwargs["values"] = c[sl] new.create_channel(**kwargs) - new.transform(*self.axis_expressions) + new.transform(*self.axis_expressions) return new def chop(self, *args, at=None, parent=None, verbose=True) -> wt_collection.Collection: diff --git a/tests/data/squeeze.py b/tests/data/squeeze.py index 9e5865752..2b16511a2 100644 --- a/tests/data/squeeze.py +++ b/tests/data/squeeze.py @@ -20,12 +20,12 @@ def test_squeeze(): d.create_variable("redundant_array", values=np.tile(np.arange(3), (5, 4, 1))) d.create_channel("keep", values=d.x[:] + d.y[:]) - d.create_channel("throw_away", values=np.zeros((5,4,3))) + d.create_channel("throw_away", values=np.zeros((5, 4, 3))) d.transform("x", "y") d = d.squeeze() # make sure it runs error free assert d.ndim == 2 - assert d.shape == (5,4) + assert d.shape == (5, 4) if __name__ == "__main__": From 4df77d79058a3065c2c3712250c15057170a0a95 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Tue, 8 Aug 2023 12:44:34 -0500 Subject: [PATCH 04/27] Update squeeze.py --- tests/data/squeeze.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/squeeze.py b/tests/data/squeeze.py index 2b16511a2..a89d6c6d3 100644 --- a/tests/data/squeeze.py +++ b/tests/data/squeeze.py @@ -1,5 +1,5 @@ #! /usr/bin/env python3 -"""Test chop.""" +"""Test squeeze.""" # --- import ------------------------------------------------------------------------------------- From f819b0a2e13e1aab0ffb800c267c0080bb0cd41e Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Tue, 8 Aug 2023 12:45:54 -0500 Subject: [PATCH 05/27] Update _data.py squeeze docstring --- WrightTools/data/_data.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WrightTools/data/_data.py b/WrightTools/data/_data.py index efc0fcca3..fbbaf8873 100644 --- a/WrightTools/data/_data.py +++ b/WrightTools/data/_data.py @@ -378,7 +378,8 @@ def squeeze(self, name=None, parent=None): Returns ------- out : wt.Data - new data object. The new data object has dimensions + new data object. The new data object has dimensions of the + (non-trivial) span of the current axes Examples -------- From ce53625e508ba845d3129b46c2ccdee83917a3a0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 17:52:45 +0000 Subject: [PATCH 06/27] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- WrightTools/data/_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WrightTools/data/_data.py b/WrightTools/data/_data.py index fbbaf8873..dd1b7866c 100644 --- a/WrightTools/data/_data.py +++ b/WrightTools/data/_data.py @@ -378,7 +378,7 @@ def squeeze(self, name=None, parent=None): Returns ------- out : wt.Data - new data object. The new data object has dimensions of the + new data object. The new data object has dimensions of the (non-trivial) span of the current axes Examples From 348994c3e9255c074c1df6ebea6198cbea737f1a Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:52:35 -0500 Subject: [PATCH 07/27] Update requirements.txt --- requirements.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 9c558e357..b7f1f5b35 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,9 @@ -. +h5py +imageio +matplotlib>=3.4.0 +numexpr +numpy>=1.15.0 +pint +python-dateutil +scipy +tidy_headers>=1.0.0 From 3ec0a6d5671f6d6ada471df02775189f92464e0b Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Thu, 10 Aug 2023 12:02:37 -0500 Subject: [PATCH 08/27] docs/requirements.txt --- docs/requirements.txt | 1 + requirements.txt | 10 +--------- 2 files changed, 2 insertions(+), 9 deletions(-) create mode 100644 docs/requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..945c9b46d --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index b7f1f5b35..945c9b46d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1 @@ -h5py -imageio -matplotlib>=3.4.0 -numexpr -numpy>=1.15.0 -pint -python-dateutil -scipy -tidy_headers>=1.0.0 +. \ No newline at end of file From 148c956bd7f11231bc22b508d3a0ed2009a354ed Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:46:01 -0500 Subject: [PATCH 09/27] interact2D use_imshow bugfix --- CHANGELOG.md | 3 +++ WrightTools/artists/_interact.py | 4 ++-- tests/artists/test_interact2D.py | 10 +++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bece8dd0..cd1d095c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ## [Unreleased] +### Fixed +- `interact2D`: fixed bug where use_imshow broke the sliders + ## [3.5.0] ### Fixed diff --git a/WrightTools/artists/_interact.py b/WrightTools/artists/_interact.py index 2edb71c32..071ab5548 100644 --- a/WrightTools/artists/_interact.py +++ b/WrightTools/artists/_interact.py @@ -445,8 +445,8 @@ def update_slider(info, use_imshow=use_imshow): ) if use_imshow: transpose = _order_for_imshow( - current_state[xaxis.natural_name][:], - current_state[yaxis.natural_name][:], + current_state.dat[xaxis.natural_name][:], + current_state.dat[yaxis.natural_name][:], ) obj2D.set_data(current_state.dat[channel.natural_name][:].transpose(transpose)) else: diff --git a/tests/artists/test_interact2D.py b/tests/artists/test_interact2D.py index 43bccc6b3..85f979a35 100755 --- a/tests/artists/test_interact2D.py +++ b/tests/artists/test_interact2D.py @@ -82,16 +82,16 @@ def test_4D(): data.create_variable("d_1", values=tau[None, None, None, :], units="ps") data.transform("w_1", "w_2", "w_3", "d_1") - return wt.artists.interact2D(data, xaxis=0, yaxis=1, local=True) + return wt.artists.interact2D(data, xaxis=0, yaxis=1, local=True, use_imshow=True) if __name__ == "__main__": import matplotlib.pyplot as plt plt.close("all") - out1 = test_perovskite() - out2 = test_MoS2() - out3 = test_asymmetric() - out4 = test_skewed() + # out1 = test_perovskite() + # out2 = test_MoS2() + # out3 = test_asymmetric() + # out4 = test_skewed() out5 = test_4D() plt.show() From 61ca0437ee85424d98518a51e7733862ec06b635 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Thu, 10 Aug 2023 12:28:21 -0500 Subject: [PATCH 10/27] Update test_interact2D.py --- tests/artists/test_interact2D.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/artists/test_interact2D.py b/tests/artists/test_interact2D.py index 85f979a35..a6548c1dc 100755 --- a/tests/artists/test_interact2D.py +++ b/tests/artists/test_interact2D.py @@ -89,9 +89,9 @@ def test_4D(): import matplotlib.pyplot as plt plt.close("all") - # out1 = test_perovskite() - # out2 = test_MoS2() - # out3 = test_asymmetric() - # out4 = test_skewed() + out1 = test_perovskite() + out2 = test_MoS2() + out3 = test_asymmetric() + out4 = test_skewed() out5 = test_4D() plt.show() From 8e931ba66e5f1cf95bf34aaf789a3ec0178d3365 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 16:52:06 -0500 Subject: [PATCH 11/27] [pre-commit.ci] pre-commit autoupdate (#1141) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.7.0 → 23.9.1](https://github.com/psf/black/compare/23.7.0...23.9.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 348695dfe..8f135199e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/psf/black - rev: 23.7.0 # Replace by any tag/version: https://github.com/psf/black/tags + rev: 23.9.1 # Replace by any tag/version: https://github.com/psf/black/tags hooks: - id: black language_version: python3 # Should be a command that runs python3.6+ From 0d108baf872880dd2bd186c4769a84a7f754357d Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Sun, 17 Sep 2023 18:01:56 -0500 Subject: [PATCH 12/27] Update _base.py (#1140) --- WrightTools/artists/_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WrightTools/artists/_base.py b/WrightTools/artists/_base.py index 31af599a3..ce20b4371 100644 --- a/WrightTools/artists/_base.py +++ b/WrightTools/artists/_base.py @@ -130,7 +130,7 @@ def _parse_plot_args(self, *args, **kwargs): raise wt_exceptions.ValueError("Cannot squeeze axis to fit channel") zi = data.channels[channel_index].points if not zi.ndim == 2: - raise wt_exceptions.DimensionalityError(zi.ndim, data.ndim) + raise wt_exceptions.DimensionalityError(2, zi.ndim) squeeze = tuple([0 if i else slice(None) for i in squeeze]) if plot_type == "imshow": if "aspect" not in kwargs.keys(): @@ -646,7 +646,7 @@ def plot(self, *args, **kwargs): zi = data.channels[channel_index].points xi = xa[squeeze] if not zi.ndim == 1: - raise wt_exceptions.DimensionalityError(1, data.ndim) + raise wt_exceptions.DimensionalityError(1, zi.ndim) args = [xi, zi] + args else: data = None From 4dbc31b2ad141167ac88ceafba2a7aefc366867e Mon Sep 17 00:00:00 2001 From: pcruzparri <43578034+pcruzparri@users.noreply.github.com> Date: Tue, 19 Sep 2023 17:23:05 -0500 Subject: [PATCH 13/27] fixes to readthedocs requirements setup --- .readthedocs.yml | 3 ++- docs/requirements.txt | 2 +- requirements.txt | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 requirements.txt diff --git a/.readthedocs.yml b/.readthedocs.yml index d2d609a94..ccefc224e 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -6,7 +6,8 @@ build: python: version: 3.8 pip_install: true - extra_requirements: [docs] + install: + - requirements: docs/requirements.txt formats: - epub diff --git a/docs/requirements.txt b/docs/requirements.txt index 945c9b46d..82ecdd2c5 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1 +1 @@ -. \ No newline at end of file +..[docs] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 945c9b46d..000000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file From 4027ec135a8726eced1d5523cc2772f5f3dde0fa Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:33:05 -0600 Subject: [PATCH 14/27] learn from attune consistent with https://docs.readthedocs.io/en/stable/config-file/v2.html --- .readthedocs.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index ccefc224e..f57919300 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,13 +1,20 @@ -requirements_file: requirements.txt +version: 2 build: - image: latest + os: ubuntu-22.04 + tools: + python: "3.9" python: - version: 3.8 - pip_install: true install: - - requirements: docs/requirements.txt + - method: pip + path: . + extra_requirements: + - docs + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/conf.py formats: - epub From 4065bacd995974d591c999cf92bf7644ec6339a0 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:48:30 -0600 Subject: [PATCH 15/27] move requirements.txt to original --- docs/requirements.txt | 1 - requirements.txt | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 docs/requirements.txt create mode 100644 requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 82ecdd2c5..000000000 --- a/docs/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -..[docs] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..945c9b46d --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +. \ No newline at end of file From a1519985e21f90e0fb053c335e68755cec7b8546 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:31:44 -0600 Subject: [PATCH 16/27] address constants --- WrightTools/data/_data.py | 8 +++++--- tests/data/squeeze.py | 13 +++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/WrightTools/data/_data.py b/WrightTools/data/_data.py index dd1b7866c..0750712c3 100644 --- a/WrightTools/data/_data.py +++ b/WrightTools/data/_data.py @@ -365,7 +365,7 @@ def squeeze(self, name=None, parent=None): i.e. if the joint shape of the axes has an array dimension with length 1, this array dimension is squeezed. - channels and variables that span beyond the axes are omitted. + channels and variables that span beyond the axes are removed. Parameters ---------- @@ -408,8 +408,6 @@ def squeeze(self, name=None, parent=None): } new.attrs.update(attrs) - # TODO: deal with constants? establish new constants? - joint_shape = wt_kit.joint_shape(*[ai[:] for ai in self.axes]) cull_dims = [j == 1 for j in joint_shape] sl = [0 if cull else slice(None) for cull in cull_dims] @@ -427,6 +425,10 @@ def squeeze(self, name=None, parent=None): kwargs["values"] = c[sl] new.create_channel(**kwargs) + # inherit constants + for c in self.constants: + new.create_constant(c.expression) + new.transform(*self.axis_expressions) return new diff --git a/tests/data/squeeze.py b/tests/data/squeeze.py index a89d6c6d3..4fca80bc8 100644 --- a/tests/data/squeeze.py +++ b/tests/data/squeeze.py @@ -27,6 +27,19 @@ def test_squeeze(): assert d.ndim == 2 assert d.shape == (5, 4) +def test_constants(): + d = wt.Data(name="test") + d.create_variable("x", values=np.array([1]).reshape(1,1)) + d.create_constant("x") + d.create_variable("y", values=np.linspace(3,5,4).reshape(-1,1)) + d.create_variable("z", values=np.linspace(0,1,6).reshape(1,-1)) + d.transform("y") + ds = d.squeeze() + assert "x" in ds.constant_expressions + d.print_tree() + ds.print_tree() + if __name__ == "__main__": test_squeeze() + test_constants() From b71c8386cd836940454228bdf17068084e938ce3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 26 Jan 2024 14:48:39 +0000 Subject: [PATCH 17/27] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/data/squeeze.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/data/squeeze.py b/tests/data/squeeze.py index 4fca80bc8..518d478fa 100644 --- a/tests/data/squeeze.py +++ b/tests/data/squeeze.py @@ -27,12 +27,13 @@ def test_squeeze(): assert d.ndim == 2 assert d.shape == (5, 4) + def test_constants(): d = wt.Data(name="test") - d.create_variable("x", values=np.array([1]).reshape(1,1)) + d.create_variable("x", values=np.array([1]).reshape(1, 1)) d.create_constant("x") - d.create_variable("y", values=np.linspace(3,5,4).reshape(-1,1)) - d.create_variable("z", values=np.linspace(0,1,6).reshape(1,-1)) + d.create_variable("y", values=np.linspace(3, 5, 4).reshape(-1, 1)) + d.create_variable("z", values=np.linspace(0, 1, 6).reshape(1, -1)) d.transform("y") ds = d.squeeze() assert "x" in ds.constant_expressions From ad29137551bad0f6fcd18540085091b9f424cea8 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Fri, 26 Jan 2024 14:55:31 -0600 Subject: [PATCH 18/27] implement value check --- CHANGELOG.md | 1 + WrightTools/data/_join.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd1d095c8..0aa5a5b6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Fixed - `interact2D`: fixed bug where use_imshow broke the sliders +- 'join' ensures valid `method` is selected ## [3.5.0] diff --git a/WrightTools/data/_join.py b/WrightTools/data/_join.py index 9728540ae..22d40fc64 100644 --- a/WrightTools/data/_join.py +++ b/WrightTools/data/_join.py @@ -76,6 +76,9 @@ def join( warnings.warn("join", category=wt_exceptions.EntireDatasetInMemoryWarning) if isinstance(datas, Collection): datas = datas.values() + valid_methods = ["first", "last", "min", "max", "mean", "sum"] + if method not in valid_methods: + raise ValueError(f"invalid method expected {valid_methods}, not {method!r}") datas = list(datas) if not isinstance(atol, collections.abc.Iterable): atol = [atol] * len(datas[0].axes) From 7e760fe28d06df62c37ffc51a8930be5ccff76b9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 26 Jan 2024 21:01:53 +0000 Subject: [PATCH 19/27] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- WrightTools/data/_join.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WrightTools/data/_join.py b/WrightTools/data/_join.py index 22d40fc64..8b56a7185 100644 --- a/WrightTools/data/_join.py +++ b/WrightTools/data/_join.py @@ -76,7 +76,7 @@ def join( warnings.warn("join", category=wt_exceptions.EntireDatasetInMemoryWarning) if isinstance(datas, Collection): datas = datas.values() - valid_methods = ["first", "last", "min", "max", "mean", "sum"] + valid_methods = ["first", "last", "min", "max", "mean", "sum"] if method not in valid_methods: raise ValueError(f"invalid method expected {valid_methods}, not {method!r}") datas = list(datas) @@ -180,7 +180,7 @@ def get_shape(out, datas, item_name): out.create_channel( shape=get_shape(out, datas, channel_name), **datas[0][channel_name].attrs, - dtype=datas[0][channel_name].dtype + dtype=datas[0][channel_name].dtype, ) count[channel_name] = np.zeros_like(out[channel_name], dtype=int) for variable_name in variable_names: @@ -189,7 +189,7 @@ def get_shape(out, datas, item_name): out.create_variable( shape=get_shape(out, datas, variable_name), **datas[0][variable_name].attrs, - dtype=datas[0][variable_name].dtype + dtype=datas[0][variable_name].dtype, ) count[variable_name] = np.zeros_like(out[variable_name], dtype=int) From 4324a2907d27ed9574a8ee59c9aa047980470103 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Fri, 26 Jan 2024 16:53:36 -0600 Subject: [PATCH 20/27] join: remove sum method --- CHANGELOG.md | 3 ++- WrightTools/data/_join.py | 2 +- tests/data/join.py | 24 ------------------------ 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aa5a5b6c..4c0a48fa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Fixed - `interact2D`: fixed bug where use_imshow broke the sliders -- 'join' ensures valid `method` is selected +- `data.join` ensures valid `method` is selected +- `data.join` no longer supports `sum` method ## [3.5.0] diff --git a/WrightTools/data/_join.py b/WrightTools/data/_join.py index 8b56a7185..9eb7b3697 100644 --- a/WrightTools/data/_join.py +++ b/WrightTools/data/_join.py @@ -76,7 +76,7 @@ def join( warnings.warn("join", category=wt_exceptions.EntireDatasetInMemoryWarning) if isinstance(datas, Collection): datas = datas.values() - valid_methods = ["first", "last", "min", "max", "mean", "sum"] + valid_methods = ["first", "last", "min", "max", "mean"] if method not in valid_methods: raise ValueError(f"invalid method expected {valid_methods}, not {method!r}") datas = list(datas) diff --git a/tests/data/join.py b/tests/data/join.py index adb4a2b37..7107bafa2 100755 --- a/tests/data/join.py +++ b/tests/data/join.py @@ -515,30 +515,6 @@ def test_overlap_last(): joined.close() -def test_overlap_sum(): - a = wt.Data() - b = wt.Data() - - a.create_variable("x", np.linspace(0, 10, 11)) - b.create_variable("x", np.linspace(5, 15, 11)) - a.transform("x") - b.transform("x") - a.create_channel("y", np.ones_like(a.x[:])) - b.create_channel("y", np.ones_like(b.x[:]) * 2) - - joined = wt.data.join([a, b], method="sum") - - assert joined.shape == (16,) - assert np.allclose(joined.x.points, np.linspace(0, 15, 16)) - assert np.isclose(joined.y[0], 1.0) - assert np.isclose(joined.y[10], 3.0) - assert np.isclose(joined.y[-1], 2.0) - - a.close() - b.close() - joined.close() - - def test_overlap_max(): a = wt.Data() b = wt.Data() From 7d3534956dec513e7fac163d69581e47f9b56df0 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Fri, 26 Jan 2024 16:57:07 -0600 Subject: [PATCH 21/27] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c0a48fa6..a8c2ed7bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Fixed - `interact2D`: fixed bug where use_imshow broke the sliders - `data.join` ensures valid `method` is selected + +### Changed - `data.join` no longer supports `sum` method ## [3.5.0] From 1bfb08284a3ba4cb8c54a80d167769113357400f Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Fri, 26 Jan 2024 17:17:13 -0600 Subject: [PATCH 22/27] Update join.py --- examples/join.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/join.py b/examples/join.py index 3277bf1a1..417dffeb7 100644 --- a/examples/join.py +++ b/examples/join.py @@ -25,12 +25,11 @@ last = wt.data.join([a, b], method="last", name="last") min = wt.data.join([a, b], method="min", name="min") max = wt.data.join([a, b], method="max", name="max") -sum = wt.data.join([a, b], method="sum", name="sum") mean = wt.data.join([a, b], method="mean", name="mean") # Plot the splits in columns fig, gs = wt.artists.create_figure(nrows=4, cols=[1, 1]) -for i, da in enumerate([a, b, first, last, min, max, sum, mean]): +for i, da in enumerate([a, b, first, last, min, max, mean]): ax = plt.subplot(gs[i]) ax.pcolor(da, vmin=0, vmax=6) wt.artists.corner_text(da.natural_name, ax=ax) From 8a290eb608e9d19151dfd684f88839a64a18cbf4 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:23:46 -0600 Subject: [PATCH 23/27] documentation --- WrightTools/data/_join.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WrightTools/data/_join.py b/WrightTools/data/_join.py index 9eb7b3697..5f7275e18 100644 --- a/WrightTools/data/_join.py +++ b/WrightTools/data/_join.py @@ -62,7 +62,7 @@ def join( The name for the data object which is created. Default is 'join'. parent : WrightTools.Collection (optional) The location to place the joined data object. Default is new temp file at root. - method : {'first', 'last', 'min', 'max', 'sum', 'mean'} + method : {'first', 'last', 'min', 'max', 'mean'} Mode to use for merged points in the joined space. Default is 'first'. verbose : bool (optional) @@ -78,7 +78,9 @@ def join( datas = datas.values() valid_methods = ["first", "last", "min", "max", "mean"] if method not in valid_methods: - raise ValueError(f"invalid method expected {valid_methods}, not {method!r}") + if method == "sum": + raise ValueError(f"method 'sum' is deprecated; consider 'mean' instead.") + raise ValueError(f"invalid method {method!r}: expected {valid_methods}") datas = list(datas) if not isinstance(atol, collections.abc.Iterable): atol = [atol] * len(datas[0].axes) From 2350270e2a19ce0c96152713a69514dbf851e871 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:49:28 -0600 Subject: [PATCH 24/27] [pre-commit.ci] pre-commit autoupdate (#1151) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1) * [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> --- .pre-commit-config.yaml | 2 +- WrightTools/__init__.py | 1 + WrightTools/__version__.py | 1 - WrightTools/__wt5_version__.py | 1 - WrightTools/_close.py | 1 - WrightTools/_dataset.py | 1 - WrightTools/_group.py | 1 - WrightTools/_open.py | 1 - WrightTools/artists/__init__.py | 1 + WrightTools/artists/_base.py | 1 - WrightTools/artists/_colors.py | 1 - WrightTools/artists/_helpers.py | 1 - WrightTools/artists/_quick.py | 1 - WrightTools/artists/_turbo.py | 1 - WrightTools/collection/__init__.py | 1 + WrightTools/collection/_cary.py | 1 - WrightTools/collection/_collection.py | 1 - WrightTools/collection/_directory.py | 1 - WrightTools/data/__init__.py | 1 + WrightTools/data/_aramis.py | 1 - WrightTools/data/_axis.py | 1 - WrightTools/data/_brunold.py | 1 - WrightTools/data/_channel.py | 1 - WrightTools/data/_colors.py | 1 - WrightTools/data/_constant.py | 1 - WrightTools/data/_data.py | 1 - WrightTools/data/_jasco.py | 1 - WrightTools/data/_join.py | 1 - WrightTools/data/_kent.py | 1 - WrightTools/data/_ocean_optics.py | 1 - WrightTools/data/_pycmds.py | 1 - WrightTools/data/_shimadzu.py | 1 - WrightTools/data/_solis.py | 1 - WrightTools/data/_spcm.py | 1 - WrightTools/data/_tensor27.py | 1 - WrightTools/data/_variable.py | 1 - WrightTools/datasets/__init__.py | 1 - WrightTools/diagrams/WMEL.py | 1 - WrightTools/diagrams/__init__.py | 1 + WrightTools/diagrams/delay.py | 1 - WrightTools/exceptions.py | 1 - WrightTools/kit/__init__.py | 1 + WrightTools/kit/_array.py | 1 - WrightTools/kit/_calculate.py | 1 - WrightTools/kit/_discover_dimensions.py | 1 - WrightTools/kit/_ini.py | 1 - WrightTools/kit/_interpolate.py | 1 - WrightTools/kit/_leastsq.py | 1 - WrightTools/kit/_lineshapes.py | 1 - WrightTools/kit/_list.py | 1 - WrightTools/kit/_path.py | 1 - WrightTools/kit/_timestamp.py | 1 - WrightTools/kit/_unicode.py | 1 - WrightTools/kit/_utilities.py | 1 - WrightTools/units.py | 1 - examples/join.py | 1 + examples/split.py | 1 + logo/logo.py | 1 - tests/base.py | 1 - tests/data/axis/convert_axis.py | 1 - tests/data/bring_to_front.py | 1 - tests/data/channel/normalize.py | 1 - tests/data/channel/null.py | 1 - tests/data/from_Aramis.py | 1 - tests/data/from_BrunoldrRaman.py | 1 - tests/data/from_JASCO.py | 1 - tests/data/from_KENT.py | 1 - tests/data/from_Solis.py | 1 - tests/data/from_Tensor27.py | 1 - tests/data/from_ocean_optics.py | 1 - tests/data/from_shimadzu.py | 1 - tests/data/from_spcm.py | 1 - tests/data/map_variable.py | 1 - tests/data/prune.py | 1 - tests/data/remove_channel.py | 1 - tests/data/rename_channels.py | 1 - tests/data/rename_variables.py | 1 - tests/data/smooth.py | 1 - tests/data/transform.py | 1 - tests/data/translate_to_txt.py | 1 - tests/dataset/argmax.py | 1 - tests/dataset/argmin.py | 1 - tests/dataset/clip.py | 1 - tests/dataset/convert_dataset.py | 1 - tests/dataset/iadd.py | 1 - tests/dataset/imul.py | 1 - tests/dataset/ipow.py | 1 - tests/dataset/isub.py | 1 - tests/dataset/itruediv.py | 1 - tests/dataset/log.py | 1 - tests/dataset/max.py | 1 - tests/dataset/min.py | 1 - tests/dataset/symmetric_root.py | 1 - tests/docs/_sphinx.py | 1 + tests/group/attributes.py | 1 - tests/kit/closest_pair.py | 1 - tests/kit/diff.py | 1 - tests/kit/fft.py | 1 - tests/kit/flatten_list.py | 1 - tests/kit/fluence.py | 1 - tests/kit/get_index.py | 1 - tests/kit/get_path_matching.py | 1 - tests/kit/glob_handler.py | 1 - tests/kit/intersperse.py | 1 - tests/kit/joint_shape.py | 1 - tests/kit/lineshapes.py | 1 - tests/kit/nm_width.py | 1 - tests/kit/smooth_1D.py | 1 - tests/kit/string2identifier.py | 1 - tests/kit/symmetric_sqrt.py | 1 - tests/kit/timer.py | 1 - tests/kit/timestamp.py | 1 - tests/kit/unicode.py | 1 - tests/kit/unique.py | 1 - tests/kit/valid_index.py | 1 - tests/units.py | 1 - 116 files changed, 10 insertions(+), 107 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 083db35ca..6b3e80e40 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/psf/black - rev: 23.12.1 # Replace by any tag/version: https://github.com/psf/black/tags + rev: 24.1.1 # Replace by any tag/version: https://github.com/psf/black/tags hooks: - id: black language_version: python3 # Should be a command that runs python3.6+ diff --git a/WrightTools/__init__.py b/WrightTools/__init__.py index 06a2c1a62..cc9828e56 100644 --- a/WrightTools/__init__.py +++ b/WrightTools/__init__.py @@ -1,4 +1,5 @@ """WrightTools init.""" + # flake8: noqa diff --git a/WrightTools/__version__.py b/WrightTools/__version__.py index 5f7bc51a1..c6b87937c 100644 --- a/WrightTools/__version__.py +++ b/WrightTools/__version__.py @@ -1,6 +1,5 @@ """Define WrightTools version.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/__wt5_version__.py b/WrightTools/__wt5_version__.py index fe9ac8dd3..37847a68c 100644 --- a/WrightTools/__wt5_version__.py +++ b/WrightTools/__wt5_version__.py @@ -1,6 +1,5 @@ """Define wt5 version.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/_close.py b/WrightTools/_close.py index 5f60da747..b34d59b22 100644 --- a/WrightTools/_close.py +++ b/WrightTools/_close.py @@ -1,6 +1,5 @@ """Function to close all open wt5 files.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/WrightTools/_dataset.py b/WrightTools/_dataset.py index cbaa68135..9eae09ae0 100644 --- a/WrightTools/_dataset.py +++ b/WrightTools/_dataset.py @@ -1,6 +1,5 @@ """Dataset base class.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/_group.py b/WrightTools/_group.py index 271834a88..94de63c66 100644 --- a/WrightTools/_group.py +++ b/WrightTools/_group.py @@ -1,6 +1,5 @@ """Group base class.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/_open.py b/WrightTools/_open.py index 0c2360b92..85c805167 100644 --- a/WrightTools/_open.py +++ b/WrightTools/_open.py @@ -1,6 +1,5 @@ """Generic open method for wt5 files.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/WrightTools/artists/__init__.py b/WrightTools/artists/__init__.py index 488d113b3..0c76a418e 100644 --- a/WrightTools/artists/__init__.py +++ b/WrightTools/artists/__init__.py @@ -1,4 +1,5 @@ """Artists.""" + # flake8: noqa diff --git a/WrightTools/artists/_base.py b/WrightTools/artists/_base.py index ce20b4371..7d880b82f 100644 --- a/WrightTools/artists/_base.py +++ b/WrightTools/artists/_base.py @@ -1,6 +1,5 @@ """Base tools for visualizing data.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/artists/_colors.py b/WrightTools/artists/_colors.py index cc852013a..e371af3e1 100644 --- a/WrightTools/artists/_colors.py +++ b/WrightTools/artists/_colors.py @@ -1,6 +1,5 @@ """Colormaps.""" - # --- import -------------------------------------------------------------------------------------- import copy diff --git a/WrightTools/artists/_helpers.py b/WrightTools/artists/_helpers.py index c45a4f097..3ead0c53d 100644 --- a/WrightTools/artists/_helpers.py +++ b/WrightTools/artists/_helpers.py @@ -1,6 +1,5 @@ """Functions to help with plotting.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/artists/_quick.py b/WrightTools/artists/_quick.py index 8420f77eb..a08abf700 100644 --- a/WrightTools/artists/_quick.py +++ b/WrightTools/artists/_quick.py @@ -1,6 +1,5 @@ """Quick plotting.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/artists/_turbo.py b/WrightTools/artists/_turbo.py index 7ec18aed8..09fb2bff0 100644 --- a/WrightTools/artists/_turbo.py +++ b/WrightTools/artists/_turbo.py @@ -1,6 +1,5 @@ """Define turbo colormap.""" - # Copyright 2019 Google LLC. # SPDX-License-Identifier: Apache-2.0 diff --git a/WrightTools/collection/__init__.py b/WrightTools/collection/__init__.py index 98069cce2..f3b82369b 100644 --- a/WrightTools/collection/__init__.py +++ b/WrightTools/collection/__init__.py @@ -1,4 +1,5 @@ """Collection class and associated.""" + # flake8: noqa diff --git a/WrightTools/collection/_cary.py b/WrightTools/collection/_cary.py index 67d231827..06a7a18c3 100644 --- a/WrightTools/collection/_cary.py +++ b/WrightTools/collection/_cary.py @@ -1,6 +1,5 @@ """Cary.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/collection/_collection.py b/WrightTools/collection/_collection.py index 7b19866ae..9f9d51991 100644 --- a/WrightTools/collection/_collection.py +++ b/WrightTools/collection/_collection.py @@ -1,6 +1,5 @@ """Collection.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/collection/_directory.py b/WrightTools/collection/_directory.py index 9f269b6d7..ebef2a4b2 100644 --- a/WrightTools/collection/_directory.py +++ b/WrightTools/collection/_directory.py @@ -1,6 +1,5 @@ """Cary.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/__init__.py b/WrightTools/data/__init__.py index 214a1704c..cc30bd67a 100644 --- a/WrightTools/data/__init__.py +++ b/WrightTools/data/__init__.py @@ -1,4 +1,5 @@ """Data class and associated.""" + # flake8: noqa diff --git a/WrightTools/data/_aramis.py b/WrightTools/data/_aramis.py index 82f4cfc5e..bb825c0d2 100644 --- a/WrightTools/data/_aramis.py +++ b/WrightTools/data/_aramis.py @@ -1,6 +1,5 @@ """Aramis.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_axis.py b/WrightTools/data/_axis.py index 2b630c2e1..3beb687a6 100644 --- a/WrightTools/data/_axis.py +++ b/WrightTools/data/_axis.py @@ -1,6 +1,5 @@ """Axis class and associated.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_brunold.py b/WrightTools/data/_brunold.py index 7942ae669..048eb395b 100644 --- a/WrightTools/data/_brunold.py +++ b/WrightTools/data/_brunold.py @@ -1,6 +1,5 @@ """Brunold.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_channel.py b/WrightTools/data/_channel.py index c495c487c..b820dea06 100644 --- a/WrightTools/data/_channel.py +++ b/WrightTools/data/_channel.py @@ -1,6 +1,5 @@ """Channel class and associated.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_colors.py b/WrightTools/data/_colors.py index 86b9bb2b2..d0ba1cd48 100644 --- a/WrightTools/data/_colors.py +++ b/WrightTools/data/_colors.py @@ -1,6 +1,5 @@ """COLORS.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_constant.py b/WrightTools/data/_constant.py index 5084a533a..63ab3129b 100644 --- a/WrightTools/data/_constant.py +++ b/WrightTools/data/_constant.py @@ -1,6 +1,5 @@ """Constant class and associated.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_data.py b/WrightTools/data/_data.py index 86d496d31..cdec37c4f 100644 --- a/WrightTools/data/_data.py +++ b/WrightTools/data/_data.py @@ -1,6 +1,5 @@ """Central data class and associated.""" - # --- import -------------------------------------------------------------------------------------- from __future__ import annotations diff --git a/WrightTools/data/_jasco.py b/WrightTools/data/_jasco.py index 7d76b1981..c652f5ba0 100644 --- a/WrightTools/data/_jasco.py +++ b/WrightTools/data/_jasco.py @@ -1,6 +1,5 @@ """JASCO.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_join.py b/WrightTools/data/_join.py index 5f7275e18..dc0a7fc55 100644 --- a/WrightTools/data/_join.py +++ b/WrightTools/data/_join.py @@ -1,6 +1,5 @@ """Join multiple data objects together.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_kent.py b/WrightTools/data/_kent.py index c17c25d24..38435b384 100644 --- a/WrightTools/data/_kent.py +++ b/WrightTools/data/_kent.py @@ -1,6 +1,5 @@ """Kent Meyer.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_ocean_optics.py b/WrightTools/data/_ocean_optics.py index 02f670bea..6541c555c 100644 --- a/WrightTools/data/_ocean_optics.py +++ b/WrightTools/data/_ocean_optics.py @@ -1,6 +1,5 @@ """Ocean Optics.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_pycmds.py b/WrightTools/data/_pycmds.py index 9e69d9df4..3f13fdfa1 100644 --- a/WrightTools/data/_pycmds.py +++ b/WrightTools/data/_pycmds.py @@ -1,6 +1,5 @@ """PyCMDS.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_shimadzu.py b/WrightTools/data/_shimadzu.py index 6a0e3421f..00dbdd7e4 100644 --- a/WrightTools/data/_shimadzu.py +++ b/WrightTools/data/_shimadzu.py @@ -1,6 +1,5 @@ """Shimadzu.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_solis.py b/WrightTools/data/_solis.py index 207c8f345..c9ce5ce21 100644 --- a/WrightTools/data/_solis.py +++ b/WrightTools/data/_solis.py @@ -1,6 +1,5 @@ """Andor.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_spcm.py b/WrightTools/data/_spcm.py index 42132bf81..ab9737fbf 100644 --- a/WrightTools/data/_spcm.py +++ b/WrightTools/data/_spcm.py @@ -1,6 +1,5 @@ """SPCM.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_tensor27.py b/WrightTools/data/_tensor27.py index 1cb2cb916..c030e6e30 100644 --- a/WrightTools/data/_tensor27.py +++ b/WrightTools/data/_tensor27.py @@ -1,6 +1,5 @@ """Tensor 27.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/data/_variable.py b/WrightTools/data/_variable.py index f5ebe5d42..32e856029 100644 --- a/WrightTools/data/_variable.py +++ b/WrightTools/data/_variable.py @@ -1,6 +1,5 @@ """Variable class and associated.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/datasets/__init__.py b/WrightTools/datasets/__init__.py index e9762b445..b29bd2f38 100644 --- a/WrightTools/datasets/__init__.py +++ b/WrightTools/datasets/__init__.py @@ -1,6 +1,5 @@ """Datasets.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/diagrams/WMEL.py b/WrightTools/diagrams/WMEL.py index d8464f083..621de7d6e 100644 --- a/WrightTools/diagrams/WMEL.py +++ b/WrightTools/diagrams/WMEL.py @@ -1,6 +1,5 @@ """WMEL diagrams.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/diagrams/__init__.py b/WrightTools/diagrams/__init__.py index 331ba7fe2..752f6ec1e 100644 --- a/WrightTools/diagrams/__init__.py +++ b/WrightTools/diagrams/__init__.py @@ -1,4 +1,5 @@ """Diagrams.""" + # flake8: noqa from . import delay diff --git a/WrightTools/diagrams/delay.py b/WrightTools/diagrams/delay.py index 231c9df8b..6c83d5077 100644 --- a/WrightTools/diagrams/delay.py +++ b/WrightTools/diagrams/delay.py @@ -1,6 +1,5 @@ """Delay space.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/exceptions.py b/WrightTools/exceptions.py index 237591742..f5d719cbc 100644 --- a/WrightTools/exceptions.py +++ b/WrightTools/exceptions.py @@ -1,6 +1,5 @@ """Custom exception types.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/kit/__init__.py b/WrightTools/kit/__init__.py index a1966fbe1..c9196e64a 100644 --- a/WrightTools/kit/__init__.py +++ b/WrightTools/kit/__init__.py @@ -1,4 +1,5 @@ """General-purpose tool kit.""" + # flake8: noqa from ._array import * diff --git a/WrightTools/kit/_array.py b/WrightTools/kit/_array.py index 51971cc2d..c4c13c495 100644 --- a/WrightTools/kit/_array.py +++ b/WrightTools/kit/_array.py @@ -1,6 +1,5 @@ """Array interaction tools.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/kit/_calculate.py b/WrightTools/kit/_calculate.py index d071576b9..8b98e6406 100644 --- a/WrightTools/kit/_calculate.py +++ b/WrightTools/kit/_calculate.py @@ -1,6 +1,5 @@ """Calculate.""" - # --- import ------------------------------------------------------------- diff --git a/WrightTools/kit/_discover_dimensions.py b/WrightTools/kit/_discover_dimensions.py index 02282e210..c3f963c5e 100644 --- a/WrightTools/kit/_discover_dimensions.py +++ b/WrightTools/kit/_discover_dimensions.py @@ -1,6 +1,5 @@ """Discover dimensions of a flattened ND array.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/kit/_ini.py b/WrightTools/kit/_ini.py index b15fa5150..778cff917 100644 --- a/WrightTools/kit/_ini.py +++ b/WrightTools/kit/_ini.py @@ -1,6 +1,5 @@ """Tools for interacting with ini files.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/kit/_interpolate.py b/WrightTools/kit/_interpolate.py index c2cedf2c1..b339d2922 100644 --- a/WrightTools/kit/_interpolate.py +++ b/WrightTools/kit/_interpolate.py @@ -1,6 +1,5 @@ """Interpolation tools.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/kit/_leastsq.py b/WrightTools/kit/_leastsq.py index d448ba367..40face4c5 100644 --- a/WrightTools/kit/_leastsq.py +++ b/WrightTools/kit/_leastsq.py @@ -1,6 +1,5 @@ """Least-square fitting tools.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/kit/_lineshapes.py b/WrightTools/kit/_lineshapes.py index 12986b66e..7fc8f8d16 100644 --- a/WrightTools/kit/_lineshapes.py +++ b/WrightTools/kit/_lineshapes.py @@ -1,6 +1,5 @@ """Lineshapes.""" - # --- import ------------------------------------------------------------- diff --git a/WrightTools/kit/_list.py b/WrightTools/kit/_list.py index 169fb542b..854653c76 100644 --- a/WrightTools/kit/_list.py +++ b/WrightTools/kit/_list.py @@ -1,6 +1,5 @@ """Tools for working with lists.""" - # --- import -------------------------------------------------------------------------------------- import itertools diff --git a/WrightTools/kit/_path.py b/WrightTools/kit/_path.py index ef1dd7560..9e386b615 100644 --- a/WrightTools/kit/_path.py +++ b/WrightTools/kit/_path.py @@ -1,6 +1,5 @@ """Filepath functions.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/kit/_timestamp.py b/WrightTools/kit/_timestamp.py index 45000f5f6..04f8ec3cb 100644 --- a/WrightTools/kit/_timestamp.py +++ b/WrightTools/kit/_timestamp.py @@ -1,6 +1,5 @@ """Timestamp class and associated.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/kit/_unicode.py b/WrightTools/kit/_unicode.py index cee0cecfd..5a1e6964b 100644 --- a/WrightTools/kit/_unicode.py +++ b/WrightTools/kit/_unicode.py @@ -1,6 +1,5 @@ """Unicode.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/kit/_utilities.py b/WrightTools/kit/_utilities.py index ca6e8fecb..cb955d68f 100644 --- a/WrightTools/kit/_utilities.py +++ b/WrightTools/kit/_utilities.py @@ -1,6 +1,5 @@ """Utilities.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/WrightTools/units.py b/WrightTools/units.py index 5bcf82198..370d424f5 100644 --- a/WrightTools/units.py +++ b/WrightTools/units.py @@ -1,6 +1,5 @@ """Unit and label handling in WrightTools.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/examples/join.py b/examples/join.py index 417dffeb7..7647076ca 100644 --- a/examples/join.py +++ b/examples/join.py @@ -4,6 +4,7 @@ Some examples of how joining works. """ + import numpy as np from matplotlib import pyplot as plt import WrightTools as wt diff --git a/examples/split.py b/examples/split.py index 4b17ad948..db704335a 100644 --- a/examples/split.py +++ b/examples/split.py @@ -4,6 +4,7 @@ Some examples of how splitting works. """ + from matplotlib import pyplot as plt import WrightTools as wt from WrightTools import datasets diff --git a/logo/logo.py b/logo/logo.py index 12cc22b66..9ad84a432 100644 --- a/logo/logo.py +++ b/logo/logo.py @@ -1,6 +1,5 @@ """Generate WrightTools logo.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/base.py b/tests/base.py index b43c9b3b9..ae5daf661 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,6 +1,5 @@ """Test basic instantiation and handling.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/axis/convert_axis.py b/tests/data/axis/convert_axis.py index b4bb0403c..1198358ff 100644 --- a/tests/data/axis/convert_axis.py +++ b/tests/data/axis/convert_axis.py @@ -1,6 +1,5 @@ """Test axis unit conversion.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/bring_to_front.py b/tests/data/bring_to_front.py index d777c382f..f0cb8bf1f 100644 --- a/tests/data/bring_to_front.py +++ b/tests/data/bring_to_front.py @@ -1,6 +1,5 @@ """Test data bring_to_front.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/channel/normalize.py b/tests/data/channel/normalize.py index 423913c1d..3e4a4f311 100644 --- a/tests/data/channel/normalize.py +++ b/tests/data/channel/normalize.py @@ -1,6 +1,5 @@ """Test channel normalize.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/channel/null.py b/tests/data/channel/null.py index 06ecde6c3..e11d3ba97 100644 --- a/tests/data/channel/null.py +++ b/tests/data/channel/null.py @@ -1,6 +1,5 @@ """Tests to do with null.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/from_Aramis.py b/tests/data/from_Aramis.py index b6aa759ea..efa6ae2a1 100644 --- a/tests/data/from_Aramis.py +++ b/tests/data/from_Aramis.py @@ -1,6 +1,5 @@ """Test from_Aramis.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/from_BrunoldrRaman.py b/tests/data/from_BrunoldrRaman.py index c7604d574..312852ddb 100644 --- a/tests/data/from_BrunoldrRaman.py +++ b/tests/data/from_BrunoldrRaman.py @@ -1,6 +1,5 @@ """test from_BrunoldrRaman""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/from_JASCO.py b/tests/data/from_JASCO.py index 1715271ef..7ce2f3845 100644 --- a/tests/data/from_JASCO.py +++ b/tests/data/from_JASCO.py @@ -1,6 +1,5 @@ """test from_JASCO""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/from_KENT.py b/tests/data/from_KENT.py index 6bf34499f..e31c2f74f 100644 --- a/tests/data/from_KENT.py +++ b/tests/data/from_KENT.py @@ -1,6 +1,5 @@ """test from_KENT""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/from_Solis.py b/tests/data/from_Solis.py index c29657272..e78741670 100644 --- a/tests/data/from_Solis.py +++ b/tests/data/from_Solis.py @@ -1,6 +1,5 @@ """test from_JASCO""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/from_Tensor27.py b/tests/data/from_Tensor27.py index 6a857015b..e902d5f28 100644 --- a/tests/data/from_Tensor27.py +++ b/tests/data/from_Tensor27.py @@ -1,6 +1,5 @@ """test from_Tensor27""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/from_ocean_optics.py b/tests/data/from_ocean_optics.py index 708581271..c65d163cc 100644 --- a/tests/data/from_ocean_optics.py +++ b/tests/data/from_ocean_optics.py @@ -1,6 +1,5 @@ """Test from_ocean_optics.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/from_shimadzu.py b/tests/data/from_shimadzu.py index 711e82c70..cfc285bdb 100644 --- a/tests/data/from_shimadzu.py +++ b/tests/data/from_shimadzu.py @@ -1,6 +1,5 @@ """test from_shimadzu""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/from_spcm.py b/tests/data/from_spcm.py index 975e4b7b2..43a9d8714 100644 --- a/tests/data/from_spcm.py +++ b/tests/data/from_spcm.py @@ -1,6 +1,5 @@ """Test from_spcm.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/map_variable.py b/tests/data/map_variable.py index dda19dfed..961fddbbb 100644 --- a/tests/data/map_variable.py +++ b/tests/data/map_variable.py @@ -1,6 +1,5 @@ """Test map_variable.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/prune.py b/tests/data/prune.py index e23e022f8..f211581b6 100644 --- a/tests/data/prune.py +++ b/tests/data/prune.py @@ -1,6 +1,5 @@ """Test remove channel.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/remove_channel.py b/tests/data/remove_channel.py index 19769c4ae..1dabe9f70 100644 --- a/tests/data/remove_channel.py +++ b/tests/data/remove_channel.py @@ -1,6 +1,5 @@ """Test remove channel.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/rename_channels.py b/tests/data/rename_channels.py index 4957af671..a7e5773e7 100644 --- a/tests/data/rename_channels.py +++ b/tests/data/rename_channels.py @@ -1,6 +1,5 @@ """Test rename_channel.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/rename_variables.py b/tests/data/rename_variables.py index 28c3ac8c5..7839362cd 100644 --- a/tests/data/rename_variables.py +++ b/tests/data/rename_variables.py @@ -1,6 +1,5 @@ """Test rename_variable.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/smooth.py b/tests/data/smooth.py index 8b6d81099..f06c77fe6 100644 --- a/tests/data/smooth.py +++ b/tests/data/smooth.py @@ -1,6 +1,5 @@ """Test data.smooth.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/transform.py b/tests/data/transform.py index b7cc7b64e..ccd265503 100644 --- a/tests/data/transform.py +++ b/tests/data/transform.py @@ -1,6 +1,5 @@ """Test transform.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/data/translate_to_txt.py b/tests/data/translate_to_txt.py index c383e056f..e73ed339b 100644 --- a/tests/data/translate_to_txt.py +++ b/tests/data/translate_to_txt.py @@ -1,6 +1,5 @@ """Test transform.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/dataset/argmax.py b/tests/dataset/argmax.py index 1cd306119..6bf2db04d 100644 --- a/tests/dataset/argmax.py +++ b/tests/dataset/argmax.py @@ -1,6 +1,5 @@ """Test dataset argmax method.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/dataset/argmin.py b/tests/dataset/argmin.py index d765bb55a..235e07e2d 100644 --- a/tests/dataset/argmin.py +++ b/tests/dataset/argmin.py @@ -1,6 +1,5 @@ """Test dataset min method.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/dataset/clip.py b/tests/dataset/clip.py index c1a0a8969..c70d0ca4d 100644 --- a/tests/dataset/clip.py +++ b/tests/dataset/clip.py @@ -1,6 +1,5 @@ """Test clipping.""" - # --- import -------------------------------------------------------------------------------------- import WrightTools as wt diff --git a/tests/dataset/convert_dataset.py b/tests/dataset/convert_dataset.py index 5428d3830..d35f25b25 100644 --- a/tests/dataset/convert_dataset.py +++ b/tests/dataset/convert_dataset.py @@ -1,6 +1,5 @@ """Test dataset unit conversion.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/dataset/iadd.py b/tests/dataset/iadd.py index a23909c4e..7196dced4 100644 --- a/tests/dataset/iadd.py +++ b/tests/dataset/iadd.py @@ -1,6 +1,5 @@ """Test in place addition.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/dataset/imul.py b/tests/dataset/imul.py index d133d0792..a1be91aab 100644 --- a/tests/dataset/imul.py +++ b/tests/dataset/imul.py @@ -1,6 +1,5 @@ """Test in place multiplication.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/dataset/ipow.py b/tests/dataset/ipow.py index 9fba23072..7291fcd01 100644 --- a/tests/dataset/ipow.py +++ b/tests/dataset/ipow.py @@ -1,6 +1,5 @@ """Test in place power.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/dataset/isub.py b/tests/dataset/isub.py index 7e0a9de9f..8c953efa9 100644 --- a/tests/dataset/isub.py +++ b/tests/dataset/isub.py @@ -1,6 +1,5 @@ """Test in place subtraction.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/dataset/itruediv.py b/tests/dataset/itruediv.py index 562abfbad..32c2239fd 100644 --- a/tests/dataset/itruediv.py +++ b/tests/dataset/itruediv.py @@ -1,6 +1,5 @@ """Test in place division.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/dataset/log.py b/tests/dataset/log.py index 9dc15d63d..6f5c57fd4 100644 --- a/tests/dataset/log.py +++ b/tests/dataset/log.py @@ -1,6 +1,5 @@ """Test log.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/dataset/max.py b/tests/dataset/max.py index 3b2a0b25d..d368538e9 100644 --- a/tests/dataset/max.py +++ b/tests/dataset/max.py @@ -1,6 +1,5 @@ """Test dataset max method.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/dataset/min.py b/tests/dataset/min.py index f43387330..cccb1d3dd 100644 --- a/tests/dataset/min.py +++ b/tests/dataset/min.py @@ -1,6 +1,5 @@ """Test dataset min method.""" - # --- import -------------------------------------------------------------------------------------- import pathlib diff --git a/tests/dataset/symmetric_root.py b/tests/dataset/symmetric_root.py index 0521b8e62..a2aabaa17 100644 --- a/tests/dataset/symmetric_root.py +++ b/tests/dataset/symmetric_root.py @@ -1,6 +1,5 @@ """Test symmetric root.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/docs/_sphinx.py b/tests/docs/_sphinx.py index e7da40cbc..1aab98e1e 100644 --- a/tests/docs/_sphinx.py +++ b/tests/docs/_sphinx.py @@ -1,4 +1,5 @@ """Test building the documentation.""" + from sphinx.cmd import build import os import shutil diff --git a/tests/group/attributes.py b/tests/group/attributes.py index 91a4d6208..e6ddb6e00 100644 --- a/tests/group/attributes.py +++ b/tests/group/attributes.py @@ -1,6 +1,5 @@ """Test getattr and associated.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/kit/closest_pair.py b/tests/kit/closest_pair.py index 20e0e6b73..00d536224 100644 --- a/tests/kit/closest_pair.py +++ b/tests/kit/closest_pair.py @@ -1,6 +1,5 @@ """Test closest pair.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/diff.py b/tests/kit/diff.py index 235f9f5f2..dff1450ea 100644 --- a/tests/kit/diff.py +++ b/tests/kit/diff.py @@ -1,6 +1,5 @@ """Test diff.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/fft.py b/tests/kit/fft.py index 5fb4973c5..6f04b4595 100644 --- a/tests/kit/fft.py +++ b/tests/kit/fft.py @@ -1,6 +1,5 @@ """Test fft.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/kit/flatten_list.py b/tests/kit/flatten_list.py index 129a501fa..388ff1822 100644 --- a/tests/kit/flatten_list.py +++ b/tests/kit/flatten_list.py @@ -1,6 +1,5 @@ """test flatten_list""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/kit/fluence.py b/tests/kit/fluence.py index d926d4618..fe88205fb 100644 --- a/tests/kit/fluence.py +++ b/tests/kit/fluence.py @@ -1,6 +1,5 @@ """Test fluence.""" - # --- import ------------------------------------------------------------- diff --git a/tests/kit/get_index.py b/tests/kit/get_index.py index d372ab726..c601eaec5 100644 --- a/tests/kit/get_index.py +++ b/tests/kit/get_index.py @@ -1,6 +1,5 @@ """Test get_index.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/get_path_matching.py b/tests/kit/get_path_matching.py index 3109f9883..1c8399740 100644 --- a/tests/kit/get_path_matching.py +++ b/tests/kit/get_path_matching.py @@ -1,6 +1,5 @@ """Test get_path_matching.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/glob_handler.py b/tests/kit/glob_handler.py index 035ac2b61..3f6f85945 100644 --- a/tests/kit/glob_handler.py +++ b/tests/kit/glob_handler.py @@ -1,6 +1,5 @@ """Test glob_handler.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/intersperse.py b/tests/kit/intersperse.py index 1cd4b9ff2..c266e67d2 100644 --- a/tests/kit/intersperse.py +++ b/tests/kit/intersperse.py @@ -1,6 +1,5 @@ """Test intersperse.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/joint_shape.py b/tests/kit/joint_shape.py index 60b85f505..d324bc8ab 100644 --- a/tests/kit/joint_shape.py +++ b/tests/kit/joint_shape.py @@ -1,6 +1,5 @@ """Test joint_shape.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/kit/lineshapes.py b/tests/kit/lineshapes.py index 4196f7c10..ccaa59576 100644 --- a/tests/kit/lineshapes.py +++ b/tests/kit/lineshapes.py @@ -1,6 +1,5 @@ """Test lineshapes.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/kit/nm_width.py b/tests/kit/nm_width.py index ad7dbb263..22c14cf18 100644 --- a/tests/kit/nm_width.py +++ b/tests/kit/nm_width.py @@ -1,6 +1,5 @@ """Test nm_width.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/smooth_1D.py b/tests/kit/smooth_1D.py index 264c57fe0..898a204e2 100644 --- a/tests/kit/smooth_1D.py +++ b/tests/kit/smooth_1D.py @@ -1,6 +1,5 @@ """Test kit.smooth_1D.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/kit/string2identifier.py b/tests/kit/string2identifier.py index b5967390b..d8d82021f 100644 --- a/tests/kit/string2identifier.py +++ b/tests/kit/string2identifier.py @@ -1,6 +1,5 @@ """Test string2identifier.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/symmetric_sqrt.py b/tests/kit/symmetric_sqrt.py index 55112d051..70d446495 100644 --- a/tests/kit/symmetric_sqrt.py +++ b/tests/kit/symmetric_sqrt.py @@ -1,6 +1,5 @@ """test symmetric_sqrt""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/kit/timer.py b/tests/kit/timer.py index 9a716c8e5..1447dfd8a 100644 --- a/tests/kit/timer.py +++ b/tests/kit/timer.py @@ -1,6 +1,5 @@ """Test timer.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/timestamp.py b/tests/kit/timestamp.py index f7011e2f5..c174f1ed0 100644 --- a/tests/kit/timestamp.py +++ b/tests/kit/timestamp.py @@ -1,6 +1,5 @@ """Test timestamp.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/unicode.py b/tests/kit/unicode.py index 73b2dcb4f..a49acb620 100644 --- a/tests/kit/unicode.py +++ b/tests/kit/unicode.py @@ -1,6 +1,5 @@ """Test unicode dictionary.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/unique.py b/tests/kit/unique.py index 064341934..f3ba01043 100644 --- a/tests/kit/unique.py +++ b/tests/kit/unique.py @@ -1,6 +1,5 @@ """Test unique.""" - # --- import ------------------------------------------------------------------------------------- diff --git a/tests/kit/valid_index.py b/tests/kit/valid_index.py index 1125a34ca..bd46dd976 100644 --- a/tests/kit/valid_index.py +++ b/tests/kit/valid_index.py @@ -1,6 +1,5 @@ """Test valid index function.""" - # --- import -------------------------------------------------------------------------------------- diff --git a/tests/units.py b/tests/units.py index 2c871a0ad..2214e691c 100644 --- a/tests/units.py +++ b/tests/units.py @@ -1,6 +1,5 @@ """Test units.""" - # --- import ------------------------------------------------------------------------------------- import numpy as np From f772f2ceab2dad1816317296005ad353e28807c0 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:20:17 -0600 Subject: [PATCH 25/27] stitch_to_animation: gif kwargs working again (#1149) * working with v3 api * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update setup.py * Update CHANGELOG.md * add verbose back in * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update _helpers.py use writer * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update setup.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: kameyer226 <61993880+kameyer226@users.noreply.github.com> --- CHANGELOG.md | 1 + WrightTools/artists/_helpers.py | 23 +++++++++++------------ setup.py | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5365eb55c..0833b0519 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Fixed - `interact2D`: fixed bug where use_imshow broke the sliders +- `artists.stitch_to_animation`: use imageio v3 api and declare pillow plugin - `data.join` ensures valid `method` is selected ### Changed diff --git a/WrightTools/artists/_helpers.py b/WrightTools/artists/_helpers.py index 3ead0c53d..1e3232e74 100644 --- a/WrightTools/artists/_helpers.py +++ b/WrightTools/artists/_helpers.py @@ -14,7 +14,7 @@ import matplotlib.patheffects as PathEffects from mpl_toolkits.axes_grid1 import make_axes_locatable -import imageio +import imageio.v3 as iio import warnings from .. import exceptions as wt_exceptions @@ -1081,14 +1081,14 @@ def subplots_adjust(fig=None, inches=1): fig.subplots_adjust(top=top, right=right, bottom=bottom, left=left) -def stitch_to_animation(images, outpath=None, *, duration=0.5, palettesize=256, verbose=True): +def stitch_to_animation(paths, outpath=None, *, duration=0.5, palettesize=256, verbose=True): """Stitch a series of images into an animation. Currently supports animated gifs, other formats coming as needed. Parameters ---------- - images : list of strings + paths : list of strings Filepaths to the images to stitch together, in order of apperence. outpath : string (optional) Path of output, including extension. If None, bases output path on path @@ -1097,22 +1097,21 @@ def stitch_to_animation(images, outpath=None, *, duration=0.5, palettesize=256, Duration of (each) frame in seconds. Default is 0.5. palettesize : int (optional) The number of colors in the resulting animation. Input is rounded to - the nearest power of 2. Default is 1024. + the nearest power of 2. Default is 256. verbose : bool (optional) Toggle talkback. Default is True. """ # parse filename if outpath is None: - outpath = os.path.splitext(images[0])[0] + ".gif" + outpath = os.path.splitext(paths[0])[0] + ".gif" # write t = wt_kit.Timer(verbose=False) - with t, imageio.get_writer( - outpath, mode="I", duration=duration, palettesize=palettesize - ) as writer: - for p in images: - image = imageio.imread(p) - writer.append_data(image) - # finish + with t, iio.imopen(outpath, "w") as gif: + for p in paths: + frame = iio.imread(p) + gif.write( + frame, plugin="pillow", duration=duration * 1e3, loop=0, palettesize=palettesize + ) if verbose: interval = np.round(t.interval, 2) print("gif generated in {0} seconds - saved at {1}".format(interval, outpath)) diff --git a/setup.py b/setup.py index 53d512fd9..6dbb6ded8 100755 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ def read(fname): python_requires=">=3.7", install_requires=[ "h5py", - "imageio", + "imageio>=2.28.0", "matplotlib>=3.4.0", "numexpr", "numpy>=1.15.0", From 1a2fbb91fc0afbe43ba7555a1d51ae3be90e9d3b Mon Sep 17 00:00:00 2001 From: rpm4 <99917976+rpm4@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:47:22 -0600 Subject: [PATCH 26/27] guess_signed (#1128) * Update _array.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update _array.py * Create signed.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update _array.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update _array.py * signed -> guess_signed make function more robust as well * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * tests pass correct the guess function * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update CHANGELOG.md * Update WrightTools/kit/_array.py * [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> Co-authored-by: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> --- CHANGELOG.md | 1 + WrightTools/kit/_array.py | 36 ++++++++++++++++++++++++++++++++++++ tests/kit/signed.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 tests/kit/signed.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 0833b0519..ddbe28355 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ## [Unreleased] ### Added +- `kit.guess_signed` for empirically guessing channel sign (useful for automated workflows) - `Data.squeeze`: squeezing the data object to the shape of the axes. ### Fixed diff --git a/WrightTools/kit/_array.py b/WrightTools/kit/_array.py index c4c13c495..691c8919b 100644 --- a/WrightTools/kit/_array.py +++ b/WrightTools/kit/_array.py @@ -27,6 +27,7 @@ "valid_index", "mask_reduce", "enforce_mask_shape", + "guess_signed", ] @@ -432,3 +433,38 @@ def enforce_mask_shape(mask, shape): """ red = tuple([i for i in range(len(shape)) if shape[i] == 1]) return mask.max(axis=red, keepdims=True) + + +def guess_signed(chan, tol=1e-1): + """guess whether or not a channel is signed by examining min and max values. + + Parameters + ------------- + chan : array-like + Input channel or array + tol : float (optional) + Tolerance value used to judge signed. `tol` should be much less than 1. To prefer signed guesses, use negative tolerance values. + + Returns + ------- + guess : bool + True if the data seems signed and False otherwise. + """ + + maxc = chan.max() + minc = chan.min() + from ..data import Channel + + if isinstance(chan, Channel): + null = chan.null + else: + null = 0 + + # avoid zero division for comparison + bottom = np.abs(maxc - null) + np.abs(minc - null) + if not bottom: # (maxc-null)=-(minc-null) + return True + + comparison = np.abs(maxc + minc - 2 * null) / bottom + # should be < 1 if signed + return comparison < 1 - tol diff --git a/tests/kit/signed.py b/tests/kit/signed.py new file mode 100644 index 000000000..f56f52d06 --- /dev/null +++ b/tests/kit/signed.py @@ -0,0 +1,30 @@ +"""Test guess_signed""" + +# --- import ------------------------------------------------------------------------------------- + + +import numpy as np +import WrightTools as wt + + +# --- test --------------------------------------------------------------------------------------- + + +def test_many_ranges(): + for minmax, signed in [ + ([-0.05, 1], False), + ([-1, 0.05], False), + ([-1, 1], True), + ([0, 0], True), + ([0, -1], False), + ([-1, 0.5], True), + ]: + assert wt.kit.guess_signed(np.array(minmax)) == signed + + +def test_channel(): + d = wt.Data() + chan = d.create_channel("chan", values=np.linspace(3, 4, 16).reshape(4, 4)) + assert wt.kit.guess_signed(chan) == False + chan.null = 3.5 + assert wt.kit.guess_signed(chan) From f298ed0f2343c46ea7bd18dd09f39a53251d987e Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:51:35 -0600 Subject: [PATCH 27/27] 3.5.1 --- CHANGELOG.md | 5 ++++- WrightTools/VERSION | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddbe28355..c295dfdbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ## [Unreleased] +## [3.5.1] + ### Added - `kit.guess_signed` for empirically guessing channel sign (useful for automated workflows) - `Data.squeeze`: squeezing the data object to the shape of the axes. @@ -365,7 +367,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Added - initial release -[Unreleased]: https://github.com/wright-group/WrightTools/-/compare/3.5.0...master +[Unreleased]: https://github.com/wright-group/WrightTools/-/compare/3.5.1...master +[3.5.1]: https://github.com/wright-group/WrightTools/compare/3.5.0...3.5.1 [3.5.0]: https://github.com/wright-group/WrightTools/compare/3.4.6...3.5.0 [3.4.6]: https://github.com/wright-group/WrightTools/compare/3.4.5...3.4.6 [3.4.5]: https://github.com/wright-group/WrightTools/compare/3.4.4...3.4.5 diff --git a/WrightTools/VERSION b/WrightTools/VERSION index 1545d9665..d5c0c9914 100644 --- a/WrightTools/VERSION +++ b/WrightTools/VERSION @@ -1 +1 @@ -3.5.0 +3.5.1