def set_type_axes(array, type, axis_names): """Sets the array.info['type'] and array.info[axes] metadata and does some checks. Used in vect and mat constructors. """ info_header.assert_info(array) if axis_names is None: axes = (None,)*array.ndim else: check_axis_names(array, axis_names) axes = tuple(axis_names) array.info['type'] = type array.axes = axes
def test_assert_info(self): """Test the assert_info function.""" # info_memaps should pass. data = npfor.open_memmap('temp.npy', mode='w+', shape=(4, 3, 3)) data[:] = 5.0 Mat = info_header.InfoMemmap(data) info_header.assert_info(Mat) del Mat os.remove('temp.npy') # info_arrays should pass. data = sp.empty((5, 6, 6)) data[:] = 4.0 Mat = info_header.InfoArray(data) info_header.assert_info(Mat) # arrays should fail. self.assertRaises(TypeError, info_header.assert_info, data)