Skip to content

Commit ea2bf94

Browse files
authored
Merge pull request #29 from usnistgov/28-plotting
Plotting Utility Upgrades
2 parents 5aa37dd + 063e284 commit ea2bf94

20 files changed

+3614
-130
lines changed

.gitignore

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
*egg-info*
2-
data/*
3-
*pyc
4-
.DS_Store
5-
6-
AFL/double_agent/_version.py
1+
# Dev
72
dev/
8-
3+
AFL/double_agent/_version.py
94
venv/
10-
.venv/
5+
.DS_Store
6+
7+
# VSCode
8+
.vscode/*
9+
!.vscode/settings.json
10+
!.vscode/tasks.json
11+
!.vscode/launch.json
12+
!.vscode/extensions.json
13+
*.code-workspace
14+
`
15+
# Cursor
16+
.cursor/
17+
.cursor-cache/
1118

1219
# Sphinx documentation
1320
docs/build/
@@ -19,4 +26,23 @@ objects.inv
1926
_build/
2027
.doctrees/
2128
*.mo
22-
AFL-agent.code-workspace
29+
30+
# Pytest
31+
.pytest_cache/
32+
.coverage*
33+
coverage.xml
34+
htmlcov/
35+
36+
# Tox
37+
.tox/
38+
.toxenv/
39+
40+
# Hypothesis
41+
.hypothesis/
42+
43+
# Cache files
44+
__pycache__/
45+
.cache/
46+
*pyc
47+
*egg-info*
48+

AFL/double_agent/PipelineOp.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__(
4848
stacklevel=2,
4949
)
5050

51+
5152
self.name = name or "PipelineOp"
5253
self.input_variable = input_variable
5354
self.output_variable = output_variable
@@ -66,8 +67,8 @@ def __init__(
6667
# silently continue for those working outside a context manager
6768
pass
6869

69-
## Gathering Arguments of Most-derived Child Class
7070

71+
## Gathering Arguments of Most-derived Child Class
7172
# Retrieve the full stack.
7273
stack = inspect.stack()
7374
valid_frames = []
@@ -257,18 +258,24 @@ def add_to_tiled(self, tiled_data):
257258
# for name, dataarray in self.output.items():
258259
# tiled_data.add_array(name, value.values)
259260

260-
def plot(self, **mpl_kwargs) -> plt.Figure:
261+
def plot(self, sample_dim: str = "sample", **mpl_kwargs) -> plt.Figure:
262+
"""Plots the output of the PipelineOp.
263+
264+
This method attempts to guess how to plot the data produced by the operation.
265+
"""
261266
n = len(self.output)
262267
if n > 0:
263-
fig, axes = plt.subplots(n, 1, figsize=(8, n * 4))
268+
fig, axes = plt.subplots(n, 1, figsize=(6, n * 3))
269+
264270
if n > 1:
265271
axes = list(axes.flatten())
266272
else:
267273
axes = [axes]
268274

269275
for i, (name, data) in enumerate(self.output.items()):
270-
if "sample" in data.dims:
271-
data = data.plot(hue="sample", ax=axes[i], **mpl_kwargs)
276+
if data.ndim > 1 and (sample_dim in data.dims):
277+
data.plot(hue=sample_dim, ax=axes[i], **mpl_kwargs)
278+
272279
else:
273280
data.plot(ax=axes[i], **mpl_kwargs)
274281
axes[i].set(title=name)

0 commit comments

Comments
 (0)