gtaylor / python-colormath

A python module that abstracts common color math operations. For example, converting from CIE L*a*b to XYZ, or from RGB to CMYK
python-colormath.readthedocs.org
BSD 3-Clause "New" or "Revised" License
456 stars 83 forks source link

Networkx 2.0 compatibility #73

Closed Erotemic closed 7 years ago

Erotemic commented 7 years ago

In the add_type_conversion method of GraphConversionManager on line 124 of color_conversions.py there is a call to networkx add_edge that does not work in the new version 2.0. This can be fixed by modifying the function as follows:

    def add_type_conversion(self, start_type, target_type, conversion_function):
        super(GraphConversionManager, self).add_type_conversion(start_type, target_type, conversion_function)
        if networkx.__version__.startswith('2'):
            self.conversion_graph.add_edge(start_type, target_type, conversion_function=conversion_function)
        else:
            self.conversion_graph.add_edge(start_type, target_type, {'conversion_function': conversion_function})
gtaylor commented 7 years ago

I'd accept a PR for this

gtaylor commented 7 years ago

Fixed in #75.