Open
Conversation
Kai-Striega
requested changes
Nov 26, 2023
Member
Kai-Striega
left a comment
There was a problem hiding this comment.
Wonderful start, just a few points that I didn't mention when we went through it last week
Comment on lines
+93
to
+101
| @pytest.mark.parametrize("rate, periods, payments, future_value, exp_result", [ | ||
| (0.07, 20, 0, 12000, -3101.0280337664), | ||
| (0.025, 4, 0, 1000, -905.9506447998), | ||
| (-0.07, 56, 0, 1200000, -69845129.5182595000), | ||
| (0.05, 20, 0, -12000, 4522.6737944760), | ||
| (0.05, 356.5288568, 0, -25000.00, 0.0006971776), | ||
| (0.05, 50, 0, 0, 0.0000000000), | ||
| (0.05, 26, 500, 0, -7187.5926504975), | ||
| ]) |
Member
There was a problem hiding this comment.
These values should be strings, not floats. A float stores an inexact representation of most numbers, the decimal representation of that number will not be the same as the floating point representation. For example see:
>>> from decimal import Decimal
>>> Decimal(0.1) == Decimal("0.1")
False
>>> Decimal(0.1)
Decimal('0.1000000000000000055511151231257827021181583404541015625')
>>> Decimal("0.1")
Decimal('0.1')
Comment on lines
+107
to
+108
| if number_type is Decimal: | ||
| assert result == pytest.approx(exp_result, rel=0.2) |
Member
There was a problem hiding this comment.
Please prefer the routines in numpy.testing over those in pytest.
In this case, we should not be testing that two values are approximately equal, but that they are exactly equal as, when we are using Decimal, we should be keeping arbitrary precision.
Comment on lines
+110
to
+111
| assert_allclose(float(result), float( | ||
| exp_result), atol=1e-10) |
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.
No description provided.