def divide(self, other): ''' Returns the elementwise ratio of this and another container data viewed as vectors. other: DataContainer ''' assert_validities(self, other) z = self.same_object() z.handle = pysirf.cSIRF_divide(self.handle, other.handle) check_status(z.handle) return z
def divide(self, other, out=None): ''' Returns the elementwise ratio of this and another container data viewed as vectors. other: DataContainer out: DataContainer to store the result to. ''' if isinstance(other, (Number, int, float, numpy.float32)): tmp = other + numpy.zeros_like(self.as_array().shape) other = self.copy() other.fill(tmp) assert_validities(self, other) if out is None: z = self.same_object() else: assert_validities(self, out) z = out z.handle = pysirf.cSIRF_divide(self.handle, other.handle) check_status(z.handle) return z
def divide(self, other, out=None): ''' Returns the elementwise ratio of this and another container data viewed as vectors. other: DataContainer out: DataContainer to store the result to. ''' if not isinstance (other, ( DataContainer , Number )): return NotImplemented if isinstance(other , Number ): tmp = other + numpy.zeros(self.shape, self.dtype) other = self.copy() other.fill(tmp) assert_validities(self, other) if out is None: out = self.same_object() out.handle = pysirf.cSIRF_ratio(self.handle, other.handle) check_status(out.handle) #out = self.copy() else: assert_validities(self, out) try_calling(pysirf.cSIRF_divide(self.handle, other.handle, out.handle)) return out