Skip to content

Inconsistent test for splines derivative #736

@GiovanniCanali

Description

@GiovanniCanali

Describe the bug
The derivative tests in test_spline.py and test_spline_surface.py occasionally fail. This is not due to an issue in the spline implementation but to a logical flaw in the tests themselves.

The spline order ranges from 1 to 8, which means the underlying polynomial degree ranges from 0 to 7. When the tests compare derivatives against values computed via automatic differentiation, they sometimes attempt to compute a second derivative of a degree-0 polynomial (a constant). PyTorch’s autograd (called by our grad) returns None for the derivative of a constant, and taking a second derivative of that value raises a TypeError (“NoneType is not subscriptable”).

In short: the tests incorrectly assume that higher-order derivatives always exist, but autograd cannot compute second derivatives of constants, leading to sporadic failures.

To reproduce
Modify, for instance, test_spline_surface.py to force the order to be always 1 (degree 0):

orders = [random.randint(1, 1) for _ in range(2)]

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions