RobertTLange / evosax

Evolution Strategies in JAX 🦎
Apache License 2.0
475 stars 44 forks source link

Evosax Import Error #39

Closed twoletters closed 1 year ago

twoletters commented 1 year ago

Hi Rob,

Thank you for developing this excellent library. I was desperate to find a working implementation of several of these optimizers. Riding on JAX is the icing on the cake.

I used pip to install matplotlib 3.1.0, evosax 0.1.0 and jax[cpu] 0.4.2. Now in Python 3.8.10, if I try to import evosax, I get the following error:

>>> import evosax
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/evosax/__init__.py", line 36, in <module>
    from .problems import ProblemMapper
  File "/usr/local/lib/python3.8/dist-packages/evosax/problems/__init__.py", line 3, in <module>
    from .bbob import BBOBFitness
  File "/usr/local/lib/python3.8/dist-packages/evosax/problems/bbob.py", line 7, in <module>
    from evosax.utils.visualizer_2d import BBOBVisualizer
  File "/usr/local/lib/python3.8/dist-packages/evosax/utils/visualizer_2d.py", line 10, in <module>
    cmap = cm.colors.LinearSegmentedColormap.from_list(
  File "/usr/local/lib/python3.8/dist-packages/matplotlib/colors.py", line 704, in from_list
    r, g, b, a = to_rgba(color)
  File "/usr/local/lib/python3.8/dist-packages/matplotlib/colors.py", line 177, in to_rgba
    rgba = _to_rgba_no_colorcycle(c, alpha)
  File "/usr/local/lib/python3.8/dist-packages/matplotlib/colors.py", line 231, in _to_rgba_no_colorcycle
    raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
ValueError: Invalid RGBA argument: '#eee'

The incriminating code is: https://github.com/RobertTLange/evosax/blob/3c7b751c434cf374516c261a8af367d492f5f859/evosax/utils/visualizer_2d.py#L10-L12 Is that a matplotlib issue or a problem in the code?

twoletters commented 1 year ago

Replacing "#eee" with "#0e0e0e" works.

RobertTLange commented 1 year ago

Thank you -- this is probably a problem with the matplotlib version! Will be fixed in the next release!

RobertTLange commented 1 year ago

Fixed in release v.0.1.4! Thank you for raising this.