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
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulationCell._tensors
def _tensors(cls, fluents: Sequence[FluentPair]) -> Iterable[tf.Tensor]: '''Yields the `fluents`' tensors.''' for _, fluent in fluents: tensor = cls._output_size(fluent.tensor) yield tensor
python
def _tensors(cls, fluents: Sequence[FluentPair]) -> Iterable[tf.Tensor]: '''Yields the `fluents`' tensors.''' for _, fluent in fluents: tensor = cls._output_size(fluent.tensor) yield tensor
[ "def", "_tensors", "(", "cls", ",", "fluents", ":", "Sequence", "[", "FluentPair", "]", ")", "->", "Iterable", "[", "tf", ".", "Tensor", "]", ":", "for", "_", ",", "fluent", "in", "fluents", ":", "tensor", "=", "cls", ".", "_output_size", "(", "fluen...
Yields the `fluents`' tensors.
[ "Yields", "the", "fluents", "tensors", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L157-L161
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulationCell._dtype
def _dtype(cls, tensor: tf.Tensor) -> tf.Tensor: '''Converts `tensor` to tf.float32 datatype if needed.''' if tensor.dtype != tf.float32: tensor = tf.cast(tensor, tf.float32) return tensor
python
def _dtype(cls, tensor: tf.Tensor) -> tf.Tensor: '''Converts `tensor` to tf.float32 datatype if needed.''' if tensor.dtype != tf.float32: tensor = tf.cast(tensor, tf.float32) return tensor
[ "def", "_dtype", "(", "cls", ",", "tensor", ":", "tf", ".", "Tensor", ")", "->", "tf", ".", "Tensor", ":", "if", "tensor", ".", "dtype", "!=", "tf", ".", "float32", ":", "tensor", "=", "tf", ".", "cast", "(", "tensor", ",", "tf", ".", "float32", ...
Converts `tensor` to tf.float32 datatype if needed.
[ "Converts", "tensor", "to", "tf", ".", "float32", "datatype", "if", "needed", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L164-L168
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulationCell._output
def _output(cls, fluents: Sequence[FluentPair]) -> Sequence[tf.Tensor]: '''Returns output tensors for `fluents`.''' return tuple(cls._dtype(t) for t in cls._tensors(fluents))
python
def _output(cls, fluents: Sequence[FluentPair]) -> Sequence[tf.Tensor]: '''Returns output tensors for `fluents`.''' return tuple(cls._dtype(t) for t in cls._tensors(fluents))
[ "def", "_output", "(", "cls", ",", "fluents", ":", "Sequence", "[", "FluentPair", "]", ")", "->", "Sequence", "[", "tf", ".", "Tensor", "]", ":", "return", "tuple", "(", "cls", ".", "_dtype", "(", "t", ")", "for", "t", "in", "cls", ".", "_tensors",...
Returns output tensors for `fluents`.
[ "Returns", "output", "tensors", "for", "fluents", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L171-L173
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulator.output_size
def output_size(self) -> Tuple[Sequence[Shape], Sequence[Shape], Sequence[Shape], int]: '''Returns the simulation output size.''' return self._cell.output_size
python
def output_size(self) -> Tuple[Sequence[Shape], Sequence[Shape], Sequence[Shape], int]: '''Returns the simulation output size.''' return self._cell.output_size
[ "def", "output_size", "(", "self", ")", "->", "Tuple", "[", "Sequence", "[", "Shape", "]", ",", "Sequence", "[", "Shape", "]", ",", "Sequence", "[", "Shape", "]", ",", "int", "]", ":", "return", "self", ".", "_cell", ".", "output_size" ]
Returns the simulation output size.
[ "Returns", "the", "simulation", "output", "size", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L214-L216
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulator.timesteps
def timesteps(self, horizon: int) -> tf.Tensor: '''Returns the input tensor for the given `horizon`.''' start, limit, delta = horizon - 1, -1, -1 timesteps_range = tf.range(start, limit, delta, dtype=tf.float32) timesteps_range = tf.expand_dims(timesteps_range, -1) batch_timestep...
python
def timesteps(self, horizon: int) -> tf.Tensor: '''Returns the input tensor for the given `horizon`.''' start, limit, delta = horizon - 1, -1, -1 timesteps_range = tf.range(start, limit, delta, dtype=tf.float32) timesteps_range = tf.expand_dims(timesteps_range, -1) batch_timestep...
[ "def", "timesteps", "(", "self", ",", "horizon", ":", "int", ")", "->", "tf", ".", "Tensor", ":", "start", ",", "limit", ",", "delta", "=", "horizon", "-", "1", ",", "-", "1", ",", "-", "1", "timesteps_range", "=", "tf", ".", "range", "(", "start...
Returns the input tensor for the given `horizon`.
[ "Returns", "the", "input", "tensor", "for", "the", "given", "horizon", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L218-L224
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulator.trajectory
def trajectory(self, horizon: int, initial_state: Optional[StateTensor] = None) -> TrajectoryOutput: '''Returns the ops for the trajectory generation with given `horizon` and `initial_state`. The simulation returns states, actions and interms as a sequence of ten...
python
def trajectory(self, horizon: int, initial_state: Optional[StateTensor] = None) -> TrajectoryOutput: '''Returns the ops for the trajectory generation with given `horizon` and `initial_state`. The simulation returns states, actions and interms as a sequence of ten...
[ "def", "trajectory", "(", "self", ",", "horizon", ":", "int", ",", "initial_state", ":", "Optional", "[", "StateTensor", "]", "=", "None", ")", "->", "TrajectoryOutput", ":", "if", "initial_state", "is", "None", ":", "initial_state", "=", "self", ".", "_ce...
Returns the ops for the trajectory generation with given `horizon` and `initial_state`. The simulation returns states, actions and interms as a sequence of tensors (i.e., all representations are factored). The reward is a batch sized tensor. The trajectoty output is a tuple: (in...
[ "Returns", "the", "ops", "for", "the", "trajectory", "generation", "with", "given", "horizon", "and", "initial_state", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L226-L272
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulator.run
def run(self, horizon: int, initial_state: Optional[StateTensor] = None) -> SimulationOutput: '''Builds the MDP graph and simulates in batch the trajectories with given `horizon`. Returns the non-fluents, states, actions, interms and rewards. Fluents and non-fluents are r...
python
def run(self, horizon: int, initial_state: Optional[StateTensor] = None) -> SimulationOutput: '''Builds the MDP graph and simulates in batch the trajectories with given `horizon`. Returns the non-fluents, states, actions, interms and rewards. Fluents and non-fluents are r...
[ "def", "run", "(", "self", ",", "horizon", ":", "int", ",", "initial_state", ":", "Optional", "[", "StateTensor", "]", "=", "None", ")", "->", "SimulationOutput", ":", "trajectory", "=", "self", ".", "trajectory", "(", "horizon", ",", "initial_state", ")",...
Builds the MDP graph and simulates in batch the trajectories with given `horizon`. Returns the non-fluents, states, actions, interms and rewards. Fluents and non-fluents are returned in factored form. Note: All output arrays have shape: (batch_size, horizon, fluent_shape). ...
[ "Builds", "the", "MDP", "graph", "and", "simulates", "in", "batch", "the", "trajectories", "with", "given", "horizon", ".", "Returns", "the", "non", "-", "fluents", "states", "actions", "interms", "and", "rewards", ".", "Fluents", "and", "non", "-", "fluents...
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L274-L320
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulator._output
def _output(cls, tensors: Sequence[tf.Tensor], dtypes: Sequence[tf.DType]) -> Sequence[tf.Tensor]: '''Converts `tensors` to the corresponding `dtypes`.''' outputs = [] for tensor, dtype in zip(tensors, dtypes): tensor = tensor[0] if tensor.dtype !=...
python
def _output(cls, tensors: Sequence[tf.Tensor], dtypes: Sequence[tf.DType]) -> Sequence[tf.Tensor]: '''Converts `tensors` to the corresponding `dtypes`.''' outputs = [] for tensor, dtype in zip(tensors, dtypes): tensor = tensor[0] if tensor.dtype !=...
[ "def", "_output", "(", "cls", ",", "tensors", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ",", "dtypes", ":", "Sequence", "[", "tf", ".", "DType", "]", ")", "->", "Sequence", "[", "tf", ".", "Tensor", "]", ":", "outputs", "=", "[", "]", "for"...
Converts `tensors` to the corresponding `dtypes`.
[ "Converts", "tensors", "to", "the", "corresponding", "dtypes", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L323-L333
train
pgxcentre/geneparse
geneparse/readers/impute2.py
Impute2Reader._get_biallelic_variant
def _get_biallelic_variant(self, variant, info, _check_alleles=True): """Creates a bi-allelic variant.""" info = info.iloc[0, :] assert not info.multiallelic # Seeking and parsing the file self._impute2_file.seek(info.seek) genotypes = self._parse_impute2_line(self._impu...
python
def _get_biallelic_variant(self, variant, info, _check_alleles=True): """Creates a bi-allelic variant.""" info = info.iloc[0, :] assert not info.multiallelic # Seeking and parsing the file self._impute2_file.seek(info.seek) genotypes = self._parse_impute2_line(self._impu...
[ "def", "_get_biallelic_variant", "(", "self", ",", "variant", ",", "info", ",", "_check_alleles", "=", "True", ")", ":", "info", "=", "info", ".", "iloc", "[", "0", ",", ":", "]", "assert", "not", "info", ".", "multiallelic", "self", ".", "_impute2_file"...
Creates a bi-allelic variant.
[ "Creates", "a", "bi", "-", "allelic", "variant", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/impute2.py#L222-L239
train
pgxcentre/geneparse
geneparse/readers/impute2.py
Impute2Reader._fix_genotypes_object
def _fix_genotypes_object(self, genotypes, variant_info): """Fixes a genotypes object (variant name, multi-allelic value.""" # Checking the name (if there were duplications) if self.has_index and variant_info.name != genotypes.variant.name: if not variant_info.name.startswith(genotyp...
python
def _fix_genotypes_object(self, genotypes, variant_info): """Fixes a genotypes object (variant name, multi-allelic value.""" # Checking the name (if there were duplications) if self.has_index and variant_info.name != genotypes.variant.name: if not variant_info.name.startswith(genotyp...
[ "def", "_fix_genotypes_object", "(", "self", ",", "genotypes", ",", "variant_info", ")", ":", "if", "self", ".", "has_index", "and", "variant_info", ".", "name", "!=", "genotypes", ".", "variant", ".", "name", ":", "if", "not", "variant_info", ".", "name", ...
Fixes a genotypes object (variant name, multi-allelic value.
[ "Fixes", "a", "genotypes", "object", "(", "variant", "name", "multi", "-", "allelic", "value", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/impute2.py#L394-L412
train
pgxcentre/geneparse
geneparse/readers/plink.py
PlinkReader._normalize_missing
def _normalize_missing(g): """Normalize a plink genotype vector.""" g = g.astype(float) g[g == -1.0] = np.nan return g
python
def _normalize_missing(g): """Normalize a plink genotype vector.""" g = g.astype(float) g[g == -1.0] = np.nan return g
[ "def", "_normalize_missing", "(", "g", ")", ":", "g", "=", "g", ".", "astype", "(", "float", ")", "g", "[", "g", "==", "-", "1.0", "]", "=", "np", ".", "nan", "return", "g" ]
Normalize a plink genotype vector.
[ "Normalize", "a", "plink", "genotype", "vector", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/plink.py#L276-L280
train
255BITS/hyperchamber
examples/shared/cifar_utils.py
maybe_download_and_extract
def maybe_download_and_extract(): """Download and extract the tarball from Alex's website.""" dest_directory = "/tmp/cifar" if not os.path.exists(dest_directory): os.makedirs(dest_directory) filename = DATA_URL.split('/')[-1] filepath = os.path.join(dest_directory, filename) if not os.path.exists(filepa...
python
def maybe_download_and_extract(): """Download and extract the tarball from Alex's website.""" dest_directory = "/tmp/cifar" if not os.path.exists(dest_directory): os.makedirs(dest_directory) filename = DATA_URL.split('/')[-1] filepath = os.path.join(dest_directory, filename) if not os.path.exists(filepa...
[ "def", "maybe_download_and_extract", "(", ")", ":", "dest_directory", "=", "\"/tmp/cifar\"", "if", "not", "os", ".", "path", ".", "exists", "(", "dest_directory", ")", ":", "os", ".", "makedirs", "(", "dest_directory", ")", "filename", "=", "DATA_URL", ".", ...
Download and extract the tarball from Alex's website.
[ "Download", "and", "extract", "the", "tarball", "from", "Alex", "s", "website", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/cifar_utils.py#L73-L89
train
255BITS/hyperchamber
examples/shared/cifar_utils.py
plot
def plot(config, image, file): """ Plot a single CIFAR image.""" image = np.squeeze(image) print(file, image.shape) imsave(file, image)
python
def plot(config, image, file): """ Plot a single CIFAR image.""" image = np.squeeze(image) print(file, image.shape) imsave(file, image)
[ "def", "plot", "(", "config", ",", "image", ",", "file", ")", ":", "image", "=", "np", ".", "squeeze", "(", "image", ")", "print", "(", "file", ",", "image", ".", "shape", ")", "imsave", "(", "file", ",", "image", ")" ]
Plot a single CIFAR image.
[ "Plot", "a", "single", "CIFAR", "image", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/cifar_utils.py#L91-L95
train
kblin/bioinf-helperlibs
helperlibs/bio/seqio.py
_get_seqtype_from_ext
def _get_seqtype_from_ext(handle): '''Predict the filetype from a handle's name''' if isinstance(handle, basestring): name = handle elif hasattr(handle, 'filename'): name = handle.filename elif hasattr(handle, 'name'): name = handle.name else: raise ValueError("Unknow...
python
def _get_seqtype_from_ext(handle): '''Predict the filetype from a handle's name''' if isinstance(handle, basestring): name = handle elif hasattr(handle, 'filename'): name = handle.filename elif hasattr(handle, 'name'): name = handle.name else: raise ValueError("Unknow...
[ "def", "_get_seqtype_from_ext", "(", "handle", ")", ":", "if", "isinstance", "(", "handle", ",", "basestring", ")", ":", "name", "=", "handle", "elif", "hasattr", "(", "handle", ",", "'filename'", ")", ":", "name", "=", "handle", ".", "filename", "elif", ...
Predict the filetype from a handle's name
[ "Predict", "the", "filetype", "from", "a", "handle", "s", "name" ]
3a732d62b4b3cc42675631db886ba534672cb134
https://github.com/kblin/bioinf-helperlibs/blob/3a732d62b4b3cc42675631db886ba534672cb134/helperlibs/bio/seqio.py#L28-L55
train
kblin/bioinf-helperlibs
helperlibs/bio/seqio.py
_guess_seqtype_from_file
def _guess_seqtype_from_file(handle): "Guess the sequence type from the file's contents" if isinstance(handle, basestring): handle = StringIO(handle) for line in handle: if not line.strip(): continue if line.lstrip().split()[0] in ('LOCUS', 'FEATURES', 'source', 'CDS', ...
python
def _guess_seqtype_from_file(handle): "Guess the sequence type from the file's contents" if isinstance(handle, basestring): handle = StringIO(handle) for line in handle: if not line.strip(): continue if line.lstrip().split()[0] in ('LOCUS', 'FEATURES', 'source', 'CDS', ...
[ "def", "_guess_seqtype_from_file", "(", "handle", ")", ":", "\"Guess the sequence type from the file's contents\"", "if", "isinstance", "(", "handle", ",", "basestring", ")", ":", "handle", "=", "StringIO", "(", "handle", ")", "for", "line", "in", "handle", ":", "...
Guess the sequence type from the file's contents
[ "Guess", "the", "sequence", "type", "from", "the", "file", "s", "contents" ]
3a732d62b4b3cc42675631db886ba534672cb134
https://github.com/kblin/bioinf-helperlibs/blob/3a732d62b4b3cc42675631db886ba534672cb134/helperlibs/bio/seqio.py#L58-L84
train
kblin/bioinf-helperlibs
helperlibs/bio/seqio.py
_unzip_handle
def _unzip_handle(handle): """Transparently unzip the file handle""" if isinstance(handle, basestring): handle = _gzip_open_filename(handle) else: handle = _gzip_open_handle(handle) return handle
python
def _unzip_handle(handle): """Transparently unzip the file handle""" if isinstance(handle, basestring): handle = _gzip_open_filename(handle) else: handle = _gzip_open_handle(handle) return handle
[ "def", "_unzip_handle", "(", "handle", ")", ":", "if", "isinstance", "(", "handle", ",", "basestring", ")", ":", "handle", "=", "_gzip_open_filename", "(", "handle", ")", "else", ":", "handle", "=", "_gzip_open_handle", "(", "handle", ")", "return", "handle"...
Transparently unzip the file handle
[ "Transparently", "unzip", "the", "file", "handle" ]
3a732d62b4b3cc42675631db886ba534672cb134
https://github.com/kblin/bioinf-helperlibs/blob/3a732d62b4b3cc42675631db886ba534672cb134/helperlibs/bio/seqio.py#L87-L93
train
kblin/bioinf-helperlibs
helperlibs/bio/seqio.py
sanity_check_insdcio
def sanity_check_insdcio(handle, id_marker, fake_id_line): """Sanity check for insdcio style files""" found_id = False found_end_marker = False for line in handle: line = line.strip() if not line: continue if line.startswith(id_marker): found_id = True ...
python
def sanity_check_insdcio(handle, id_marker, fake_id_line): """Sanity check for insdcio style files""" found_id = False found_end_marker = False for line in handle: line = line.strip() if not line: continue if line.startswith(id_marker): found_id = True ...
[ "def", "sanity_check_insdcio", "(", "handle", ",", "id_marker", ",", "fake_id_line", ")", ":", "found_id", "=", "False", "found_end_marker", "=", "False", "for", "line", "in", "handle", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "not", "line",...
Sanity check for insdcio style files
[ "Sanity", "check", "for", "insdcio", "style", "files" ]
3a732d62b4b3cc42675631db886ba534672cb134
https://github.com/kblin/bioinf-helperlibs/blob/3a732d62b4b3cc42675631db886ba534672cb134/helperlibs/bio/seqio.py#L117-L146
train
kblin/bioinf-helperlibs
helperlibs/bio/seqio.py
sanity_check_fasta
def sanity_check_fasta(handle): """Sanity check FASTA files.""" header_found = False for line in handle: if line.startswith('>'): header_found = True break handle.seek(0) if header_found: return handle fake_header_line = ">DUMMY" new_handle = String...
python
def sanity_check_fasta(handle): """Sanity check FASTA files.""" header_found = False for line in handle: if line.startswith('>'): header_found = True break handle.seek(0) if header_found: return handle fake_header_line = ">DUMMY" new_handle = String...
[ "def", "sanity_check_fasta", "(", "handle", ")", ":", "header_found", "=", "False", "for", "line", "in", "handle", ":", "if", "line", ".", "startswith", "(", "'>'", ")", ":", "header_found", "=", "True", "break", "handle", ".", "seek", "(", "0", ")", "...
Sanity check FASTA files.
[ "Sanity", "check", "FASTA", "files", "." ]
3a732d62b4b3cc42675631db886ba534672cb134
https://github.com/kblin/bioinf-helperlibs/blob/3a732d62b4b3cc42675631db886ba534672cb134/helperlibs/bio/seqio.py#L163-L181
train
kblin/bioinf-helperlibs
helperlibs/bio/seqio.py
parse
def parse(handle, seqtype=None, robust=False): '''Wrap SeqIO.parse''' if seqtype is None: seqtype = _get_seqtype_from_ext(handle) if seqtype.startswith('gz-'): handle = _unzip_handle(handle) seqtype = seqtype[3:] # False positive from pylint, both handles are fileobj-like #...
python
def parse(handle, seqtype=None, robust=False): '''Wrap SeqIO.parse''' if seqtype is None: seqtype = _get_seqtype_from_ext(handle) if seqtype.startswith('gz-'): handle = _unzip_handle(handle) seqtype = seqtype[3:] # False positive from pylint, both handles are fileobj-like #...
[ "def", "parse", "(", "handle", ",", "seqtype", "=", "None", ",", "robust", "=", "False", ")", ":", "if", "seqtype", "is", "None", ":", "seqtype", "=", "_get_seqtype_from_ext", "(", "handle", ")", "if", "seqtype", ".", "startswith", "(", "'gz-'", ")", "...
Wrap SeqIO.parse
[ "Wrap", "SeqIO", ".", "parse" ]
3a732d62b4b3cc42675631db886ba534672cb134
https://github.com/kblin/bioinf-helperlibs/blob/3a732d62b4b3cc42675631db886ba534672cb134/helperlibs/bio/seqio.py#L184-L204
train
Nic30/hwtGraph
hwtGraph/elk/containers/constants.py
PortConstraints.isOrderFixed
def isOrderFixed(self): """ Returns whether the order of ports is fixed. @return true if the order of ports is fixed """ return (self == PortConstraints.FIXED_ORDER or self == PortConstraints.FIXED_RATIO or self == PortConstraints.FIXED_POS)
python
def isOrderFixed(self): """ Returns whether the order of ports is fixed. @return true if the order of ports is fixed """ return (self == PortConstraints.FIXED_ORDER or self == PortConstraints.FIXED_RATIO or self == PortConstraints.FIXED_POS)
[ "def", "isOrderFixed", "(", "self", ")", ":", "return", "(", "self", "==", "PortConstraints", ".", "FIXED_ORDER", "or", "self", "==", "PortConstraints", ".", "FIXED_RATIO", "or", "self", "==", "PortConstraints", ".", "FIXED_POS", ")" ]
Returns whether the order of ports is fixed. @return true if the order of ports is fixed
[ "Returns", "whether", "the", "order", "of", "ports", "is", "fixed", "." ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/containers/constants.py#L98-L106
train
testedminds/sand
sand/graph.py
_dicts_to_columns
def _dicts_to_columns(dicts): """ Given a List of Dictionaries with uniform keys, returns a single Dictionary with keys holding a List of values matching the key in the original List. [{'name': 'Field Museum', 'location': 'Chicago'}, {'name': 'Epcot', 'location': 'Orlando'}] => {'name': ...
python
def _dicts_to_columns(dicts): """ Given a List of Dictionaries with uniform keys, returns a single Dictionary with keys holding a List of values matching the key in the original List. [{'name': 'Field Museum', 'location': 'Chicago'}, {'name': 'Epcot', 'location': 'Orlando'}] => {'name': ...
[ "def", "_dicts_to_columns", "(", "dicts", ")", ":", "keys", "=", "dicts", "[", "0", "]", ".", "keys", "(", ")", "result", "=", "dict", "(", "(", "k", ",", "[", "]", ")", "for", "k", "in", "keys", ")", "for", "d", "in", "dicts", ":", "for", "k...
Given a List of Dictionaries with uniform keys, returns a single Dictionary with keys holding a List of values matching the key in the original List. [{'name': 'Field Museum', 'location': 'Chicago'}, {'name': 'Epcot', 'location': 'Orlando'}] => {'name': ['Field Museum', 'Epcot'], 'location'...
[ "Given", "a", "List", "of", "Dictionaries", "with", "uniform", "keys", "returns", "a", "single", "Dictionary", "with", "keys", "holding", "a", "List", "of", "values", "matching", "the", "key", "in", "the", "original", "List", "." ]
234f0eedb0742920cdf26da9bc84bf3f863a2f02
https://github.com/testedminds/sand/blob/234f0eedb0742920cdf26da9bc84bf3f863a2f02/sand/graph.py#L25-L43
train
testedminds/sand
sand/graph.py
from_vertices_and_edges
def from_vertices_and_edges(vertices, edges, vertex_name_key='name', vertex_id_key='id', edge_foreign_keys=('source', 'target'), directed=True): """ This representation assumes that vertices and edges are encoded in two lists, each list containing a Python dict for each vertex an...
python
def from_vertices_and_edges(vertices, edges, vertex_name_key='name', vertex_id_key='id', edge_foreign_keys=('source', 'target'), directed=True): """ This representation assumes that vertices and edges are encoded in two lists, each list containing a Python dict for each vertex an...
[ "def", "from_vertices_and_edges", "(", "vertices", ",", "edges", ",", "vertex_name_key", "=", "'name'", ",", "vertex_id_key", "=", "'id'", ",", "edge_foreign_keys", "=", "(", "'source'", ",", "'target'", ")", ",", "directed", "=", "True", ")", ":", "vertex_dat...
This representation assumes that vertices and edges are encoded in two lists, each list containing a Python dict for each vertex and each edge, respectively. A distinguished element of the vertex dicts contain a vertex ID which is used in the edge dicts to refer to source and target vertices. All the re...
[ "This", "representation", "assumes", "that", "vertices", "and", "edges", "are", "encoded", "in", "two", "lists", "each", "list", "containing", "a", "Python", "dict", "for", "each", "vertex", "and", "each", "edge", "respectively", ".", "A", "distinguished", "el...
234f0eedb0742920cdf26da9bc84bf3f863a2f02
https://github.com/testedminds/sand/blob/234f0eedb0742920cdf26da9bc84bf3f863a2f02/sand/graph.py#L46-L84
train
testedminds/sand
sand/graph.py
from_edges
def from_edges(edges, source_key='source', target_key='target', weight_key='weight', directed=True): """ Given a List of Dictionaries with source, target, and weight attributes, return a weighted, directed graph. """ raw = list(map(lambda x: [x[source_key], x[target_key], int(x[weight_key])], edges)) ...
python
def from_edges(edges, source_key='source', target_key='target', weight_key='weight', directed=True): """ Given a List of Dictionaries with source, target, and weight attributes, return a weighted, directed graph. """ raw = list(map(lambda x: [x[source_key], x[target_key], int(x[weight_key])], edges)) ...
[ "def", "from_edges", "(", "edges", ",", "source_key", "=", "'source'", ",", "target_key", "=", "'target'", ",", "weight_key", "=", "'weight'", ",", "directed", "=", "True", ")", ":", "raw", "=", "list", "(", "map", "(", "lambda", "x", ":", "[", "x", ...
Given a List of Dictionaries with source, target, and weight attributes, return a weighted, directed graph.
[ "Given", "a", "List", "of", "Dictionaries", "with", "source", "target", "and", "weight", "attributes", "return", "a", "weighted", "directed", "graph", "." ]
234f0eedb0742920cdf26da9bc84bf3f863a2f02
https://github.com/testedminds/sand/blob/234f0eedb0742920cdf26da9bc84bf3f863a2f02/sand/graph.py#L87-L98
train
pgxcentre/geneparse
geneparse/utils.py
flip_alleles
def flip_alleles(genotypes): """Flip the alleles of an Genotypes instance.""" warnings.warn("deprecated: use 'Genotypes.flip_coded'", DeprecationWarning) genotypes.reference, genotypes.coded = (genotypes.coded, genotypes.reference) genotypes.genotypes = 2 - ge...
python
def flip_alleles(genotypes): """Flip the alleles of an Genotypes instance.""" warnings.warn("deprecated: use 'Genotypes.flip_coded'", DeprecationWarning) genotypes.reference, genotypes.coded = (genotypes.coded, genotypes.reference) genotypes.genotypes = 2 - ge...
[ "def", "flip_alleles", "(", "genotypes", ")", ":", "warnings", ".", "warn", "(", "\"deprecated: use 'Genotypes.flip_coded'\"", ",", "DeprecationWarning", ")", "genotypes", ".", "reference", ",", "genotypes", ".", "coded", "=", "(", "genotypes", ".", "coded", ",", ...
Flip the alleles of an Genotypes instance.
[ "Flip", "the", "alleles", "of", "an", "Genotypes", "instance", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L45-L51
train
pgxcentre/geneparse
geneparse/utils.py
code_minor
def code_minor(genotypes): """Encode the genotypes with respect to the minor allele. This confirms that "reference" is the major allele and that "coded" is the minor allele. In other words, this function can be used to make sure that the genotype value is the number of minor alleles for an individ...
python
def code_minor(genotypes): """Encode the genotypes with respect to the minor allele. This confirms that "reference" is the major allele and that "coded" is the minor allele. In other words, this function can be used to make sure that the genotype value is the number of minor alleles for an individ...
[ "def", "code_minor", "(", "genotypes", ")", ":", "warnings", ".", "warn", "(", "\"deprecated: use 'Genotypes.code_minor'\"", ",", "DeprecationWarning", ")", "_", ",", "minor_coded", "=", "maf", "(", "genotypes", ")", "if", "not", "minor_coded", ":", "return", "f...
Encode the genotypes with respect to the minor allele. This confirms that "reference" is the major allele and that "coded" is the minor allele. In other words, this function can be used to make sure that the genotype value is the number of minor alleles for an individual.
[ "Encode", "the", "genotypes", "with", "respect", "to", "the", "minor", "allele", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L54-L69
train
pgxcentre/geneparse
geneparse/utils.py
maf
def maf(genotypes): """Computes the MAF and returns a boolean indicating if the minor allele is currently the coded allele. """ warnings.warn("deprecated: use 'Genotypes.maf'", DeprecationWarning) g = genotypes.genotypes maf = np.nansum(g) / (2 * np.sum(~np.isnan(g))) if maf > 0.5: ...
python
def maf(genotypes): """Computes the MAF and returns a boolean indicating if the minor allele is currently the coded allele. """ warnings.warn("deprecated: use 'Genotypes.maf'", DeprecationWarning) g = genotypes.genotypes maf = np.nansum(g) / (2 * np.sum(~np.isnan(g))) if maf > 0.5: ...
[ "def", "maf", "(", "genotypes", ")", ":", "warnings", ".", "warn", "(", "\"deprecated: use 'Genotypes.maf'\"", ",", "DeprecationWarning", ")", "g", "=", "genotypes", ".", "genotypes", "maf", "=", "np", ".", "nansum", "(", "g", ")", "/", "(", "2", "*", "n...
Computes the MAF and returns a boolean indicating if the minor allele is currently the coded allele.
[ "Computes", "the", "MAF", "and", "returns", "a", "boolean", "indicating", "if", "the", "minor", "allele", "is", "currently", "the", "coded", "allele", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L72-L84
train
pgxcentre/geneparse
geneparse/utils.py
genotype_to_df
def genotype_to_df(g, samples, as_string=False): """Convert a genotype object to a pandas dataframe. By default, the encoded values are stored, but the as_string argument can be used to represent it as characters (alleles) instead. """ name = g.variant.name if g.variant.name else "genotypes" d...
python
def genotype_to_df(g, samples, as_string=False): """Convert a genotype object to a pandas dataframe. By default, the encoded values are stored, but the as_string argument can be used to represent it as characters (alleles) instead. """ name = g.variant.name if g.variant.name else "genotypes" d...
[ "def", "genotype_to_df", "(", "g", ",", "samples", ",", "as_string", "=", "False", ")", ":", "name", "=", "g", ".", "variant", ".", "name", "if", "g", ".", "variant", ".", "name", "else", "\"genotypes\"", "df", "=", "pd", ".", "DataFrame", "(", "g", ...
Convert a genotype object to a pandas dataframe. By default, the encoded values are stored, but the as_string argument can be used to represent it as characters (alleles) instead.
[ "Convert", "a", "genotype", "object", "to", "a", "pandas", "dataframe", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L133-L155
train
pgxcentre/geneparse
geneparse/utils.py
compute_ld
def compute_ld(cur_geno, other_genotypes, r2=False): """Compute LD between a marker and a list of markers. Args: cur_geno (Genotypes): The genotypes of the marker. other_genotypes (list): A list of genotypes. Returns: numpy.array: An array containing the r or r**2 values between cu...
python
def compute_ld(cur_geno, other_genotypes, r2=False): """Compute LD between a marker and a list of markers. Args: cur_geno (Genotypes): The genotypes of the marker. other_genotypes (list): A list of genotypes. Returns: numpy.array: An array containing the r or r**2 values between cu...
[ "def", "compute_ld", "(", "cur_geno", ",", "other_genotypes", ",", "r2", "=", "False", ")", ":", "norm_cur", "=", "normalize_genotypes", "(", "cur_geno", ")", "norm_others", "=", "np", ".", "stack", "(", "tuple", "(", "normalize_genotypes", "(", "g", ")", ...
Compute LD between a marker and a list of markers. Args: cur_geno (Genotypes): The genotypes of the marker. other_genotypes (list): A list of genotypes. Returns: numpy.array: An array containing the r or r**2 values between cur_geno and other_genotypes. Note: ...
[ "Compute", "LD", "between", "a", "marker", "and", "a", "list", "of", "markers", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L158-L207
train
pgxcentre/geneparse
geneparse/utils.py
normalize_genotypes
def normalize_genotypes(genotypes): """Normalize the genotypes. Args: genotypes (Genotypes): The genotypes to normalize. Returns: numpy.array: The normalized genotypes. """ genotypes = genotypes.genotypes return (genotypes - np.nanmean(genotypes)) / np.nanstd(genotypes)
python
def normalize_genotypes(genotypes): """Normalize the genotypes. Args: genotypes (Genotypes): The genotypes to normalize. Returns: numpy.array: The normalized genotypes. """ genotypes = genotypes.genotypes return (genotypes - np.nanmean(genotypes)) / np.nanstd(genotypes)
[ "def", "normalize_genotypes", "(", "genotypes", ")", ":", "genotypes", "=", "genotypes", ".", "genotypes", "return", "(", "genotypes", "-", "np", ".", "nanmean", "(", "genotypes", ")", ")", "/", "np", ".", "nanstd", "(", "genotypes", ")" ]
Normalize the genotypes. Args: genotypes (Genotypes): The genotypes to normalize. Returns: numpy.array: The normalized genotypes.
[ "Normalize", "the", "genotypes", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L210-L221
train
geophysics-ubonn/crtomo_tools
lib/crtomo/interface.py
crmod_interface._get_tdm
def _get_tdm(self, m): """For a given model, return a tdMan instance Parameters ---------- m : ndarray Model parameters (linear, ohm m) """ m = np.atleast_2d(m) assert len(m.shape) == 2 tdm = crtomo.tdMan(grid=self.grid, tempdir=self.tempdir) ...
python
def _get_tdm(self, m): """For a given model, return a tdMan instance Parameters ---------- m : ndarray Model parameters (linear, ohm m) """ m = np.atleast_2d(m) assert len(m.shape) == 2 tdm = crtomo.tdMan(grid=self.grid, tempdir=self.tempdir) ...
[ "def", "_get_tdm", "(", "self", ",", "m", ")", ":", "m", "=", "np", ".", "atleast_2d", "(", "m", ")", "assert", "len", "(", "m", ".", "shape", ")", "==", "2", "tdm", "=", "crtomo", ".", "tdMan", "(", "grid", "=", "self", ".", "grid", ",", "te...
For a given model, return a tdMan instance Parameters ---------- m : ndarray Model parameters (linear, ohm m)
[ "For", "a", "given", "model", "return", "a", "tdMan", "instance" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/interface.py#L43-L63
train
geophysics-ubonn/crtomo_tools
lib/crtomo/interface.py
crmod_interface.J
def J(self, log_sigma): """Return the sensitivity matrix Parameters ---------- log_sigma : numpy.ndarray log_e conductivities """ m = 1.0 / np.exp(log_sigma) tdm = self._get_tdm(m) tdm.model( sensitivities=True, # out...
python
def J(self, log_sigma): """Return the sensitivity matrix Parameters ---------- log_sigma : numpy.ndarray log_e conductivities """ m = 1.0 / np.exp(log_sigma) tdm = self._get_tdm(m) tdm.model( sensitivities=True, # out...
[ "def", "J", "(", "self", ",", "log_sigma", ")", ":", "m", "=", "1.0", "/", "np", ".", "exp", "(", "log_sigma", ")", "tdm", "=", "self", ".", "_get_tdm", "(", "m", ")", "tdm", ".", "model", "(", "sensitivities", "=", "True", ",", ")", "measurement...
Return the sensitivity matrix Parameters ---------- log_sigma : numpy.ndarray log_e conductivities
[ "Return", "the", "sensitivity", "matrix" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/interface.py#L88-L136
train
redhat-openstack/python-tripleo-helper
tripleohelper/baremetal.py
BaremetalFactory.set_ironic_uuid
def set_ironic_uuid(self, uuid_list): """Map a list of Ironic UUID to BM nodes. """ # TODO(Gonéri): ensure we adjust the correct node i = iter(self.nodes) for uuid in uuid_list: node = next(i) node.uuid = uuid
python
def set_ironic_uuid(self, uuid_list): """Map a list of Ironic UUID to BM nodes. """ # TODO(Gonéri): ensure we adjust the correct node i = iter(self.nodes) for uuid in uuid_list: node = next(i) node.uuid = uuid
[ "def", "set_ironic_uuid", "(", "self", ",", "uuid_list", ")", ":", "i", "=", "iter", "(", "self", ".", "nodes", ")", "for", "uuid", "in", "uuid_list", ":", "node", "=", "next", "(", "i", ")", "node", ".", "uuid", "=", "uuid" ]
Map a list of Ironic UUID to BM nodes.
[ "Map", "a", "list", "of", "Ironic", "UUID", "to", "BM", "nodes", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/baremetal.py#L89-L96
train
althonos/moclo
moclo/moclo/registry/_utils.py
find_resistance
def find_resistance(record): """Infer the antibiotics resistance of the given record. Arguments: record (`~Bio.SeqRecord.SeqRecord`): an annotated sequence. Raises: RuntimeError: when there's not exactly one resistance cassette. """ for feature in record.features: labels =...
python
def find_resistance(record): """Infer the antibiotics resistance of the given record. Arguments: record (`~Bio.SeqRecord.SeqRecord`): an annotated sequence. Raises: RuntimeError: when there's not exactly one resistance cassette. """ for feature in record.features: labels =...
[ "def", "find_resistance", "(", "record", ")", ":", "for", "feature", "in", "record", ".", "features", ":", "labels", "=", "set", "(", "feature", ".", "qualifiers", ".", "get", "(", "\"label\"", ",", "[", "]", ")", ")", "cassettes", "=", "labels", ".", ...
Infer the antibiotics resistance of the given record. Arguments: record (`~Bio.SeqRecord.SeqRecord`): an annotated sequence. Raises: RuntimeError: when there's not exactly one resistance cassette.
[ "Infer", "the", "antibiotics", "resistance", "of", "the", "given", "record", "." ]
28a03748df8a2fa43f0c0c8098ca64d11559434e
https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/registry/_utils.py#L16-L33
train
rsms/tc
setup.py
shell_cmd
def shell_cmd(args, cwd=None): '''Returns stdout as string or None on failure ''' if cwd is None: cwd = os.path.abspath('.') if not isinstance(args, (list, tuple)): args = [args] ps = Popen(args, shell=True, cwd=cwd, stdout=PIPE, stderr=PIPE, close_fds=True) stdout, stderr = ps.communic...
python
def shell_cmd(args, cwd=None): '''Returns stdout as string or None on failure ''' if cwd is None: cwd = os.path.abspath('.') if not isinstance(args, (list, tuple)): args = [args] ps = Popen(args, shell=True, cwd=cwd, stdout=PIPE, stderr=PIPE, close_fds=True) stdout, stderr = ps.communic...
[ "def", "shell_cmd", "(", "args", ",", "cwd", "=", "None", ")", ":", "if", "cwd", "is", "None", ":", "cwd", "=", "os", ".", "path", ".", "abspath", "(", "'.'", ")", "if", "not", "isinstance", "(", "args", ",", "(", "list", ",", "tuple", ")", ")"...
Returns stdout as string or None on failure
[ "Returns", "stdout", "as", "string", "or", "None", "on", "failure" ]
db5da0def734246818f4a6e4531be63b7cbaa236
https://github.com/rsms/tc/blob/db5da0def734246818f4a6e4531be63b7cbaa236/setup.py#L36-L51
train
althonos/moclo
moclo/moclo/record.py
CircularRecord.reverse_complement
def reverse_complement( self, id=False, name=False, description=False, features=True, annotations=False, letter_annotations=True, dbxrefs=False, ): """Return a new ``CircularRecord`` with reverse complement sequence. """ return ...
python
def reverse_complement( self, id=False, name=False, description=False, features=True, annotations=False, letter_annotations=True, dbxrefs=False, ): """Return a new ``CircularRecord`` with reverse complement sequence. """ return ...
[ "def", "reverse_complement", "(", "self", ",", "id", "=", "False", ",", "name", "=", "False", ",", "description", "=", "False", ",", "features", "=", "True", ",", "annotations", "=", "False", ",", "letter_annotations", "=", "True", ",", "dbxrefs", "=", "...
Return a new ``CircularRecord`` with reverse complement sequence.
[ "Return", "a", "new", "CircularRecord", "with", "reverse", "complement", "sequence", "." ]
28a03748df8a2fa43f0c0c8098ca64d11559434e
https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/record.py#L141-L163
train
redhat-openstack/python-tripleo-helper
tripleohelper/ssh.py
SshClient.load_private_key
def load_private_key(self, priv_key): """Register the SSH private key.""" with open(priv_key) as fd: self._private_key = paramiko.RSAKey.from_private_key(fd)
python
def load_private_key(self, priv_key): """Register the SSH private key.""" with open(priv_key) as fd: self._private_key = paramiko.RSAKey.from_private_key(fd)
[ "def", "load_private_key", "(", "self", ",", "priv_key", ")", ":", "with", "open", "(", "priv_key", ")", "as", "fd", ":", "self", ".", "_private_key", "=", "paramiko", ".", "RSAKey", ".", "from_private_key", "(", "fd", ")" ]
Register the SSH private key.
[ "Register", "the", "SSH", "private", "key", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ssh.py#L68-L71
train
redhat-openstack/python-tripleo-helper
tripleohelper/ssh.py
SshClient.start
def start(self): """Start the ssh client and connect to the host. It will wait until the ssh service is available during 90 seconds. If it doesn't succed to connect then the function will raise an SSHException. """ if self.via_ip: connect_to = self.via_ip ...
python
def start(self): """Start the ssh client and connect to the host. It will wait until the ssh service is available during 90 seconds. If it doesn't succed to connect then the function will raise an SSHException. """ if self.via_ip: connect_to = self.via_ip ...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "via_ip", ":", "connect_to", "=", "self", ".", "via_ip", "self", ".", "description", "=", "'[%s@%s via %s]'", "%", "(", "self", ".", "_user", ",", "self", ".", "_hostname", ",", "self", ".", "...
Start the ssh client and connect to the host. It will wait until the ssh service is available during 90 seconds. If it doesn't succed to connect then the function will raise an SSHException.
[ "Start", "the", "ssh", "client", "and", "connect", "to", "the", "host", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ssh.py#L98-L142
train
redhat-openstack/python-tripleo-helper
tripleohelper/ssh.py
SshClient._get_channel
def _get_channel(self): """Returns a channel according to if there is a redirection to do or not. """ channel = self._transport.open_session() channel.set_combine_stderr(True) channel.get_pty() return channel
python
def _get_channel(self): """Returns a channel according to if there is a redirection to do or not. """ channel = self._transport.open_session() channel.set_combine_stderr(True) channel.get_pty() return channel
[ "def", "_get_channel", "(", "self", ")", ":", "channel", "=", "self", ".", "_transport", ".", "open_session", "(", ")", "channel", ".", "set_combine_stderr", "(", "True", ")", "channel", ".", "get_pty", "(", ")", "return", "channel" ]
Returns a channel according to if there is a redirection to do or not.
[ "Returns", "a", "channel", "according", "to", "if", "there", "is", "a", "redirection", "to", "do", "or", "not", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ssh.py#L237-L244
train
NJDFan/ctypes-bitfield
bitfield/__init__.py
print_fields
def print_fields(bf, *args, **kwargs): """ Print all the fields of a Bitfield object to stdout. This is primarly a diagnostic aid during debugging. """ vals = {k: hex(v) for k, v in bf.items()} print(bf.base, vals, *args, **kwargs)
python
def print_fields(bf, *args, **kwargs): """ Print all the fields of a Bitfield object to stdout. This is primarly a diagnostic aid during debugging. """ vals = {k: hex(v) for k, v in bf.items()} print(bf.base, vals, *args, **kwargs)
[ "def", "print_fields", "(", "bf", ",", "*", "args", ",", "**", "kwargs", ")", ":", "vals", "=", "{", "k", ":", "hex", "(", "v", ")", "for", "k", ",", "v", "in", "bf", ".", "items", "(", ")", "}", "print", "(", "bf", ".", "base", ",", "vals"...
Print all the fields of a Bitfield object to stdout. This is primarly a diagnostic aid during debugging.
[ "Print", "all", "the", "fields", "of", "a", "Bitfield", "object", "to", "stdout", ".", "This", "is", "primarly", "a", "diagnostic", "aid", "during", "debugging", "." ]
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/__init__.py#L201-L208
train
NJDFan/ctypes-bitfield
bitfield/__init__.py
Bitfield.clone
def clone(self): """Return a new bitfield with the same value. The returned value is a copy, and so is no longer linked to the original bitfield. This is important when the original is located at anything other than normal memory, with accesses to it either slow or havi...
python
def clone(self): """Return a new bitfield with the same value. The returned value is a copy, and so is no longer linked to the original bitfield. This is important when the original is located at anything other than normal memory, with accesses to it either slow or havi...
[ "def", "clone", "(", "self", ")", ":", "temp", "=", "self", ".", "__class__", "(", ")", "temp", ".", "base", "=", "self", ".", "base", "return", "temp" ]
Return a new bitfield with the same value. The returned value is a copy, and so is no longer linked to the original bitfield. This is important when the original is located at anything other than normal memory, with accesses to it either slow or having side effects. Creating a...
[ "Return", "a", "new", "bitfield", "with", "the", "same", "value", ".", "The", "returned", "value", "is", "a", "copy", "and", "so", "is", "no", "longer", "linked", "to", "the", "original", "bitfield", ".", "This", "is", "important", "when", "the", "origin...
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/__init__.py#L44-L56
train
gebn/wood
wood/comparison.py
Comparison.new
def new(self, base: pathlib.PurePath = pathlib.PurePath(), include_intermediates: bool = True) -> Iterator[str]: """ Find the list of new paths in this comparison. :param base: The base directory to prepend to the right entity's name. :param include_intermediates: Whether to...
python
def new(self, base: pathlib.PurePath = pathlib.PurePath(), include_intermediates: bool = True) -> Iterator[str]: """ Find the list of new paths in this comparison. :param base: The base directory to prepend to the right entity's name. :param include_intermediates: Whether to...
[ "def", "new", "(", "self", ",", "base", ":", "pathlib", ".", "PurePath", "=", "pathlib", ".", "PurePath", "(", ")", ",", "include_intermediates", ":", "bool", "=", "True", ")", "->", "Iterator", "[", "str", "]", ":", "if", "self", ".", "is_new", ":",...
Find the list of new paths in this comparison. :param base: The base directory to prepend to the right entity's name. :param include_intermediates: Whether to include new non-empty directories in the returned iterable. If you o...
[ "Find", "the", "list", "of", "new", "paths", "in", "this", "comparison", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L61-L76
train
gebn/wood
wood/comparison.py
Comparison.modified
def modified(self, base: pathlib.PurePath = pathlib.PurePath()) \ -> Iterator[str]: """ Find the paths of modified files. There is no option to include intermediate directories, as all files and directories exist in both the left and right trees. :param base: The bas...
python
def modified(self, base: pathlib.PurePath = pathlib.PurePath()) \ -> Iterator[str]: """ Find the paths of modified files. There is no option to include intermediate directories, as all files and directories exist in both the left and right trees. :param base: The bas...
[ "def", "modified", "(", "self", ",", "base", ":", "pathlib", ".", "PurePath", "=", "pathlib", ".", "PurePath", "(", ")", ")", "->", "Iterator", "[", "str", "]", ":", "if", "self", ".", "is_modified", ":", "yield", "str", "(", "base", "/", "self", "...
Find the paths of modified files. There is no option to include intermediate directories, as all files and directories exist in both the left and right trees. :param base: The base directory to recursively append to the right entity. :return: An iterable of paths of...
[ "Find", "the", "paths", "of", "modified", "files", ".", "There", "is", "no", "option", "to", "include", "intermediate", "directories", "as", "all", "files", "and", "directories", "exist", "in", "both", "the", "left", "and", "right", "trees", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L91-L105
train
gebn/wood
wood/comparison.py
Comparison.deleted
def deleted(self, base: pathlib.PurePath = pathlib.PurePath(), include_children: bool = True, include_directories: bool = True) -> Iterator[str]: """ Find the paths of entities deleted between the left and right entities in this comparison. :param base: T...
python
def deleted(self, base: pathlib.PurePath = pathlib.PurePath(), include_children: bool = True, include_directories: bool = True) -> Iterator[str]: """ Find the paths of entities deleted between the left and right entities in this comparison. :param base: T...
[ "def", "deleted", "(", "self", ",", "base", ":", "pathlib", ".", "PurePath", "=", "pathlib", ".", "PurePath", "(", ")", ",", "include_children", ":", "bool", "=", "True", ",", "include_directories", ":", "bool", "=", "True", ")", "->", "Iterator", "[", ...
Find the paths of entities deleted between the left and right entities in this comparison. :param base: The base directory to recursively append to entities. :param include_children: Whether to recursively include children of deleted directories. These are thems...
[ "Find", "the", "paths", "of", "entities", "deleted", "between", "the", "left", "and", "right", "entities", "in", "this", "comparison", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L116-L133
train
gebn/wood
wood/comparison.py
Comparison.compare
def compare(left: Optional[L], right: Optional[R]) -> 'Comparison[L, R]': """ Calculate the comparison of two entities. | left | right | Return Type | |===========|===========|=========================| | file | file | FileComparison | ...
python
def compare(left: Optional[L], right: Optional[R]) -> 'Comparison[L, R]': """ Calculate the comparison of two entities. | left | right | Return Type | |===========|===========|=========================| | file | file | FileComparison | ...
[ "def", "compare", "(", "left", ":", "Optional", "[", "L", "]", ",", "right", ":", "Optional", "[", "R", "]", ")", "->", "'Comparison[L, R]'", ":", "if", "isinstance", "(", "left", ",", "File", ")", "and", "isinstance", "(", "right", ",", "Directory", ...
Calculate the comparison of two entities. | left | right | Return Type | |===========|===========|=========================| | file | file | FileComparison | | file | directory | FileDirectoryComparison | | file | None | Fil...
[ "Calculate", "the", "comparison", "of", "two", "entities", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L157-L189
train
gebn/wood
wood/comparison.py
Comparison.print_hierarchy
def print_hierarchy(self, level: int = 0, file: IO[str] = sys.stdout) \ -> None: """ Print this comparison and its children with indentation to represent nesting. :param level: The level of indentation to use. This is mostly for internal use, but you ca...
python
def print_hierarchy(self, level: int = 0, file: IO[str] = sys.stdout) \ -> None: """ Print this comparison and its children with indentation to represent nesting. :param level: The level of indentation to use. This is mostly for internal use, but you ca...
[ "def", "print_hierarchy", "(", "self", ",", "level", ":", "int", "=", "0", ",", "file", ":", "IO", "[", "str", "]", "=", "sys", ".", "stdout", ")", "->", "None", ":", "print", "(", "' '", "*", "self", ".", "_INDENT_SIZE", "*", "level", "+", "str"...
Print this comparison and its children with indentation to represent nesting. :param level: The level of indentation to use. This is mostly for internal use, but you can use it to inset the root comparison. :param file: The stream to print to. Default...
[ "Print", "this", "comparison", "and", "its", "children", "with", "indentation", "to", "represent", "nesting", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L191-L202
train
gebn/wood
wood/comparison.py
FileComparison.is_modified
def is_modified(self) -> bool: """ Find whether the files on the left and right are different. Note, modified implies the contents of the file have changed, which is predicated on the file existing on both the left and right. Therefore this will be false if the file on the left h...
python
def is_modified(self) -> bool: """ Find whether the files on the left and right are different. Note, modified implies the contents of the file have changed, which is predicated on the file existing on both the left and right. Therefore this will be false if the file on the left h...
[ "def", "is_modified", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "is_new", "or", "self", ".", "is_deleted", ":", "return", "False", "return", "self", ".", "left", ".", "md5", "!=", "self", ".", "right", ".", "md5" ]
Find whether the files on the left and right are different. Note, modified implies the contents of the file have changed, which is predicated on the file existing on both the left and right. Therefore this will be false if the file on the left has been deleted, or the file on the right i...
[ "Find", "whether", "the", "files", "on", "the", "left", "and", "right", "are", "different", ".", "Note", "modified", "implies", "the", "contents", "of", "the", "file", "have", "changed", "which", "is", "predicated", "on", "the", "file", "existing", "on", "...
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L224-L236
train
pgxcentre/geneparse
geneparse/index/impute2.py
generate_index
def generate_index(fn, cols=None, names=None, sep=" "): """Build a index for the given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field se...
python
def generate_index(fn, cols=None, names=None, sep=" "): """Build a index for the given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field se...
[ "def", "generate_index", "(", "fn", ",", "cols", "=", "None", ",", "names", "=", "None", ",", "sep", "=", "\" \"", ")", ":", "assert", "cols", "is", "not", "None", ",", "\"'cols' was not set\"", "assert", "names", "is", "not", "None", ",", "\"'names' was...
Build a index for the given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field separator. Returns: pandas.DataFrame: the index.
[ "Build", "a", "index", "for", "the", "given", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/impute2.py#L59-L92
train
pgxcentre/geneparse
geneparse/index/impute2.py
get_open_func
def get_open_func(fn, return_fmt=False): """Get the opening function. Args: fn (str): the name of the file. return_fmt (bool): if the file format needs to be returned. Returns: tuple: either a tuple containing two elements: a boolean telling if the format is bgzip, and the ...
python
def get_open_func(fn, return_fmt=False): """Get the opening function. Args: fn (str): the name of the file. return_fmt (bool): if the file format needs to be returned. Returns: tuple: either a tuple containing two elements: a boolean telling if the format is bgzip, and the ...
[ "def", "get_open_func", "(", "fn", ",", "return_fmt", "=", "False", ")", ":", "bgzip", "=", "None", "with", "open", "(", "fn", ",", "\"rb\"", ")", "as", "i_file", ":", "bgzip", "=", "i_file", ".", "read", "(", "3", ")", "==", "b\"\\x1f\\x8b\\x08\"", ...
Get the opening function. Args: fn (str): the name of the file. return_fmt (bool): if the file format needs to be returned. Returns: tuple: either a tuple containing two elements: a boolean telling if the format is bgzip, and the opening function.
[ "Get", "the", "opening", "function", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/impute2.py#L95-L133
train
pgxcentre/geneparse
geneparse/index/impute2.py
get_index
def get_index(fn, cols, names, sep): """Restores the index for a given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field separator. Re...
python
def get_index(fn, cols, names, sep): """Restores the index for a given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field separator. Re...
[ "def", "get_index", "(", "fn", ",", "cols", ",", "names", ",", "sep", ")", ":", "if", "not", "has_index", "(", "fn", ")", ":", "return", "generate_index", "(", "fn", ",", "cols", ",", "names", ",", "sep", ")", "file_index", "=", "read_index", "(", ...
Restores the index for a given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field separator. Returns: pandas.DataFrame: the index. ...
[ "Restores", "the", "index", "for", "a", "given", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/impute2.py#L136-L165
train
pgxcentre/geneparse
geneparse/index/impute2.py
write_index
def write_index(fn, index): """Writes the index to file. Args: fn (str): the name of the file that will contain the index. index (pandas.DataFrame): the index. """ with open(fn, "wb") as o_file: o_file.write(_CHECK_STRING) o_file.write(zlib.compress(bytes( i...
python
def write_index(fn, index): """Writes the index to file. Args: fn (str): the name of the file that will contain the index. index (pandas.DataFrame): the index. """ with open(fn, "wb") as o_file: o_file.write(_CHECK_STRING) o_file.write(zlib.compress(bytes( i...
[ "def", "write_index", "(", "fn", ",", "index", ")", ":", "with", "open", "(", "fn", ",", "\"wb\"", ")", "as", "o_file", ":", "o_file", ".", "write", "(", "_CHECK_STRING", ")", "o_file", ".", "write", "(", "zlib", ".", "compress", "(", "bytes", "(", ...
Writes the index to file. Args: fn (str): the name of the file that will contain the index. index (pandas.DataFrame): the index.
[ "Writes", "the", "index", "to", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/impute2.py#L168-L181
train
pgxcentre/geneparse
geneparse/index/impute2.py
read_index
def read_index(fn): """Reads index from file. Args: fn (str): the name of the file containing the index. Returns: pandas.DataFrame: the index of the file. Before reading the index, we check the first couple of bytes to see if it is a valid index file. """ index = None ...
python
def read_index(fn): """Reads index from file. Args: fn (str): the name of the file containing the index. Returns: pandas.DataFrame: the index of the file. Before reading the index, we check the first couple of bytes to see if it is a valid index file. """ index = None ...
[ "def", "read_index", "(", "fn", ")", ":", "index", "=", "None", "with", "open", "(", "fn", ",", "\"rb\"", ")", "as", "i_file", ":", "if", "i_file", ".", "read", "(", "len", "(", "_CHECK_STRING", ")", ")", "!=", "_CHECK_STRING", ":", "raise", "ValueEr...
Reads index from file. Args: fn (str): the name of the file containing the index. Returns: pandas.DataFrame: the index of the file. Before reading the index, we check the first couple of bytes to see if it is a valid index file.
[ "Reads", "index", "from", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/impute2.py#L184-L206
train
rhayes777/PyAutoFit
autofit/tools/pipeline.py
make_path
def make_path(phase) -> str: """ Create the path to the folder at which the metadata and optimizer pickle should be saved """ return "{}/{}{}{}".format(conf.instance.output_path, phase.phase_path, phase.phase_name, phase.phase_tag)
python
def make_path(phase) -> str: """ Create the path to the folder at which the metadata and optimizer pickle should be saved """ return "{}/{}{}{}".format(conf.instance.output_path, phase.phase_path, phase.phase_name, phase.phase_tag)
[ "def", "make_path", "(", "phase", ")", "->", "str", ":", "return", "\"{}/{}{}{}\"", ".", "format", "(", "conf", ".", "instance", ".", "output_path", ",", "phase", ".", "phase_path", ",", "phase", ".", "phase_name", ",", "phase", ".", "phase_tag", ")" ]
Create the path to the folder at which the metadata and optimizer pickle should be saved
[ "Create", "the", "path", "to", "the", "folder", "at", "which", "the", "metadata", "and", "optimizer", "pickle", "should", "be", "saved" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L177-L181
train
rhayes777/PyAutoFit
autofit/tools/pipeline.py
save_optimizer_for_phase
def save_optimizer_for_phase(phase): """ Save the optimizer associated with the phase as a pickle """ with open(make_optimizer_pickle_path(phase), "w+b") as f: f.write(pickle.dumps(phase.optimizer))
python
def save_optimizer_for_phase(phase): """ Save the optimizer associated with the phase as a pickle """ with open(make_optimizer_pickle_path(phase), "w+b") as f: f.write(pickle.dumps(phase.optimizer))
[ "def", "save_optimizer_for_phase", "(", "phase", ")", ":", "with", "open", "(", "make_optimizer_pickle_path", "(", "phase", ")", ",", "\"w+b\"", ")", "as", "f", ":", "f", ".", "write", "(", "pickle", ".", "dumps", "(", "phase", ".", "optimizer", ")", ")"...
Save the optimizer associated with the phase as a pickle
[ "Save", "the", "optimizer", "associated", "with", "the", "phase", "as", "a", "pickle" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L184-L189
train
rhayes777/PyAutoFit
autofit/tools/pipeline.py
assert_optimizer_pickle_matches_for_phase
def assert_optimizer_pickle_matches_for_phase(phase): """ Assert that the previously saved optimizer is equal to the phase's optimizer if a saved optimizer is found. Parameters ---------- phase The phase Raises ------- exc.PipelineException """ path = make_optimizer_pic...
python
def assert_optimizer_pickle_matches_for_phase(phase): """ Assert that the previously saved optimizer is equal to the phase's optimizer if a saved optimizer is found. Parameters ---------- phase The phase Raises ------- exc.PipelineException """ path = make_optimizer_pic...
[ "def", "assert_optimizer_pickle_matches_for_phase", "(", "phase", ")", ":", "path", "=", "make_optimizer_pickle_path", "(", "phase", ")", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "with", "open", "(", "path", ",", "\"r+b\"", ")", "as", ...
Assert that the previously saved optimizer is equal to the phase's optimizer if a saved optimizer is found. Parameters ---------- phase The phase Raises ------- exc.PipelineException
[ "Assert", "that", "the", "previously", "saved", "optimizer", "is", "equal", "to", "the", "phase", "s", "optimizer", "if", "a", "saved", "optimizer", "is", "found", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L192-L212
train
rhayes777/PyAutoFit
autofit/tools/pipeline.py
ResultsCollection.add
def add(self, phase_name, result): """ Add the result of a phase. Parameters ---------- phase_name: str The name of the phase result The result of that phase """ if phase_name in self.__result_dict: raise exc.PipelineEx...
python
def add(self, phase_name, result): """ Add the result of a phase. Parameters ---------- phase_name: str The name of the phase result The result of that phase """ if phase_name in self.__result_dict: raise exc.PipelineEx...
[ "def", "add", "(", "self", ",", "phase_name", ",", "result", ")", ":", "if", "phase_name", "in", "self", ".", "__result_dict", ":", "raise", "exc", ".", "PipelineException", "(", "\"Results from a phase called {} already exist in the pipeline\"", ".", "format", "(",...
Add the result of a phase. Parameters ---------- phase_name: str The name of the phase result The result of that phase
[ "Add", "the", "result", "of", "a", "phase", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L38-L53
train
rhayes777/PyAutoFit
autofit/tools/pipeline.py
ResultsCollection.from_phase
def from_phase(self, phase_name): """ Returns the result of a previous phase by its name Parameters ---------- phase_name: str The name of a previous phase Returns ------- result: Result The result of that phase Raises ...
python
def from_phase(self, phase_name): """ Returns the result of a previous phase by its name Parameters ---------- phase_name: str The name of a previous phase Returns ------- result: Result The result of that phase Raises ...
[ "def", "from_phase", "(", "self", ",", "phase_name", ")", ":", "try", ":", "return", "self", ".", "__result_dict", "[", "phase_name", "]", "except", "KeyError", ":", "raise", "exc", ".", "PipelineException", "(", "\"No previous phase named {} found in results ({})\"...
Returns the result of a previous phase by its name Parameters ---------- phase_name: str The name of a previous phase Returns ------- result: Result The result of that phase Raises ------ exc.PipelineException ...
[ "Returns", "the", "result", "of", "a", "previous", "phase", "by", "its", "name" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L74-L97
train
rhayes777/PyAutoFit
autofit/tools/pipeline.py
Pipeline.save_metadata
def save_metadata(self, phase, data_name): """ Save metadata associated with the phase, such as the name of the pipeline, the name of the phase and the name of the data being fit """ with open("{}/.metadata".format(make_path(phase)), "w+") as f: f.write("pipeline={}\n...
python
def save_metadata(self, phase, data_name): """ Save metadata associated with the phase, such as the name of the pipeline, the name of the phase and the name of the data being fit """ with open("{}/.metadata".format(make_path(phase)), "w+") as f: f.write("pipeline={}\n...
[ "def", "save_metadata", "(", "self", ",", "phase", ",", "data_name", ")", ":", "with", "open", "(", "\"{}/.metadata\"", ".", "format", "(", "make_path", "(", "phase", ")", ")", ",", "\"w+\"", ")", "as", "f", ":", "f", ".", "write", "(", "\"pipeline={}\...
Save metadata associated with the phase, such as the name of the pipeline, the name of the phase and the name of the data being fit
[ "Save", "metadata", "associated", "with", "the", "phase", "such", "as", "the", "name", "of", "the", "pipeline", "the", "name", "of", "the", "phase", "and", "the", "name", "of", "the", "data", "being", "fit" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L134-L141
train
rhayes777/PyAutoFit
autofit/tools/pipeline.py
Pipeline.run_function
def run_function(self, func, data_name=None, assert_optimizer_pickle_matches=True): """ Run the function for each phase in the pipeline. Parameters ---------- assert_optimizer_pickle_matches data_name func A function that takes a phase and prior resul...
python
def run_function(self, func, data_name=None, assert_optimizer_pickle_matches=True): """ Run the function for each phase in the pipeline. Parameters ---------- assert_optimizer_pickle_matches data_name func A function that takes a phase and prior resul...
[ "def", "run_function", "(", "self", ",", "func", ",", "data_name", "=", "None", ",", "assert_optimizer_pickle_matches", "=", "True", ")", ":", "results", "=", "ResultsCollection", "(", ")", "for", "i", ",", "phase", "in", "enumerate", "(", "self", ".", "ph...
Run the function for each phase in the pipeline. Parameters ---------- assert_optimizer_pickle_matches data_name func A function that takes a phase and prior results, returning results for that phase Returns ------- results: ResultsCollection...
[ "Run", "the", "function", "for", "each", "phase", "in", "the", "pipeline", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L143-L167
train
Riminder/python-riminder-api
riminder/bytesutils.py
strtobytes
def strtobytes(input, encoding): """Take a str and transform it into a byte array.""" py_version = sys.version_info[0] if py_version >= 3: return _strtobytes_py3(input, encoding) return _strtobytes_py2(input, encoding)
python
def strtobytes(input, encoding): """Take a str and transform it into a byte array.""" py_version = sys.version_info[0] if py_version >= 3: return _strtobytes_py3(input, encoding) return _strtobytes_py2(input, encoding)
[ "def", "strtobytes", "(", "input", ",", "encoding", ")", ":", "py_version", "=", "sys", ".", "version_info", "[", "0", "]", "if", "py_version", ">=", "3", ":", "return", "_strtobytes_py3", "(", "input", ",", "encoding", ")", "return", "_strtobytes_py2", "(...
Take a str and transform it into a byte array.
[ "Take", "a", "str", "and", "transform", "it", "into", "a", "byte", "array", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/bytesutils.py#L14-L19
train
pgxcentre/geneparse
geneparse/index/__main__.py
index_impute2
def index_impute2(fn): """Indexes an IMPUTE2 file. Args: fn (str): The name of the IMPUTE2 file. """ logger.info("Indexing {} (IMPUTE2)".format(fn)) impute2_index(fn, cols=[0, 1, 2], names=["chrom", "name", "pos"], sep=" ") logger.info("Index generated")
python
def index_impute2(fn): """Indexes an IMPUTE2 file. Args: fn (str): The name of the IMPUTE2 file. """ logger.info("Indexing {} (IMPUTE2)".format(fn)) impute2_index(fn, cols=[0, 1, 2], names=["chrom", "name", "pos"], sep=" ") logger.info("Index generated")
[ "def", "index_impute2", "(", "fn", ")", ":", "logger", ".", "info", "(", "\"Indexing {} (IMPUTE2)\"", ".", "format", "(", "fn", ")", ")", "impute2_index", "(", "fn", ",", "cols", "=", "[", "0", ",", "1", ",", "2", "]", ",", "names", "=", "[", "\"ch...
Indexes an IMPUTE2 file. Args: fn (str): The name of the IMPUTE2 file.
[ "Indexes", "an", "IMPUTE2", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/__main__.py#L60-L69
train
pgxcentre/geneparse
geneparse/index/__main__.py
index_bgen
def index_bgen(fn, legacy=False): """Indexes a BGEN file. Args: fn (str): The name of the BGEN file. """ logger.info("Indexing {} (BGEN) using 'bgenix'{}".format( fn, " (legacy mode)" if legacy else "", )) command = ["bgenix", "-g", fn, "-index"] if legacy: command....
python
def index_bgen(fn, legacy=False): """Indexes a BGEN file. Args: fn (str): The name of the BGEN file. """ logger.info("Indexing {} (BGEN) using 'bgenix'{}".format( fn, " (legacy mode)" if legacy else "", )) command = ["bgenix", "-g", fn, "-index"] if legacy: command....
[ "def", "index_bgen", "(", "fn", ",", "legacy", "=", "False", ")", ":", "logger", ".", "info", "(", "\"Indexing {} (BGEN) using 'bgenix'{}\"", ".", "format", "(", "fn", ",", "\" (legacy mode)\"", "if", "legacy", "else", "\"\"", ",", ")", ")", "command", "=", ...
Indexes a BGEN file. Args: fn (str): The name of the BGEN file.
[ "Indexes", "a", "BGEN", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/__main__.py#L72-L91
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
create_untl_xml_subelement
def create_untl_xml_subelement(parent, element, prefix=''): """Create a UNTL XML subelement.""" subelement = SubElement(parent, prefix + element.tag) if element.content is not None: subelement.text = element.content if element.qualifier is not None: subelement.attrib["qualifier"] = eleme...
python
def create_untl_xml_subelement(parent, element, prefix=''): """Create a UNTL XML subelement.""" subelement = SubElement(parent, prefix + element.tag) if element.content is not None: subelement.text = element.content if element.qualifier is not None: subelement.attrib["qualifier"] = eleme...
[ "def", "create_untl_xml_subelement", "(", "parent", ",", "element", ",", "prefix", "=", "''", ")", ":", "subelement", "=", "SubElement", "(", "parent", ",", "prefix", "+", "element", ".", "tag", ")", "if", "element", ".", "content", "is", "not", "None", ...
Create a UNTL XML subelement.
[ "Create", "a", "UNTL", "XML", "subelement", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L22-L35
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
add_missing_children
def add_missing_children(required_children, element_children): """Determine if there are elements not in the children that need to be included as blank elements in the form. """ element_tags = [element.tag for element in element_children] # Loop through the elements that should be in the form. f...
python
def add_missing_children(required_children, element_children): """Determine if there are elements not in the children that need to be included as blank elements in the form. """ element_tags = [element.tag for element in element_children] # Loop through the elements that should be in the form. f...
[ "def", "add_missing_children", "(", "required_children", ",", "element_children", ")", ":", "element_tags", "=", "[", "element", ".", "tag", "for", "element", "in", "element_children", "]", "for", "contained_element", "in", "required_children", ":", "if", "contained...
Determine if there are elements not in the children that need to be included as blank elements in the form.
[ "Determine", "if", "there", "are", "elements", "not", "in", "the", "children", "that", "need", "to", "be", "included", "as", "blank", "elements", "in", "the", "form", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L38-L53
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
UNTLElement.set_qualifier
def set_qualifier(self, value): """Set the qualifier for the element. Verifies the element is allowed to have a qualifier, and throws an exception if not. """ if self.allows_qualifier: self.qualifier = value.strip() else: raise UNTLStructureExcept...
python
def set_qualifier(self, value): """Set the qualifier for the element. Verifies the element is allowed to have a qualifier, and throws an exception if not. """ if self.allows_qualifier: self.qualifier = value.strip() else: raise UNTLStructureExcept...
[ "def", "set_qualifier", "(", "self", ",", "value", ")", ":", "if", "self", ".", "allows_qualifier", ":", "self", ".", "qualifier", "=", "value", ".", "strip", "(", ")", "else", ":", "raise", "UNTLStructureException", "(", "'Element \"%s\" does not allow a qualif...
Set the qualifier for the element. Verifies the element is allowed to have a qualifier, and throws an exception if not.
[ "Set", "the", "qualifier", "for", "the", "element", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L85-L96
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
UNTLElement.add_form
def add_form(self, **kwargs): """Add the form attribute to the UNTL Python object.""" vocabularies = kwargs.get('vocabularies', None) qualifier = kwargs.get('qualifier', None) content = kwargs.get('content', None) parent_tag = kwargs.get('parent_tag', None) superuser = kw...
python
def add_form(self, **kwargs): """Add the form attribute to the UNTL Python object.""" vocabularies = kwargs.get('vocabularies', None) qualifier = kwargs.get('qualifier', None) content = kwargs.get('content', None) parent_tag = kwargs.get('parent_tag', None) superuser = kw...
[ "def", "add_form", "(", "self", ",", "**", "kwargs", ")", ":", "vocabularies", "=", "kwargs", ".", "get", "(", "'vocabularies'", ",", "None", ")", "qualifier", "=", "kwargs", ".", "get", "(", "'qualifier'", ",", "None", ")", "content", "=", "kwargs", "...
Add the form attribute to the UNTL Python object.
[ "Add", "the", "form", "attribute", "to", "the", "UNTL", "Python", "object", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L127-L191
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
UNTLElement.record_content_length
def record_content_length(self): """Calculate length of record, excluding metadata.""" untldict = py2dict(self) untldict.pop('meta', None) return len(str(untldict))
python
def record_content_length(self): """Calculate length of record, excluding metadata.""" untldict = py2dict(self) untldict.pop('meta', None) return len(str(untldict))
[ "def", "record_content_length", "(", "self", ")", ":", "untldict", "=", "py2dict", "(", "self", ")", "untldict", ".", "pop", "(", "'meta'", ",", "None", ")", "return", "len", "(", "str", "(", "untldict", ")", ")" ]
Calculate length of record, excluding metadata.
[ "Calculate", "length", "of", "record", "excluding", "metadata", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L204-L208
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
FormGenerator.create_form_data
def create_form_data(self, **kwargs): """Create groupings of form elements.""" # Get the specified keyword arguments. children = kwargs.get('children', []) sort_order = kwargs.get('sort_order', None) solr_response = kwargs.get('solr_response', None) superuser = kwargs.get...
python
def create_form_data(self, **kwargs): """Create groupings of form elements.""" # Get the specified keyword arguments. children = kwargs.get('children', []) sort_order = kwargs.get('sort_order', None) solr_response = kwargs.get('solr_response', None) superuser = kwargs.get...
[ "def", "create_form_data", "(", "self", ",", "**", "kwargs", ")", ":", "children", "=", "kwargs", ".", "get", "(", "'children'", ",", "[", "]", ")", "sort_order", "=", "kwargs", ".", "get", "(", "'sort_order'", ",", "None", ")", "solr_response", "=", "...
Create groupings of form elements.
[ "Create", "groupings", "of", "form", "elements", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L216-L295
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
FormGenerator.create_form_groupings
def create_form_groupings(self, vocabularies, solr_response, element_group_dict, sort_order): """Create a group object from groupings of element objects.""" element_list = [] #...
python
def create_form_groupings(self, vocabularies, solr_response, element_group_dict, sort_order): """Create a group object from groupings of element objects.""" element_list = [] #...
[ "def", "create_form_groupings", "(", "self", ",", "vocabularies", ",", "solr_response", ",", "element_group_dict", ",", "sort_order", ")", ":", "element_list", "=", "[", "]", "for", "group_name", ",", "group_list", "in", "element_group_dict", ".", "items", "(", ...
Create a group object from groupings of element objects.
[ "Create", "a", "group", "object", "from", "groupings", "of", "element", "objects", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L297-L324
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
FormGenerator.get_vocabularies
def get_vocabularies(self): """Get the vocabularies to pull the qualifiers from.""" # Timeout in seconds. timeout = 15 socket.setdefaulttimeout(timeout) # Create the ordered vocabulary URL. vocab_url = VOCABULARIES_URL.replace('all', 'all-verbose') # Request the v...
python
def get_vocabularies(self): """Get the vocabularies to pull the qualifiers from.""" # Timeout in seconds. timeout = 15 socket.setdefaulttimeout(timeout) # Create the ordered vocabulary URL. vocab_url = VOCABULARIES_URL.replace('all', 'all-verbose') # Request the v...
[ "def", "get_vocabularies", "(", "self", ")", ":", "timeout", "=", "15", "socket", ".", "setdefaulttimeout", "(", "timeout", ")", "vocab_url", "=", "VOCABULARIES_URL", ".", "replace", "(", "'all'", ",", "'all-verbose'", ")", "try", ":", "vocab_dict", "=", "ev...
Get the vocabularies to pull the qualifiers from.
[ "Get", "the", "vocabularies", "to", "pull", "the", "qualifiers", "from", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L326-L338
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.create_xml_string
def create_xml_string(self): """Create a UNTL document in a string from a UNTL metadata root object. untl_xml_string = metadata_root_object.create_xml_string() """ root = self.create_xml() xml = '<?xml version="1.0" encoding="UTF-8"?>\n' + tostring( root, pr...
python
def create_xml_string(self): """Create a UNTL document in a string from a UNTL metadata root object. untl_xml_string = metadata_root_object.create_xml_string() """ root = self.create_xml() xml = '<?xml version="1.0" encoding="UTF-8"?>\n' + tostring( root, pr...
[ "def", "create_xml_string", "(", "self", ")", ":", "root", "=", "self", ".", "create_xml", "(", ")", "xml", "=", "'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n'", "+", "tostring", "(", "root", ",", "pretty_print", "=", "True", ")", "return", "xml" ]
Create a UNTL document in a string from a UNTL metadata root object. untl_xml_string = metadata_root_object.create_xml_string()
[ "Create", "a", "UNTL", "document", "in", "a", "string", "from", "a", "UNTL", "metadata", "root", "object", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L358-L369
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.create_xml
def create_xml(self, useNamespace=False): """Create an ElementTree representation of the object.""" UNTL_NAMESPACE = 'http://digital2.library.unt.edu/untl/' UNTL = '{%s}' % UNTL_NAMESPACE NSMAP = {'untl': UNTL_NAMESPACE} if useNamespace: root = Element(UNTL + self.t...
python
def create_xml(self, useNamespace=False): """Create an ElementTree representation of the object.""" UNTL_NAMESPACE = 'http://digital2.library.unt.edu/untl/' UNTL = '{%s}' % UNTL_NAMESPACE NSMAP = {'untl': UNTL_NAMESPACE} if useNamespace: root = Element(UNTL + self.t...
[ "def", "create_xml", "(", "self", ",", "useNamespace", "=", "False", ")", ":", "UNTL_NAMESPACE", "=", "'http://digital2.library.unt.edu/untl/'", "UNTL", "=", "'{%s}'", "%", "UNTL_NAMESPACE", "NSMAP", "=", "{", "'untl'", ":", "UNTL_NAMESPACE", "}", "if", "useNamesp...
Create an ElementTree representation of the object.
[ "Create", "an", "ElementTree", "representation", "of", "the", "object", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L371-L392
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.create_element_dict
def create_element_dict(self): """Convert a UNTL Python object into a UNTL Python dictionary.""" untl_dict = {} # Loop through all UNTL elements in the Python object. for element in self.children: # If an entry for the element list hasn't been made in the # dictio...
python
def create_element_dict(self): """Convert a UNTL Python object into a UNTL Python dictionary.""" untl_dict = {} # Loop through all UNTL elements in the Python object. for element in self.children: # If an entry for the element list hasn't been made in the # dictio...
[ "def", "create_element_dict", "(", "self", ")", ":", "untl_dict", "=", "{", "}", "for", "element", "in", "self", ".", "children", ":", "if", "element", ".", "tag", "not", "in", "untl_dict", ":", "untl_dict", "[", "element", ".", "tag", "]", "=", "[", ...
Convert a UNTL Python object into a UNTL Python dictionary.
[ "Convert", "a", "UNTL", "Python", "object", "into", "a", "UNTL", "Python", "dictionary", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L394-L423
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.create_xml_file
def create_xml_file(self, untl_filename): """Create a UNTL file. Writes file to supplied file path. """ try: f = open(untl_filename, 'w') f.write(self.create_xml_string().encode('utf-8')) f.close() except: raise UNTLStructureExcept...
python
def create_xml_file(self, untl_filename): """Create a UNTL file. Writes file to supplied file path. """ try: f = open(untl_filename, 'w') f.write(self.create_xml_string().encode('utf-8')) f.close() except: raise UNTLStructureExcept...
[ "def", "create_xml_file", "(", "self", ",", "untl_filename", ")", ":", "try", ":", "f", "=", "open", "(", "untl_filename", ",", "'w'", ")", "f", ".", "write", "(", "self", ".", "create_xml_string", "(", ")", ".", "encode", "(", "'utf-8'", ")", ")", "...
Create a UNTL file. Writes file to supplied file path.
[ "Create", "a", "UNTL", "file", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L425-L437
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.sort_untl
def sort_untl(self, sort_structure): """Sort the UNTL Python object by the index of a sort structure pre-ordered list. """ self.children.sort(key=lambda obj: sort_structure.index(obj.tag))
python
def sort_untl(self, sort_structure): """Sort the UNTL Python object by the index of a sort structure pre-ordered list. """ self.children.sort(key=lambda obj: sort_structure.index(obj.tag))
[ "def", "sort_untl", "(", "self", ",", "sort_structure", ")", ":", "self", ".", "children", ".", "sort", "(", "key", "=", "lambda", "obj", ":", "sort_structure", ".", "index", "(", "obj", ".", "tag", ")", ")" ]
Sort the UNTL Python object by the index of a sort structure pre-ordered list.
[ "Sort", "the", "UNTL", "Python", "object", "by", "the", "index", "of", "a", "sort", "structure", "pre", "-", "ordered", "list", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L439-L443
train
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.generate_form_data
def generate_form_data(self, **kwargs): """Create a form dictionary with the key being the element name and the value being a list of form element objects. """ # Add elements that are missing from the form. self.children = add_missing_children( self.contained_children...
python
def generate_form_data(self, **kwargs): """Create a form dictionary with the key being the element name and the value being a list of form element objects. """ # Add elements that are missing from the form. self.children = add_missing_children( self.contained_children...
[ "def", "generate_form_data", "(", "self", ",", "**", "kwargs", ")", ":", "self", ".", "children", "=", "add_missing_children", "(", "self", ".", "contained_children", ",", "self", ".", "children", ")", "kwargs", "[", "'children'", "]", "=", "self", ".", "c...
Create a form dictionary with the key being the element name and the value being a list of form element objects.
[ "Create", "a", "form", "dictionary", "with", "the", "key", "being", "the", "element", "name", "and", "the", "value", "being", "a", "list", "of", "form", "element", "objects", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L449-L461
train
unt-libraries/pyuntl
pyuntl/etd_ms_structure.py
contributor_director
def contributor_director(**kwargs): """Define the expanded qualifier name.""" if kwargs.get('qualifier') in ETD_MS_CONTRIBUTOR_EXPANSION: # Return the element object. return ETD_MSContributor( role=ETD_MS_CONTRIBUTOR_EXPANSION[kwargs.get('qualifier')], **kwargs ) ...
python
def contributor_director(**kwargs): """Define the expanded qualifier name.""" if kwargs.get('qualifier') in ETD_MS_CONTRIBUTOR_EXPANSION: # Return the element object. return ETD_MSContributor( role=ETD_MS_CONTRIBUTOR_EXPANSION[kwargs.get('qualifier')], **kwargs ) ...
[ "def", "contributor_director", "(", "**", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'qualifier'", ")", "in", "ETD_MS_CONTRIBUTOR_EXPANSION", ":", "return", "ETD_MSContributor", "(", "role", "=", "ETD_MS_CONTRIBUTOR_EXPANSION", "[", "kwargs", ".", "get"...
Define the expanded qualifier name.
[ "Define", "the", "expanded", "qualifier", "name", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/etd_ms_structure.py#L211-L220
train
unt-libraries/pyuntl
pyuntl/etd_ms_structure.py
date_director
def date_director(**kwargs): """Direct which class should be used based on the date qualifier or if the date should be converted at all. """ # If the date is a creation date, return the element object. if kwargs.get('qualifier') == 'creation': return ETD_MSDate(content=kwargs.get('content')....
python
def date_director(**kwargs): """Direct which class should be used based on the date qualifier or if the date should be converted at all. """ # If the date is a creation date, return the element object. if kwargs.get('qualifier') == 'creation': return ETD_MSDate(content=kwargs.get('content')....
[ "def", "date_director", "(", "**", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'qualifier'", ")", "==", "'creation'", ":", "return", "ETD_MSDate", "(", "content", "=", "kwargs", ".", "get", "(", "'content'", ")", ".", "strip", "(", ")", ")", ...
Direct which class should be used based on the date qualifier or if the date should be converted at all.
[ "Direct", "which", "class", "should", "be", "used", "based", "on", "the", "date", "qualifier", "or", "if", "the", "date", "should", "be", "converted", "at", "all", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/etd_ms_structure.py#L234-L245
train
unt-libraries/pyuntl
pyuntl/etd_ms_structure.py
subject_director
def subject_director(**kwargs): """Direct how to handle a subject element.""" if kwargs.get('qualifier') not in ['KWD', '']: return ETD_MSSubject(scheme=kwargs.get('qualifier'), **kwargs) else: return ETD_MSSubject(content=kwargs.get('content'))
python
def subject_director(**kwargs): """Direct how to handle a subject element.""" if kwargs.get('qualifier') not in ['KWD', '']: return ETD_MSSubject(scheme=kwargs.get('qualifier'), **kwargs) else: return ETD_MSSubject(content=kwargs.get('content'))
[ "def", "subject_director", "(", "**", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'qualifier'", ")", "not", "in", "[", "'KWD'", ",", "''", "]", ":", "return", "ETD_MSSubject", "(", "scheme", "=", "kwargs", ".", "get", "(", "'qualifier'", ")",...
Direct how to handle a subject element.
[ "Direct", "how", "to", "handle", "a", "subject", "element", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/etd_ms_structure.py#L262-L267
train
unt-libraries/pyuntl
pyuntl/etd_ms_structure.py
ETD_MSElement.get_child_content
def get_child_content(self, children, element_name): """Get the requested element content from a list of children.""" # Loop through the children and get the specified element. for child in children: # If the child is the requested element, return its content. if child.ta...
python
def get_child_content(self, children, element_name): """Get the requested element content from a list of children.""" # Loop through the children and get the specified element. for child in children: # If the child is the requested element, return its content. if child.ta...
[ "def", "get_child_content", "(", "self", ",", "children", ",", "element_name", ")", ":", "for", "child", "in", "children", ":", "if", "child", ".", "tag", "==", "element_name", ":", "return", "child", ".", "content", "return", "''" ]
Get the requested element content from a list of children.
[ "Get", "the", "requested", "element", "content", "from", "a", "list", "of", "children", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/etd_ms_structure.py#L69-L76
train
geophysics-ubonn/crtomo_tools
src/td_residuals.py
shiftedColorMap
def shiftedColorMap(cmap, start=0, midpoint=0.5, stop=1.0, name='shiftedcmap'): ''' Function to offset the "center" of a colormap. Useful for data with a negative min and positive max and you want the middle of the colormap's dynamic range to be at zero Parameters ---------- cmap: T...
python
def shiftedColorMap(cmap, start=0, midpoint=0.5, stop=1.0, name='shiftedcmap'): ''' Function to offset the "center" of a colormap. Useful for data with a negative min and positive max and you want the middle of the colormap's dynamic range to be at zero Parameters ---------- cmap: T...
[ "def", "shiftedColorMap", "(", "cmap", ",", "start", "=", "0", ",", "midpoint", "=", "0.5", ",", "stop", "=", "1.0", ",", "name", "=", "'shiftedcmap'", ")", ":", "cdict", "=", "{", "'red'", ":", "[", "]", ",", "'green'", ":", "[", "]", ",", "'blu...
Function to offset the "center" of a colormap. Useful for data with a negative min and positive max and you want the middle of the colormap's dynamic range to be at zero Parameters ---------- cmap: The matplotlib colormap to be altered start: Offset from lowest point in the colo...
[ "Function", "to", "offset", "the", "center", "of", "a", "colormap", ".", "Useful", "for", "data", "with", "a", "negative", "min", "and", "positive", "max", "and", "you", "want", "the", "middle", "of", "the", "colormap", "s", "dynamic", "range", "to", "be...
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_residuals.py#L10-L60
train
geophysics-ubonn/crtomo_tools
src/td_residuals.py
read_lastmodfile
def read_lastmodfile(directory): """ Return the number of the final inversion result. """ filename = '{0}/exe/inv.lastmod'.format(directory) # filename HAS to exist. Otherwise the inversion was not finished if(not os.path.isfile(filename)): return None linestring = open(filename, 'r...
python
def read_lastmodfile(directory): """ Return the number of the final inversion result. """ filename = '{0}/exe/inv.lastmod'.format(directory) # filename HAS to exist. Otherwise the inversion was not finished if(not os.path.isfile(filename)): return None linestring = open(filename, 'r...
[ "def", "read_lastmodfile", "(", "directory", ")", ":", "filename", "=", "'{0}/exe/inv.lastmod'", ".", "format", "(", "directory", ")", "if", "(", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ")", ":", "return", "None", "linestring", "=", ...
Return the number of the final inversion result.
[ "Return", "the", "number", "of", "the", "final", "inversion", "result", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_residuals.py#L63-L76
train
Riminder/python-riminder-api
riminder/webhook.py
Webhook.setHandler
def setHandler(self, event_name, callback): """Set an handler for given event.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) if callable(event_name): raise TypeError('{} is not callable'.format(callback)) sel...
python
def setHandler(self, event_name, callback): """Set an handler for given event.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) if callable(event_name): raise TypeError('{} is not callable'.format(callback)) sel...
[ "def", "setHandler", "(", "self", ",", "event_name", ",", "callback", ")", ":", "if", "event_name", "not", "in", "self", ".", "handlers", ":", "raise", "ValueError", "(", "'{} is not a valid event'", ".", "format", "(", "event_name", ")", ")", "if", "callabl...
Set an handler for given event.
[ "Set", "an", "handler", "for", "given", "event", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/webhook.py#L59-L65
train
Riminder/python-riminder-api
riminder/webhook.py
Webhook.isHandlerPresent
def isHandlerPresent(self, event_name): """Check if an event has an handler.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) return self.handlers[event_name] is not None
python
def isHandlerPresent(self, event_name): """Check if an event has an handler.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) return self.handlers[event_name] is not None
[ "def", "isHandlerPresent", "(", "self", ",", "event_name", ")", ":", "if", "event_name", "not", "in", "self", ".", "handlers", ":", "raise", "ValueError", "(", "'{} is not a valid event'", ".", "format", "(", "event_name", ")", ")", "return", "self", ".", "h...
Check if an event has an handler.
[ "Check", "if", "an", "event", "has", "an", "handler", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/webhook.py#L67-L71
train
Riminder/python-riminder-api
riminder/webhook.py
Webhook.removeHandler
def removeHandler(self, event_name): """Remove handler for given event.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) self.handlers[event_name] = None
python
def removeHandler(self, event_name): """Remove handler for given event.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) self.handlers[event_name] = None
[ "def", "removeHandler", "(", "self", ",", "event_name", ")", ":", "if", "event_name", "not", "in", "self", ".", "handlers", ":", "raise", "ValueError", "(", "'{} is not a valid event'", ".", "format", "(", "event_name", ")", ")", "self", ".", "handlers", "["...
Remove handler for given event.
[ "Remove", "handler", "for", "given", "event", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/webhook.py#L73-L77
train
Riminder/python-riminder-api
riminder/webhook.py
Webhook._get_fct_number_of_arg
def _get_fct_number_of_arg(self, fct): """Get the number of argument of a fuction.""" py_version = sys.version_info[0] if py_version >= 3: return len(inspect.signature(fct).parameters) return len(inspect.getargspec(fct)[0])
python
def _get_fct_number_of_arg(self, fct): """Get the number of argument of a fuction.""" py_version = sys.version_info[0] if py_version >= 3: return len(inspect.signature(fct).parameters) return len(inspect.getargspec(fct)[0])
[ "def", "_get_fct_number_of_arg", "(", "self", ",", "fct", ")", ":", "py_version", "=", "sys", ".", "version_info", "[", "0", "]", "if", "py_version", ">=", "3", ":", "return", "len", "(", "inspect", ".", "signature", "(", "fct", ")", ".", "parameters", ...
Get the number of argument of a fuction.
[ "Get", "the", "number", "of", "argument", "of", "a", "fuction", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/webhook.py#L95-L100
train
eventifyio/eventify
eventify/service.py
event_tracker
def event_tracker(func): """ Event tracking handler """ @wraps(func) async def wrapper(*args, **kwargs): """ Wraps function to provide redis tracking """ event = Event(args[0]) session = kwargs['session'] service_name = session.name awa...
python
def event_tracker(func): """ Event tracking handler """ @wraps(func) async def wrapper(*args, **kwargs): """ Wraps function to provide redis tracking """ event = Event(args[0]) session = kwargs['session'] service_name = session.name awa...
[ "def", "event_tracker", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "async", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "event", "=", "Event", "(", "args", "[", "0", "]", ")", "session", "=", "kwargs", "[", "'se...
Event tracking handler
[ "Event", "tracking", "handler" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/service.py#L19-L35
train
KnightConan/sspdatatables
src/sspdatatables/utils/decorator.py
ensure_ajax
def ensure_ajax(valid_request_methods, error_response_context=None): """ Intends to ensure the received the request is ajax request and it is included in the valid request methods :param valid_request_methods: list: list of valid request methods, such as 'GET', 'POST' :param error_response_co...
python
def ensure_ajax(valid_request_methods, error_response_context=None): """ Intends to ensure the received the request is ajax request and it is included in the valid request methods :param valid_request_methods: list: list of valid request methods, such as 'GET', 'POST' :param error_response_co...
[ "def", "ensure_ajax", "(", "valid_request_methods", ",", "error_response_context", "=", "None", ")", ":", "def", "real_decorator", "(", "view_func", ")", ":", "def", "wrap_func", "(", "request", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "not", ...
Intends to ensure the received the request is ajax request and it is included in the valid request methods :param valid_request_methods: list: list of valid request methods, such as 'GET', 'POST' :param error_response_context: None/dict: context dictionary to render, if error occurs :return...
[ "Intends", "to", "ensure", "the", "received", "the", "request", "is", "ajax", "request", "and", "it", "is", "included", "in", "the", "valid", "request", "methods" ]
1179a11358734e5e472e5eee703e8d34fa49e9bf
https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/utils/decorator.py#L8-L38
train
KnightConan/sspdatatables
src/sspdatatables/utils/decorator.py
generate_error_json_response
def generate_error_json_response(error_dict, error_response_context=None): """ Intends to build an error json response. If the error_response_context is None, then we generate this response using data tables format :param error_dict: str/dict: contains the error message(s) :param error_response_con...
python
def generate_error_json_response(error_dict, error_response_context=None): """ Intends to build an error json response. If the error_response_context is None, then we generate this response using data tables format :param error_dict: str/dict: contains the error message(s) :param error_response_con...
[ "def", "generate_error_json_response", "(", "error_dict", ",", "error_response_context", "=", "None", ")", ":", "response", "=", "error_dict", "if", "isinstance", "(", "error_dict", ",", "str", ")", ":", "response", "=", "{", "\"error\"", ":", "response", "}", ...
Intends to build an error json response. If the error_response_context is None, then we generate this response using data tables format :param error_dict: str/dict: contains the error message(s) :param error_response_context: None/dict: context dictionary to render, if error occurs :return: JsonR...
[ "Intends", "to", "build", "an", "error", "json", "response", ".", "If", "the", "error_response_context", "is", "None", "then", "we", "generate", "this", "response", "using", "data", "tables", "format" ]
1179a11358734e5e472e5eee703e8d34fa49e9bf
https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/utils/decorator.py#L41-L59
train
gofed/gofedlib
gofedlib/go/symbolsextractor/extractor.py
GoSymbolsExtractor._mergeGoSymbols
def _mergeGoSymbols(self, jsons = []): """ Exported symbols for a given package does not have any prefix. So I can drop all import paths that are file specific and merge all symbols. Assuming all files in the given package has mutual exclusive symbols. """ # <siXy> imports are per file, exports are per pa...
python
def _mergeGoSymbols(self, jsons = []): """ Exported symbols for a given package does not have any prefix. So I can drop all import paths that are file specific and merge all symbols. Assuming all files in the given package has mutual exclusive symbols. """ # <siXy> imports are per file, exports are per pa...
[ "def", "_mergeGoSymbols", "(", "self", ",", "jsons", "=", "[", "]", ")", ":", "symbols", "=", "{", "}", "symbols", "[", "\"types\"", "]", "=", "[", "]", "symbols", "[", "\"funcs\"", "]", "=", "[", "]", "symbols", "[", "\"vars\"", "]", "=", "[", "...
Exported symbols for a given package does not have any prefix. So I can drop all import paths that are file specific and merge all symbols. Assuming all files in the given package has mutual exclusive symbols.
[ "Exported", "symbols", "for", "a", "given", "package", "does", "not", "have", "any", "prefix", ".", "So", "I", "can", "drop", "all", "import", "paths", "that", "are", "file", "specific", "and", "merge", "all", "symbols", ".", "Assuming", "all", "files", ...
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/go/symbolsextractor/extractor.py#L203-L222
train
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/_winapi.py
MemoryMap.read
def read(self, n): """ Read n bytes from mapped view. """ out = ctypes.create_string_buffer(n) ctypes.windll.kernel32.RtlMoveMemory(out, self.view + self.pos, n) self.pos += n return out.raw
python
def read(self, n): """ Read n bytes from mapped view. """ out = ctypes.create_string_buffer(n) ctypes.windll.kernel32.RtlMoveMemory(out, self.view + self.pos, n) self.pos += n return out.raw
[ "def", "read", "(", "self", ",", "n", ")", ":", "out", "=", "ctypes", ".", "create_string_buffer", "(", "n", ")", "ctypes", ".", "windll", ".", "kernel32", ".", "RtlMoveMemory", "(", "out", ",", "self", ".", "view", "+", "self", ".", "pos", ",", "n...
Read n bytes from mapped view.
[ "Read", "n", "bytes", "from", "mapped", "view", "." ]
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/_winapi.py#L145-L152
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/transition_simulator.py
ActionSimulationCell._output
def _output(cls, fluents: Sequence[FluentPair]) -> Sequence[tf.Tensor]: '''Converts `fluents` to tensors with datatype tf.float32.''' output = [] for _, fluent in fluents: tensor = fluent.tensor if tensor.dtype != tf.float32: tensor = tf.cast(tensor, tf.fl...
python
def _output(cls, fluents: Sequence[FluentPair]) -> Sequence[tf.Tensor]: '''Converts `fluents` to tensors with datatype tf.float32.''' output = [] for _, fluent in fluents: tensor = fluent.tensor if tensor.dtype != tf.float32: tensor = tf.cast(tensor, tf.fl...
[ "def", "_output", "(", "cls", ",", "fluents", ":", "Sequence", "[", "FluentPair", "]", ")", "->", "Sequence", "[", "tf", ".", "Tensor", "]", ":", "output", "=", "[", "]", "for", "_", ",", "fluent", "in", "fluents", ":", "tensor", "=", "fluent", "."...
Converts `fluents` to tensors with datatype tf.float32.
[ "Converts", "fluents", "to", "tensors", "with", "datatype", "tf", ".", "float32", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/transition_simulator.py#L124-L132
train
255BITS/hyperchamber
hyperchamber/selector.py
Selector.set
def set(self, key, value): """Sets a hyperparameter. Can be used to set an array of hyperparameters.""" self.store[key]=value return self.store
python
def set(self, key, value): """Sets a hyperparameter. Can be used to set an array of hyperparameters.""" self.store[key]=value return self.store
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "store", "[", "key", "]", "=", "value", "return", "self", ".", "store" ]
Sets a hyperparameter. Can be used to set an array of hyperparameters.
[ "Sets", "a", "hyperparameter", ".", "Can", "be", "used", "to", "set", "an", "array", "of", "hyperparameters", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L29-L32
train
255BITS/hyperchamber
hyperchamber/selector.py
Selector.config_at
def config_at(self, i): """Gets the ith config""" selections = {} for key in self.store: value = self.store[key] if isinstance(value, list): selected = i % len(value) i = i // len(value) selections[key]= value[selected] else: sele...
python
def config_at(self, i): """Gets the ith config""" selections = {} for key in self.store: value = self.store[key] if isinstance(value, list): selected = i % len(value) i = i // len(value) selections[key]= value[selected] else: sele...
[ "def", "config_at", "(", "self", ",", "i", ")", ":", "selections", "=", "{", "}", "for", "key", "in", "self", ".", "store", ":", "value", "=", "self", ".", "store", "[", "key", "]", "if", "isinstance", "(", "value", ",", "list", ")", ":", "select...
Gets the ith config
[ "Gets", "the", "ith", "config" ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L77-L89
train
255BITS/hyperchamber
hyperchamber/selector.py
Selector.top
def top(self, sort_by): """Get the best results according to your custom sort method.""" sort = sorted(self.results, key=sort_by) return sort
python
def top(self, sort_by): """Get the best results according to your custom sort method.""" sort = sorted(self.results, key=sort_by) return sort
[ "def", "top", "(", "self", ",", "sort_by", ")", ":", "sort", "=", "sorted", "(", "self", ".", "results", ",", "key", "=", "sort_by", ")", "return", "sort" ]
Get the best results according to your custom sort method.
[ "Get", "the", "best", "results", "according", "to", "your", "custom", "sort", "method", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L101-L104
train
255BITS/hyperchamber
hyperchamber/selector.py
Selector.load_or_create_config
def load_or_create_config(self, filename, config=None): """Loads a config from disk. Defaults to a random config if none is specified""" os.makedirs(os.path.dirname(os.path.expanduser(filename)), exist_ok=True) if os.path.exists(filename): return self.load(filename) if(conf...
python
def load_or_create_config(self, filename, config=None): """Loads a config from disk. Defaults to a random config if none is specified""" os.makedirs(os.path.dirname(os.path.expanduser(filename)), exist_ok=True) if os.path.exists(filename): return self.load(filename) if(conf...
[ "def", "load_or_create_config", "(", "self", ",", "filename", ",", "config", "=", "None", ")", ":", "os", ".", "makedirs", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "expanduser", "(", "filename", ")", ")", ",", "exist_ok", ...
Loads a config from disk. Defaults to a random config if none is specified
[ "Loads", "a", "config", "from", "disk", ".", "Defaults", "to", "a", "random", "config", "if", "none", "is", "specified" ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L115-L125
train
redhat-openstack/python-tripleo-helper
tripleohelper/undercloud.py
Undercloud.configure
def configure(self, repositories): """Prepare the system to be ready for an undercloud installation. """ self.enable_repositories(repositories) self.create_stack_user() self.install_base_packages() self.clean_system() self.yum_update(allow_reboot=True) sel...
python
def configure(self, repositories): """Prepare the system to be ready for an undercloud installation. """ self.enable_repositories(repositories) self.create_stack_user() self.install_base_packages() self.clean_system() self.yum_update(allow_reboot=True) sel...
[ "def", "configure", "(", "self", ",", "repositories", ")", ":", "self", ".", "enable_repositories", "(", "repositories", ")", "self", ".", "create_stack_user", "(", ")", "self", ".", "install_base_packages", "(", ")", "self", ".", "clean_system", "(", ")", "...
Prepare the system to be ready for an undercloud installation.
[ "Prepare", "the", "system", "to", "be", "ready", "for", "an", "undercloud", "installation", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/undercloud.py#L32-L42
train
redhat-openstack/python-tripleo-helper
tripleohelper/undercloud.py
Undercloud.openstack_undercloud_install
def openstack_undercloud_install(self): """Deploy an undercloud on the host. """ instack_undercloud_ver, _ = self.run('repoquery --whatprovides /usr/share/instack-undercloud/puppet-stack-config/puppet-stack-config.pp') if instack_undercloud_ver.rstrip('\n') == 'instack-undercloud-0:2.2.0...
python
def openstack_undercloud_install(self): """Deploy an undercloud on the host. """ instack_undercloud_ver, _ = self.run('repoquery --whatprovides /usr/share/instack-undercloud/puppet-stack-config/puppet-stack-config.pp') if instack_undercloud_ver.rstrip('\n') == 'instack-undercloud-0:2.2.0...
[ "def", "openstack_undercloud_install", "(", "self", ")", ":", "instack_undercloud_ver", ",", "_", "=", "self", ".", "run", "(", "'repoquery --whatprovides /usr/share/instack-undercloud/puppet-stack-config/puppet-stack-config.pp'", ")", "if", "instack_undercloud_ver", ".", "rstr...
Deploy an undercloud on the host.
[ "Deploy", "an", "undercloud", "on", "the", "host", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/undercloud.py#L56-L70
train
redhat-openstack/python-tripleo-helper
tripleohelper/undercloud.py
Undercloud.create_flavor
def create_flavor(self, name): """Create a new baremetal flavor. :param name: the name of the flavor """ self.add_environment_file(user='stack', filename='stackrc') self.run('openstack flavor create --id auto --ram 4096 --disk 40 --vcpus 1 baremetal', user='stack', success_statu...
python
def create_flavor(self, name): """Create a new baremetal flavor. :param name: the name of the flavor """ self.add_environment_file(user='stack', filename='stackrc') self.run('openstack flavor create --id auto --ram 4096 --disk 40 --vcpus 1 baremetal', user='stack', success_statu...
[ "def", "create_flavor", "(", "self", ",", "name", ")", ":", "self", ".", "add_environment_file", "(", "user", "=", "'stack'", ",", "filename", "=", "'stackrc'", ")", "self", ".", "run", "(", "'openstack flavor create --id auto --ram 4096 --disk 40 --vcpus 1 baremetal'...
Create a new baremetal flavor. :param name: the name of the flavor
[ "Create", "a", "new", "baremetal", "flavor", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/undercloud.py#L188-L196
train
redhat-openstack/python-tripleo-helper
tripleohelper/undercloud.py
Undercloud.list_nodes
def list_nodes(self): """List the Ironic nodes UUID.""" self.add_environment_file(user='stack', filename='stackrc') ret, _ = self.run("ironic node-list --fields uuid|awk '/-.*-/ {print $2}'", user='stack') # NOTE(Gonéri): the good new is, the order of the nodes is preserved and follow th...
python
def list_nodes(self): """List the Ironic nodes UUID.""" self.add_environment_file(user='stack', filename='stackrc') ret, _ = self.run("ironic node-list --fields uuid|awk '/-.*-/ {print $2}'", user='stack') # NOTE(Gonéri): the good new is, the order of the nodes is preserved and follow th...
[ "def", "list_nodes", "(", "self", ")", ":", "self", ".", "add_environment_file", "(", "user", "=", "'stack'", ",", "filename", "=", "'stackrc'", ")", "ret", ",", "_", "=", "self", ".", "run", "(", "\"ironic node-list --fields uuid|awk '/-.*-/ {print $2}'\"", ","...
List the Ironic nodes UUID.
[ "List", "the", "Ironic", "nodes", "UUID", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/undercloud.py#L198-L204
train
redhat-openstack/python-tripleo-helper
tripleohelper/undercloud.py
Undercloud.set_flavor
def set_flavor(self, node, flavor): """Set a flavor to a given ironic node. :param uuid: the ironic node UUID :param flavor: the flavor name """ command = ( 'ironic node-update {uuid} add ' 'properties/capabilities=profile:{flavor},boot_option:local').for...
python
def set_flavor(self, node, flavor): """Set a flavor to a given ironic node. :param uuid: the ironic node UUID :param flavor: the flavor name """ command = ( 'ironic node-update {uuid} add ' 'properties/capabilities=profile:{flavor},boot_option:local').for...
[ "def", "set_flavor", "(", "self", ",", "node", ",", "flavor", ")", ":", "command", "=", "(", "'ironic node-update {uuid} add '", "'properties/capabilities=profile:{flavor},boot_option:local'", ")", ".", "format", "(", "uuid", "=", "node", ".", "uuid", ",", "flavor",...
Set a flavor to a given ironic node. :param uuid: the ironic node UUID :param flavor: the flavor name
[ "Set", "a", "flavor", "to", "a", "given", "ironic", "node", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/undercloud.py#L206-L219
train