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

chore: Refactor RSI test code and add almostEqual function #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

datascienceqing
Copy link

TestRSI_Calculate failed because issue with floating point precision.

@@ -72,13 +77,13 @@ func TestRSI_Calculate(t *testing.T) {

r, result := rsi.New(prices[:initialLength])
if result != results[0] {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if result != results[0] {
if !almostEqual(result, results[0], 0.000001) {

@MicahParks
Copy link
Owner

Does floating point precision have small deviations between platforms? What operating system and version of Go have you noticed tests failing on?

@datascienceqing
Copy link
Author

datascienceqing commented May 11, 2024 via email

@MicahParks
Copy link
Owner

MicahParks commented May 15, 2024

Would you include the full test output? I don't have access to a Macbook and am curious to see the output.

@datascienceqing
Copy link
Author

datascienceqing commented May 17, 2024 via email

@datascienceqing
Copy link
Author

datascienceqing commented May 17, 2024 via email

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.

2 participants