Making the str equivalent of the dimensionless_unscaled unit more discoverable
See original GitHub issueWe’re using astropy.unit
in a context where we want every value to be an astropy Quantity
. We’re also serializing definitions of the things we’re measuring in YAML, so we’re making heavy use of the string representations of astropy Unit
s. Some of these things have intrinsically dimensionless_unscaled
units, so we’re seeing a lot of:
unit: ''
in our YAML files. While unit: 'mmag'
→ Unit('mmag')
is easy to understand, my colleagues have asked a lot of questions about these “empty string” units.
So I’m wondering if we can improve the UX of the string representations of dimensionless_unscaled
units a bit. I have two ideas:
- Make the string
'dimensionless_unscaled'
an alias for the string''
so that we can write'dimensionless_unscaled'
in text serializations ofUnit
s. - Improve the discoverability of the
dimensionless_unscaled
in the documentation. Most units are featured in a nice table on the package page (http://docs.astropy.org/en/stable/units/index.html) butdimensionless_unscaled
is only explicitly mentioned on a deeper topic page (http://docs.astropy.org/en/stable/units/standard_units.html#the-dimensionless-unit) and even then its string representation is only mentioned in passing.
What does astropy think about these proposals? I’m happy to turn this into a PR if one or both of these ideas seem useful.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Standard Units — Astropy v5.2
units includes the concept of the dimensionless unit, used to indicate quantities that do not have a physical dimension.
Read more >Standard units — Astropy v0.4.2
Standard units are defined in the astropy.units package as object instances. All units are defined in term of basic 'irreducible' units. The irreducible...
Read more >Untitled
"string") { throw new Error("name isn't a string: " + name); } if (name != ... dimensionally dimensioned dimensioning dimensionless dimensions dimer dimers ......
Read more >python - Spectrum1D does not recognize u. ...
I think you're making things more complicated for yourself than ... It is basically syntactic sugar equivalent to Quantity(array, unit) .
Read more >arXiv:1303.6575v1 [hep-ph] 26 Mar 2013
As most sensible theories of low-energy physics arising from string compactification contain supersymmetry in four dimen-.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pllim - Yes, I actually had a similar confusion with the documentation recently so I’d be happy to give it a shot!
Thanks @pllim, I didn’t realized that
Unit('1')
also worked, not justUnit(1)
. It’d be worth adding that to the “documentation improvement” aspect of this issue.