Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-temporal raster source visualizer fails when batch size is 1 #1956

Closed
chrisjkuch opened this issue Oct 11, 2023 · 2 comments · Fixed by #1958
Closed

Multi-temporal raster source visualizer fails when batch size is 1 #1956

chrisjkuch opened this issue Oct 11, 2023 · 2 comments · Fixed by #1958
Labels

Comments

@chrisjkuch
Copy link

chrisjkuch commented Oct 11, 2023

subfigs = fig.subfigures(nrows=batch_sz, ncols=1, hspace=0.0)
subfig_axs = [
subfig.subplots(
nrows=T, ncols=params['subplot_args']['ncols'])
for subfig in subfigs.flat
]

This code fails when the batch size is 1 because the created subfigs doesn't have a flat property if there's only one row and one column. Not sure whether this should be fixed upstream in matplotlib...

Matplotlib version 3.7.1, rastervision version 0.21.2

import matplotlib.pyplot as plt
fig = plt.figure()
subfigs = fig.subfigures(nrows=2, ncols=1, hspace=0)
subfigs.flat
#> <numpy.flatiter object at 0x5575c63e68f0>

subfigs = fig.subfigures(nrows=1, ncols=1, hspace=0)
subfigs.flat
#> Traceback (most recent call last):
#>   File "<string>", line 1, in <module>
#> AttributeError: 'SubFigure' object has no attribute 'flat'

Created at 2023-10-11 17:12:31 CDT by reprexlite v0.5.0

@AdeelH
Copy link
Collaborator

AdeelH commented Oct 12, 2023

Looks like fig.subfigures() needs squeeze=False to act more consistently, just like plt.subplots(). Thanks for catching that!

@chrisjkuch
Copy link
Author

Thanks for such a quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants