Upcoming switch to Colors package (breaking change)

397 views
Skip to first unread message

Tim Holy

unread,
Aug 23, 2015, 11:52:08 PM8/23/15
to julia-users
Hi all,

We've recently reworked the handling of Colors by Julia into a few new
packages:
https://github.com/JuliaGraphics/ColorTypes.jl
https://github.com/JuliaGraphics/Colors.jl
https://github.com/JuliaGraphics/ColorVectorSpace.jl
and are in the process of switching most of the julia package ecosystem from
Color.jl to Colors.jl. This is going to be a breaking change, because the type
names are different (which is part of the motivation for this change). More
background is discussed here: https://github.com/JuliaLang/Color.jl/issues/101

To try to minimize any transition-induced pain, we're going to try to
synchronize the switch to Colors.jl across all of those packages. I'm
tentatively hoping to switch Tuesday or Wednesday, depending on how many
issues crop up. No one should switch before that, or you'll be left in a state
of inconsistency across packages that use colors.

If you haven't received a pull request from me, it means you're on your own
with regard to this change. However, I'm happy to advise/help out. I've found
the shell script below to be immensely helpful.

Any questions? Feel free to respond here or by filing issues over at Colors.jl
or ColorTypes.jl.

Best,
--Tim

# Intended to be run from the top directory in a package
# Do not run this twice on the same source tree without discarding
# the first set of changes.
sed -i 's/\bColor\b/Colors/g' REQUIRE

fls=$(find . -name "*.jl")
sed -i 's/\bColor\b/Colors/g' $fls # Color -> Colors
sed -i -E 's/\bcolor\("(.*?)"\)/colorant\"\1\"/g' $fls # color("red") ->
colorant"red"
sed -i 's/AbstractAlphaColorValue/TransparentColor/g' $fls
sed -i 's/AlphaColorValue/TransparentColor/g' $fls # might mean ColorAlpha
sed -i 's/ColorValue/Color/g' $fls
sed -i 's/ColourValue/Color/g' $fls
sed -i -E 's/\bLAB\b/Lab/g' $fls
sed -i -E 's/\bLUV\b/Luv/g' $fls
sed -i -E 's/\b([a-zA-Z0-9_\.]+)\.c\.(\w)\b/\1\.\2/g' $fls # colval.c.r ->
colval.c
# This next one is quite dangerous, esp. for LCHab types...
# ...on the other hand, git diff is nice about showing the things we should fix
sed -i -E 's/\b([a-zA-Z0-9_\.]+)\.c\b/color(\1)/g' $fls

# These are not essential, but they generalize to RGB24 better
# However, they are too error-prone to use by default since other color
# types like Lab have fields with the same names
#sed -i -E 's/\b([a-zA-Z0-9_\.]+)\.r\b/red(\1)/g' $fls # c.r -> red(c)
#sed -i -E 's/\b([a-zA-Z0-9_\.]+)\.g\b/green(\1)/g' $fls
#sed -i -E 's/\b([a-zA-Z0-9_\.]+)\.b\b/blue(\1)/g' $fls
#sed -i -E 's/\b([a-zA-Z0-9_\.]+)\.alpha\b/alpha(\1)/g' $fls # c.alpha ->
alpha(c)

Tim Holy

unread,
Aug 25, 2015, 7:00:25 AM8/25/15
to julia-users
The migration of most core packages from Color.jl to Colors.jl is done. Please update your own code accordingly. As a reminder, there's a helpful sed-based script below and posted at https://github.com/JuliaGraphics/Colors.jl#migrating-from-colorjl (the latter is more likely to be updated as any improvements get discovered).

Best,
--Tim

Stefan Karpinski

unread,
Aug 25, 2015, 8:53:32 AM8/25/15
to Julia Users
Thanks again for doing this work and the script to help port code is really great.

harven

unread,
Aug 27, 2015, 3:09:53 PM8/27/15
to julia-users


sed -i -E 's/\b([a-zA-Z0-9_\.]+)\.c\b/color(\1)/g' $fls

# These are not essential, but they generalize to RGB24 better
# However, they are too error-prone to use by default since other color
# types like Lab have fields with the same names
#sed -i -E 's/\b([a-zA-Z0-9_\.]+)\.r\b/red(\1)/g' $fls          # c.r -> red(c)
#sed -i -E 's/\b([a-zA-Z0-9_\.]+)\.g\b/green(\1)/g' $fls
#sed -i -E 's/\b([a-zA-Z0-9_\.]+)\.b\b/blue(\1)/g' $fls
#sed -i -E 's/\b([a-zA-Z0-9_\.]+)\.alpha\b/alpha(\1)/g' $fls     # c.alpha ->
alpha(c)


Beware that sed -E is not posix compliant. GNU (and FreeBSD) sed use  -r for extended regular  expressions.
I think -E only works on OSX and FreeBSD. Your script probably breaks on linux. If you want something portable,
you better write it in julia.

Tim Holy

unread,
Aug 27, 2015, 5:15:51 PM8/27/15
to julia...@googlegroups.com
The script online (https://github.com/JuliaGraphics/Colors.jl#migrating-from-colorjl) has already been updated with -r.

--Tim
Reply all
Reply to author
Forward
0 new messages