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

thousand_spaces #26

Open
userJay opened this issue Jul 4, 2021 · 5 comments
Open

thousand_spaces #26

userJay opened this issue Jul 4, 2021 · 5 comments

Comments

@userJay
Copy link

userJay commented Jul 4, 2021

As far as I know standard conform spacing is:
4.899 7 kΩ ± 1.1 Ω
4.899 68 kΩ ± 0.1 Ω
4.899 681 kΩ ± 0.01 Ω

Currently it is in the first case like this:
4.8997 kΩ ± 1.1 Ω

so the first should be: "nr < 4 and nl < 4: " and "if nr >= 4: " and " if nl >= 4:".

Modul is ummy.py

elif self.thousand_spaces:

if nr < 4 and nl < 4:
    return s + ellipses

s = list(s)
if nr >= 4:
    for i in range(int(nr/3)):
        s.insert(d + i + (i+1)*3 + 1, sp)
if nl >= 4:
    for i in range(int(nl/3)):
        s.insert(d - (i+1)*3, sp)

I love your great work with MetrolPy!
I'm sorry, for my bad contribution quality - I'm a rooky in this issue. But I'll soon learn how to to proper issues, push, pulls and what ever exist to contribute good way.

@hvparks
Copy link
Collaborator

hvparks commented Jul 5, 2021

This is intentional, see for example https://www.bipm.org/en/publications/si-brochure section 5.4.4:

"However, when there are only four digits before or after the decimal marker, it is customary not to use a space to isolate a single digit. The practice of grouping digits in this way is a matter of choice..."

However that does bring up the question of what happens when one more decimal place is added, should it be
4.899 6814 or 4.899 681 4? The SI Brochure seems to follow the former, but MetroloPy displays it as the latter at the moment.

I really appreciate your comments

@userJay
Copy link
Author

userJay commented Jul 5, 2021

Okay - also a interesting source. I'm following ISO 80000-1 section 7.3.1.
The example is: 1 234,567 8 in stead of 1234,4578.

@ftessier
Copy link
Member

ftessier commented Jul 5, 2021

For the purpose of parsing the output, it might prove useful to add an option to output without typographical separators (if not already the case), or to use _ as the thousands separator instead of spaces. Notably, python, julia and rust all allow '_' in numbers for this purpose, which is great to clarify long numbers in the code!

@hvparks
Copy link
Collaborator

hvparks commented Jul 5, 2021

setting "uc.gummy.thousand_spaces = False" does turn off the separators, though there is currently no option to change the separators. The separators are spaces in unicode output and thin spaces in html and latex output.

@ftessier
Copy link
Member

ftessier commented Jul 5, 2021

Kudos for the thin space output in html and latex!! 🏅

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

No branches or pull requests

3 participants