def numpy_ndarray_unpy(self): ''' Converts a numpy array to an mxArray. An appropriate data type is selected using select_mxclass_by_dtype. Fattens the array or scalar out to 2d if necessary. See Issue #5 ''' self = np.atleast_2d(self) mxclass = select_mxclass_by_dtype(self.dtype.type) cobj = mx.create_numeric_array(mxclass=mxclass, dims=self.shape) wrapper = mx.wrap_pycobject(cobj) wrap_array = np.asarray(wrapper) wrap_array[...] = self return wrapper
def numpy_ndarray_unpy(self): ''' Converts a numpy array to an mxArray. An appropriate data type is selected using select_mxclass_by_dtype. Fattens the array or scalar out to 2d if necessary. See Issue #5 ''' self = np.atleast_2d(self) mxclass = select_mxclass_by_dtype(self.dtype.type) cobj = mx.create_numeric_array(mxclass = mxclass, dims = self.shape) wrapper = mx.wrap_pycobject(cobj) wrap_array = np.asarray(wrapper) wrap_array[...] = self return wrapper
def test_wrap_wrongthing(): ''' Wrapping things that don't belong raises error ''' return mx.wrap_pycobject(42)
def test_wrap_bare_cell(): ''' Test that the wrapping function seems to work ''' return mx.wrap_pycobject(bare_cell(()))