Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Support "percent" as a unit in Taurus #596

Open
cpascual opened this issue Oct 25, 2017 · 1 comment
Open

Support "percent" as a unit in Taurus #596

cpascual opened this issue Oct 25, 2017 · 1 comment

Comments

@cpascual
Copy link
Member

cpascual commented Oct 25, 2017

current pint (v0.8) does not define a unit for percent.
This could be added in taurus.external.pint. See the following recipe:

The recipe is to do :

In [1]: from taurus.external.pint import UR, Q_
In [2]: UR.define('percent = 0.01*count = %')
In [3]: print Q_("50 percent") 
50 %

In [4]: print Q_("50 percent").to('dimensionless')
0.5

In [5]: print Q_("50 percent") + 1
1.5

BUT: the % symbol is not supported in pint yet (see hgrecco/pint#429 ).

So I see three possibilities:

  • wait for the above issue in pint to be resolved before introducing this in taurus.
  • register the percent without the abbreviation: UR.define('percent = 0.01*count')
  • register the percent with pct as abbreviation instead of % (but this is IMHO problematic because once "%" is supported we would introduce a backwards-incompatibility if we wanted to switch to %)
@cpascual cpascual added this to the Jan18 milestone Oct 25, 2017
@cpascual cpascual modified the milestones: Jan18, Jul18 Feb 1, 2018
@cpascual cpascual modified the milestones: Jul18, Jan19 Jul 2, 2018
@cpascual
Copy link
Member Author

cpascual commented Jul 2, 2018

I removed the milestone since I think that we should wait for this to be solved in hgrecco/pint#429

@cpascual cpascual removed this from the Jan19 milestone Jul 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant