Skip to content

Commit fb481ae

Browse files
committed
fix quick1D bugs
remove initial blank figure calculated nfigs handles reduced channel size (that is not caused by constants)
1 parent 872a927 commit fb481ae

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

WrightTools/artists/_quick/_2D.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ def update_figure(self, d) -> plt.Figure:
108108
self.colorbar.set_label(label=channel.natural_name)
109109
self.colorbar.set_ticks(norm_ticks)
110110
self.fig.canvas.draw_idle()
111-
plt.sca(self.ax)
112111
return self.fig
113112

114113

WrightTools/artists/_quick/_util.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def __init__(self, data: Data, *axes, **kwargs):
8080
self.__class__.__name__,
8181
)
8282
self.kwargs = kwargs
83-
self.logger.info(f"{self.kwargs=}")
8483

8584
def __iter__(self):
8685
with closing(self.data._from_slice(self.channel_slice)) as sliced:
@@ -164,10 +163,12 @@ def __init__(self, *args, **kwargs):
164163
self.max_figures = kwargs.get("max_figures", 10)
165164
# pre-calculate the number of plots to decide whether to make a folder
166165
shape = self.data.channels[self.channel_index].shape
167-
uninvolved_shape = (
166+
uninvolved_shape = tuple(
168167
size if self.channel_slice[i] == 0 else 1 for i, size in enumerate(shape)
169168
)
170169
removed_shape = self.data._chop_prep(*[a.expression for a in self.axes], at=self.at)[0]
170+
# further reduce if the channel is just lower dimensionality
171+
removed_shape = [min(x,y) for x,y in zip(removed_shape, shape)]
171172
self.nfigs = reduce(int.__mul__, removed_shape) // reduce(
172173
int.__mul__, uninvolved_shape
173174
)
@@ -181,22 +182,22 @@ def __init__(self, *args, **kwargs):
181182

182183
def __call__(self):
183184
if self.autosave:
184-
out = [self.filepath for _ in self]
185+
out = [self.filepath for _ in self.__iter__()]
185186
else: # unique figures; stops at fig limit
186187
out = []
187188
for i, fig in enumerate(self.__iter__()):
188-
print(i)
189+
self.logger.info(f"frame {i}")
189190
out.append(fig)
190-
if i > 9:
191-
break
191+
self.fig = None # unlink fig from self
192192
self.draw_figure()
193-
if i == self.max_figures:
194-
raise Warning(
195-
f"number of figures reached the limit (10). "
196-
+ f"Only the first 10 figures will be processed."
197-
)
198-
# last figure is empty
199-
plt.close(fig)
193+
if i == self.max_figures:
194+
self.logger.warn(
195+
f"number of figures reached the limit (10). "
196+
+ f"Only the first 10 figures will be processed."
197+
)
198+
break
199+
# last figure is empty(?)
200+
plt.close(self.fig)
200201
return out
201202

202203
return QuickLegacy

0 commit comments

Comments
 (0)