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

Round tripping Quantities through String #122

Open
jdm204 opened this issue Mar 13, 2024 · 3 comments
Open

Round tripping Quantities through String #122

jdm204 opened this issue Mar 13, 2024 · 3 comments

Comments

@jdm204
Copy link

jdm204 commented Mar 13, 2024

Hi, thanks for the package, nice to have an alternative approach to the Unitful type-based one.

Is there a way in this package to convert back and fourth between Quantities and String representations so that quantities could be serialised to strings and parsed back again? Like in Unitful, string(q::Quantity) prints a space between the last numeral and the unit, which yields an error with uparse.

@MilesCranmer
Copy link
Member

Just so I understand, would you want a way to parse the current pretty-printed output? Or would you want to have a printing function that gives something you can directly type into the REPL?

@MilesCranmer
Copy link
Member

Btw, is there a function in Base for prints that aim to give a string representation that can be typed back into the REPL? Like some show(::IO, ::Val{:raw}, x) or something?

@jdm204
Copy link
Author

jdm204 commented Mar 14, 2024

Just so I understand, would you want a way to parse the current pretty-printed output? Or would you want to have a printing function that gives something you can directly type into the REPL?

I suppose either would suit my needs, maybe parsing units with the space might make more sense as "2 mL"/1 nM" etc is a pretty common way to write these quantities for humans!

Btw, is there a function in Base for prints that aim to give a string representation that can be typed back into the REPL? Like some show(::IO, ::Val{:raw}, x) or something?

I was looking and didn't find it, though I did realise I don't understand Julia's display system as well as I should.

Also worth noting a similar issue with Unitful: PainterQubits/Unitful.jl#470

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

2 participants