Add Support for Specifying Arbitrary Tangents, etc. in spline()#636
Conversation
Codecov Report
@@ Coverage Diff @@
## master #636 +/- ##
==========================================
+ Coverage 93.94% 94.02% +0.07%
==========================================
Files 31 31
Lines 6543 6627 +84
Branches 713 724 +11
==========================================
+ Hits 6147 6231 +84
Misses 258 258
Partials 138 138
Continue to review full report at Codecov.
|
* Added support for specifying the tangents at arbitrary interpolation points when interpolating a B-spline curve with `Workplane.spline()`. * Added support for specifying whether the tangents should be automatically scaled. (I.e., only use the tangent vector directions, rather than their magnitudes.) * Added support for specifying the value of the curve function parameter at the interpolation points. * Added support for specifying the interpolator's tolerance value. Q: _There are a number of whitespace, and other formatting changes introduced by `black`. Is there a specific list of parameters that you use when running code formatting?_
a88443f to
1caae59
Compare
|
What is exactly the use case for Regarding black, we use the defaults of |
* Reformatted the code with `black` 19.10b. This is the version that's used by the Travis continuous integration check. The default version of `black` that comes with Conda is 20.8b1, which produces different formatting. <environment.yml> should be updated to require the specific version of `black` used to check code before it's merged.
* Updated `Edge.makeSpline()` to use different temporary variables in the several for loops in the function body. Python for [loop target variables leak](https://eli.thegreenplace.net/2015/the-scope-of-index-variables-in-pythons-for-loops/) to the function (or enclosing module) scope, and MyPy doesn't accept [reusing the same variable name with a different type](python/mypy#1174) (except in specific cases, and when `--allow-redefinition` is used).
|
@pavpen any thoughts regarding my questions above? |
* Moved the tests cases, so they're next to each other. * Added a comment about the relationship between the two test cases.
…s` Argument * Changed the type hint to `Sequence` instead of `List`, since other list-like objects are acceptable, as wel.
* Updated `makeSpline` to construct an explicit exception, rather than use an `assert` to check input parameters.
* Updated DocString indentation. Hopefully, that fixes the Sphinx-generated documentation. I can't currently build locally.
|
@pavpen thanks, second question was about the tangents. You answered it in the review comments. |
* Fixed the `testSplineTangentMagnitudeBelowToleranceThrows` unit test. It was failing since `spline()`'s parameter `tolerance` seems to have been renamed to `tol`.
|
If we check the length of tangents and raise a ValueError, should we be doing the same for parameters? I don't think it's valid to have a different number of parameters to interpolation points. |
|
I'm a bit worried I have not handled |
|
Damn, my code was passing black but I was using version 20.8b1 to check. Needs 8d2c0b9 to pass with 19.10. |
👍 I see you added a commit for this. I think it's a good idea. The OCC library should throw an exception, if we don't check, but I think Python exceptions are much easier to understand. The ones coming from C++ often don't explain the reason for the exception. |
|
Thankyou very much @pavpen, this is a great contribution. Thanks also for the detailed comments and examples, they made reviewing much easier. |
|
+1, big thanks for the contributions and patience @pavpen . |
|
Thanks for all the help. I have a few more minor suggestions that I can write issues for. Also, I kind of hacked the SVG exporter so I can generate the SVGs that I used for the examples above. I changed the styling, so the graphic works both on bright and on dark backgrounds (like GitHub's dark theme). I was thinking it may be useful to add that as a feature, as well. Although it may require a bit of discussion. |
|
Sounds good, let's discuss in a new issue @pavpen . |






Workplane.spline().Q: There are a number of whitespace, and other formatting changes introduced by
black. Is there a specific list of parameters that you use when running code formatting?