Menu

#718 OverflowErrors with float types in 8.1.6

closed-fixed
None
PyTango
5
2015-05-31
2015-04-23
No

With PyTango 8.1.6 (built without numpy due to bug #704) I have problems with float arguments that have values <= 0. With the PowerSupply server example from the quick tour doc, and this client:

import PyTango
dp = PyTango.DeviceProxy('test/test/test')
dp.current = 1
print dp.current
dp.current = 0
print dp.current

I get an OverflowError on the second "print dp.current":

Traceback (most recent call last):
  File "client.py", line 5, in <module>
    dp.current = 0
  File "/usr/lib64/python2.7/site-packages/PyTango/device_proxy.py", line 223, in __DeviceProxy__setattr
    self.write_attribute(name, value)
  File "/usr/lib64/python2.7/site-packages/PyTango/green.py", line 165, in greener
    ret = submit(fn, self, *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/PyTango/green.py", line 81, in synch_submit
    return get_synch_executor().submit(fn, *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/PyTango/green.py", line 73, in submit
    return fn(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/PyTango/device_proxy.py", line 981, in __DeviceProxy__write_attribute
    return self._write_attribute(*args, **kwargs)
OverflowError: Value is too small.

The same error also appears when calling commands that take or return float or float array arguments. It does not appear when building with numpy.

Discussion

  • Georg Brandl

    Georg Brandl - 2015-04-23

    Looking at the source of the exception, I noticed that in src/boost/cpp/fast_from_py.h, in the definition of DEFINE_FAST_TANGO_FROMPY_NUM there is a difference between the Numpy and non-Numpy cases: the non-Numpy case does not check for TangoScalarTypeLimits::is_integer.

     
  • Vincent Michel

    Vincent Michel - 2015-05-08

    I can confirm this bug (same version).
    Here is a simple device server to reproduce it:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    #!/usr/bin/python
    from PyTango.server import Device, DeviceMeta, attribute
    
    class Dummy(Device):
        __metaclass__ = DeviceMeta
    
        Test = attribute(dtype=float)
    
        def read_Test(self):
           return -0.1
    
    if __name__ == "__main__":
        PyTango.server.run((Dummy,))
    
     
  • Tiago Coutinho

    Tiago Coutinho - 2015-05-11

    Confirmed.

    When not using numpy, the range check is done for double types.

    Unfortunately, the std::numeric_limits<t>::min() returns the minimum integer when T=int/long but in case of float/double returns the smallest positive.</t>

    The test is now similar to what is done in case of having numpy and the problem should be fixed.
    Will become visible in next PyTango 8.1.7

    Thanks for reporting

     
  • Tiago Coutinho

    Tiago Coutinho - 2015-05-11
    • status: open --> closed-fixed
     
  • Tiago Coutinho

    Tiago Coutinho - 2015-05-11

    Just one more thing:

    Bug #704 should now be fixed so you when you build next PyTango 8.1.7 I really recommend enabling numpy.

     
  • Georg Brandl

    Georg Brandl - 2015-05-31

    Thanks!

     

Log in to post a comment.

MongoDB Logo MongoDB