"colour.utilities.from_range_.*" definitions mutate their arguments. #685
Replies: 5 comments
-
Hi @dfoxfranke, Yes, we could explicitly write it in the docs, but We can surely update the docs to make that clear. Cheers, Thomas |
Beta Was this translation helpful? Give feedback.
-
Oh and btw, all that system, i.e. the Automatic Colour Conversion Graph, is "beta" and not really production-ready, so thank you for diving into it, you are the first person to really report anything about it! |
Beta Was this translation helpful? Give feedback.
-
Maybe I'm missing an idiom, but I find myself using Such code possibly could be simplified by use of Python's |
Beta Was this translation helpful? Give feedback.
-
So I'm picturing an idiom like this: from colour.utilities import dynscale, to_dyndomain_degrees, from_dynrange_degrees
def frobulate_upsidedown(h):
with dynscale('1'):
h = to_dyndomain_degrees(h)
hp = colour.frobulate(h + 0.5) - 0.5
return from_dynrange_degrees(hp)
The behavior of With something like this available I wouldn't have to write code like in my previous comment, and the mutational behavior of |
Beta Was this translation helpful? Give feedback.
-
Hello @dfoxfranke, We have context manager in-use in quite a few places internally for exactly the purpose you described (if I understood correctly). It is mentioned here: https://colour.readthedocs.io/en/develop/basics.html#working-with-the-domain-range-scales and the docs (that could use and example): https://colour.readthedocs.io/en/develop/generated/colour.domain_range_scale.html#colour.domain_range_scale with colour.domain_range_scale('1'):
colour.adaptation.chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2) |
Beta Was this translation helpful? Give feedback.
-
I can't tell from the docs whether this is intended behavior or a bug, but it sure caught me by surprise.
Gives:
I expected:
to_domain_100
is returning a numpy array, and thenfrom_range_100
is mutating that array in-place.Beta Was this translation helpful? Give feedback.
All reactions