-
Notifications
You must be signed in to change notification settings - Fork 124
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
repr
Infinity
#1449
base: RB-10.5
Are you sure you want to change the base?
repr
Infinity
#1449
Conversation
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.
Thanks Eric - repr()
changes LGTM, but I think we can omit the str()
changes - see inline comment for rationale...
src/IECorePython/IECoreBinding.cpp
Outdated
s << boost::lexical_cast<string>( x[i] );\ | ||
if constexpr( std::numeric_limits<VEC::BaseType>::has_infinity )\ | ||
{\ | ||
s << (\ | ||
x[i] == std::numeric_limits<VEC::BaseType>::infinity() ? g_positiveInfString :\ | ||
( x[i] == -std::numeric_limits<VEC::BaseType>::infinity() ? g_negativeInfString :\ | ||
boost::lexical_cast<std::string>( x[i] ) ) \ | ||
);\ | ||
}\ | ||
else\ | ||
{\ | ||
s << boost::lexical_cast<string>( x[i] );\ | ||
}\ |
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.
I think we should omit this special treatment for str()
, and limit it only to repr()
. The main requirement for str()
is that it be simple and readable, which I think we had covered already. Only repr()
has the requirement that it generate a string that executes in Python, so I think that's the only place it makes sense to use the Python-specific syntax.
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.
That makes sense to me. I reverted the str()
treatment and added a test to verify str()
is correct for inf
values and squashed into 3b46e20.
dc0c599
to
3b46e20
Compare
Squashed down a fix for the |
This fixes a bug where
imath
vectors and colors with values set to infinity were notrepr
-ing in a form that could then beeval
-ed.Checklist