Skip to content

feat: add testcase of polynom_for_points #11811

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

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions linear_algebra/src/polynom_for_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ def points_to_polynomial(coordinates: list[list[int]]) -> str:
f(x)=x^2*-1.0+x^1*-0.0+x^0*-2.0
>>> print(points_to_polynomial([[1, 5], [2, 2], [3, 9]]))
f(x)=x^2*5.0+x^1*-18.0+x^0*18.0
>>> print(points_to_polynomial([[1, 1], [1, 2], [1, 3]]))
x=1
>>> print(points_to_polynomial([[1, 1], [2, 2], [2, 2]]))
Copy link
Member

Choose a reason for hiding this comment

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

Please try removing the print()...

Suggested change
>>> print(points_to_polynomial([[1, 1], [1, 2], [1, 3]]))
x=1
>>> print(points_to_polynomial([[1, 1], [2, 2], [2, 2]]))
>>> points_to_polynomial([[1, 1], [1, 2], [1, 3]])
x=1
>>> points_to_polynomial([[1, 1], [2, 2], [2, 2]])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please try removing the print()...

@cclauss now check I removed the print statement but I did't see any major change in output

Copy link
Member

Choose a reason for hiding this comment

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

That sounds right because calling print() is not usually needed in doctests. Can you please remove print() from all tests in this file then I think we can land this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @cclauss check I removed the print from remaining place of polynom_for_points test cases

Traceback (most recent call last):
...
ValueError: The program cannot work out a fitting polynomial.
"""
if len(coordinates) == 0 or not all(len(pair) == 2 for pair in coordinates):
raise ValueError("The program cannot work out a fitting polynomial.")
Expand Down