"Unit not specified" VS "Unitless"

Hi,
When processing Tango attributes in Taurus, we would like to differentiate between 2 related-but-different cases regarding value units:

A) no one defined (yet) the units for the attribute (i.e. due to lazy/incomplete configuration in the DB)

B) the attribute value is "unitless" (e.g. it is a unitless and dimensionless factor)

(see https://github.com/taurus-org/taurus/issues/584)

Unfortunately, we found that (Py)Tango does not differentiate between these cases: leaving the "unit" attribute parameter as an empty string (which IMHO, it should be the way to specify the B case), causes Tango to reset it to "Not specified" (case A).

To make things uglier, PyTango treats the "Not specified" unit values and reports "No Unit" (which could be mistaken as case B when it really is case A)

As a workaround we found that we can specify " " (a one-space string) and arbitrarily assign it the B meaning in Taurus, but I think that Tango should clarify this in its docs and should support some standard way of explicitly configuring unitless values (maybe "unitless" or "None" or "No unit").

Also, I think that it would be better if PyTango returned PyTango.constants.UnitNotSpec instead of "No unit" for the case A.
I'm worried about slowing down the queries on the property_device_attribute table, as it is the same where memorized values is stored.

The chosen solution should take this into account.
Keep on dancing,

http://www.tango-controls.org/resources/howto/how-fandango/
What do you mean by unitless units? How does this differ form units not specified? I am not sure I understand.
Andy
What do you mean by unitless units? How does this differ form units not specified? I am not sure I understand.

Not "unitless units" but "unitless value"

An attribute can represent a physical quantity (e.g. a current in mA). But often the units are *not* introduced in the DB (I consider this a misconfiguration, but it happens frequently, mostly because in Tango units are generally used only for "cosmetic" uses). This is the case A in my original message. This is what is and should be handled as "Not specified".

On the other hand, an attribute may be intrinsically unitless (e.g. if its value represents a scaling factor). This is the case B in my original message. But there is no standard way of specifying this case B in Tango: setting an empty string produces the same effect as using "Not specified".

As I mentioned, it is possible to set the unit to a one-space string, and Taurus will interpret it as a unitless quantity (Taurus uses the pint [1] python module to parse the unit strings), but IMHO a more explicit name/constant (e.g."None" or "Null" or "unitless" ) should be defined and documented in Tango to specify case B

[1] http://pint.readthedocs.io
sergi_rubio
I'm worried about slowing down the queries on the property_device_attribute table, as it is the same where memorized values is stored.

The chosen solution should take this into account.

That is certainly something to consider, but keeping in mind that a properly configured system already would be defining the units of all its attributes.
 
Register or login to create to post a reply.