Skip to content

Commit 90cd784

Browse files
committed
tests
1 parent 207ecd2 commit 90cd784

2 files changed

Lines changed: 15 additions & 21 deletions

File tree

WrightTools/artists/_base.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def _apply_labels(
6060
y label. Default is None. if a string, autolabel is overwritten with ylabel
6161
data : WrightTools.data.Data object (optional)
6262
data to autolabel from. Default is None.
63-
channel_index : integer (optional)
64-
Channel index. Default is 0.
63+
channel : WrightTools.data.Channel object (optional)
64+
Channel index. Default is None.
6565
"""
6666
# read from data
6767
if autolabel in ["xy", "both", "x"] and not xlabel:
@@ -514,17 +514,15 @@ def scatter(self, *args, **kwargs):
514514
Use `cmap` instead to control colors."
515515
)
516516

517-
channel_ = data.get_channel(kwargs.pop("channel", 0))
518-
channel = kwargs.pop("channel", 0)
519-
channel_index = wt_kit.get_index(data.channel_names, channel)
517+
channel = data.get_channel(kwargs.pop("channel", 0))
520518

521519
limits = {}
522-
limits = self._parse_limits(data=data, channel=channel_, **limits)
520+
limits = self._parse_limits(data=data, channel=channel, **limits)
523521
norm = Normalize(**limits)
524522

525-
cmap = _parse_cmap(data, signed=channel_.signed, **kwargs)["cmap"]
523+
cmap = _parse_cmap(data, signed=channel.signed, **kwargs)["cmap"]
526524

527-
z = channel_[:]
525+
z = channel[:]
528526

529527
# fill x, y, z to joint shape
530528
shape = wt_kit.joint_shape(z, *coords)
@@ -547,7 +545,7 @@ def full(arr, shape):
547545
xlabel=kwargs.pop("xlabel", None),
548546
ylabel=kwargs.pop("ylabel", None),
549547
data=data,
550-
channel=channel_,
548+
channel=channel,
551549
)
552550

553551
return super().scatter(*args, **kwargs)
@@ -629,29 +627,27 @@ def plot(self, *args, **kwargs):
629627
# unpack data object, if given
630628
if isinstance(args[0], Data):
631629
data = args.pop(0)
632-
channel = kwargs.pop("channel", 0)
633-
channel_index = wt_kit.get_index(data.channel_names, channel)
634-
squeeze = np.array(data.channels[channel_index].shape) == 1
630+
channel = data.get_channel(kwargs.pop("channel", 0))
631+
squeeze = np.array(channel.shape) == 1
635632
xa = data.axes[0]
636633
for sq, xs in zip(squeeze, xa.shape):
637634
if sq and xs != 1:
638635
raise wt_exceptions.ValueError("Cannot squeeze axis to fit channel")
639636
squeeze = tuple([0 if i else slice(None) for i in squeeze])
640-
zi = data.channels[channel_index].points
637+
zi = channel.points
641638
xi = xa[squeeze]
642639
if not zi.ndim == 1:
643640
raise wt_exceptions.DimensionalityError(1, zi.ndim)
644641
args = [xi, zi] + args
645642
else:
646-
data = None
647-
channel_index = 0
643+
data = channel = None
648644
# labels
649645
self._apply_labels(
650646
autolabel=kwargs.pop("autolabel", False),
651647
xlabel=kwargs.pop("xlabel", None),
652648
ylabel=kwargs.pop("ylabel", None),
653649
data=data,
654-
channel=channel_,
650+
channel=channel,
655651
)
656652
# call parent
657653
return super().plot(*args, **kwargs)

WrightTools/data/_data.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -880,20 +880,18 @@ def moment(self, axis, channel=0, moment=1, *, resultant=None):
880880

881881
warnings.warn("moment", category=wt_exceptions.EntireDatasetInMemoryWarning)
882882

883-
channel_index = wt_kit.get_index(self.channel_names, channel)
884-
channel = self.channel_names[channel_index]
883+
channel:Channel = self.get_channel(channel)
885884

886-
if self[channel].shape[axis_index] == 1:
885+
if channel.shape[axis_index] == 1:
887886
raise wt_exceptions.ValueError(
888887
"Channel '{}' has a single point along Axis '{}', cannot compute moment".format(
889888
channel, axis
890889
)
891890
)
892891

893-
new_shape = list(self[channel].shape)
892+
new_shape = list(channel.shape)
894893
new_shape[axis_index] = 1
895894

896-
channel = self[channel]
897895
axis_inp = axis
898896
axis = self.axes[index]
899897
x = axis[:]

0 commit comments

Comments
 (0)