compas icon indicating copy to clipboard operation
compas copied to clipboard

Color Error when the inputs are partly `int`

Open ZacZhangzhuo opened this issue 11 months ago • 4 comments

Describe the bug As titled.

To Reproduce

from compas.colors import Color

color = Color(0.0,0.0,0)

print(Color.coerce(color))
 File "\compas\src\compas\colors\color.py", line 585, in coerce
    raise ColorError
 compas.colors.color.ColorError

ZacZhangzhuo avatar Mar 13 '24 09:03 ZacZhangzhuo

@tomvanmele the current implementation coerces str int and float as an argument. this screams for a refactor with typing.overload which was introduced in py 3.5.

implementing type specific versions of the function is much cleaner IMO. this could be a nice segue to introduce overload

jf--- avatar Apr 06 '24 16:04 jf---

that would indeed be very nice, but unfortunately, COMPAS 2.x still has to maintain compatibility with IronPython. once we start COMPAS 3 (which will be soon), we can start using this kind of mechanism...

tomvanmele avatar Apr 08 '24 17:04 tomvanmele

Terrific, could you pls label it as compas_3 as a reminder to self?

jf--- avatar Apr 08 '24 19:04 jf---

sure done

tomvanmele avatar Apr 08 '24 19:04 tomvanmele