class PatchPandas(PatchSimple): modulename = 'pandas' input_functions = [ 'read_csv', 'read_table', 'read_excel', 'read_hdf', 'read_pickle', 'read_stata', 'read_msgpack' ] output_functions = [ 'DataFrame.to_csv', 'DataFrame.to_excel', 'DataFrame.to_hdf', 'DataFrame.to_msgpack', 'DataFrame.to_stata', 'DataFrame.to_pickle' ] output_functions += [ 'Panel.to_excel', 'Panel.to_hdf', 'Panel.to_msgpack', 'Panel.to_pickle' ] output_functions += [ 'Series.to_csv', 'Series.to_hdf', 'Series.to_msgpack', 'Series.to_pickle' ] input_wrapper = create_wrapper(log_input, 0, 'pandas') output_wrapper = create_wrapper(log_output, 0, 'pandas') add_module_to_db(modulename, input_functions, output_functions)
class PatchGDAL(PatchSimple): modulename = 'gdal' input_functions = ['Open'] output_functions = ['Driver.Create', 'Driver.CreateCopy'] input_wrapper = create_wrapper(log_input, 0, 'gdal') output_wrapper = create_wrapper(log_output, 0, 'gdal')
class PatchPillow(PatchSimple): modulename = 'PIL' input_functions = ['Image.open'] output_functions = ['Image.save'] input_wrapper = create_wrapper(log_input, 0, 'Pillow') output_wrapper = create_wrapper(log_output, 0, 'Pillow')
class PatchSKLearn(PatchSimple): modulename = 'sklearn' input_functions = ['datasets.load_svmlight_file'] output_functions = ['datasets.dump_svmlight_file'] input_wrapper = create_wrapper(log_input, 0, 'sklearn') output_wrapper = create_wrapper(log_output, 0, 'sklearn')
class PatchImageio(PatchSimple): modulename = 'imageio' input_functions = ['core.functions.get_reader', 'core.functions.read'] output_functions = ['core.functions.get_writer'] input_wrapper = create_wrapper(log_input, 0, 'imageio') output_wrapper = create_wrapper(log_output, 0, 'imageio')
class PatchTifffile(PatchSimple): modulename = 'tifffile' input_functions = ['imread'] output_functions = ['imsave'] input_wrapper = create_wrapper(log_input, 0, 'tifffile') output_wrapper = create_wrapper(log_output, 0, 'tifffile')
class PatchBS4(PatchSimple): modulename = 'bs4' input_functions = ['BeautifulSoup'] output_functions = [] input_wrapper = create_wrapper(log_input, 0, 'bs4') output_wrapper = create_wrapper(log_output, 0, 'bs4')
class PatchLXML(PatchSimple): modulename = 'lxml.etree' input_functions = ['parse', 'iterparse'] output_functions = [] input_wrapper = create_wrapper(log_input, 0, 'lxml') output_wrapper = create_wrapper(log_output, 0, 'lxml')
class PatchMPL(PatchSimple): modulename = 'matplotlib.pyplot' input_functions = [] output_functions = ['savefig'] input_wrapper = create_wrapper(log_input, 0, 'matplotlib') output_wrapper = create_wrapper(log_output, 0, 'matplotlib')
class PatchNumpy(PatchSimple): modulename = 'numpy' input_functions = ['genfromtxt', 'loadtxt', 'load', 'fromfile'] output_functions = ['save', 'savez', 'savez_compressed', 'savetxt'] input_wrapper = create_wrapper(log_input, 0, 'numpy') output_wrapper = create_wrapper(log_output, 0, 'numpy')
class PatchNIBabel(PatchSimple): modulename = 'nibabel' images = ['nifti1.Nifti1Image', 'nifti2.Nifti2Image', 'freesurfer.mghformat.MGHImage', 'spm99analyze.Spm99AnalyzeImage', 'minc1.Minc1Image', 'minc2.Minc2Image', 'analyze.AnalyzeImage', 'parrec.PARRECImage', 'spm2analyze.Spm2AnalyzeImage'] input_functions = [image_name + '.from_filename' for image_name in images] output_functions = [image_name + '.to_filename' for image_name in images] input_wrapper = create_wrapper(log_input, 0, 'nibabel') output_wrapper = create_wrapper(log_output, 0, 'nibabel')
class PatchSKImage(PatchSimple): modulename = 'skimage' input_functions = [ 'io.imread', 'io.load_sift', 'io.load_surf', 'external.tifffile.imread' ] output_functions = ['io.imsave', 'external.tifffile.imsave'] input_wrapper = create_wrapper(log_input, 0, 'sklearn') output_wrapper = create_wrapper(log_output, 0, 'sklearn')
class PatchNumpy(PatchSimple): modulename = 'numpy' # The `load` function is *deliberately* not included here # as it calls fromfile internally, and then we get two duplicate # entries recorded in the log input_functions = ['genfromtxt', 'loadtxt', 'fromfile'] output_functions = ['save', 'savez', 'savez_compressed', 'savetxt'] input_wrapper = create_wrapper(log_input, 0, 'numpy') output_wrapper = create_wrapper(log_output, 0, 'numpy')
class PatchIris(PatchSimple): modulename = 'iris' input_functions = [ 'iris.load', 'iris.load_cube', 'iris.load_cubes', 'iris.load_raw' ] output_functions = ['iris.save'] input_wrapper = create_wrapper(log_input, 0, modulename) output_wrapper = create_wrapper(log_output, 1, modulename) add_module_to_db(modulename, input_functions, output_functions)
def add(self, function_names, log_function, arg_loc, modname, function_type): if isinstance(function_names, six.string_types): function_names = [function_names] wrapper = create_wrapper(log_function, arg_loc, modname) for f in function_names: self.functions.append({ 'function': f, 'wrapper': wrapper, 'type': function_type })