Repository: kutaslab/fitgrid

Issue:
plot_betas fails on grid with single channel
Wrap `axes` in list when single object?

Discussion:
codecov-io: # [Codecov](https://codecov.io/gh/kutaslab/fitgrid/pull/52?src=pr&el=h1) Report
> Merging [#52](https://codecov.io/gh/kutaslab/fitgrid/pull/52?src=pr&el=desc) into [master](https://codecov.io/gh/kutaslab/fitgrid/commit/5b4dae658d22e5aabfef7360c1c3a8e0a52da918?src=pr&el=desc) will **increase** coverage by `0.1%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/kutaslab/fitgrid/pull/52/graphs/tree.svg?width=650&token=d9xVBW7gSn&height=150&src=pr)](https://codecov.io/gh/kutaslab/fitgrid/pull/52?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##           master      #52     +/-   ##
=========================================
+ Coverage    78.9%   79.01%   +0.1%     
=========================================
  Files           8        8             
  Lines         403      405      +2     
=========================================
+ Hits          318      320      +2     
  Misses         85       85
```


| [Impacted Files](https://codecov.io/gh/kutaslab/fitgrid/pull/52?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [fitgrid/fitgrid.py](https://codecov.io/gh/kutaslab/fitgrid/pull/52/diff?src=pr&el=tree#diff-Zml0Z3JpZC9maXRncmlkLnB5) | `88.33% <100%> (+0.19%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/kutaslab/fitgrid/pull/52?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/kutaslab/fitgrid/pull/52?src=pr&el=footer). Last update [5b4dae6...edacbfe](https://codecov.io/gh/kutaslab/fitgrid/pull/52?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/fitgrid/fitgrid.py b/fitgrid/fitgrid.py
index 8569c1d..5cd5f5a 100644
--- a/fitgrid/fitgrid.py
+++ b/fitgrid/fitgrid.py
@@ -237,6 +237,10 @@ class FitGrid:
                 nrows=len(channels), figsize=figsize, sharey=True
             )
 
+            # wrap in list to allow for zipping later
+            if not isinstance(axes, np.ndarray):
+                axes = [axes]
+
             for ax, chan in zip(axes, channels):
                 for beta in params[chan]:
                     ax.plot(params[chan][beta], label=beta)


Test patch:
diff --git a/tests/test_fitgrid.py b/tests/test_fitgrid.py
index f14a93a..97d2d98 100644
--- a/tests/test_fitgrid.py
+++ b/tests/test_fitgrid.py
@@ -161,6 +161,15 @@ def test__smoke_plot_betas():
     grid.plot_betas()
 
 
+# https://github.com/kutaslab/fitgrid/issues/51
+def test__plot_betas_single_channel():
+
+    epochs = fitgrid.generate(n_samples=2, n_channels=1)
+
+    grid = epochs.lm(RHS='categorical + continuous')
+    grid.plot_betas()
+
+
 def test__smoke_plot_adj_rsquared():
 
     epochs = fitgrid.generate()