diff --git a/docs/source/configuration/configuration.rst b/docs/source/configuration/configuration.rst index a1e2bc6..68b31d2 100644 --- a/docs/source/configuration/configuration.rst +++ b/docs/source/configuration/configuration.rst @@ -11,9 +11,14 @@ Each parameter of the configuration is defined by a XML-tag which is indicated b A parameter can contain multiple attributes which are defined as key-value-pairs and some of them may be optional. All attribute values must be quoted as in the example below. The required types shown in the documentation refer to the unquoted value. -Most numeric attributes require a unit which has to be defined as a second attribute with the suffix *_unit* which is also shown in the example below. +Most numeric attributes require a unit which can be either included in the value or defined as a second attribute with the suffix *_unit*. +The documentation uses the latter case for clarity. Both cases are shown as examples below. All astropy units defined `here `_ can be used. +.. code-block:: xml + + + .. code-block:: xml diff --git a/esbo_etc/classes/Entry.py b/esbo_etc/classes/Entry.py index d0b727f..665a2ee 100644 --- a/esbo_etc/classes/Entry.py +++ b/esbo_etc/classes/Entry.py @@ -79,8 +79,14 @@ class Entry(object): try: self.__setattr__(name, float(attr) * unit) except ValueError: - return "Expected parameter '" + name + "' with unit '" + unit.to_string() + \ - "' but got no unit and cannot convert '" + attr + "' to a numeric value." + try: + self.__setattr__(name, u.Quantity(attr)) + mes = self.check_quantity(name, unit, use_default) + if mes is not None: + return mes + except [ValueError, TypeError]: + return "Expected parameter '" + name + "' with unit '" + unit.to_string() + \ + "' but got no unit and cannot convert '" + attr + "' to a numeric value." else: return "Expected parameter '" + name + "' with unit '" + unit.to_string() + "' but got no unit." elif not attr.unit.is_equivalent(unit):