Repository navigation
fix(conversions): use US gallon and exact cubic foot factors in volume_conversion - #15812
Open
Bhaveshmeghwal21 wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Describe your change
volume_conversionconverts through cubic meters (value * from_factor * to_factor), so each unit'sfrom_factor * to_factorshould be 1. Two entries break that:gallongoes in as0.00454m3 (an imperial gallon) but comes out as264.172gallons per m3 (US gallons).volume_conversion(1, "gallon", "litre")gave 4.54, and one gallon was 19.19 cups instead of 16.cubic footused0.028m3. A cubic foot is 0.0283168 m3, so it was about 1% low.The factors are now
0.00378541(US gallon, matching264.172) and0.0283168. The gallon to cubic yard and cubic foot to cup doctests held the wrong outputs, so I updated them to the corrected values (3 gallons = 0.01485 cubic yards, 4 cubic feet = 478.75 cups), and added doctests for 1 gallon = 3.785 L and 1 cubic foot = 28.317 L. The doctest edits can't go in a separate PR: the old expected values came from the wrong factors, so they fail as soon as the factors are fixed.With this change
from_factor * to_factoris 1 (within 1e-5) for every unit in the table, and 1 gallon comes out as 16 cups.Checklist