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

FIX: gracfully handle missing seaborn dependency #9835

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

scott-huberty
Copy link
Contributor

@scott-huberty scott-huberty commented Nov 27, 2024

xref: #9561 (comment)

Fixes a regression I introduced in #9561

MWE:

On current main, this code will fail if seaborn is not installed even if matplotlib is installed:

conda create -n xr-test python=3.10 xarray pooch scipy matplotlib
import xarray as xr
air = xr.tutorial.open_dataset("air_temperature")
air.air.isel(time=0).plot.contourf(colors="k")

As mentioned in #9561 (comment) , it seems that this wasn't caught by a CI because there isnt' a CI that has matplotlib but not seaborn installed.

EDIT: AFAICT - The behavior before #9561 was that if you pass a single color to the colors parameter like in the MWE, xarray will try to use Seaborn for this but fallback to matplotlib if necessary (e.g. if Seaborn is not installed).

xref: pydata#9561 (comment)

Fixes regression introduced in pydata#9561

this specific seaborn import should be handled gracefully, as it was before #pydata#9561
@scott-huberty scott-huberty mentioned this pull request Nov 27, 2024
4 tasks
@max-sixty
Copy link
Collaborator

Thanks a lot for checking & following up!

@max-sixty max-sixty enabled auto-merge (squash) November 27, 2024 23:54
@scott-huberty
Copy link
Contributor Author

Thanks a lot for checking & following up!

No problem, figured I should fix what I broke! 😅

@max-sixty max-sixty merged commit 7fd572d into pydata:main Nov 28, 2024
28 checks passed
@scott-huberty scott-huberty deleted the color_param_bugfix branch November 28, 2024 00:36
@mathause
Copy link
Collaborator

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants