-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Minor changes to animation code ahead of the array animation fix #2313
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 for the PR! I'm not sure I understand your first commit. Looking for a better explanation.
'" with a frame whose name of type "number" also equates to "' + | ||
name + '". This is valid but may potentially lead to unexpected ' + | ||
'behavior since all plotly.js frame names are stored internally ' + | ||
'as strings.'); | ||
|
||
if(numericNameWarningCount > 5) { | ||
Lib.warn('addFrames: This API call has yielded too many warnings. ' + | ||
if(numericNameWarningCount === numericNameWarningCountLimit) { |
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.
Why ===
instead of >
?
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.
Explanation of 1st commit: it looked to me as though Lib.warn
continued to be invoked past the 5 warnings, because I didn't see an actual condition that'd bypass this code path, so I added an extra condition in the if
line. With the commit, if numericNameWarningCount >= numericNameWarningCountLimit
then it doesn't descend in the if
, so it won't warn there anymore. The condition for raising the "Too many warnings" is an equality check, because numericNameWarningCount
is initially 0 but gets incremented past the condition check ie. before this check. If numericNameWarningCount
is 5 here, then we've been through this conditional branch 5 times (with numericNameWarningCount
values 1, 2, 3, 4, 5); we emit the "too many warning" things and won't come into this conditional branch again. Hope I got it right but maybe you're seeing an off-by-one error?
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.
Ok. That makes sense. Can we add a test for this? Using jasmine spyOn(Lib, 'warn')
should make this task relatively easy.
var thisUpdate = {}; | ||
|
||
for(var ai in data[i]) { | ||
thisUpdate[ai] = [data[i][ai]]; |
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.
Strange. I wonder what Ricky had in mind here. Good catch 👌
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.
Could've been just some initial logic that remained there.
…ddFrames` call too
.then(function() { | ||
// Five (`var numericNameWarningCountLimit = 5`) warnings and one warning saying that there won't be more warnings | ||
expect(Lib.warn.calls.count()).toEqual(5 + 1); | ||
}).catch(fail).then(done); |
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.
Excellent test. Thanks!
Good stuff. Thanks for taking on the animation code. 💃 |
These should involve no actual logic change, see the commit texts.