home / github / commits

Menu
  • GraphQL API
  • Search all tables

commits: b14eea2f06bbcf1a02c4ae4cba9ed981aef69292

This data as json

sha message author_date committer_date raw_author raw_committer repo author committer
b14eea2f06bbcf1a02c4ae4cba9ed981aef69292 Fix contourf set under (#3601) * Copy colors for bad, under, and over values in _build_discrete_cmap() Copies the cmap._rgba_bad, cmap._rgba_under, and cmap._rgba_over values to new_cmap, in case they have been set to non-default values. Allows the user to customize plots more by using matplotlib methods on a cmap before passing as an argument to xarray's plotting methods. Previously these settings were overridden by defaults when creating the cmap actually used to make the plot. * Tests that cmap.set_bad, cmap.set_under, cmap.set_over not overridden * Add defaults in case cmap is a str in _build_discrete_cmap If the input cmap is a str, getting _rgba_bad, _rgba_under, or _rgba_over attributes from it will fail. To fix this, provide defaults taken from new_cmap. * Consolidate tests of cmap.set_bad() cmap.set_under() and cmap.set_over() Make one unit test test all three properties, rather than having a separate test for each. * Do not read/modify private members for bad, under and over colors * Only change under, over colors if they were set by user When modifying a colormap, we only want to preserve the under and over colors of the original colormap if they were explicitly set by the user. In _build_discrete_cmap this makes no difference, as the new_cmap returned by mpl.colors.from_levels_and_colors has the same minimum and maximum colors as its input, so the default under and over colors would not change anyway and could be copied regardless. However, for clarity and in case the same pattern is needed in future elsewhere, it is nicer to add a checks for: whether the under color is the same as cmap(0), only setting under for new_cmap if it is not; and whether the over color is the same as cmap(cmap.N - 1), only setting over for new_cmap if it is not. * Remove temporary variable that is only used once * Use deepcopy instead of copy for cmaps cmaps contain tuples member variables, so safer to deepcopy instead of just copy to make sure we never change the copied variable. * Set different colors for bad, under and over when testing * Extra test checking bad, under and over colors when not set explicitly * Comment on why test uses deepcopy * Pass vmin and vmax in test_contourf_cmap_set() Set vmin and vmax so that _build_discrete_colormap is called with extend='both'. extend is passed to mpl.colors.from_levels_and_colors(), which returns a result with sensible under and over values if extend='both', but not if extend='neither' (but if extend='neither' the under and over values would not be used because the data would all be within the plotted range) * Don't use private members in tests * Add whats-new * Fix isort * Update doc/whats-new.rst Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com> 2020-02-24T20:20:07Z 2020-02-24T20:20:07Z 7e21ec85163297602c88c6fc49638c2c95b296a9 cd792325681cbad9f663f2879d8b69f1edbb678f 13221727 3958036 19864447
Powered by Datasette · Queries took 0.846ms · About: xarray-datasette