Skip to content

ignore invalid trace indices in restyle and update #3114

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

Merged
merged 2 commits into from
Oct 16, 2018

Conversation

antoinerg
Copy link
Contributor

Fixes #3113

@@ -490,6 +490,9 @@ exports.coerceTraceIndices = function(gd, traceIndices) {
else if(!Array.isArray(traceIndices) || !traceIndices.length) {
return gd.data.map(function(_, i) { return i; });
}
else if(Array.isArray(traceIndices)) {
return traceIndices.filter(function(i) {return i < gd.data.length;});
}
Copy link
Contributor Author

@antoinerg antoinerg Oct 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I do a Lib.warn('trace indice is not number or is out of bound')?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea - should help users debug, since this really shouldn't happen normally.

indice index is not a number or is out of bounds

Also I guess while we're at it we should filter out non-integers and negative numbers. Oh hey lib.isIndex - accepts strings too but those seem to be OK, ie a=[1,2,3]; a['1']===2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray for lib.isIndex. I really should spend some time to find out all the functions we have in lib!

@alexcjohnson
Copy link
Collaborator

Thanks for the quick fix @antoinerg ! 🚀 Very nice tests.
💃

@antoinerg antoinerg merged commit 5468d6a into master Oct 16, 2018
@antoinerg antoinerg self-assigned this Oct 17, 2018
@etpinard etpinard added the bug something broken label Oct 23, 2018
@etpinard
Copy link
Contributor

🆘 delete branch alert 🆘

@etpinard etpinard deleted the 3113-restyle-invalid-trace branch October 23, 2018 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants