From: W. Trevor King Date: Wed, 17 Oct 2012 17:12:31 +0000 (-0400) Subject: calibration: fix Python-to-caldac cast in CalibrationSetting._caldacs_set. X-Git-Tag: 0.6~24 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=31b24aac5102335f6029c035212271bd8d09fdf6;p=pycomedi.git calibration: fix Python-to-caldac cast in CalibrationSetting._caldacs_set. Pointed out by Éric Piel using Cython 0.15.1: Error compiling Cython file: ------------------------------------------------------------ ... raise MemoryError() self.setting.num_caldacs = length for i,x in enumerate(value): if i >= length: raise ValueError((i, length)) self.setting.caldacs[i] = x ^ ------------------------------------------------------------ pycomedi/calibration.pyx:505:39: Cannot convert Python object to 'comedi_caldac_t' --- diff --git a/pycomedi/calibration.pxd b/pycomedi/calibration.pxd index cbd827b..ca0b302 100644 --- a/pycomedi/calibration.pxd +++ b/pycomedi/calibration.pxd @@ -42,6 +42,7 @@ cdef class CalibrationSetting (object): cdef _comedilib_h.comedi_calibration_setting_t *setting cdef public _Subdevice subdevice + cdef _caldacs_set_single(self, index, Caldac caldac) cpdef _soft_calibration_set(self, CalibratedConverter value) diff --git a/pycomedi/calibration.pyx b/pycomedi/calibration.pyx index 67eed07..f68eb96 100644 --- a/pycomedi/calibration.pyx +++ b/pycomedi/calibration.pyx @@ -545,6 +545,8 @@ cdef class CalibrationSetting (object): c.caldac = &self.setting.caldacs[i] ret.append(c) return ret + cdef _caldacs_set_single(self, index, Caldac caldac): + self.setting.caldacs[index] = caldac.caldac[0] def _caldacs_set(self, value): assert self.setting is not NULL, 'load setting first' if self.setting.caldacs is not NULL: @@ -559,7 +561,7 @@ cdef class CalibrationSetting (object): for i,x in enumerate(value): if i >= length: raise ValueError((i, length)) - self.setting.caldacs[i] = x + self._caldacs_set_single(i, x) caldacs = property(fget=_caldacs_get, fset=_caldacs_set) def _soft_calibration_get(self):