repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._save_potentials
def _save_potentials(self, directory): """save potentials to a directory """ print('saving potentials') digits = int(np.ceil(np.log10(self.configs.configs.shape[0]))) for i in range(0, self.configs.configs.shape[0]): pot_data = self.get_potential(i) filena...
python
def _save_potentials(self, directory): """save potentials to a directory """ print('saving potentials') digits = int(np.ceil(np.log10(self.configs.configs.shape[0]))) for i in range(0, self.configs.configs.shape[0]): pot_data = self.get_potential(i) filena...
[ "def", "_save_potentials", "(", "self", ",", "directory", ")", ":", "print", "(", "'saving potentials'", ")", "digits", "=", "int", "(", "np", ".", "ceil", "(", "np", ".", "log10", "(", "self", ".", "configs", ".", "configs", ".", "shape", "[", "0", ...
save potentials to a directory
[ "save", "potentials", "to", "a", "directory" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L409-L426
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.clear_measurements
def clear_measurements(self): """Forget any previous measurements """ mid_list = self.assignments.get('measurements', None) if mid_list is not None: for mid in mid_list: self.configs.delete_measurements(mid=mid) self.assignments['measurements'] = N...
python
def clear_measurements(self): """Forget any previous measurements """ mid_list = self.assignments.get('measurements', None) if mid_list is not None: for mid in mid_list: self.configs.delete_measurements(mid=mid) self.assignments['measurements'] = N...
[ "def", "clear_measurements", "(", "self", ")", ":", "mid_list", "=", "self", ".", "assignments", ".", "get", "(", "'measurements'", ",", "None", ")", "if", "mid_list", "is", "not", "None", ":", "for", "mid", "in", "mid_list", ":", "self", ".", "configs",...
Forget any previous measurements
[ "Forget", "any", "previous", "measurements" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L428-L435
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.measurements
def measurements(self): """Return the measurements associated with this instance. if measurements are not present, check if we can model, and then run CRMod to load the measurements. """ # check if we have measurements mid = self.assignments.get('measurements', None) ...
python
def measurements(self): """Return the measurements associated with this instance. if measurements are not present, check if we can model, and then run CRMod to load the measurements. """ # check if we have measurements mid = self.assignments.get('measurements', None) ...
[ "def", "measurements", "(", "self", ")", ":", "mid", "=", "self", ".", "assignments", ".", "get", "(", "'measurements'", ",", "None", ")", "if", "mid", "is", "None", ":", "return_value", "=", "self", ".", "model", "(", "voltages", "=", "True", ",", "...
Return the measurements associated with this instance. if measurements are not present, check if we can model, and then run CRMod to load the measurements.
[ "Return", "the", "measurements", "associated", "with", "this", "instance", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L437-L461
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._read_sensitivities
def _read_sensitivities(self, sens_dir): """import sensitivities from a directory Note ---- * check that signs are correct in case CRMod switches potential electrodes """ if self.assignments['sensitivities'] is not None: print('Sensitivities alrea...
python
def _read_sensitivities(self, sens_dir): """import sensitivities from a directory Note ---- * check that signs are correct in case CRMod switches potential electrodes """ if self.assignments['sensitivities'] is not None: print('Sensitivities alrea...
[ "def", "_read_sensitivities", "(", "self", ",", "sens_dir", ")", ":", "if", "self", ".", "assignments", "[", "'sensitivities'", "]", "is", "not", "None", ":", "print", "(", "'Sensitivities already imported. Will not overwrite!'", ")", "return", "else", ":", "self"...
import sensitivities from a directory Note ---- * check that signs are correct in case CRMod switches potential electrodes
[ "import", "sensitivities", "from", "a", "directory" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L500-L532
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._read_potentials
def _read_potentials(self, pot_dir): """import potentials from a directory """ if self.assignments['potentials'] is not None: print('Potentials already imported. Will not overwrite!') return else: self.assignments['potentials'] = {} pot_files ...
python
def _read_potentials(self, pot_dir): """import potentials from a directory """ if self.assignments['potentials'] is not None: print('Potentials already imported. Will not overwrite!') return else: self.assignments['potentials'] = {} pot_files ...
[ "def", "_read_potentials", "(", "self", ",", "pot_dir", ")", ":", "if", "self", ".", "assignments", "[", "'potentials'", "]", "is", "not", "None", ":", "print", "(", "'Potentials already imported. Will not overwrite!'", ")", "return", "else", ":", "self", ".", ...
import potentials from a directory
[ "import", "potentials", "from", "a", "directory" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L534-L552
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.get_potential
def get_potential(self, config_nr): """Return potential data for a given measurement configuration. Parameters ---------- config_nr: int Number of the configurations. Starts at 0 Returns ------- pot_data: list with two numpy.ndarrays Firs...
python
def get_potential(self, config_nr): """Return potential data for a given measurement configuration. Parameters ---------- config_nr: int Number of the configurations. Starts at 0 Returns ------- pot_data: list with two numpy.ndarrays Firs...
[ "def", "get_potential", "(", "self", ",", "config_nr", ")", ":", "if", "self", ".", "assignments", "[", "'potentials'", "]", "is", "None", ":", "self", ".", "_check_state", "(", ")", "if", "self", ".", "can_model", ":", "self", ".", "model", "(", "pote...
Return potential data for a given measurement configuration. Parameters ---------- config_nr: int Number of the configurations. Starts at 0 Returns ------- pot_data: list with two numpy.ndarrays First array: magnitude potentials, second array: ph...
[ "Return", "potential", "data", "for", "a", "given", "measurement", "configuration", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L554-L575
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.get_sensitivity
def get_sensitivity(self, config_nr): """return a sensitivity, as well as corresponding metadata, for a given measurement configuration. Indices start at zero. """ if self.assignments['sensitivities'] is None: self._check_state() if self.can_model: ...
python
def get_sensitivity(self, config_nr): """return a sensitivity, as well as corresponding metadata, for a given measurement configuration. Indices start at zero. """ if self.assignments['sensitivities'] is None: self._check_state() if self.can_model: ...
[ "def", "get_sensitivity", "(", "self", ",", "config_nr", ")", ":", "if", "self", ".", "assignments", "[", "'sensitivities'", "]", "is", "None", ":", "self", ".", "_check_state", "(", ")", "if", "self", ".", "can_model", ":", "self", ".", "model", "(", ...
return a sensitivity, as well as corresponding metadata, for a given measurement configuration. Indices start at zero.
[ "return", "a", "sensitivity", "as", "well", "as", "corresponding", "metadata", "for", "a", "given", "measurement", "configuration", ".", "Indices", "start", "at", "zero", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L577-L589
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.read_voltages
def read_voltages(self, voltage_file): """import voltages from a volt.dat file Parameters ---------- voltage_file : string Path to volt.dat file """ measurements_raw = np.loadtxt( voltage_file, skiprows=1, ) measuremen...
python
def read_voltages(self, voltage_file): """import voltages from a volt.dat file Parameters ---------- voltage_file : string Path to volt.dat file """ measurements_raw = np.loadtxt( voltage_file, skiprows=1, ) measuremen...
[ "def", "read_voltages", "(", "self", ",", "voltage_file", ")", ":", "measurements_raw", "=", "np", ".", "loadtxt", "(", "voltage_file", ",", "skiprows", "=", "1", ",", ")", "measurements", "=", "np", ".", "atleast_2d", "(", "measurements_raw", ")", "A", "=...
import voltages from a volt.dat file Parameters ---------- voltage_file : string Path to volt.dat file
[ "import", "voltages", "from", "a", "volt", ".", "dat", "file" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L769-L834
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.model
def model(self, voltages=True, sensitivities=False, potentials=False, output_directory=None, silent=False, ): """Forward model the tomodir and read in the results """ self._check_state() if self.can_model...
python
def model(self, voltages=True, sensitivities=False, potentials=False, output_directory=None, silent=False, ): """Forward model the tomodir and read in the results """ self._check_state() if self.can_model...
[ "def", "model", "(", "self", ",", "voltages", "=", "True", ",", "sensitivities", "=", "False", ",", "potentials", "=", "False", ",", "output_directory", "=", "None", ",", "silent", "=", "False", ",", ")", ":", "self", ".", "_check_state", "(", ")", "if...
Forward model the tomodir and read in the results
[ "Forward", "model", "the", "tomodir", "and", "read", "in", "the", "results" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L875-L910
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._invert
def _invert(self, tempdir, catch_output=True, **kwargs): """Internal function than runs an inversion using CRTomo. Parameters ---------- tempdir : string directory which to use as a tomodir catch_output : bool, optional if True, catch all outputs of the C...
python
def _invert(self, tempdir, catch_output=True, **kwargs): """Internal function than runs an inversion using CRTomo. Parameters ---------- tempdir : string directory which to use as a tomodir catch_output : bool, optional if True, catch all outputs of the C...
[ "def", "_invert", "(", "self", ",", "tempdir", ",", "catch_output", "=", "True", ",", "**", "kwargs", ")", ":", "nr_cores", "=", "kwargs", ".", "get", "(", "'cores'", ",", "2", ")", "print", "(", "'attempting inversion in directory: {0}'", ".", "format", "...
Internal function than runs an inversion using CRTomo. Parameters ---------- tempdir : string directory which to use as a tomodir catch_output : bool, optional if True, catch all outputs of the CRTomo call (default: True) cores : int, optional ...
[ "Internal", "function", "than", "runs", "an", "inversion", "using", "CRTomo", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L912-L954
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.invert
def invert(self, output_directory=None, catch_output=True, **kwargs): """Invert this instance, and import the result files No directories/files will be overwritten. Raise an IOError if the output directory exists. Parameters ---------- output_directory: string, optional...
python
def invert(self, output_directory=None, catch_output=True, **kwargs): """Invert this instance, and import the result files No directories/files will be overwritten. Raise an IOError if the output directory exists. Parameters ---------- output_directory: string, optional...
[ "def", "invert", "(", "self", ",", "output_directory", "=", "None", ",", "catch_output", "=", "True", ",", "**", "kwargs", ")", ":", "self", ".", "_check_state", "(", ")", "if", "self", ".", "can_invert", ":", "if", "output_directory", "is", "not", "None...
Invert this instance, and import the result files No directories/files will be overwritten. Raise an IOError if the output directory exists. Parameters ---------- output_directory: string, optional use this directory as output directory for the generated tomodir. ...
[ "Invert", "this", "instance", "and", "import", "the", "result", "files" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L956-L1001
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.read_inversion_results
def read_inversion_results(self, tomodir): """Import inversion results from a tomodir into this instance WARNING: Not finished! """ self._read_inversion_results(tomodir) self._read_inv_ctr(tomodir) self._read_resm_m(tomodir) self._read_eps_ctr(tomodir)
python
def read_inversion_results(self, tomodir): """Import inversion results from a tomodir into this instance WARNING: Not finished! """ self._read_inversion_results(tomodir) self._read_inv_ctr(tomodir) self._read_resm_m(tomodir) self._read_eps_ctr(tomodir)
[ "def", "read_inversion_results", "(", "self", ",", "tomodir", ")", ":", "self", ".", "_read_inversion_results", "(", "tomodir", ")", "self", ".", "_read_inv_ctr", "(", "tomodir", ")", "self", ".", "_read_resm_m", "(", "tomodir", ")", "self", ".", "_read_eps_ct...
Import inversion results from a tomodir into this instance WARNING: Not finished!
[ "Import", "inversion", "results", "from", "a", "tomodir", "into", "this", "instance" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1003-L1011
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.plot_eps_data_hist
def plot_eps_data_hist(self, dfs): """Plot histograms of data residuals and data error weighting TODO: * add percentage of data below/above the RMS value """ # check if this is a DC inversion if 'datum' in dfs[0]: dc_inv = True else: d...
python
def plot_eps_data_hist(self, dfs): """Plot histograms of data residuals and data error weighting TODO: * add percentage of data below/above the RMS value """ # check if this is a DC inversion if 'datum' in dfs[0]: dc_inv = True else: d...
[ "def", "plot_eps_data_hist", "(", "self", ",", "dfs", ")", ":", "if", "'datum'", "in", "dfs", "[", "0", "]", ":", "dc_inv", "=", "True", "else", ":", "dc_inv", "=", "False", "nr_y", "=", "len", "(", "dfs", ")", "size_y", "=", "5", "/", "2.54", "*...
Plot histograms of data residuals and data error weighting TODO: * add percentage of data below/above the RMS value
[ "Plot", "histograms", "of", "data", "residuals", "and", "data", "error", "weighting" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1038-L1140
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._read_eps_ctr
def _read_eps_ctr(tomodir): """Parse a CRTomo eps.ctr file. TODO: change parameters to only provide eps.ctr file Parameters ---------- tomodir: string Path to directory path Returns ------- """ epsctr_file = tomodir + os.sep + 'inv...
python
def _read_eps_ctr(tomodir): """Parse a CRTomo eps.ctr file. TODO: change parameters to only provide eps.ctr file Parameters ---------- tomodir: string Path to directory path Returns ------- """ epsctr_file = tomodir + os.sep + 'inv...
[ "def", "_read_eps_ctr", "(", "tomodir", ")", ":", "epsctr_file", "=", "tomodir", "+", "os", ".", "sep", "+", "'inv'", "+", "os", ".", "sep", "+", "'eps.ctr'", "if", "not", "os", ".", "path", ".", "isfile", "(", "epsctr_file", ")", ":", "print", "(", ...
Parse a CRTomo eps.ctr file. TODO: change parameters to only provide eps.ctr file Parameters ---------- tomodir: string Path to directory path Returns -------
[ "Parse", "a", "CRTomo", "eps", ".", "ctr", "file", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1218-L1258
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan._read_resm_m
def _read_resm_m(self, tomodir): """Read in the resolution matrix of an inversion Parameters ---------- tomodir: string directory path to a tomodir """ resm_file = tomodir + os.sep + 'inv' + os.sep + 'res_m.diag' if not os.path.isfile(resm_file): ...
python
def _read_resm_m(self, tomodir): """Read in the resolution matrix of an inversion Parameters ---------- tomodir: string directory path to a tomodir """ resm_file = tomodir + os.sep + 'inv' + os.sep + 'res_m.diag' if not os.path.isfile(resm_file): ...
[ "def", "_read_resm_m", "(", "self", ",", "tomodir", ")", ":", "resm_file", "=", "tomodir", "+", "os", ".", "sep", "+", "'inv'", "+", "os", ".", "sep", "+", "'res_m.diag'", "if", "not", "os", ".", "path", ".", "isfile", "(", "resm_file", ")", ":", "...
Read in the resolution matrix of an inversion Parameters ---------- tomodir: string directory path to a tomodir
[ "Read", "in", "the", "resolution", "matrix", "of", "an", "inversion" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1622-L1648
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.register_forward_model
def register_forward_model(self, pid_mag, pid_pha): """Register parameter sets as the forward models for magnitude and phase Parameters ---------- pid_mag: int parameter id corresponding to the magnitude model pid_pha: int parameter id correspondi...
python
def register_forward_model(self, pid_mag, pid_pha): """Register parameter sets as the forward models for magnitude and phase Parameters ---------- pid_mag: int parameter id corresponding to the magnitude model pid_pha: int parameter id correspondi...
[ "def", "register_forward_model", "(", "self", ",", "pid_mag", ",", "pid_pha", ")", ":", "self", ".", "register_magnitude_model", "(", "pid_mag", ")", "self", ".", "register_phase_model", "(", "pid_pha", ")" ]
Register parameter sets as the forward models for magnitude and phase Parameters ---------- pid_mag: int parameter id corresponding to the magnitude model pid_pha: int parameter id corresponding to the phase model
[ "Register", "parameter", "sets", "as", "the", "forward", "models", "for", "magnitude", "and", "phase" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1686-L1698
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.register_magnitude_model
def register_magnitude_model(self, pid): """Set a given parameter model to the forward magnitude model """ if self.assignments['forward_model'] is None: self.assignments['forward_model'] = [None, None] self.assignments['forward_model'][0] = pid
python
def register_magnitude_model(self, pid): """Set a given parameter model to the forward magnitude model """ if self.assignments['forward_model'] is None: self.assignments['forward_model'] = [None, None] self.assignments['forward_model'][0] = pid
[ "def", "register_magnitude_model", "(", "self", ",", "pid", ")", ":", "if", "self", ".", "assignments", "[", "'forward_model'", "]", "is", "None", ":", "self", ".", "assignments", "[", "'forward_model'", "]", "=", "[", "None", ",", "None", "]", "self", "...
Set a given parameter model to the forward magnitude model
[ "Set", "a", "given", "parameter", "model", "to", "the", "forward", "magnitude", "model" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1700-L1706
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.register_phase_model
def register_phase_model(self, pid): """Set a given parameter model to the forward phase model """ if self.assignments['forward_model'] is None: self.assignments['forward_model'] = [None, None] self.assignments['forward_model'][1] = pid
python
def register_phase_model(self, pid): """Set a given parameter model to the forward phase model """ if self.assignments['forward_model'] is None: self.assignments['forward_model'] = [None, None] self.assignments['forward_model'][1] = pid
[ "def", "register_phase_model", "(", "self", ",", "pid", ")", ":", "if", "self", ".", "assignments", "[", "'forward_model'", "]", "is", "None", ":", "self", ".", "assignments", "[", "'forward_model'", "]", "=", "[", "None", ",", "None", "]", "self", ".", ...
Set a given parameter model to the forward phase model
[ "Set", "a", "given", "parameter", "model", "to", "the", "forward", "phase", "model" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1708-L1714
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.add_homogeneous_model
def add_homogeneous_model(self, magnitude, phase=0): """Add a homogeneous resistivity model to the tomodir. This is useful for synthetic measurements. Parameters ---------- magnitude : float magnitude [Ohm m] value of the homogeneous model phase : float, opti...
python
def add_homogeneous_model(self, magnitude, phase=0): """Add a homogeneous resistivity model to the tomodir. This is useful for synthetic measurements. Parameters ---------- magnitude : float magnitude [Ohm m] value of the homogeneous model phase : float, opti...
[ "def", "add_homogeneous_model", "(", "self", ",", "magnitude", ",", "phase", "=", "0", ")", ":", "if", "self", ".", "assignments", "[", "'forward_model'", "]", "is", "not", "None", ":", "print", "(", "'model already set, will overwrite'", ")", "magnitude_model",...
Add a homogeneous resistivity model to the tomodir. This is useful for synthetic measurements. Parameters ---------- magnitude : float magnitude [Ohm m] value of the homogeneous model phase : float, optional phase [mrad] value of the homogeneous model ...
[ "Add", "a", "homogeneous", "resistivity", "model", "to", "the", "tomodir", ".", "This", "is", "useful", "for", "synthetic", "measurements", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1716-L1748
train
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.show_parset
def show_parset(self, pid): """Plot a given parameter set """ fig, ax = plt.subplots() self.plot.plot_elements_to_ax(pid, ax=ax) return fig, ax
python
def show_parset(self, pid): """Plot a given parameter set """ fig, ax = plt.subplots() self.plot.plot_elements_to_ax(pid, ax=ax) return fig, ax
[ "def", "show_parset", "(", "self", ",", "pid", ")", ":", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", ")", "self", ".", "plot", ".", "plot_elements_to_ax", "(", "pid", ",", "ax", "=", "ax", ")", "return", "fig", ",", "ax" ]
Plot a given parameter set
[ "Plot", "a", "given", "parameter", "set" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L1882-L1887
train
wdv4758h/python-everywhere
setup.py
cythonize
def cythonize(*args, **kwargs): ''' dirty hack, only import cythonize at the time you use it. if you don't write Cython extension, you won't fail even if you don't install Cython. ''' global cythonize from Cython.Build import cythonize return cythonize(*args, **kwargs)
python
def cythonize(*args, **kwargs): ''' dirty hack, only import cythonize at the time you use it. if you don't write Cython extension, you won't fail even if you don't install Cython. ''' global cythonize from Cython.Build import cythonize return cythonize(*args, **kwargs)
[ "def", "cythonize", "(", "*", "args", ",", "**", "kwargs", ")", ":", "global", "cythonize", "from", "Cython", ".", "Build", "import", "cythonize", "return", "cythonize", "(", "*", "args", ",", "**", "kwargs", ")" ]
dirty hack, only import cythonize at the time you use it. if you don't write Cython extension, you won't fail even if you don't install Cython.
[ "dirty", "hack", "only", "import", "cythonize", "at", "the", "time", "you", "use", "it", "." ]
1d1bafd9f908b08c7bdb0470c6e54181c928f32f
https://github.com/wdv4758h/python-everywhere/blob/1d1bafd9f908b08c7bdb0470c6e54181c928f32f/setup.py#L4-L13
train
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.response
def response(self, url): """Grab an API response.""" resp = requests.get(url).content return self.parseresponse(resp)
python
def response(self, url): """Grab an API response.""" resp = requests.get(url).content return self.parseresponse(resp)
[ "def", "response", "(", "self", ",", "url", ")", ":", "resp", "=", "requests", ".", "get", "(", "url", ")", ".", "content", "return", "self", ".", "parseresponse", "(", "resp", ")" ]
Grab an API response.
[ "Grab", "an", "API", "response", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L84-L88
train
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.errorhandle
def errorhandle(self, resp): """Parse API error responses and raise appropriate exceptions.""" if self.format == 'json': parsed = xmltodict.parse(resp) errors = parsed[self.RESPONSE_TOKEN][self.ERROR_TOKEN] # Create list of errors if more than one error re...
python
def errorhandle(self, resp): """Parse API error responses and raise appropriate exceptions.""" if self.format == 'json': parsed = xmltodict.parse(resp) errors = parsed[self.RESPONSE_TOKEN][self.ERROR_TOKEN] # Create list of errors if more than one error re...
[ "def", "errorhandle", "(", "self", ",", "resp", ")", ":", "if", "self", ".", "format", "==", "'json'", ":", "parsed", "=", "xmltodict", ".", "parse", "(", "resp", ")", "errors", "=", "parsed", "[", "self", ".", "RESPONSE_TOKEN", "]", "[", "self", "."...
Parse API error responses and raise appropriate exceptions.
[ "Parse", "API", "error", "responses", "and", "raise", "appropriate", "exceptions", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L90-L111
train
nhfruchter/pgh-bustime
pghbustime/interface.py
BustimeAPI.parseresponse
def parseresponse(self, resp): """Parse an API response.""" # Support Python 3's bytes type from socket repsonses if sys.version_info.major > 2: resp = resp.decode('utf-8') if self.RESPONSE_TOKEN not in resp: raise BustimeError("The Bustime API returned an inval...
python
def parseresponse(self, resp): """Parse an API response.""" # Support Python 3's bytes type from socket repsonses if sys.version_info.major > 2: resp = resp.decode('utf-8') if self.RESPONSE_TOKEN not in resp: raise BustimeError("The Bustime API returned an inval...
[ "def", "parseresponse", "(", "self", ",", "resp", ")", ":", "if", "sys", ".", "version_info", ".", "major", ">", "2", ":", "resp", "=", "resp", ".", "decode", "(", "'utf-8'", ")", "if", "self", ".", "RESPONSE_TOKEN", "not", "in", "resp", ":", "raise"...
Parse an API response.
[ "Parse", "an", "API", "response", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L113-L127
train
zalando-stups/lizzy-client
lizzy_client/utils.py
get_stack_refs
def get_stack_refs(refs: list): # copy pasted from Senza """ Returns a list of stack references with name and version. """ refs = list(refs) refs.reverse() stack_refs = [] last_stack = None while refs: ref = refs.pop() if last_stack is not None and re.compile(r'v[0-9][a-...
python
def get_stack_refs(refs: list): # copy pasted from Senza """ Returns a list of stack references with name and version. """ refs = list(refs) refs.reverse() stack_refs = [] last_stack = None while refs: ref = refs.pop() if last_stack is not None and re.compile(r'v[0-9][a-...
[ "def", "get_stack_refs", "(", "refs", ":", "list", ")", ":", "refs", "=", "list", "(", "refs", ")", "refs", ".", "reverse", "(", ")", "stack_refs", "=", "[", "]", "last_stack", "=", "None", "while", "refs", ":", "ref", "=", "refs", ".", "pop", "(",...
Returns a list of stack references with name and version.
[ "Returns", "a", "list", "of", "stack", "references", "with", "name", "and", "version", "." ]
0af9733ca5a25ebd0a9dc1453f2a7592efcee56a
https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/utils.py#L35-L62
train
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.instance_for_arguments
def instance_for_arguments(self, arguments): """ Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel attributed to this instance. Parameters ---------- arguments : dict The dictionary representation of prior an...
python
def instance_for_arguments(self, arguments): """ Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel attributed to this instance. Parameters ---------- arguments : dict The dictionary representation of prior an...
[ "def", "instance_for_arguments", "(", "self", ",", "arguments", ")", ":", "model_instance", "=", "ModelInstance", "(", ")", "for", "prior_model_tuple", "in", "self", ".", "prior_model_tuples", ":", "setattr", "(", "model_instance", ",", "prior_model_tuple", ".", "...
Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel attributed to this instance. Parameters ---------- arguments : dict The dictionary representation of prior and parameter values. This is created in the model_instance_from_* ...
[ "Creates", "a", "ModelInstance", "which", "has", "an", "attribute", "and", "class", "instance", "corresponding", "to", "every", "PriorModel", "attributed", "to", "this", "instance", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L378-L402
train
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.mapper_from_partial_prior_arguments
def mapper_from_partial_prior_arguments(self, arguments): """ Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors, keeping existing priors where no mapping is provided. Parameters ---------- arguments: {Prior: Prior} A di...
python
def mapper_from_partial_prior_arguments(self, arguments): """ Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors, keeping existing priors where no mapping is provided. Parameters ---------- arguments: {Prior: Prior} A di...
[ "def", "mapper_from_partial_prior_arguments", "(", "self", ",", "arguments", ")", ":", "original_prior_dict", "=", "{", "prior", ":", "prior", "for", "prior", "in", "self", ".", "priors", "}", "return", "self", ".", "mapper_from_prior_arguments", "(", "{", "**",...
Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors, keeping existing priors where no mapping is provided. Parameters ---------- arguments: {Prior: Prior} A dictionary mapping_matrix priors to priors Returns ------- ...
[ "Creates", "a", "new", "model", "mapper", "from", "a", "dictionary", "mapping_matrix", "existing", "priors", "to", "new", "priors", "keeping", "existing", "priors", "where", "no", "mapping", "is", "provided", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L404-L420
train
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.mapper_from_prior_arguments
def mapper_from_prior_arguments(self, arguments): """ Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors. Parameters ---------- arguments: {Prior: Prior} A dictionary mapping_matrix priors to priors Returns ----...
python
def mapper_from_prior_arguments(self, arguments): """ Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors. Parameters ---------- arguments: {Prior: Prior} A dictionary mapping_matrix priors to priors Returns ----...
[ "def", "mapper_from_prior_arguments", "(", "self", ",", "arguments", ")", ":", "mapper", "=", "copy", ".", "deepcopy", "(", "self", ")", "for", "prior_model_tuple", "in", "self", ".", "prior_model_tuples", ":", "setattr", "(", "mapper", ",", "prior_model_tuple",...
Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors. Parameters ---------- arguments: {Prior: Prior} A dictionary mapping_matrix priors to priors Returns ------- model_mapper: ModelMapper A new model mapper w...
[ "Creates", "a", "new", "model", "mapper", "from", "a", "dictionary", "mapping_matrix", "existing", "priors", "to", "new", "priors", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L422-L442
train
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.mapper_from_gaussian_tuples
def mapper_from_gaussian_tuples(self, tuples, a=None, r=None): """ Creates a new model mapper from a list of floats describing the mean values of gaussian priors. The widths \ of the new priors are taken from the width_config. The new gaussian priors must be provided in the same \ order ...
python
def mapper_from_gaussian_tuples(self, tuples, a=None, r=None): """ Creates a new model mapper from a list of floats describing the mean values of gaussian priors. The widths \ of the new priors are taken from the width_config. The new gaussian priors must be provided in the same \ order ...
[ "def", "mapper_from_gaussian_tuples", "(", "self", ",", "tuples", ",", "a", "=", "None", ",", "r", "=", "None", ")", ":", "prior_tuples", "=", "self", ".", "prior_tuples_ordered_by_id", "prior_class_dict", "=", "self", ".", "prior_class_dict", "arguments", "=", ...
Creates a new model mapper from a list of floats describing the mean values of gaussian priors. The widths \ of the new priors are taken from the width_config. The new gaussian priors must be provided in the same \ order as the priors associated with model. If a is not None then all priors are ...
[ "Creates", "a", "new", "model", "mapper", "from", "a", "list", "of", "floats", "describing", "the", "mean", "values", "of", "gaussian", "priors", ".", "The", "widths", "\\", "of", "the", "new", "priors", "are", "taken", "from", "the", "width_config", ".", ...
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L444-L499
train
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
ModelMapper.info
def info(self): """ Use the priors that make up the model_mapper to generate information on each parameter of the overall model. This information is extracted from each priors *model_info* property. """ info = [] for prior_model_name, prior_model in self.prior_model_tup...
python
def info(self): """ Use the priors that make up the model_mapper to generate information on each parameter of the overall model. This information is extracted from each priors *model_info* property. """ info = [] for prior_model_name, prior_model in self.prior_model_tup...
[ "def", "info", "(", "self", ")", ":", "info", "=", "[", "]", "for", "prior_model_name", ",", "prior_model", "in", "self", ".", "prior_model_tuples", ":", "info", ".", "append", "(", "prior_model", ".", "name", "+", "'\\n'", ")", "info", ".", "extend", ...
Use the priors that make up the model_mapper to generate information on each parameter of the overall model. This information is extracted from each priors *model_info* property.
[ "Use", "the", "priors", "that", "make", "up", "the", "model_mapper", "to", "generate", "information", "on", "each", "parameter", "of", "the", "overall", "model", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L520-L532
train
peterbe/gg
gg/builtins/push/gg_push.py
push
def push(config, force=False): """Create push the current branch.""" repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out( "Can't commit when on the master branch. " "You really ought to do work in branches." ) s...
python
def push(config, force=False): """Create push the current branch.""" repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out( "Can't commit when on the master branch. " "You really ought to do work in branches." ) s...
[ "def", "push", "(", "config", ",", "force", "=", "False", ")", ":", "repo", "=", "config", ".", "repo", "active_branch", "=", "repo", ".", "active_branch", "if", "active_branch", ".", "name", "==", "\"master\"", ":", "error_out", "(", "\"Can't commit when on...
Create push the current branch.
[ "Create", "push", "the", "current", "branch", "." ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/push/gg_push.py#L12-L52
train
tslight/treepick
treepick/__main__.py
chkpath
def chkpath(path): """ Checks if a path exists. """ if os.path.exists(path): return path else: msg = "{0} does not exist.".format(path) raise argparse.ArgumentTypeError(msg)
python
def chkpath(path): """ Checks if a path exists. """ if os.path.exists(path): return path else: msg = "{0} does not exist.".format(path) raise argparse.ArgumentTypeError(msg)
[ "def", "chkpath", "(", "path", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "path", "else", ":", "msg", "=", "\"{0} does not exist.\"", ".", "format", "(", "path", ")", "raise", "argparse", ".", "ArgumentTypeError", ...
Checks if a path exists.
[ "Checks", "if", "a", "path", "exists", "." ]
7adf838900f11e8845e17d8c79bb2b23617aec2c
https://github.com/tslight/treepick/blob/7adf838900f11e8845e17d8c79bb2b23617aec2c/treepick/__main__.py#L14-L22
train
geophysics-ubonn/crtomo_tools
src/volt_correct_temperature.py
readin_volt
def readin_volt(filename): """Read in measurement data from a volt.dat file and return electrodes and measured resistance. """ with open(filename, 'r') as fid: content = np.loadtxt(fid, skiprows=1, usecols=[0, 1, 2]) volt = content[:, 2] elecs = content[:, 0:2] return elecs, ...
python
def readin_volt(filename): """Read in measurement data from a volt.dat file and return electrodes and measured resistance. """ with open(filename, 'r') as fid: content = np.loadtxt(fid, skiprows=1, usecols=[0, 1, 2]) volt = content[:, 2] elecs = content[:, 0:2] return elecs, ...
[ "def", "readin_volt", "(", "filename", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "fid", ":", "content", "=", "np", ".", "loadtxt", "(", "fid", ",", "skiprows", "=", "1", ",", "usecols", "=", "[", "0", ",", "1", ",", "2", ...
Read in measurement data from a volt.dat file and return electrodes and measured resistance.
[ "Read", "in", "measurement", "data", "from", "a", "volt", ".", "dat", "file", "and", "return", "electrodes", "and", "measured", "resistance", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/volt_correct_temperature.py#L56-L64
train
geophysics-ubonn/crtomo_tools
src/volt_correct_temperature.py
save_volt
def save_volt(elecs, volt, filename): """Save the values in volt-format. """ # bring data in shape content = np.column_stack((elecs, volt, np.zeros(len(volt)))) # save datapoints with open(filename, 'w') as fid: fid.write('{0}\n'.format(content.shape[0])) with open(filename, 'ab') a...
python
def save_volt(elecs, volt, filename): """Save the values in volt-format. """ # bring data in shape content = np.column_stack((elecs, volt, np.zeros(len(volt)))) # save datapoints with open(filename, 'w') as fid: fid.write('{0}\n'.format(content.shape[0])) with open(filename, 'ab') a...
[ "def", "save_volt", "(", "elecs", ",", "volt", ",", "filename", ")", ":", "content", "=", "np", ".", "column_stack", "(", "(", "elecs", ",", "volt", ",", "np", ".", "zeros", "(", "len", "(", "volt", ")", ")", ")", ")", "with", "open", "(", "filen...
Save the values in volt-format.
[ "Save", "the", "values", "in", "volt", "-", "format", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/volt_correct_temperature.py#L90-L100
train
geophysics-ubonn/crtomo_tools
src/volt_correct_temperature.py
main
def main(): """Function to remove temperature effect from field data """ options = handle_options() # read in observed and synthetic data elecs, d_obs = readin_volt(options.d_obs) elecs, d_est = readin_volt(options.d_est) elecs, d_estTC = readin_volt(options.d_estTC) # calculate correct...
python
def main(): """Function to remove temperature effect from field data """ options = handle_options() # read in observed and synthetic data elecs, d_obs = readin_volt(options.d_obs) elecs, d_est = readin_volt(options.d_est) elecs, d_estTC = readin_volt(options.d_estTC) # calculate correct...
[ "def", "main", "(", ")", ":", "options", "=", "handle_options", "(", ")", "elecs", ",", "d_obs", "=", "readin_volt", "(", "options", ".", "d_obs", ")", "elecs", ",", "d_est", "=", "readin_volt", "(", "options", ".", "d_est", ")", "elecs", ",", "d_estTC...
Function to remove temperature effect from field data
[ "Function", "to", "remove", "temperature", "effect", "from", "field", "data" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/volt_correct_temperature.py#L103-L121
train
Maples7/dict-recursive-update
dict_recursive_update/__init__.py
recursive_update
def recursive_update(default, custom): '''Return a dict merged from default and custom >>> recursive_update('a', 'b') Traceback (most recent call last): ... TypeError: Params of recursive_update should be dicts >>> recursive_update({'a': [1]}, {'a': [2], 'c': {'d': {'c': 3}}}) {'a': [2...
python
def recursive_update(default, custom): '''Return a dict merged from default and custom >>> recursive_update('a', 'b') Traceback (most recent call last): ... TypeError: Params of recursive_update should be dicts >>> recursive_update({'a': [1]}, {'a': [2], 'c': {'d': {'c': 3}}}) {'a': [2...
[ "def", "recursive_update", "(", "default", ",", "custom", ")", ":", "if", "not", "isinstance", "(", "default", ",", "dict", ")", "or", "not", "isinstance", "(", "custom", ",", "dict", ")", ":", "raise", "TypeError", "(", "'Params of recursive_update should be ...
Return a dict merged from default and custom >>> recursive_update('a', 'b') Traceback (most recent call last): ... TypeError: Params of recursive_update should be dicts >>> recursive_update({'a': [1]}, {'a': [2], 'c': {'d': {'c': 3}}}) {'a': [2], 'c': {'d': {'c': 3}}} >>> recursive_up...
[ "Return", "a", "dict", "merged", "from", "default", "and", "custom" ]
07204cdab891ac4123b19fe3fa148c3dd1c93992
https://github.com/Maples7/dict-recursive-update/blob/07204cdab891ac4123b19fe3fa148c3dd1c93992/dict_recursive_update/__init__.py#L11-L38
train
peterbe/gg
gg/builtins/cleanup/gg_cleanup.py
cleanup
def cleanup(config, searchstring, force=False): """Deletes a found branch locally and remotely.""" repo = config.repo branches_ = list(find(repo, searchstring)) if not branches_: error_out("No branches found") elif len(branches_) > 1: error_out( "More than one branch fou...
python
def cleanup(config, searchstring, force=False): """Deletes a found branch locally and remotely.""" repo = config.repo branches_ = list(find(repo, searchstring)) if not branches_: error_out("No branches found") elif len(branches_) > 1: error_out( "More than one branch fou...
[ "def", "cleanup", "(", "config", ",", "searchstring", ",", "force", "=", "False", ")", ":", "repo", "=", "config", ".", "repo", "branches_", "=", "list", "(", "find", "(", "repo", ",", "searchstring", ")", ")", "if", "not", "branches_", ":", "error_out...
Deletes a found branch locally and remotely.
[ "Deletes", "a", "found", "branch", "locally", "and", "remotely", "." ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/cleanup/gg_cleanup.py#L13-L84
train
geophysics-ubonn/crtomo_tools
src/td_correct_temperature.py
calc_correction
def calc_correction(temp, mag, add=False, T_std=10, m=0.021): """Function to add or substract the temperature effect to given data. The function can be called in python scripts. For application via command line in a file system use the script td_correct_temperature.py. The data is taken and given in Ohm...
python
def calc_correction(temp, mag, add=False, T_std=10, m=0.021): """Function to add or substract the temperature effect to given data. The function can be called in python scripts. For application via command line in a file system use the script td_correct_temperature.py. The data is taken and given in Ohm...
[ "def", "calc_correction", "(", "temp", ",", "mag", ",", "add", "=", "False", ",", "T_std", "=", "10", ",", "m", "=", "0.021", ")", ":", "if", "mag", ".", "shape", "[", "1", "]", "==", "3", ":", "if", "add", ":", "data_x", "=", "(", "m", "*", ...
Function to add or substract the temperature effect to given data. The function can be called in python scripts. For application via command line in a file system use the script td_correct_temperature.py. The data is taken and given in Ohmm. rho_std_i = (m * (T_i - 25°) + 1) / (m * (T_std - 25°) + 1) *...
[ "Function", "to", "add", "or", "substract", "the", "temperature", "effect", "to", "given", "data", ".", "The", "function", "can", "be", "called", "in", "python", "scripts", ".", "For", "application", "via", "command", "line", "in", "a", "file", "system", "...
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_correct_temperature.py#L137-L173
train
geophysics-ubonn/crtomo_tools
src/td_correct_temperature.py
save_mag_to_file
def save_mag_to_file(mag, filename, rhofile): """Save the values in rho- or mag-format. """ if rhofile: # bring data in shape null = np.zeros(len(mag)) if mag.shape[1] == 3: null = np.column_stack((null, null, null, null)) result = np.column_stack((mag, null)) ...
python
def save_mag_to_file(mag, filename, rhofile): """Save the values in rho- or mag-format. """ if rhofile: # bring data in shape null = np.zeros(len(mag)) if mag.shape[1] == 3: null = np.column_stack((null, null, null, null)) result = np.column_stack((mag, null)) ...
[ "def", "save_mag_to_file", "(", "mag", ",", "filename", ",", "rhofile", ")", ":", "if", "rhofile", ":", "null", "=", "np", ".", "zeros", "(", "len", "(", "mag", ")", ")", "if", "mag", ".", "shape", "[", "1", "]", "==", "3", ":", "null", "=", "n...
Save the values in rho- or mag-format.
[ "Save", "the", "values", "in", "rho", "-", "or", "mag", "-", "format", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_correct_temperature.py#L176-L210
train
geophysics-ubonn/crtomo_tools
src/td_correct_temperature.py
main
def main(): """Function to add or substract the temperature effect to data in a tomodir """ options = handle_options() # read in temperature and resistivity data tempdata = readin_temp(options.temp_file) magdata = readin_rho(options.filename, options.rhofile, ...
python
def main(): """Function to add or substract the temperature effect to data in a tomodir """ options = handle_options() # read in temperature and resistivity data tempdata = readin_temp(options.temp_file) magdata = readin_rho(options.filename, options.rhofile, ...
[ "def", "main", "(", ")", ":", "options", "=", "handle_options", "(", ")", "tempdata", "=", "readin_temp", "(", "options", ".", "temp_file", ")", "magdata", "=", "readin_rho", "(", "options", ".", "filename", ",", "options", ".", "rhofile", ",", "aniso", ...
Function to add or substract the temperature effect to data in a tomodir
[ "Function", "to", "add", "or", "substract", "the", "temperature", "effect", "to", "data", "in", "a", "tomodir" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_correct_temperature.py#L213-L232
train
lalinsky/mbdata
mbdata/api/utils.py
singular
def singular(plural): """ Take a plural English word and turn it into singular Obviously, this doesn't work in general. It know just enough words to generate XML tag names for list items. For example, if we have an element called 'tracks' in the response, it will be serialized as a list without ...
python
def singular(plural): """ Take a plural English word and turn it into singular Obviously, this doesn't work in general. It know just enough words to generate XML tag names for list items. For example, if we have an element called 'tracks' in the response, it will be serialized as a list without ...
[ "def", "singular", "(", "plural", ")", ":", "if", "plural", ".", "endswith", "(", "'ies'", ")", ":", "return", "plural", "[", ":", "-", "3", "]", "+", "'y'", "if", "plural", ".", "endswith", "(", "'s'", ")", ":", "return", "plural", "[", ":", "-"...
Take a plural English word and turn it into singular Obviously, this doesn't work in general. It know just enough words to generate XML tag names for list items. For example, if we have an element called 'tracks' in the response, it will be serialized as a list without named items in JSON, but we need ...
[ "Take", "a", "plural", "English", "word", "and", "turn", "it", "into", "singular" ]
1ec788834047ced8614ad9763e430afe1d1e65e7
https://github.com/lalinsky/mbdata/blob/1ec788834047ced8614ad9763e430afe1d1e65e7/mbdata/api/utils.py#L56-L70
train
geophysics-ubonn/crtomo_tools
src/sens_center_plot.py
sens_center.plot_single_configuration
def plot_single_configuration(self, config_nr, sens_file): """ plot sensitivity distribution with center of mass for a single configuration. The electrodes used are colored. Parameters ---------- config_nr: int number of configuration sens_file: strin...
python
def plot_single_configuration(self, config_nr, sens_file): """ plot sensitivity distribution with center of mass for a single configuration. The electrodes used are colored. Parameters ---------- config_nr: int number of configuration sens_file: strin...
[ "def", "plot_single_configuration", "(", "self", ",", "config_nr", ",", "sens_file", ")", ":", "indices", "=", "elem", ".", "load_column_file_to_elements_advanced", "(", "sens_file", ",", "[", "2", ",", "3", "]", ",", "False", ",", "False", ")", "elem", ".",...
plot sensitivity distribution with center of mass for a single configuration. The electrodes used are colored. Parameters ---------- config_nr: int number of configuration sens_file: string, file path filename to sensitvity file
[ "plot", "sensitivity", "distribution", "with", "center", "of", "mass", "for", "a", "single", "configuration", ".", "The", "electrodes", "used", "are", "colored", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sens_center_plot.py#L168-L220
train
geophysics-ubonn/crtomo_tools
src/sens_center_plot.py
sens_center.plot_sens_center
def plot_sens_center(self, frequency=2): """ plot sensitivity center distribution for all configurations in config.dat. The centers of mass are colored by the data given in volt_file. """ try: colors = np.loadtxt(self.volt_file, skiprows=1) except IOE...
python
def plot_sens_center(self, frequency=2): """ plot sensitivity center distribution for all configurations in config.dat. The centers of mass are colored by the data given in volt_file. """ try: colors = np.loadtxt(self.volt_file, skiprows=1) except IOE...
[ "def", "plot_sens_center", "(", "self", ",", "frequency", "=", "2", ")", ":", "try", ":", "colors", "=", "np", ".", "loadtxt", "(", "self", ".", "volt_file", ",", "skiprows", "=", "1", ")", "except", "IOError", ":", "print", "(", "'IOError opening {0}'",...
plot sensitivity center distribution for all configurations in config.dat. The centers of mass are colored by the data given in volt_file.
[ "plot", "sensitivity", "center", "distribution", "for", "all", "configurations", "in", "config", ".", "dat", ".", "The", "centers", "of", "mass", "are", "colored", "by", "the", "data", "given", "in", "volt_file", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sens_center_plot.py#L222-L269
train
geophysics-ubonn/crtomo_tools
src/sens_center_plot.py
sens_center.color_electrodes
def color_electrodes(self, config_nr, ax): """ Color the electrodes used in specific configuration. Voltage electrodes are yellow, Current electrodes are red ?! """ electrodes = np.loadtxt(options.config_file, skiprows=1) electrodes = self.configs[~np.isnan(self.configs)....
python
def color_electrodes(self, config_nr, ax): """ Color the electrodes used in specific configuration. Voltage electrodes are yellow, Current electrodes are red ?! """ electrodes = np.loadtxt(options.config_file, skiprows=1) electrodes = self.configs[~np.isnan(self.configs)....
[ "def", "color_electrodes", "(", "self", ",", "config_nr", ",", "ax", ")", ":", "electrodes", "=", "np", ".", "loadtxt", "(", "options", ".", "config_file", ",", "skiprows", "=", "1", ")", "electrodes", "=", "self", ".", "configs", "[", "~", "np", ".", ...
Color the electrodes used in specific configuration. Voltage electrodes are yellow, Current electrodes are red ?!
[ "Color", "the", "electrodes", "used", "in", "specific", "configuration", ".", "Voltage", "electrodes", "are", "yellow", "Current", "electrodes", "are", "red", "?!" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sens_center_plot.py#L271-L291
train
geophysics-ubonn/crtomo_tools
src/sens_center_plot.py
sens_center.compute_sens
def compute_sens(self, elem_file, elec_file, configs): """ Compute the sensitivities for the given input data. A CRMod instance is called to create the sensitivity files. """ CRMod_config = CRMod.config() # activate 2D mode and set sink nr if self.options.sink is ...
python
def compute_sens(self, elem_file, elec_file, configs): """ Compute the sensitivities for the given input data. A CRMod instance is called to create the sensitivity files. """ CRMod_config = CRMod.config() # activate 2D mode and set sink nr if self.options.sink is ...
[ "def", "compute_sens", "(", "self", ",", "elem_file", ",", "elec_file", ",", "configs", ")", ":", "CRMod_config", "=", "CRMod", ".", "config", "(", ")", "if", "self", ".", "options", ".", "sink", "is", "not", "None", ":", "print", "(", "'2D mode with sin...
Compute the sensitivities for the given input data. A CRMod instance is called to create the sensitivity files.
[ "Compute", "the", "sensitivities", "for", "the", "given", "input", "data", ".", "A", "CRMod", "instance", "is", "called", "to", "create", "the", "sensitivity", "files", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sens_center_plot.py#L293-L328
train
geophysics-ubonn/crtomo_tools
src/sens_center_plot.py
sens_center.compute_center_of_mass
def compute_center_of_mass(self, filename): """ Center of mass is computed using the sensitivity data output from CRMod Data weights can be applied using command line options """ sens = np.loadtxt(filename, skiprows=1) X = sens[:, 0] Z = sens[:, 1] # C = ...
python
def compute_center_of_mass(self, filename): """ Center of mass is computed using the sensitivity data output from CRMod Data weights can be applied using command line options """ sens = np.loadtxt(filename, skiprows=1) X = sens[:, 0] Z = sens[:, 1] # C = ...
[ "def", "compute_center_of_mass", "(", "self", ",", "filename", ")", ":", "sens", "=", "np", ".", "loadtxt", "(", "filename", ",", "skiprows", "=", "1", ")", "X", "=", "sens", "[", ":", ",", "0", "]", "Z", "=", "sens", "[", ":", ",", "1", "]", "...
Center of mass is computed using the sensitivity data output from CRMod Data weights can be applied using command line options
[ "Center", "of", "mass", "is", "computed", "using", "the", "sensitivity", "data", "output", "from", "CRMod", "Data", "weights", "can", "be", "applied", "using", "command", "line", "options" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sens_center_plot.py#L330-L366
train
geophysics-ubonn/crtomo_tools
src/td_init.py
handle_cmd_options
def handle_cmd_options(): ''' Get the options from the command line. ''' parser = OptionParser() parser.add_option("-s", "--silent", action="store_true", dest="silent", help="print any warnings", default=False) (options, args) = parser.parse_args() return options, args
python
def handle_cmd_options(): ''' Get the options from the command line. ''' parser = OptionParser() parser.add_option("-s", "--silent", action="store_true", dest="silent", help="print any warnings", default=False) (options, args) = parser.parse_args() return options, args
[ "def", "handle_cmd_options", "(", ")", ":", "parser", "=", "OptionParser", "(", ")", "parser", ".", "add_option", "(", "\"-s\"", ",", "\"--silent\"", ",", "action", "=", "\"store_true\"", ",", "dest", "=", "\"silent\"", ",", "help", "=", "\"print any warnings\...
Get the options from the command line.
[ "Get", "the", "options", "from", "the", "command", "line", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_init.py#L18-L26
train
geophysics-ubonn/crtomo_tools
src/td_init.py
move
def move(fname, folder, options): """Move file to dir if existing """ if os.path.isfile(fname): shutil.move(fname, folder) else: if options.silent is False: print('{0} missing'.format(fname))
python
def move(fname, folder, options): """Move file to dir if existing """ if os.path.isfile(fname): shutil.move(fname, folder) else: if options.silent is False: print('{0} missing'.format(fname))
[ "def", "move", "(", "fname", ",", "folder", ",", "options", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "fname", ")", ":", "shutil", ".", "move", "(", "fname", ",", "folder", ")", "else", ":", "if", "options", ".", "silent", "is", "Fal...
Move file to dir if existing
[ "Move", "file", "to", "dir", "if", "existing" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_init.py#L29-L36
train
Infinidat/infi.traceback
src/infi/traceback/__init__.py
print_tb
def print_tb(tb, limit=None, file=None): """Print up to 'limit' stack trace entries from the traceback 'tb'. If 'limit' is omitted or None, all entries are printed. If 'file' is omitted or None, the output goes to sys.stderr; otherwise 'file' should be an open file or file-like object with a write() ...
python
def print_tb(tb, limit=None, file=None): """Print up to 'limit' stack trace entries from the traceback 'tb'. If 'limit' is omitted or None, all entries are printed. If 'file' is omitted or None, the output goes to sys.stderr; otherwise 'file' should be an open file or file-like object with a write() ...
[ "def", "print_tb", "(", "tb", ",", "limit", "=", "None", ",", "file", "=", "None", ")", ":", "if", "file", "is", "None", ":", "file", "=", "sys", ".", "stderr", "if", "limit", "is", "None", ":", "if", "hasattr", "(", "sys", ",", "'tracebacklimit'",...
Print up to 'limit' stack trace entries from the traceback 'tb'. If 'limit' is omitted or None, all entries are printed. If 'file' is omitted or None, the output goes to sys.stderr; otherwise 'file' should be an open file or file-like object with a write() method.
[ "Print", "up", "to", "limit", "stack", "trace", "entries", "from", "the", "traceback", "tb", "." ]
ae25455ec451c136458d2781fea876964375bf8b
https://github.com/Infinidat/infi.traceback/blob/ae25455ec451c136458d2781fea876964375bf8b/src/infi/traceback/__init__.py#L85-L98
train
Infinidat/infi.traceback
src/infi/traceback/__init__.py
print_exception
def print_exception(etype, value, tb, limit=None, file=None, chain=True): """Print exception up to 'limit' stack trace entries from 'tb' to 'file'. This differs from print_tb() in the following ways: (1) if traceback is not None, it prints a header "Traceback (most recent call last):"; (2) it prints th...
python
def print_exception(etype, value, tb, limit=None, file=None, chain=True): """Print exception up to 'limit' stack trace entries from 'tb' to 'file'. This differs from print_tb() in the following ways: (1) if traceback is not None, it prints a header "Traceback (most recent call last):"; (2) it prints th...
[ "def", "print_exception", "(", "etype", ",", "value", ",", "tb", ",", "limit", "=", "None", ",", "file", "=", "None", ",", "chain", "=", "True", ")", ":", "import", "traceback", "if", "file", "is", "None", ":", "file", "=", "sys", ".", "stderr", "i...
Print exception up to 'limit' stack trace entries from 'tb' to 'file'. This differs from print_tb() in the following ways: (1) if traceback is not None, it prints a header "Traceback (most recent call last):"; (2) it prints the exception type and value after the stack trace; (3) if type is SyntaxError ...
[ "Print", "exception", "up", "to", "limit", "stack", "trace", "entries", "from", "tb", "to", "file", "." ]
ae25455ec451c136458d2781fea876964375bf8b
https://github.com/Infinidat/infi.traceback/blob/ae25455ec451c136458d2781fea876964375bf8b/src/infi/traceback/__init__.py#L168-L187
train
gofed/gofedlib
gofedlib/go/projectinfo.py
ProjectInfo.construct
def construct(self, data): """Construct info about a project from artefact :param data: golang-project-packages artefact :type data: json/dict """ occurrences = {} main_occurrences = {} # occurrences of devel packages for pkg in data["data"]["dependencies"]: package = pkg["package"] for item in...
python
def construct(self, data): """Construct info about a project from artefact :param data: golang-project-packages artefact :type data: json/dict """ occurrences = {} main_occurrences = {} # occurrences of devel packages for pkg in data["data"]["dependencies"]: package = pkg["package"] for item in...
[ "def", "construct", "(", "self", ",", "data", ")", ":", "occurrences", "=", "{", "}", "main_occurrences", "=", "{", "}", "for", "pkg", "in", "data", "[", "\"data\"", "]", "[", "\"dependencies\"", "]", ":", "package", "=", "pkg", "[", "\"package\"", "]"...
Construct info about a project from artefact :param data: golang-project-packages artefact :type data: json/dict
[ "Construct", "info", "about", "a", "project", "from", "artefact" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/go/projectinfo.py#L43-L103
train
NiklasRosenstein/py-bundler
bundler/modules.py
ModuleInfo.join_import_from
def join_import_from(self, import_spec): """ Joins a relative import like `from .foo import bar` with this module as its parent module. If the module is not a root module or package root, it will be joined with the package root. """ if not self.isroot and not self.ispkg: parent = self.nam...
python
def join_import_from(self, import_spec): """ Joins a relative import like `from .foo import bar` with this module as its parent module. If the module is not a root module or package root, it will be joined with the package root. """ if not self.isroot and not self.ispkg: parent = self.nam...
[ "def", "join_import_from", "(", "self", ",", "import_spec", ")", ":", "if", "not", "self", ".", "isroot", "and", "not", "self", ".", "ispkg", ":", "parent", "=", "self", ".", "name", ".", "rpartition", "(", "'.'", ")", "[", "0", "]", "else", ":", "...
Joins a relative import like `from .foo import bar` with this module as its parent module. If the module is not a root module or package root, it will be joined with the package root.
[ "Joins", "a", "relative", "import", "like", "from", ".", "foo", "import", "bar", "with", "this", "module", "as", "its", "parent", "module", ".", "If", "the", "module", "is", "not", "a", "root", "module", "or", "package", "root", "it", "will", "be", "jo...
80dd6dc971667ba015f7f67481417c45cc757231
https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/modules.py#L80-L91
train
geophysics-ubonn/crtomo_tools
lib/crtomo/status.py
is_tomodir
def is_tomodir(directory): """Check if the supplied directory is a tomodir Parameters ---------- directory: string Check if the supplied path is a valid tomodir Returns ------- is_tomodir: bool True if the supplied directory is a tomodir directory """ if os.path.isd...
python
def is_tomodir(directory): """Check if the supplied directory is a tomodir Parameters ---------- directory: string Check if the supplied path is a valid tomodir Returns ------- is_tomodir: bool True if the supplied directory is a tomodir directory """ if os.path.isd...
[ "def", "is_tomodir", "(", "directory", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "directory", ")", ":", "if", "(", "os", ".", "path", ".", "isdir", "(", "directory", "+", "\"/exe\"", ")", "and", "os", ".", "path", ".", "isdir", "(", "...
Check if the supplied directory is a tomodir Parameters ---------- directory: string Check if the supplied path is a valid tomodir Returns ------- is_tomodir: bool True if the supplied directory is a tomodir directory
[ "Check", "if", "the", "supplied", "directory", "is", "a", "tomodir" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/status.py#L9-L32
train
geophysics-ubonn/crtomo_tools
lib/crtomo/status.py
td_is_finished
def td_is_finished(tomodir): """Return the state of modeling and inversion for a given tomodir. The result does not take into account sensitivities or potentials, as optionally generated by CRMod. Parameters ---------- tomodir: string Directory to check Returns ------- crmo...
python
def td_is_finished(tomodir): """Return the state of modeling and inversion for a given tomodir. The result does not take into account sensitivities or potentials, as optionally generated by CRMod. Parameters ---------- tomodir: string Directory to check Returns ------- crmo...
[ "def", "td_is_finished", "(", "tomodir", ")", ":", "if", "not", "is_tomodir", "(", "tomodir", ")", ":", "raise", "Exception", "(", "'Supplied directory is not a tomodir!'", ")", "if", "(", "os", ".", "path", ".", "isfile", "(", "tomodir", "+", "os", ".", "...
Return the state of modeling and inversion for a given tomodir. The result does not take into account sensitivities or potentials, as optionally generated by CRMod. Parameters ---------- tomodir: string Directory to check Returns ------- crmod_is_finished: bool True if ...
[ "Return", "the", "state", "of", "modeling", "and", "inversion", "for", "a", "given", "tomodir", ".", "The", "result", "does", "not", "take", "into", "account", "sensitivities", "or", "potentials", "as", "optionally", "generated", "by", "CRMod", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/status.py#L35-L91
train
geophysics-ubonn/crtomo_tools
lib/crtomo/status.py
is_sipdir
def is_sipdir(directory): """ Simple check if the supplied directory is a SIP directory. Parameters ---------- directory: string Check if the supplied path is a valid SIP directory Returns ------- is_sipdir: bool True if the supplied directory is a SIP directory """ ...
python
def is_sipdir(directory): """ Simple check if the supplied directory is a SIP directory. Parameters ---------- directory: string Check if the supplied path is a valid SIP directory Returns ------- is_sipdir: bool True if the supplied directory is a SIP directory """ ...
[ "def", "is_sipdir", "(", "directory", ")", ":", "is_sipdir", "=", "True", "if", "(", "not", "os", ".", "path", ".", "isfile", "(", "directory", "+", "os", ".", "sep", "+", "'frequencies.dat'", ")", ")", ":", "is_sipdir", "=", "False", "if", "(", "not...
Simple check if the supplied directory is a SIP directory. Parameters ---------- directory: string Check if the supplied path is a valid SIP directory Returns ------- is_sipdir: bool True if the supplied directory is a SIP directory
[ "Simple", "check", "if", "the", "supplied", "directory", "is", "a", "SIP", "directory", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/status.py#L94-L116
train
geophysics-ubonn/crtomo_tools
lib/crtomo/status.py
sipdir_is_finished
def sipdir_is_finished(sipdir): """Return the state of modeling and inversion for a given SIP dir. The result does not take into account sensitivities or potentials, as optionally generated by CRMod. Parameters ---------- sipdir: string Directory to check Returns ------- cr...
python
def sipdir_is_finished(sipdir): """Return the state of modeling and inversion for a given SIP dir. The result does not take into account sensitivities or potentials, as optionally generated by CRMod. Parameters ---------- sipdir: string Directory to check Returns ------- cr...
[ "def", "sipdir_is_finished", "(", "sipdir", ")", ":", "if", "not", "is_sipdir", "(", "sipdir", ")", ":", "raise", "Exception", "(", "'Directory is not a valid SIP directory!'", ")", "subdirs_raw", "=", "sorted", "(", "glob", ".", "glob", "(", "sipdir", "+", "o...
Return the state of modeling and inversion for a given SIP dir. The result does not take into account sensitivities or potentials, as optionally generated by CRMod. Parameters ---------- sipdir: string Directory to check Returns ------- crmod_is_finished: bool True if a...
[ "Return", "the", "state", "of", "modeling", "and", "inversion", "for", "a", "given", "SIP", "dir", ".", "The", "result", "does", "not", "take", "into", "account", "sensitivities", "or", "potentials", "as", "optionally", "generated", "by", "CRMod", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/status.py#L119-L154
train
redhat-openstack/python-tripleo-helper
tripleohelper/ovb_undercloud.py
OVBUndercloud.enable_neutron_hack
def enable_neutron_hack(self, os_username, os_password, os_project_id, os_auth_url): """Enable the neutron hack on the undercloud. This script will watch the undercloud and copy any relevant network configuration in the host OpenStack. This is required to avoid the firewall limitations ...
python
def enable_neutron_hack(self, os_username, os_password, os_project_id, os_auth_url): """Enable the neutron hack on the undercloud. This script will watch the undercloud and copy any relevant network configuration in the host OpenStack. This is required to avoid the firewall limitations ...
[ "def", "enable_neutron_hack", "(", "self", ",", "os_username", ",", "os_password", ",", "os_project_id", ",", "os_auth_url", ")", ":", "self", ".", "yum_install", "(", "[", "'python-neutronclient'", "]", ")", "self", ".", "send_file", "(", "pkg_data_filename", "...
Enable the neutron hack on the undercloud. This script will watch the undercloud and copy any relevant network configuration in the host OpenStack. This is required to avoid the firewall limitations (no-spoofing and DHCP restriction).
[ "Enable", "the", "neutron", "hack", "on", "the", "undercloud", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ovb_undercloud.py#L96-L126
train
redhat-openstack/python-tripleo-helper
tripleohelper/ovb_undercloud.py
OVBUndercloud.patch_ironic_ramdisk
def patch_ironic_ramdisk(self): """Clean the disk before flushing the new image. See: https://bugs.launchpad.net/ironic-lib/+bug/1550604 """ tmpdir = self.run('mktemp -d')[0].rstrip('\n') self.run('cd {tmpdir}; zcat /home/stack/ironic-python-agent.initramfs| cpio -id'.format(tmp...
python
def patch_ironic_ramdisk(self): """Clean the disk before flushing the new image. See: https://bugs.launchpad.net/ironic-lib/+bug/1550604 """ tmpdir = self.run('mktemp -d')[0].rstrip('\n') self.run('cd {tmpdir}; zcat /home/stack/ironic-python-agent.initramfs| cpio -id'.format(tmp...
[ "def", "patch_ironic_ramdisk", "(", "self", ")", ":", "tmpdir", "=", "self", ".", "run", "(", "'mktemp -d'", ")", "[", "0", "]", ".", "rstrip", "(", "'\\n'", ")", "self", ".", "run", "(", "'cd {tmpdir}; zcat /home/stack/ironic-python-agent.initramfs| cpio -id'", ...
Clean the disk before flushing the new image. See: https://bugs.launchpad.net/ironic-lib/+bug/1550604
[ "Clean", "the", "disk", "before", "flushing", "the", "new", "image", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ovb_undercloud.py#L128-L137
train
elifiner/termenu
termenu/menu.py
show_menu
def show_menu(title, options, default=None, height=None, width=None, multiselect=False, precolored=False): """ Shows an interactive menu in the terminal. Arguments: options: list of menu options default: initial option to highlight height: maximum height of the menu width: m...
python
def show_menu(title, options, default=None, height=None, width=None, multiselect=False, precolored=False): """ Shows an interactive menu in the terminal. Arguments: options: list of menu options default: initial option to highlight height: maximum height of the menu width: m...
[ "def", "show_menu", "(", "title", ",", "options", ",", "default", "=", "None", ",", "height", "=", "None", ",", "width", "=", "None", ",", "multiselect", "=", "False", ",", "precolored", "=", "False", ")", ":", "plugins", "=", "[", "FilterPlugin", "(",...
Shows an interactive menu in the terminal. Arguments: options: list of menu options default: initial option to highlight height: maximum height of the menu width: maximum width of the menu multiselect: allow multiple items to be selected? precolored: allow strings wi...
[ "Shows", "an", "interactive", "menu", "in", "the", "terminal", "." ]
a7a57a1b07d8451003ee750704cdf0d904e9e272
https://github.com/elifiner/termenu/blob/a7a57a1b07d8451003ee750704cdf0d904e9e272/termenu/menu.py#L6-L39
train
elifiner/termenu
termenu/menu.py
pluggable
def pluggable(method): """ Mark a class method as extendable with plugins. """ def wrapped(self, *args, **kwargs): if hasattr(self, "_plugins"): # call the last plugin, it may call the previous via self.parent.method # creating a call call chain return getattr...
python
def pluggable(method): """ Mark a class method as extendable with plugins. """ def wrapped(self, *args, **kwargs): if hasattr(self, "_plugins"): # call the last plugin, it may call the previous via self.parent.method # creating a call call chain return getattr...
[ "def", "pluggable", "(", "method", ")", ":", "def", "wrapped", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "hasattr", "(", "self", ",", "\"_plugins\"", ")", ":", "return", "getattr", "(", "self", ".", "_plugins", "[", "-", "...
Mark a class method as extendable with plugins.
[ "Mark", "a", "class", "method", "as", "extendable", "with", "plugins", "." ]
a7a57a1b07d8451003ee750704cdf0d904e9e272
https://github.com/elifiner/termenu/blob/a7a57a1b07d8451003ee750704cdf0d904e9e272/termenu/menu.py#L46-L58
train
elifiner/termenu
termenu/menu.py
register_plugin
def register_plugin(host, plugin): """ Register a plugin with a host object. Some @pluggable methods in the host will have their behaviour altered by the plugin. """ class OriginalMethods(object): def __getattr__(self, name): return lambda *args, **kwargs: getattr(host, name).ori...
python
def register_plugin(host, plugin): """ Register a plugin with a host object. Some @pluggable methods in the host will have their behaviour altered by the plugin. """ class OriginalMethods(object): def __getattr__(self, name): return lambda *args, **kwargs: getattr(host, name).ori...
[ "def", "register_plugin", "(", "host", ",", "plugin", ")", ":", "class", "OriginalMethods", "(", "object", ")", ":", "def", "__getattr__", "(", "self", ",", "name", ")", ":", "return", "lambda", "*", "args", ",", "**", "kwargs", ":", "getattr", "(", "h...
Register a plugin with a host object. Some @pluggable methods in the host will have their behaviour altered by the plugin.
[ "Register", "a", "plugin", "with", "a", "host", "object", ".", "Some" ]
a7a57a1b07d8451003ee750704cdf0d904e9e272
https://github.com/elifiner/termenu/blob/a7a57a1b07d8451003ee750704cdf0d904e9e272/termenu/menu.py#L60-L72
train
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/sftp_client.py
SFTPClient.chdir
def chdir(self, path=None): """ Change the "current directory" of this SFTP session. Since SFTP doesn't really have the concept of a current working directory, this is emulated by Paramiko. Once you use this method to set a working directory, all operations on this `.SFTPClient...
python
def chdir(self, path=None): """ Change the "current directory" of this SFTP session. Since SFTP doesn't really have the concept of a current working directory, this is emulated by Paramiko. Once you use this method to set a working directory, all operations on this `.SFTPClient...
[ "def", "chdir", "(", "self", ",", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "self", ".", "_cwd", "=", "None", "return", "if", "not", "stat", ".", "S_ISDIR", "(", "self", ".", "stat", "(", "path", ")", ".", "st_mode", ")", ...
Change the "current directory" of this SFTP session. Since SFTP doesn't really have the concept of a current working directory, this is emulated by Paramiko. Once you use this method to set a working directory, all operations on this `.SFTPClient` object will be relative to that path. ...
[ "Change", "the", "current", "directory", "of", "this", "SFTP", "session", ".", "Since", "SFTP", "doesn", "t", "really", "have", "the", "concept", "of", "a", "current", "working", "directory", "this", "is", "emulated", "by", "Paramiko", ".", "Once", "you", ...
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/sftp_client.py#L480-L500
train
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/message.py
Message.get_int
def get_int(self): """ Fetch an int from the stream. :return: a 32-bit unsigned `int`. """ byte = self.get_bytes(1) if byte == max_byte: return util.inflate_long(self.get_binary()) byte += self.get_bytes(3) return struct.unpack('>I', byte)[0]
python
def get_int(self): """ Fetch an int from the stream. :return: a 32-bit unsigned `int`. """ byte = self.get_bytes(1) if byte == max_byte: return util.inflate_long(self.get_binary()) byte += self.get_bytes(3) return struct.unpack('>I', byte)[0]
[ "def", "get_int", "(", "self", ")", ":", "byte", "=", "self", ".", "get_bytes", "(", "1", ")", "if", "byte", "==", "max_byte", ":", "return", "util", ".", "inflate_long", "(", "self", ".", "get_binary", "(", ")", ")", "byte", "+=", "self", ".", "ge...
Fetch an int from the stream. :return: a 32-bit unsigned `int`.
[ "Fetch", "an", "int", "from", "the", "stream", "." ]
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/message.py#L132-L142
train
reorx/torext
torext/log.py
set_logger
def set_logger(name, level='INFO', fmt=None, datefmt=None, propagate=1, remove_handlers=False): """ This function will clear the previous handlers and set only one handler, which will only be StreamHandler for the logger. This f...
python
def set_logger(name, level='INFO', fmt=None, datefmt=None, propagate=1, remove_handlers=False): """ This function will clear the previous handlers and set only one handler, which will only be StreamHandler for the logger. This f...
[ "def", "set_logger", "(", "name", ",", "level", "=", "'INFO'", ",", "fmt", "=", "None", ",", "datefmt", "=", "None", ",", "propagate", "=", "1", ",", "remove_handlers", "=", "False", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "name", ...
This function will clear the previous handlers and set only one handler, which will only be StreamHandler for the logger. This function is designed to be able to called multiple times in a context. Note that if a logger has no handlers, it will be added a handler automatically when it is used.
[ "This", "function", "will", "clear", "the", "previous", "handlers", "and", "set", "only", "one", "handler", "which", "will", "only", "be", "StreamHandler", "for", "the", "logger", "." ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/log.py#L152-L188
train
reorx/torext
torext/log.py
BaseFormatter.format
def format(self, record): """ return log in unicode """ self._format_record(record) record_dict = {} for k, v in record.__dict__.items(): if isinstance(k, str): k = decode_(k, 'utf8') if isinstance(v, str): v = deco...
python
def format(self, record): """ return log in unicode """ self._format_record(record) record_dict = {} for k, v in record.__dict__.items(): if isinstance(k, str): k = decode_(k, 'utf8') if isinstance(v, str): v = deco...
[ "def", "format", "(", "self", ",", "record", ")", ":", "self", ".", "_format_record", "(", "record", ")", "record_dict", "=", "{", "}", "for", "k", ",", "v", "in", "record", ".", "__dict__", ".", "items", "(", ")", ":", "if", "isinstance", "(", "k"...
return log in unicode
[ "return", "log", "in", "unicode" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/log.py#L108-L134
train
Riminder/python-riminder-api
riminder/profile.py
Profile.list
def list(self, source_ids=None, seniority="all", stage=None, date_start="1494539999", date_end=TIMESTAMP_NOW, filter_id=None, page=1, limit=30, sort_by='ranking', filter_reference=None, order_by=None): """ Retreive all profiles that match the query param. Args: ...
python
def list(self, source_ids=None, seniority="all", stage=None, date_start="1494539999", date_end=TIMESTAMP_NOW, filter_id=None, page=1, limit=30, sort_by='ranking', filter_reference=None, order_by=None): """ Retreive all profiles that match the query param. Args: ...
[ "def", "list", "(", "self", ",", "source_ids", "=", "None", ",", "seniority", "=", "\"all\"", ",", "stage", "=", "None", ",", "date_start", "=", "\"1494539999\"", ",", "date_end", "=", "TIMESTAMP_NOW", ",", "filter_id", "=", "None", ",", "page", "=", "1"...
Retreive all profiles that match the query param. Args: date_end: <string> REQUIRED (default to timestamp of now) profiles' last date of reception date_start: <string> REQUIRED (default to "1494539999") profiles' first date of reception ...
[ "Retreive", "all", "profiles", "that", "match", "the", "query", "param", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L68-L110
train
Riminder/python-riminder-api
riminder/profile.py
Profile.add
def add(self, source_id=None, file_path=None, profile_reference="", timestamp_reception=None, training_metadata=[]): """ Add a profile resume to a sourced id. Args: source_id: <string> source id file_path: ...
python
def add(self, source_id=None, file_path=None, profile_reference="", timestamp_reception=None, training_metadata=[]): """ Add a profile resume to a sourced id. Args: source_id: <string> source id file_path: ...
[ "def", "add", "(", "self", ",", "source_id", "=", "None", ",", "file_path", "=", "None", ",", "profile_reference", "=", "\"\"", ",", "timestamp_reception", "=", "None", ",", "training_metadata", "=", "[", "]", ")", ":", "data", "=", "{", "}", "data", "...
Add a profile resume to a sourced id. Args: source_id: <string> source id file_path: <string> local path to resume file profile_reference: <string> (default to "") ...
[ "Add", "a", "profile", "resume", "to", "a", "sourced", "id", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L112-L142
train
Riminder/python-riminder-api
riminder/profile.py
Profile.addList
def addList(self, source_id, dir_path, is_recurcive=False, timestamp_reception=None, training_metadata=[]): """Add all profile from a given directory.""" if not path.isdir(dir_path): raise ValueError(dir_path + ' is not a directory') files_to_send = _get_files_from_dir(dir_path, is_r...
python
def addList(self, source_id, dir_path, is_recurcive=False, timestamp_reception=None, training_metadata=[]): """Add all profile from a given directory.""" if not path.isdir(dir_path): raise ValueError(dir_path + ' is not a directory') files_to_send = _get_files_from_dir(dir_path, is_r...
[ "def", "addList", "(", "self", ",", "source_id", ",", "dir_path", ",", "is_recurcive", "=", "False", ",", "timestamp_reception", "=", "None", ",", "training_metadata", "=", "[", "]", ")", ":", "if", "not", "path", ".", "isdir", "(", "dir_path", ")", ":",...
Add all profile from a given directory.
[ "Add", "all", "profile", "from", "a", "given", "directory", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L144-L166
train
Riminder/python-riminder-api
riminder/profile.py
Profile.get
def get(self, source_id=None, profile_id=None, profile_reference=None): """ Retrieve the profile information associated with profile id. Args: source_id: <string> source id profile_id: <string> ...
python
def get(self, source_id=None, profile_id=None, profile_reference=None): """ Retrieve the profile information associated with profile id. Args: source_id: <string> source id profile_id: <string> ...
[ "def", "get", "(", "self", ",", "source_id", "=", "None", ",", "profile_id", "=", "None", ",", "profile_reference", "=", "None", ")", ":", "query_params", "=", "{", "}", "query_params", "[", "\"source_id\"", "]", "=", "_validate_source_id", "(", "source_id",...
Retrieve the profile information associated with profile id. Args: source_id: <string> source id profile_id: <string> profile id Returns profile information
[ "Retrieve", "the", "profile", "information", "associated", "with", "profile", "id", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L168-L189
train
Riminder/python-riminder-api
riminder/profile.py
ProfileStage.set
def set(self, source_id=None, profile_id=None, filter_id=None, stage=None, profile_reference=None, filter_reference=None): """ Edit the profile stage given a filter. Args: profile_id: <string> profile id body params: ...
python
def set(self, source_id=None, profile_id=None, filter_id=None, stage=None, profile_reference=None, filter_reference=None): """ Edit the profile stage given a filter. Args: profile_id: <string> profile id body params: ...
[ "def", "set", "(", "self", ",", "source_id", "=", "None", ",", "profile_id", "=", "None", ",", "filter_id", "=", "None", ",", "stage", "=", "None", ",", "profile_reference", "=", "None", ",", "filter_reference", "=", "None", ")", ":", "data", "=", "{",...
Edit the profile stage given a filter. Args: profile_id: <string> profile id body params: source_id: <string> source id associated to the profile filter_id: ...
[ "Edit", "the", "profile", "stage", "given", "a", "filter", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L292-L326
train
Riminder/python-riminder-api
riminder/profile.py
ProfileRevealing.get
def get(self, source_id=None, profile_id=None, profile_reference=None, filter_id=None, filter_reference=None): """ Retrieve the interpretability information. Args: source_id: <string> source id profile_id: <str...
python
def get(self, source_id=None, profile_id=None, profile_reference=None, filter_id=None, filter_reference=None): """ Retrieve the interpretability information. Args: source_id: <string> source id profile_id: <str...
[ "def", "get", "(", "self", ",", "source_id", "=", "None", ",", "profile_id", "=", "None", ",", "profile_reference", "=", "None", ",", "filter_id", "=", "None", ",", "filter_reference", "=", "None", ")", ":", "query_params", "=", "{", "}", "query_params", ...
Retrieve the interpretability information. Args: source_id: <string> source id profile_id: <string> profile id filter_id: <string> ...
[ "Retrieve", "the", "interpretability", "information", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L380-L407
train
Riminder/python-riminder-api
riminder/profile.py
ProfileJson.check
def check(self, profile_data, training_metadata=[]): """Use the api to check weither the profile_data are valid.""" data = { "profile_json": _validate_dict(profile_data, "profile_data"), "training_metadata": _validate_training_metadata(training_metadata), } respon...
python
def check(self, profile_data, training_metadata=[]): """Use the api to check weither the profile_data are valid.""" data = { "profile_json": _validate_dict(profile_data, "profile_data"), "training_metadata": _validate_training_metadata(training_metadata), } respon...
[ "def", "check", "(", "self", ",", "profile_data", ",", "training_metadata", "=", "[", "]", ")", ":", "data", "=", "{", "\"profile_json\"", ":", "_validate_dict", "(", "profile_data", ",", "\"profile_data\"", ")", ",", "\"training_metadata\"", ":", "_validate_tra...
Use the api to check weither the profile_data are valid.
[ "Use", "the", "api", "to", "check", "weither", "the", "profile_data", "are", "valid", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L417-L424
train
Riminder/python-riminder-api
riminder/profile.py
ProfileJson.add
def add(self, source_id, profile_data, training_metadata=[], profile_reference=None, timestamp_reception=None): """Use the api to add a new profile using profile_data.""" data = { "source_id": _validate_source_id(source_id), "profile_json": _validate_dict(profile_data, "profile_d...
python
def add(self, source_id, profile_data, training_metadata=[], profile_reference=None, timestamp_reception=None): """Use the api to add a new profile using profile_data.""" data = { "source_id": _validate_source_id(source_id), "profile_json": _validate_dict(profile_data, "profile_d...
[ "def", "add", "(", "self", ",", "source_id", ",", "profile_data", ",", "training_metadata", "=", "[", "]", ",", "profile_reference", "=", "None", ",", "timestamp_reception", "=", "None", ")", ":", "data", "=", "{", "\"source_id\"", ":", "_validate_source_id", ...
Use the api to add a new profile using profile_data.
[ "Use", "the", "api", "to", "add", "a", "new", "profile", "using", "profile_data", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L426-L440
train
kwlzn/blast
blast/scanner.py
DirScanner.md5sum
def md5sum(self, f): ''' md5sums a file, returning the hex digest Parameters: - f filename string ''' m = hashlib.md5() fh = open(f, 'r') while 1: chunk = fh.read(BUF_SIZE) if not chunk: break m.update(chunk) ...
python
def md5sum(self, f): ''' md5sums a file, returning the hex digest Parameters: - f filename string ''' m = hashlib.md5() fh = open(f, 'r') while 1: chunk = fh.read(BUF_SIZE) if not chunk: break m.update(chunk) ...
[ "def", "md5sum", "(", "self", ",", "f", ")", ":", "m", "=", "hashlib", ".", "md5", "(", ")", "fh", "=", "open", "(", "f", ",", "'r'", ")", "while", "1", ":", "chunk", "=", "fh", ".", "read", "(", "BUF_SIZE", ")", "if", "not", "chunk", ":", ...
md5sums a file, returning the hex digest Parameters: - f filename string
[ "md5sums", "a", "file", "returning", "the", "hex", "digest" ]
ae18a19182a6884c453bf9b2a3c6386bd3b2655a
https://github.com/kwlzn/blast/blob/ae18a19182a6884c453bf9b2a3c6386bd3b2655a/blast/scanner.py#L16-L29
train
kwlzn/blast
blast/scanner.py
DirScanner.iterdupes
def iterdupes(self, compare=None, filt=None): ''' streaming item iterator with low overhead duplicate file detection Parameters: - compare compare function between files (defaults to md5sum) ''' if not compare: compare = self.md5sum seen_siz = {} ...
python
def iterdupes(self, compare=None, filt=None): ''' streaming item iterator with low overhead duplicate file detection Parameters: - compare compare function between files (defaults to md5sum) ''' if not compare: compare = self.md5sum seen_siz = {} ...
[ "def", "iterdupes", "(", "self", ",", "compare", "=", "None", ",", "filt", "=", "None", ")", ":", "if", "not", "compare", ":", "compare", "=", "self", ".", "md5sum", "seen_siz", "=", "{", "}", "seen_sum", "=", "{", "}", "size_func", "=", "lambda", ...
streaming item iterator with low overhead duplicate file detection Parameters: - compare compare function between files (defaults to md5sum)
[ "streaming", "item", "iterator", "with", "low", "overhead", "duplicate", "file", "detection" ]
ae18a19182a6884c453bf9b2a3c6386bd3b2655a
https://github.com/kwlzn/blast/blob/ae18a19182a6884c453bf9b2a3c6386bd3b2655a/blast/scanner.py#L71-L102
train
gebn/wood
wood/integrations/s3.py
objects_to_root
def objects_to_root(objects: List) -> Root: """ Convert a list of s3 ObjectSummaries into a directory tree. :param objects: The list of objects, e.g. the result of calling `.objects.all()` on a bucket. :return: The tree structure, contained within a root node. """ def _to_t...
python
def objects_to_root(objects: List) -> Root: """ Convert a list of s3 ObjectSummaries into a directory tree. :param objects: The list of objects, e.g. the result of calling `.objects.all()` on a bucket. :return: The tree structure, contained within a root node. """ def _to_t...
[ "def", "objects_to_root", "(", "objects", ":", "List", ")", "->", "Root", ":", "def", "_to_tree", "(", "objs", ":", "Iterable", ")", "->", "Dict", ":", "path_tree", "=", "{", "}", "for", "obj", "in", "objs", ":", "is_dir", "=", "obj", ".", "key", "...
Convert a list of s3 ObjectSummaries into a directory tree. :param objects: The list of objects, e.g. the result of calling `.objects.all()` on a bucket. :return: The tree structure, contained within a root node.
[ "Convert", "a", "list", "of", "s3", "ObjectSummaries", "into", "a", "directory", "tree", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/integrations/s3.py#L16-L77
train
gebn/wood
wood/integrations/s3.py
Syncer._delete
def _delete(self, paths: Iterable[str]) -> None: """ Delete a collection of paths from S3. :param paths: The paths to delete. The prefix will be prepended to each one. :raises ClientError: If any request fails. """ for chunk in util.chunk(paths, sel...
python
def _delete(self, paths: Iterable[str]) -> None: """ Delete a collection of paths from S3. :param paths: The paths to delete. The prefix will be prepended to each one. :raises ClientError: If any request fails. """ for chunk in util.chunk(paths, sel...
[ "def", "_delete", "(", "self", ",", "paths", ":", "Iterable", "[", "str", "]", ")", "->", "None", ":", "for", "chunk", "in", "util", ".", "chunk", "(", "paths", ",", "self", ".", "_MAX_DELETES_PER_REQUEST", ")", ":", "keys", "=", "list", "(", "[", ...
Delete a collection of paths from S3. :param paths: The paths to delete. The prefix will be prepended to each one. :raises ClientError: If any request fails.
[ "Delete", "a", "collection", "of", "paths", "from", "S3", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/integrations/s3.py#L101-L116
train
gebn/wood
wood/integrations/s3.py
Syncer._upload
def _upload(self, items: Iterable[Tuple[str, str]]) -> None: """ Upload a collection of paths to S3. :param items: An iterable of pairs containing the local path of the file to upload, and the remote path to upload it to. The prefix will be appended t...
python
def _upload(self, items: Iterable[Tuple[str, str]]) -> None: """ Upload a collection of paths to S3. :param items: An iterable of pairs containing the local path of the file to upload, and the remote path to upload it to. The prefix will be appended t...
[ "def", "_upload", "(", "self", ",", "items", ":", "Iterable", "[", "Tuple", "[", "str", ",", "str", "]", "]", ")", "->", "None", ":", "for", "src", ",", "key", "in", "items", ":", "logger", ".", "info", "(", "f'Uploading {src} to {key}'", ")", "mimet...
Upload a collection of paths to S3. :param items: An iterable of pairs containing the local path of the file to upload, and the remote path to upload it to. The prefix will be appended to each remote path.
[ "Upload", "a", "collection", "of", "paths", "to", "S3", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/integrations/s3.py#L118-L136
train
geophysics-ubonn/crtomo_tools
src/grid_rotate.py
rotmat
def rotmat(alpha): """Rotate around z-axis """ R = np.array(((np.cos(alpha), -np.sin(alpha)), (np.sin(alpha), np.cos(alpha)))) return R
python
def rotmat(alpha): """Rotate around z-axis """ R = np.array(((np.cos(alpha), -np.sin(alpha)), (np.sin(alpha), np.cos(alpha)))) return R
[ "def", "rotmat", "(", "alpha", ")", ":", "R", "=", "np", ".", "array", "(", "(", "(", "np", ".", "cos", "(", "alpha", ")", ",", "-", "np", ".", "sin", "(", "alpha", ")", ")", ",", "(", "np", ".", "sin", "(", "alpha", ")", ",", "np", ".", ...
Rotate around z-axis
[ "Rotate", "around", "z", "-", "axis" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/grid_rotate.py#L37-L43
train
edx/edx-celeryutils
celery_utils/logged_task.py
LoggedTask.apply_async
def apply_async(self, args=None, kwargs=None, **options): # pylint: disable=arguments-differ """ Emit a log statement when the task is submitted. """ result = super(LoggedTask, self).apply_async(args=args, kwargs=kwargs, **options) log.info('Task {}[{}] submitted with arguments ...
python
def apply_async(self, args=None, kwargs=None, **options): # pylint: disable=arguments-differ """ Emit a log statement when the task is submitted. """ result = super(LoggedTask, self).apply_async(args=args, kwargs=kwargs, **options) log.info('Task {}[{}] submitted with arguments ...
[ "def", "apply_async", "(", "self", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "**", "options", ")", ":", "result", "=", "super", "(", "LoggedTask", ",", "self", ")", ".", "apply_async", "(", "args", "=", "args", ",", "kwargs", "=", ...
Emit a log statement when the task is submitted.
[ "Emit", "a", "log", "statement", "when", "the", "task", "is", "submitted", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/logged_task.py#L22-L33
train
edx/edx-celeryutils
celery_utils/logged_task.py
LoggedTask.on_retry
def on_retry(self, exc, task_id, args, kwargs, einfo): """ Capture the exception that caused the task to be retried, if any. """ super(LoggedTask, self).on_retry(exc, task_id, args, kwargs, einfo) log.warning('[{}] retried due to {}'.format(task_id, getattr(einfo, 'traceback', No...
python
def on_retry(self, exc, task_id, args, kwargs, einfo): """ Capture the exception that caused the task to be retried, if any. """ super(LoggedTask, self).on_retry(exc, task_id, args, kwargs, einfo) log.warning('[{}] retried due to {}'.format(task_id, getattr(einfo, 'traceback', No...
[ "def", "on_retry", "(", "self", ",", "exc", ",", "task_id", ",", "args", ",", "kwargs", ",", "einfo", ")", ":", "super", "(", "LoggedTask", ",", "self", ")", ".", "on_retry", "(", "exc", ",", "task_id", ",", "args", ",", "kwargs", ",", "einfo", ")"...
Capture the exception that caused the task to be retried, if any.
[ "Capture", "the", "exception", "that", "caused", "the", "task", "to", "be", "retried", "if", "any", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/logged_task.py#L35-L40
train
edx/edx-celeryutils
celery_utils/logged_task.py
LoggedTask.on_failure
def on_failure(self, exc, task_id, args, kwargs, einfo): """ Capture the exception that caused the task to fail, if any. """ log.error('[{}] failed due to {}'.format(task_id, getattr(einfo, 'traceback', None))) super(LoggedTask, self).on_failure(exc, task_id, args, kwargs, einfo)
python
def on_failure(self, exc, task_id, args, kwargs, einfo): """ Capture the exception that caused the task to fail, if any. """ log.error('[{}] failed due to {}'.format(task_id, getattr(einfo, 'traceback', None))) super(LoggedTask, self).on_failure(exc, task_id, args, kwargs, einfo)
[ "def", "on_failure", "(", "self", ",", "exc", ",", "task_id", ",", "args", ",", "kwargs", ",", "einfo", ")", ":", "log", ".", "error", "(", "'[{}] failed due to {}'", ".", "format", "(", "task_id", ",", "getattr", "(", "einfo", ",", "'traceback'", ",", ...
Capture the exception that caused the task to fail, if any.
[ "Capture", "the", "exception", "that", "caused", "the", "task", "to", "fail", "if", "any", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/logged_task.py#L42-L47
train
hotzenklotz/pybeerxml
pybeerxml/parser.py
Parser.nodes_to_object
def nodes_to_object(self, node, object): "Map all child nodes to one object's attributes" for n in list(node): self.node_to_object(n, object)
python
def nodes_to_object(self, node, object): "Map all child nodes to one object's attributes" for n in list(node): self.node_to_object(n, object)
[ "def", "nodes_to_object", "(", "self", ",", "node", ",", "object", ")", ":", "\"Map all child nodes to one object's attributes\"", "for", "n", "in", "list", "(", "node", ")", ":", "self", ".", "node_to_object", "(", "n", ",", "object", ")" ]
Map all child nodes to one object's attributes
[ "Map", "all", "child", "nodes", "to", "one", "object", "s", "attributes" ]
e9cf8d6090b1e01e5bbb101e255792b134affbe0
https://github.com/hotzenklotz/pybeerxml/blob/e9cf8d6090b1e01e5bbb101e255792b134affbe0/pybeerxml/parser.py#L15-L19
train
hotzenklotz/pybeerxml
pybeerxml/parser.py
Parser.node_to_object
def node_to_object(self, node, object): "Map a single node to one object's attributes" attribute = self.to_lower(node.tag) # Yield is a protected keyword in Python, so let's rename it attribute = "_yield" if attribute == "yield" else attribute try: valueString = no...
python
def node_to_object(self, node, object): "Map a single node to one object's attributes" attribute = self.to_lower(node.tag) # Yield is a protected keyword in Python, so let's rename it attribute = "_yield" if attribute == "yield" else attribute try: valueString = no...
[ "def", "node_to_object", "(", "self", ",", "node", ",", "object", ")", ":", "\"Map a single node to one object's attributes\"", "attribute", "=", "self", ".", "to_lower", "(", "node", ".", "tag", ")", "attribute", "=", "\"_yield\"", "if", "attribute", "==", "\"y...
Map a single node to one object's attributes
[ "Map", "a", "single", "node", "to", "one", "object", "s", "attributes" ]
e9cf8d6090b1e01e5bbb101e255792b134affbe0
https://github.com/hotzenklotz/pybeerxml/blob/e9cf8d6090b1e01e5bbb101e255792b134affbe0/pybeerxml/parser.py#L21-L38
train
hotzenklotz/pybeerxml
pybeerxml/parser.py
Parser.parse
def parse(self, xml_file): "Get a list of parsed recipes from BeerXML input" recipes = [] with open(xml_file, "rt") as f: tree = ElementTree.parse(f) for recipeNode in tree.iter(): if self.to_lower(recipeNode.tag) != "recipe": continue ...
python
def parse(self, xml_file): "Get a list of parsed recipes from BeerXML input" recipes = [] with open(xml_file, "rt") as f: tree = ElementTree.parse(f) for recipeNode in tree.iter(): if self.to_lower(recipeNode.tag) != "recipe": continue ...
[ "def", "parse", "(", "self", ",", "xml_file", ")", ":", "\"Get a list of parsed recipes from BeerXML input\"", "recipes", "=", "[", "]", "with", "open", "(", "xml_file", ",", "\"rt\"", ")", "as", "f", ":", "tree", "=", "ElementTree", ".", "parse", "(", "f", ...
Get a list of parsed recipes from BeerXML input
[ "Get", "a", "list", "of", "parsed", "recipes", "from", "BeerXML", "input" ]
e9cf8d6090b1e01e5bbb101e255792b134affbe0
https://github.com/hotzenklotz/pybeerxml/blob/e9cf8d6090b1e01e5bbb101e255792b134affbe0/pybeerxml/parser.py#L40-L104
train
hotzenklotz/pybeerxml
pybeerxml/parser.py
Parser.to_lower
def to_lower(self, string): "Helper function to transform strings to lower case" value = None try: value = string.lower() except AttributeError: value = "" finally: return value
python
def to_lower(self, string): "Helper function to transform strings to lower case" value = None try: value = string.lower() except AttributeError: value = "" finally: return value
[ "def", "to_lower", "(", "self", ",", "string", ")", ":", "\"Helper function to transform strings to lower case\"", "value", "=", "None", "try", ":", "value", "=", "string", ".", "lower", "(", ")", "except", "AttributeError", ":", "value", "=", "\"\"", "finally",...
Helper function to transform strings to lower case
[ "Helper", "function", "to", "transform", "strings", "to", "lower", "case" ]
e9cf8d6090b1e01e5bbb101e255792b134affbe0
https://github.com/hotzenklotz/pybeerxml/blob/e9cf8d6090b1e01e5bbb101e255792b134affbe0/pybeerxml/parser.py#L106-L114
train
maxzheng/localconfig
localconfig/manager.py
LocalConfig._to_dot_key
def _to_dot_key(cls, section, key=None): """ Return the section and key in dot notation format. """ if key: return (NON_ALPHA_NUM.sub('_', section.lower()), NON_ALPHA_NUM.sub('_', key.lower())) else: return NON_ALPHA_NUM.sub('_', section.lower())
python
def _to_dot_key(cls, section, key=None): """ Return the section and key in dot notation format. """ if key: return (NON_ALPHA_NUM.sub('_', section.lower()), NON_ALPHA_NUM.sub('_', key.lower())) else: return NON_ALPHA_NUM.sub('_', section.lower())
[ "def", "_to_dot_key", "(", "cls", ",", "section", ",", "key", "=", "None", ")", ":", "if", "key", ":", "return", "(", "NON_ALPHA_NUM", ".", "sub", "(", "'_'", ",", "section", ".", "lower", "(", ")", ")", ",", "NON_ALPHA_NUM", ".", "sub", "(", "'_'"...
Return the section and key in dot notation format.
[ "Return", "the", "section", "and", "key", "in", "dot", "notation", "format", "." ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L102-L107
train
maxzheng/localconfig
localconfig/manager.py
LocalConfig.save
def save(self, target_file=None, as_template=False): """ Save the config :param str target_file: File to save to. Defaults to `self._last_source` if set :param bool as_template: Save the config with all keys and sections commented out for user to modify :raise AttributeError: if...
python
def save(self, target_file=None, as_template=False): """ Save the config :param str target_file: File to save to. Defaults to `self._last_source` if set :param bool as_template: Save the config with all keys and sections commented out for user to modify :raise AttributeError: if...
[ "def", "save", "(", "self", ",", "target_file", "=", "None", ",", "as_template", "=", "False", ")", ":", "self", ".", "_read_sources", "(", ")", "if", "not", "target_file", ":", "if", "not", "self", ".", "_last_source", ":", "raise", "AttributeError", "(...
Save the config :param str target_file: File to save to. Defaults to `self._last_source` if set :param bool as_template: Save the config with all keys and sections commented out for user to modify :raise AttributeError: if target file is not provided and `self._last_source` is not set
[ "Save", "the", "config" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L203-L229
train
maxzheng/localconfig
localconfig/manager.py
LocalConfig._parse_extra
def _parse_extra(self, fp): """ Parse and store the config comments and create maps for dot notion lookup """ comment = '' section = '' fp.seek(0) for line in fp: line = line.rstrip() if not line: if comment: comment ...
python
def _parse_extra(self, fp): """ Parse and store the config comments and create maps for dot notion lookup """ comment = '' section = '' fp.seek(0) for line in fp: line = line.rstrip() if not line: if comment: comment ...
[ "def", "_parse_extra", "(", "self", ",", "fp", ")", ":", "comment", "=", "''", "section", "=", "''", "fp", ".", "seek", "(", "0", ")", "for", "line", "in", "fp", ":", "line", "=", "line", ".", "rstrip", "(", ")", "if", "not", "line", ":", "if",...
Parse and store the config comments and create maps for dot notion lookup
[ "Parse", "and", "store", "the", "config", "comments", "and", "create", "maps", "for", "dot", "notion", "lookup" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L231-L265
train
maxzheng/localconfig
localconfig/manager.py
LocalConfig._typed_value
def _typed_value(self, value): """ Transform string value to an actual data type of the same value. """ if value not in self._value_cache: new_value = value if is_int(value): new_value = int(value) elif is_float(value): new_value = flo...
python
def _typed_value(self, value): """ Transform string value to an actual data type of the same value. """ if value not in self._value_cache: new_value = value if is_int(value): new_value = int(value) elif is_float(value): new_value = flo...
[ "def", "_typed_value", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "self", ".", "_value_cache", ":", "new_value", "=", "value", "if", "is_int", "(", "value", ")", ":", "new_value", "=", "int", "(", "value", ")", "elif", "is_float",...
Transform string value to an actual data type of the same value.
[ "Transform", "string", "value", "to", "an", "actual", "data", "type", "of", "the", "same", "value", "." ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L330-L345
train
maxzheng/localconfig
localconfig/manager.py
LocalConfig.add_section
def add_section(self, section, comment=None): """ Add a section :param str section: Section to add :raise DuplicateSectionError: if section already exist. """ self._read_sources() if self._to_dot_key(section) in self._dot_keys: raise DuplicateSection...
python
def add_section(self, section, comment=None): """ Add a section :param str section: Section to add :raise DuplicateSectionError: if section already exist. """ self._read_sources() if self._to_dot_key(section) in self._dot_keys: raise DuplicateSection...
[ "def", "add_section", "(", "self", ",", "section", ",", "comment", "=", "None", ")", ":", "self", ".", "_read_sources", "(", ")", "if", "self", ".", "_to_dot_key", "(", "section", ")", "in", "self", ".", "_dot_keys", ":", "raise", "DuplicateSectionError", ...
Add a section :param str section: Section to add :raise DuplicateSectionError: if section already exist.
[ "Add", "a", "section" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L381-L396
train
maxzheng/localconfig
localconfig/manager.py
LocalConfig._set_comment
def _set_comment(self, section, comment, key=None): """ Set a comment for section or key :param str section: Section to add comment to :param str comment: Comment to add :param str key: Key to add comment to """ if '\n' in comment: comment = '\n# '.j...
python
def _set_comment(self, section, comment, key=None): """ Set a comment for section or key :param str section: Section to add comment to :param str comment: Comment to add :param str key: Key to add comment to """ if '\n' in comment: comment = '\n# '.j...
[ "def", "_set_comment", "(", "self", ",", "section", ",", "comment", ",", "key", "=", "None", ")", ":", "if", "'\\n'", "in", "comment", ":", "comment", "=", "'\\n# '", ".", "join", "(", "comment", ".", "split", "(", "'\\n'", ")", ")", "comment", "=", ...
Set a comment for section or key :param str section: Section to add comment to :param str comment: Comment to add :param str key: Key to add comment to
[ "Set", "a", "comment", "for", "section", "or", "key" ]
636087f2489295d9dae2693dda8a86e4daa4ff9d
https://github.com/maxzheng/localconfig/blob/636087f2489295d9dae2693dda8a86e4daa4ff9d/localconfig/manager.py#L398-L414
train
thiagopbueno/tf-rddlsim
tfrddlsim/policy/random_policy.py
RandomPolicy._sample_actions
def _sample_actions(self, state: Sequence[tf.Tensor]) -> Tuple[Sequence[tf.Tensor], tf.Tensor, tf.Tensor]: '''Returns sampled action fluents and tensors related to the sampling. Args: state (Sequence[tf.Tensor]): A list of state fluents. Returns: Tuple[Seque...
python
def _sample_actions(self, state: Sequence[tf.Tensor]) -> Tuple[Sequence[tf.Tensor], tf.Tensor, tf.Tensor]: '''Returns sampled action fluents and tensors related to the sampling. Args: state (Sequence[tf.Tensor]): A list of state fluents. Returns: Tuple[Seque...
[ "def", "_sample_actions", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "Tuple", "[", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "tf", ".", "Tensor", ",", "tf", ".", "Tensor", "]", ":", "default", "=", ...
Returns sampled action fluents and tensors related to the sampling. Args: state (Sequence[tf.Tensor]): A list of state fluents. Returns: Tuple[Sequence[tf.Tensor], tf.Tensor, tf.Tensor]: A tuple with action fluents, an integer tensor for the number of samples, and ...
[ "Returns", "sampled", "action", "fluents", "and", "tensors", "related", "to", "the", "sampling", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/policy/random_policy.py#L70-L86
train
thiagopbueno/tf-rddlsim
tfrddlsim/policy/random_policy.py
RandomPolicy._check_preconditions
def _check_preconditions(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor], bound_constraints: Dict[str, Constraints], default: Sequence[tf.Tensor]) -> Tuple[tf.Tensor, Sequence[tf.Tensor], tf.Tensor]: '''Samples action fluents until all preconditions ...
python
def _check_preconditions(self, state: Sequence[tf.Tensor], action: Sequence[tf.Tensor], bound_constraints: Dict[str, Constraints], default: Sequence[tf.Tensor]) -> Tuple[tf.Tensor, Sequence[tf.Tensor], tf.Tensor]: '''Samples action fluents until all preconditions ...
[ "def", "_check_preconditions", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "action", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "bound_constraints", ":", "Dict", "[", "str", ",", "Constraints", "]", ",", "d...
Samples action fluents until all preconditions are satisfied. Checks action preconditions for the sampled `action` and current `state`, and iff all preconditions are satisfied it returns the sampled action fluents. Args: state (Sequence[tf.Tensor]): A list of state fluents. ...
[ "Samples", "action", "fluents", "until", "all", "preconditions", "are", "satisfied", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/policy/random_policy.py#L88-L127
train
thiagopbueno/tf-rddlsim
tfrddlsim/policy/random_policy.py
RandomPolicy._sample_action
def _sample_action(self, constraints: Dict[str, Constraints], default: Sequence[tf.Tensor], prob: float = 0.3) -> Sequence[tf.Tensor]: '''Samples action fluents respecting the given bound `constraints`. With probability `prob` it chooses the action fluent default val...
python
def _sample_action(self, constraints: Dict[str, Constraints], default: Sequence[tf.Tensor], prob: float = 0.3) -> Sequence[tf.Tensor]: '''Samples action fluents respecting the given bound `constraints`. With probability `prob` it chooses the action fluent default val...
[ "def", "_sample_action", "(", "self", ",", "constraints", ":", "Dict", "[", "str", ",", "Constraints", "]", ",", "default", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "prob", ":", "float", "=", "0.3", ")", "->", "Sequence", "[", "tf", ".", ...
Samples action fluents respecting the given bound `constraints`. With probability `prob` it chooses the action fluent default value, with probability 1-`prob` it samples the fluent w.r.t. its bounds. Args: constraints (Dict[str, Tuple[Optional[TensorFluent], Optional[TensorFluent]]...
[ "Samples", "action", "fluents", "respecting", "the", "given", "bound", "constraints", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/policy/random_policy.py#L129-L155
train
thiagopbueno/tf-rddlsim
tfrddlsim/policy/random_policy.py
RandomPolicy._sample_action_fluent
def _sample_action_fluent(self, name: str, dtype: tf.DType, size: Sequence[int], constraints: Dict[str, Constraints], default_value: tf.Tensor, prob: float) -> tf.Tensor: '''Samples the action fluent with given `name`, `dtype`, and `size`. ...
python
def _sample_action_fluent(self, name: str, dtype: tf.DType, size: Sequence[int], constraints: Dict[str, Constraints], default_value: tf.Tensor, prob: float) -> tf.Tensor: '''Samples the action fluent with given `name`, `dtype`, and `size`. ...
[ "def", "_sample_action_fluent", "(", "self", ",", "name", ":", "str", ",", "dtype", ":", "tf", ".", "DType", ",", "size", ":", "Sequence", "[", "int", "]", ",", "constraints", ":", "Dict", "[", "str", ",", "Constraints", "]", ",", "default_value", ":",...
Samples the action fluent with given `name`, `dtype`, and `size`. With probability `prob` it chooses the action fluent `default_value`, with probability 1-`prob` it samples the fluent w.r.t. its `constraints`. Args: name (str): The name of the action fluent. dtype (tf.D...
[ "Samples", "the", "action", "fluent", "with", "given", "name", "dtype", "and", "size", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/policy/random_policy.py#L157-L215
train
Nic30/hwtGraph
hwtGraph/elk/fromHwt/convertor.py
UnitToLNode
def UnitToLNode(u: Unit, node: Optional[LNode]=None, toL: Optional[dict]=None, optimizations=[]) -> LNode: """ Build LNode instance from Unit instance :attention: unit has to be synthesized """ if toL is None: toL = {} if node is None: root = LNod...
python
def UnitToLNode(u: Unit, node: Optional[LNode]=None, toL: Optional[dict]=None, optimizations=[]) -> LNode: """ Build LNode instance from Unit instance :attention: unit has to be synthesized """ if toL is None: toL = {} if node is None: root = LNod...
[ "def", "UnitToLNode", "(", "u", ":", "Unit", ",", "node", ":", "Optional", "[", "LNode", "]", "=", "None", ",", "toL", ":", "Optional", "[", "dict", "]", "=", "None", ",", "optimizations", "=", "[", "]", ")", "->", "LNode", ":", "if", "toL", "is"...
Build LNode instance from Unit instance :attention: unit has to be synthesized
[ "Build", "LNode", "instance", "from", "Unit", "instance" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/convertor.py#L20-L102
train
redhat-openstack/python-tripleo-helper
tripleohelper/host0.py
Host0.configure
def configure(self, rhsm=None, repositories=None): """This method will configure the host0 and run the hypervisor.""" if rhsm is not None: self.rhsm_register(rhsm) if repositories is not None: self.enable_repositories(repositories) self.create_stack_user() ...
python
def configure(self, rhsm=None, repositories=None): """This method will configure the host0 and run the hypervisor.""" if rhsm is not None: self.rhsm_register(rhsm) if repositories is not None: self.enable_repositories(repositories) self.create_stack_user() ...
[ "def", "configure", "(", "self", ",", "rhsm", "=", "None", ",", "repositories", "=", "None", ")", ":", "if", "rhsm", "is", "not", "None", ":", "self", ".", "rhsm_register", "(", "rhsm", ")", "if", "repositories", "is", "not", "None", ":", "self", "."...
This method will configure the host0 and run the hypervisor.
[ "This", "method", "will", "configure", "the", "host0", "and", "run", "the", "hypervisor", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/host0.py#L35-L42
train
redhat-openstack/python-tripleo-helper
tripleohelper/host0.py
Host0.deploy_hypervisor
def deploy_hypervisor(self): """Install the libvirtd and instack-undercloud packages. """ self.yum_install(['libvirt-daemon-driver-nwfilter', 'libvirt-client', 'libvirt-daemon-config-network', 'libvirt-daemon-driver-nodedev', 'libvirt-daemon-kvm', 'libvirt-python', 'libvirt-daemon-config-nwfilte...
python
def deploy_hypervisor(self): """Install the libvirtd and instack-undercloud packages. """ self.yum_install(['libvirt-daemon-driver-nwfilter', 'libvirt-client', 'libvirt-daemon-config-network', 'libvirt-daemon-driver-nodedev', 'libvirt-daemon-kvm', 'libvirt-python', 'libvirt-daemon-config-nwfilte...
[ "def", "deploy_hypervisor", "(", "self", ")", ":", "self", ".", "yum_install", "(", "[", "'libvirt-daemon-driver-nwfilter'", ",", "'libvirt-client'", ",", "'libvirt-daemon-config-network'", ",", "'libvirt-daemon-driver-nodedev'", ",", "'libvirt-daemon-kvm'", ",", "'libvirt-...
Install the libvirtd and instack-undercloud packages.
[ "Install", "the", "libvirtd", "and", "instack", "-", "undercloud", "packages", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/host0.py#L44-L54
train
redhat-openstack/python-tripleo-helper
tripleohelper/host0.py
Host0.build_undercloud_on_libvirt
def build_undercloud_on_libvirt(self, image_path, rhsm=None, repositories=[]): """Build the Undercloud by using instack-virt-setup script.""" self.run('sysctl net.ipv4.ip_forward=1') self.fetch_image(path=image_path, dest='/home/stack/guest_image.qcow2', ...
python
def build_undercloud_on_libvirt(self, image_path, rhsm=None, repositories=[]): """Build the Undercloud by using instack-virt-setup script.""" self.run('sysctl net.ipv4.ip_forward=1') self.fetch_image(path=image_path, dest='/home/stack/guest_image.qcow2', ...
[ "def", "build_undercloud_on_libvirt", "(", "self", ",", "image_path", ",", "rhsm", "=", "None", ",", "repositories", "=", "[", "]", ")", ":", "self", ".", "run", "(", "'sysctl net.ipv4.ip_forward=1'", ")", "self", ".", "fetch_image", "(", "path", "=", "image...
Build the Undercloud by using instack-virt-setup script.
[ "Build", "the", "Undercloud", "by", "using", "instack", "-", "virt", "-", "setup", "script", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/host0.py#L56-L105
train