Skip to content

fix(conversions): use the exact pascal factor in pressure_conversion - #15811

Open
Bhaveshmeghwal21 wants to merge 1 commit into
TheAlgorithms:masterfrom
Bhaveshmeghwal21:fix/pressure-conversion-pascal-factor
Open

Bhaveshmeghwal21 wants to merge 1 commit into
TheAlgorithms:masterfrom
Bhaveshmeghwal21:fix/pressure-conversion-pascal-factor

Conversation

@Bhaveshmeghwal21

@Bhaveshmeghwal21 Bhaveshmeghwal21 commented Nov 26, 2026 •

Copy link
Copy Markdown

Describe your change

  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Add an algorithm?
  • Documentation change?

pressure_conversion converts through atm (value * from_factor * to_factor). The pascal entry used 0.0000098 atm per pascal, but 1 Pa is 1/101325 atm = 9.86923e-6, the value kilopascal already uses (0.00986923). So every conversion from pascal came out about 0.7% low:

>>> pressure_conversion(101325, "pascal", "atm")
0.99298  # rounded, should be 1

The factor is now 0.00000986923. The pascal to psi doctest held the wrong output (0.000144), so I updated it to the corrected value (0.000145037; 1 Pa is 0.000145038 psi) and added a doctest for 101325 Pa = 1 atm. The doctest edit can't go in a separate PR: the old expected value came from the wrong factor, so it fails as soon as the factor is fixed.

With this change from_factor * to_factor is 1 (within 3e-6) for every unit in the table. pascal was the only entry that was far off (0.993).

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues, then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant