-
Notifications
You must be signed in to change notification settings - Fork 52
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
Fix inner product integrate #522
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b58cd18
Test inner_product_integrate
m5signorini a7c86bc
Fix integrand args and typing
m5signorini 71f68e5
Merge branch 'develop' into fix/inner_product_integrate
m5signorini c2c210f
Use of np.asarray, decreased rtol and formatting
m5signorini ca9e851
Merge branch 'fix/inner_product_integrate' of https://github.com/GAA-…
m5signorini b6b7bb1
Merge branch 'develop' into fix/inner_product_integrate
vnmabus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,42 @@ def f( # noqa: WPS430 | |
rtol=1e-4, | ||
) | ||
|
||
def test_mixed_several_variables(self) -> None: | ||
"""Test inner_product with basis and grid multivariable functions.""" | ||
def f( # noqa: WPS430 | ||
x: np.typing.NDArray[np.float_], | ||
y: np.typing.NDArray[np.float_], | ||
) -> np.typing.NDArray[np.float_]: | ||
return x + y | ||
|
||
t = np.linspace(0, 1, 50) | ||
vnmabus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
x2, y2 = _ndm(t, 2 * t) | ||
|
||
data_matrix = f(x2, y2) | ||
|
||
grid_points = [t, 2 * t] | ||
|
||
fd = skfda.FDataGrid( | ||
data_matrix[np.newaxis, ...], | ||
grid_points=grid_points, | ||
) | ||
|
||
basis = TensorBasis([ | ||
MonomialBasis(n_basis=5, domain_range=(0, 1)), | ||
MonomialBasis(n_basis=5, domain_range=(0, 2)), | ||
]) | ||
|
||
fd_basis = fd.to_basis(basis) | ||
|
||
res = 16 / 3 | ||
|
||
np.testing.assert_allclose( | ||
skfda.misc.inner_product(fd, fd_basis), | ||
res, | ||
rtol=1e-4, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the actual tolerance? Can we put a lower There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The minimum tolerance for this test is of order 1e-14. It has been updated. |
||
) | ||
|
||
def test_vector_valued(self) -> None: | ||
"""Test inner_product with vector valued functions.""" | ||
def f( # noqa: WPS430 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Use
np.asarray
instead.