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

Tag percentages with certain format #2759

Merged
merged 3 commits into from Dec 18, 2023
Merged

Tag percentages with certain format #2759

merged 3 commits into from Dec 18, 2023

Conversation

OAGr
Copy link
Contributor

@OAGr OAGr commented Dec 17, 2023

image

Pretty straightforward. I'm a bit nervous that this will have trouble for huge or tiny percentages, but as I think about it, that doesn't seem like a huge concern - I think we can deal with it later on, as needed.

Copy link

changeset-bot bot commented Dec 17, 2023

🦋 Changeset detected

Latest commit: 24079c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@quri/squiggle-lang Patch
@quri/squiggle-components Patch
@quri/prettier-plugin-squiggle Patch
vscode-squiggle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@OAGr OAGr marked this pull request as ready for review December 17, 2023 17:51
@OAGr OAGr requested a review from berekuk as a code owner December 17, 2023 17:51
Copy link

vercel bot commented Dec 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
quri-hub ✅ Ready (Inspect) Visit Preview Dec 18, 2023 9:58pm
squiggle-components ✅ Ready (Inspect) Visit Preview Dec 18, 2023 9:58pm
2 Ignored Deployments
Name Status Preview Updated (UTC)
quri-ui ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2023 9:58pm
squiggle-website ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2023 9:58pm

Copy link
Contributor

sweep-ai bot commented Dec 17, 2023

Apply Sweep Rules to your PR?

  • Apply: All docstrings and comments should be up to date.
  • Apply: Ensure that all variables and functions have descriptive names.
  • Apply: Avoid using unnecessary separators or extra characters in code.
  • Apply: Use consistent indentation and spacing throughout the code.
  • Apply: Ensure that all code is properly formatted and follows the style guide.
  • Apply: Avoid using magic numbers or hard-coded values in the code.

],
});
};

export const library = [
makeUnitFn("n", "nano", 1e-9),
makeUnitFn("m", "mili", 1e-3),
makeUnitFn("%", "percent", 1e-2),
makeUnitFn("%", "percent", 1e-2, ".2%"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

.2~p seems slightly better; it rounds larger numbers too much but doesn't lose heading significant digits in small numbers:

> format('.2~p')(3456789)
'350000000%'
> format('.2~p')(34.56789)
'3500%'
> format('.2~p')(0.3456789)
'35%'
> format('.2~p')(0.003456789)
'0.35%'
> format('.2~p')(0.00003456789)
'0.0035%'

Compared to .2%:

> format('.2%')(3456789)
'345678900.00%'
> format('.2%')(34.56789)
'3456.79%'
> format('.2%')(0.3456789)
'34.57%'
> format('.2%')(0.003456789)
'0.35%'
> format('.2%')(0.00003456789)
'0.00%'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that's neat, happy to change.

Copy link

codecov bot commented Dec 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e681c2e) 71.56% compared to head (24079c2) 71.61%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2759      +/-   ##
==========================================
+ Coverage   71.56%   71.61%   +0.04%     
==========================================
  Files         118      118              
  Lines        6465     6469       +4     
  Branches     1318     1322       +4     
==========================================
+ Hits         4627     4633       +6     
+ Misses       1830     1828       -2     
  Partials        8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants