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 decimal math inaccuracy in increment/decrement services #766

Merged
merged 2 commits into from
May 15, 2024

Conversation

frenck
Copy link
Owner

@frenck frenck commented May 15, 2024

Updates increment and decrement services in Spook to handle floating-point arithmetic inaccuracies.

  • Replaces the strict equality check for step multiples with a tolerance-based check using math.isclose in custom_components/spook/ectoplasms/number/services/decrement.py and increment.py. This change addresses the issue of floating-point arithmetic inaccuracies when checking if an amount is a multiple of the step value.
  • Applies the same tolerance-based check for step multiples in custom_components/spook/ectoplasms/input_number/services/decrement.py and increment.py, ensuring consistency across different types of number entities within Spook.

fixes #744


For more details, open the Copilot Workspace session.

@frenck frenck added the bugfix Inconsistencies or issues which will cause a problem for users or implementors. label May 15, 2024
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
66.7% Duplication on New Code

See analysis details on SonarCloud

@frenck frenck merged commit b97febf into main May 15, 2024
14 checks passed
@frenck frenck deleted the fix-decimal-inaccuracy branch May 15, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Inconsistencies or issues which will cause a problem for users or implementors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Increment/Decrement doesn't work on step of 0.1
1 participant