#43 Fix Polynomial.compute() and Exponential.compute() #44
Merged
pberkes merged 8 commits intopberkes:masterfrom Jul 28, 2022
Merged
#43 Fix Polynomial.compute() and Exponential.compute() #44pberkes merged 8 commits intopberkes:masterfrom
pberkes merged 8 commits intopberkes:masterfrom
Conversation
assert_array_almost_equal() Does not work well for numbers with large magnitudes. assert_allclose() is better suited.
Remove redundant comma
Owner
|
Thank you! LGTM |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The major fix in this PR is changes to the complexity classes to fix #43 and make sure
Polynomial.compute()andExponential.compute()return sensible values. Test cases are added for this and some other changes.Major Fix: Compute() make aware of time transform
The
compute()function onbig_o.complexities.Polynomial()andbig_o.complexities.Exponential()fail becausethese classes implement custom
_transform_time()functions that alter the coefficients as calculated.big_O/big_o/complexities.py
Lines 176 to 177 in 82b8bb3
However, the
compute()function does not seem to account for_transform_time().This PR addresses the issue by introducing the
_inverse_transform_time()function and calling it withincompute()to correct the mathematical function.Test Cases
The
compute()function already has test cases, but they seem to miss this issue because onlyLinearis tested.big_O/big_o/test/test_complexities.py
Lines 10 to 15 in 82b8bb3
This PR adds test cases for all of the included complexity classes.
This PR also replaces the
numpy.testing.assert_array_almost_equal()withnumpy.testing.assert_allclose().The reason is
assert_array_almost_equal()does not scale well for large floating point numbers, as is noted in Numpy's documentation.If
assert_array_almost_equal()where used with the new test cases, the tests would fail due to the lost in precision in large floating point numbers.Other Changes
Expanded
TestComplexities.test_not_fittedto test all complexity classes, not justLinearAdded
coefficients()function to Polynomial classes to correct displaying the coefficients in there standard form, instead of the coefficient transformed by_transform_time()and_transform_n(). Previously printing a Polynomial or Exponential class would show incorrect coefficients.Change printing behavior from
"Polynomial: : not yet fitted"to"Polynomial: not yet fitted"