PeterRochford / SkillMetrics

A Python library for calculating and displaying the skill of model predictions against observations.
GNU General Public License v3.0
201 stars 92 forks source link

local variable 'markercolor' referenced before assignment #9

Closed rjp23 closed 5 years ago

rjp23 commented 5 years ago

When trying to use a legend (e.g. examples 5 and 9) I get this error:

skill_metrics/plot_pattern_diagram_markers.pyc in plot_pattern_diagram_markers(X, Y, option) 72 marker.append(symbol + color) 73 rgba = clr.to_rgb(color) + (alpha,) ---> 74 markercolor.append(rgba) 75 76 # Plot markers at data points

UnboundLocalError: local variable 'markercolor' referenced before assignment

rjp23 commented 5 years ago

Pretty sure this is the bug and the fix

        if len(X) <= len(kind):
            # Define markers with specified color
            marker = []
            markercolor = []
            for color in colorm:
                for symbol in kind:
                    marker.append(symbol + option['markercolor'])
                    rgba = clr.to_rgb(option['markercolor']) + (alpha,)
                    markercolor.append(rgba)
        else:
            # Define markers and colors using predefined list
            marker = []
            markercolor = [] <-- THIS WAS MISSING
            for color in colorm:
                for symbol in kind:
                    marker.append(symbol + color)
                    rgba = clr.to_rgb(color) + (alpha,)
                    markercolor.append(rgba)
PeterRochford commented 5 years ago

Thank you for pointing out the bug. I have made the change and just pushed new updates of the Skill Metrics package to GitHub. I hope to publish a new version via pip within the next couple of days.

PeterRochford commented 5 years ago

This bug has been fixed in SkillMetrics Version 1.1.6 that has been published via pip.