-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PlugAlgo : Add array[1]
-> scalar conversion
#5817
PlugAlgo : Add array[1]
-> scalar conversion
#5817
Conversation
Yeah, I think I'm in full agreement, both with finding this somewhat uncomfortable, and also in agreeing that this is probably the most pragmatic approach. The code LGTM. |
Ugh. This is quite unfortunate but I'd go for it as it will make things easier for users...
I wonder if returning the first value, rather than no value for lengths > 1 would be more or less surprising in that situation? |
+1 for 'the first' if you pick a scalar output for an array input. |
I'm far less comfortable with applying this to lengths |
Fair point. |
5615407
to
e4f8665
Compare
I've updated the PR with the equivalent conversions for all the other plug types now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This conversion is available in the various query nodes, and is particularly useful when querying attributes and primitive variables from certain DCCs which like to write everything as arrays, even if they make more sense as scalars.
I can only assume I had them there temporarily for testing, but they certainly don't belong - GafferTest should not depend on GafferScene or GafferImage.
e4f8665
to
c27398f
Compare
Rebased to fix merge conflict, and merging... |
This conversion is available in the various query nodes, and is particularly useful when querying attributes and primitive variables from certain DCCs which like to write everything as arrays, even if they make more sense as scalars.
I've only implemented this for FloatPlug, IntPlug and BoolPlug so far. If there's general support for the idea then I'll update to include other types too. Part of me dislikes the conversion and wishes everything was just typed more logically in the first place. And I worry that the existence of the conversion only for length 1 might lead to a surprise or two for things with animated array lengths. But on balance I think this is probably the most pragmatic thing to do - it lets users deal easily with a bunch of common problem scenarios without resorting to the performance hit of expressions.