Skip to content
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

Constraint contours with rounded-off edgepath bug fix #4102

Merged
merged 12 commits into from
Aug 28, 2019

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Aug 2, 2019

Fixes a contourcarpet bug reported in https://github.com/plotly/phoenix-integration/issues/244

before: https://codepen.io/etpinard/pen/BXwzvw
after: https://codepen.io/etpinard/pen/bXoeOa

This bug also affects contour traces with type: 'constraint' contours. See

before: https://codepen.io/etpinard/pen/QeqEZm?editors=0010
after: https://codepen.io/etpinard/pen/jgGrex?editors=1010

This PR is another step towards fixing all the edge cases at the contour edges - like #1309


This bug occurs when a contour(carpet) trace with contours.type: 'constraint' has all its edgepaths (computed in findAllPaths) rounded off (done here in findAllPaths). In this case, the checks for below the contour value are off and the resulting contour-fill paths are missing a boundary prefix making the fill region incorrect and leading to this bug.

Thank you very much to whoever wrote these comments

// starting points on the edges of the lattice for each contour
starts: [],
// all unclosed paths (may have less items than starts,
// if a path is closed by rounding)
edgepaths: [],

they got me thinking about a potential fix.

The most important part of this PR are the 5️⃣ new mocks. Please note that mocks contour_constraints_equal_boundary_minmax and carpet_rounded-off-edgepath-gt render fine on master currently. I added them here as they proved very useful in figuring out how to fix this bug w/o causing regressions.

In brief,

  • commit 0fe878f, rearranges a few things to make levels and constraint contours logic more similar. This commit should not introduce any changes in behaviour.
  • commit 6ba77c6 is the minimal fix. I'm very confident this commit will need not lead to any regressions.
  • commits 26e66fe and 6f9a59d attempt to merge the closeBoundaries logic for contour and contourcarpet together. I'm fairly confident the work here is correct, but perhaps we shouldn't release these commits in a patch version.

Moreover, since I spent almost a full week in src/traces/contour/ and src/traces/contourcarpet/, I made a few clean-up commits and I decided to "might as well" checked off #1311.

cc @plotly/plotly_js

- assign contours.value to variable
- assign cd0.trace to variable
- apply Math.min and Math.max instead of using .apply (only 2 values)
- break up if clauses into multiple lines
... as they don't support hover (yet).
... no need to have separate file for these routines.
  N.B. this mock renders fine on master, but failed during
       one attempt at fixing contour+constraint bug
... with incorrect baselines.

    Note that carpet_rounded_off-edgepath-gt renders correctly, but
    is important to lock down the correct fix.
- this way the "prefixBoundary" logic for both `levels` and
  `constraint` contours is in the same place
- note that `cheater_contour` mock fails if we call closeBoundaries
  on contourcarpet trace with `levels` contours
++ update incorrect baselines added two commits ago.
... with similar `edgepaths.length vs starts.length` logic than
    previous commit.

    Note that this patch may also fix un-reported bug for contour
    traces with level contours. I haven't been able to spot any
    while working on this patch.
... in this case joinAllPaths does enough already to render the
    constraint contours correctly.
@etpinard etpinard added bug something broken status: reviewable labels Aug 2, 2019
Copy link
Contributor

@archmoj archmoj left a comment

Choose a reason for hiding this comment

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

@etpinard
Excellently done.
💃
You may consider using a mock like this with repetitive data abstracted out:
Also please find my question below:
Thanks very much for this PR.

src/traces/contour/find_all_paths.js Show resolved Hide resolved
@etpinard etpinard added this to the v1.50.0 milestone Aug 8, 2019
@etpinard
Copy link
Contributor Author

(finally) merging this thing for 1.50.0

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.

2 participants