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

Interaction issue between GDSCTools, Reports and Colormap #13

Open
Donnyvdm opened this issue Sep 25, 2021 · 0 comments
Open

Interaction issue between GDSCTools, Reports and Colormap #13

Donnyvdm opened this issue Sep 25, 2021 · 0 comments
Labels

Comments

@Donnyvdm
Copy link

I've got an issue when running the test suite of GDSCTools. There are many ways to fix it, but I think the most natural fix is in the colormap package, hence this issue. Feel free to move it to one of the other repos if you think that's more appropriate.

The fix I'm proposing is that the cmap_builder-function should check if there is only one parameter given and it is already a matplotlib cmap, it should simply return that cmap.

A solution would look roughly like this:

from matplotlib.colors import Colormap as MPLColormap
...
def cmap_builder(name, name2=None, name3=None):
    ...
    elif name in c.colormaps:
        return c.cmap(name)
    elif isinstance(name, MPLColormap):   # Proposed addition
        return name                                     

This issue arises from the following code:
In GDCTools.anova_results:

class ANOVAResults(object):
    ....
    def get_html_table(...):
        ....
        cmap_clip = cmap_builder('#ffffff', '#0070FF')
        ...
        html.add_bgcolor(this, cmap_clip, mode='clip', threshold=clip_threshold)

The add_bgcolor comes from reports.HTMLTable class:

    def add_bgcolor(self, colname, cmap='copper', mode='absmax', threshold=2):
        ....
        cmap = cmap_builder(cmap)

So this last cmap_builder gets called with an object that's already a matplotlib colormap.

If you're happy with the above solution, I can submit a PR. If you want to fix it in Reports or GDSCTools, please let me know.

@cokelaer cokelaer added the bug label Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants