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

Fix inner product integrate #522

Merged
merged 6 commits into from
Mar 23, 2023
Merged

Fix inner product integrate #522

merged 6 commits into from
Mar 23, 2023

Conversation

m5signorini
Copy link
Contributor

Currently, when doing the inner product between different types of functional data objects (for example, between FDataGrid and FDataBasis) if the functions are multivariate, then the product fails.

This is an error that occurs when using the method _inner_product_integrate, which is not usually called when dealing with the same types of functional objects.
However, when using general Callable objects or when mixing types, it is called; failing when dealing with more than one variable.

This pull request aims to solve this issue while adding a new test for the inner_product. This test ensures that the product is correctly calculated between FDataGrid and FDataBasis objects.

@codecov
Copy link

codecov bot commented Mar 16, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 🎉

Comparison is base (d5efb95) 85.63% compared to head (b6b7bb1) 85.66%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #522      +/-   ##
===========================================
+ Coverage    85.63%   85.66%   +0.02%     
===========================================
  Files          143      143              
  Lines        11384    11397      +13     
===========================================
+ Hits          9749     9763      +14     
+ Misses        1635     1634       -1     
Impacted Files Coverage Δ
skfda/misc/_math.py 84.49% <100.00%> (+0.12%) ⬆️
skfda/tests/test_math.py 98.71% <100.00%> (+0.23%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

f1 = arg1(args)[:, 0, :]
f2 = arg2(args)[:, 0, :]
def integrand(*args: NDArrayFloat) -> NDArrayFloat: # noqa: WPS430
f_args = cast(NDArrayFloat, args)
Copy link
Member

Choose a reason for hiding this comment

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

Use np.asarray instead.

skfda/tests/test_math.py Show resolved Hide resolved
np.testing.assert_allclose(
skfda.misc.inner_product(fd, fd_basis),
res,
rtol=1e-4,
Copy link
Member

Choose a reason for hiding this comment

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

What is the actual tolerance? Can we put a lower rtol?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@vnmabus vnmabus merged commit 039fe26 into develop Mar 23, 2023
@vnmabus vnmabus deleted the fix/inner_product_integrate branch August 17, 2023 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants