Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
JMX._get_csv_config_random
(path, delimiter, loop, variable_names)
:type path: str :type delimiter: str :type loop: bool :type variable_names: string :return:
def _get_csv_config_random(path, delimiter, loop, variable_names): """ :type path: str :type delimiter: str :type loop: bool :type variable_names: string :return: """ element = etree.Element("com.blazemeter.jmeter.RandomCSVDataSetConfig", ...
[ "def", "_get_csv_config_random", "(", "path", ",", "delimiter", ",", "loop", ",", "variable_names", ")", ":", "element", "=", "etree", ".", "Element", "(", "\"com.blazemeter.jmeter.RandomCSVDataSetConfig\"", ",", "guiclass", "=", "\"com.blazemeter.jmeter.RandomCSVDataSetC...
[ 1259, 4 ]
[ 1281, 22 ]
python
en
['en', 'error', 'th']
False
JMX.set_enabled
(self, sel, state)
Toggle items by selector :type sel: str :type state: bool
Toggle items by selector
def set_enabled(self, sel, state): """ Toggle items by selector :type sel: str :type state: bool """ items = self.get(sel) self.log.debug("Enable %s elements %s: %s", state, sel, items) for item in items: item.set("enabled", 'true' if state el...
[ "def", "set_enabled", "(", "self", ",", "sel", ",", "state", ")", ":", "items", "=", "self", ".", "get", "(", "sel", ")", "self", ".", "log", ".", "debug", "(", "\"Enable %s elements %s: %s\"", ",", "state", ",", "sel", ",", "items", ")", "for", "ite...
[ 1283, 4 ]
[ 1293, 61 ]
python
en
['en', 'error', 'th']
False
JMX.set_text
(self, sel, text)
Set text value :type sel: str :type text: str
Set text value
def set_text(self, sel, text): """ Set text value :type sel: str :type text: str """ items = self.get(sel) res = 0 for item in items: item.text = str(text) res += 1 return res
[ "def", "set_text", "(", "self", ",", "sel", ",", "text", ")", ":", "items", "=", "self", ".", "get", "(", "sel", ")", "res", "=", "0", "for", "item", "in", "items", ":", "item", ".", "text", "=", "str", "(", "text", ")", "res", "+=", "1", "re...
[ 1295, 4 ]
[ 1308, 18 ]
python
en
['en', 'error', 'th']
False
JMX._get_once_controller
()
Generates Once Only Controller :return: etree element, OnceOnlyController
Generates Once Only Controller
def _get_once_controller(): """ Generates Once Only Controller :return: etree element, OnceOnlyController """ controller = etree.Element("OnceOnlyController", guiclass="OnceOnlyControllerGui", testclass="OnceOnlyController", testname="Once Only...
[ "def", "_get_once_controller", "(", ")", ":", "controller", "=", "etree", ".", "Element", "(", "\"OnceOnlyController\"", ",", "guiclass", "=", "\"OnceOnlyControllerGui\"", ",", "testclass", "=", "\"OnceOnlyController\"", ",", "testname", "=", "\"Once Only Controller\"",...
[ 1339, 4 ]
[ 1348, 25 ]
python
en
['en', 'error', 'th']
False
JMX._get_loop_controller
(loops)
Generates Loop Controller Expected values(by JMeter): LoopController.loops(iterations): int LoopController.continue_forever: boolean :return: etree element, LoopController
Generates Loop Controller
def _get_loop_controller(loops): """ Generates Loop Controller Expected values(by JMeter): LoopController.loops(iterations): int LoopController.continue_forever: boolean :return: etree element, LoopController """ if loops == 'forever': ...
[ "def", "_get_loop_controller", "(", "loops", ")", ":", "if", "loops", "==", "'forever'", ":", "iterations", "=", "-", "1", "else", ":", "iterations", "=", "loops", "controller", "=", "etree", ".", "Element", "(", "\"LoopController\"", ",", "guiclass", "=", ...
[ 1351, 4 ]
[ 1371, 25 ]
python
en
['en', 'error', 'th']
False
_get_dist
(metadata_directory)
Return a pkg_resources.Distribution for the provided metadata directory.
Return a pkg_resources.Distribution for the provided metadata directory.
def _get_dist(metadata_directory): # type: (str) -> Distribution """Return a pkg_resources.Distribution for the provided metadata directory. """ dist_dir = metadata_directory.rstrip(os.sep) # Build a PathMetadata object, from path to metadata. :wink: base_dir, dist_dir_name = os.path.split(...
[ "def", "_get_dist", "(", "metadata_directory", ")", ":", "# type: (str) -> Distribution", "dist_dir", "=", "metadata_directory", ".", "rstrip", "(", "os", ".", "sep", ")", "# Build a PathMetadata object, from path to metadata. :wink:", "base_dir", ",", "dist_dir_name", "=",...
[ 69, 0 ]
[ 93, 5 ]
python
en
['en', 'en', 'en']
True
InstallRequirement.format_debug
(self)
An un-tested helper for getting state, for debugging.
An un-tested helper for getting state, for debugging.
def format_debug(self): # type: () -> str """An un-tested helper for getting state, for debugging. """ attributes = vars(self) names = sorted(attributes) state = ( "{}={!r}".format(attr, attributes[attr]) for attr in sorted(names) ) return '<{...
[ "def", "format_debug", "(", "self", ")", ":", "# type: () -> str", "attributes", "=", "vars", "(", "self", ")", "names", "=", "sorted", "(", "attributes", ")", "state", "=", "(", "\"{}={!r}\"", ".", "format", "(", "attr", ",", "attributes", "[", "attr", ...
[ 238, 4 ]
[ 251, 9 ]
python
en
['da', 'en', 'en']
True
InstallRequirement.is_pinned
(self)
Return whether I am pinned to an exact version. For example, some-package==1.2 is pinned; some-package>1.2 is not.
Return whether I am pinned to an exact version.
def is_pinned(self): # type: () -> bool """Return whether I am pinned to an exact version. For example, some-package==1.2 is pinned; some-package>1.2 is not. """ specifiers = self.specifier return (len(specifiers) == 1 and next(iter(specifiers)).operator ...
[ "def", "is_pinned", "(", "self", ")", ":", "# type: () -> bool", "specifiers", "=", "self", ".", "specifier", "return", "(", "len", "(", "specifiers", ")", "==", "1", "and", "next", "(", "iter", "(", "specifiers", ")", ")", ".", "operator", "in", "{", ...
[ 267, 4 ]
[ 275, 65 ]
python
en
['en', 'en', 'en']
True
InstallRequirement.has_hash_options
(self)
Return whether any known-good hashes are specified as options. These activate --require-hashes mode; hashes specified as part of a URL do not.
Return whether any known-good hashes are specified as options.
def has_hash_options(self): # type: () -> bool """Return whether any known-good hashes are specified as options. These activate --require-hashes mode; hashes specified as part of a URL do not. """ return bool(self.hash_options)
[ "def", "has_hash_options", "(", "self", ")", ":", "# type: () -> bool", "return", "bool", "(", "self", ".", "hash_options", ")" ]
[ 296, 4 ]
[ 304, 38 ]
python
en
['en', 'en', 'en']
True
InstallRequirement.hashes
(self, trust_internet=True)
Return a hash-comparer that considers my option- and URL-based hashes to be known-good. Hashes in URLs--ones embedded in the requirements file, not ones downloaded from an index server--are almost peers with ones from flags. They satisfy --require-hashes (whether it was implicitly or ...
Return a hash-comparer that considers my option- and URL-based hashes to be known-good.
def hashes(self, trust_internet=True): # type: (bool) -> Hashes """Return a hash-comparer that considers my option- and URL-based hashes to be known-good. Hashes in URLs--ones embedded in the requirements file, not ones downloaded from an index server--are almost peers with ones...
[ "def", "hashes", "(", "self", ",", "trust_internet", "=", "True", ")", ":", "# type: (bool) -> Hashes", "good_hashes", "=", "self", ".", "hash_options", ".", "copy", "(", ")", "link", "=", "self", ".", "link", "if", "trust_internet", "else", "self", ".", "...
[ 306, 4 ]
[ 326, 34 ]
python
en
['en', 'en', 'en']
True
InstallRequirement.from_path
(self)
Format a nice indicator to show where this "comes from"
Format a nice indicator to show where this "comes from"
def from_path(self): # type: () -> Optional[str] """Format a nice indicator to show where this "comes from" """ if self.req is None: return None s = str(self.req) if self.comes_from: if isinstance(self.comes_from, six.string_types): ...
[ "def", "from_path", "(", "self", ")", ":", "# type: () -> Optional[str]", "if", "self", ".", "req", "is", "None", ":", "return", "None", "s", "=", "str", "(", "self", ".", "req", ")", "if", "self", ".", "comes_from", ":", "if", "isinstance", "(", "self...
[ 328, 4 ]
[ 342, 16 ]
python
en
['en', 'en', 'en']
True
InstallRequirement._set_requirement
(self)
Set requirement after generating metadata.
Set requirement after generating metadata.
def _set_requirement(self): # type: () -> None """Set requirement after generating metadata. """ assert self.req is None assert self.metadata is not None assert self.source_dir is not None # Construct a Requirement object from the generated metadata if is...
[ "def", "_set_requirement", "(", "self", ")", ":", "# type: () -> None", "assert", "self", ".", "req", "is", "None", "assert", "self", ".", "metadata", "is", "not", "None", "assert", "self", ".", "source_dir", "is", "not", "None", "# Construct a Requirement objec...
[ 386, 4 ]
[ 406, 9 ]
python
en
['da', 'en', 'en']
True
InstallRequirement.check_if_exists
(self, use_user_site)
Find an installed distribution that satisfies or conflicts with this requirement, and set self.satisfied_by or self.should_reinstall appropriately.
Find an installed distribution that satisfies or conflicts with this requirement, and set self.satisfied_by or self.should_reinstall appropriately.
def check_if_exists(self, use_user_site): # type: (bool) -> None """Find an installed distribution that satisfies or conflicts with this requirement, and set self.satisfied_by or self.should_reinstall appropriately. """ if self.req is None: return exis...
[ "def", "check_if_exists", "(", "self", ",", "use_user_site", ")", ":", "# type: (bool) -> None", "if", "self", ".", "req", "is", "None", ":", "return", "existing_dist", "=", "get_distribution", "(", "self", ".", "req", ".", "name", ")", "if", "not", "existin...
[ 424, 4 ]
[ 458, 49 ]
python
en
['en', 'en', 'en']
True
InstallRequirement.load_pyproject_toml
(self)
Load the pyproject.toml file. After calling this routine, all of the attributes related to PEP 517 processing for this requirement have been set. In particular, the use_pep517 attribute can be used to determine whether we should follow the PEP 517 or legacy (setup.py) code path. ...
Load the pyproject.toml file.
def load_pyproject_toml(self): # type: () -> None """Load the pyproject.toml file. After calling this routine, all of the attributes related to PEP 517 processing for this requirement have been set. In particular, the use_pep517 attribute can be used to determine whether we shou...
[ "def", "load_pyproject_toml", "(", "self", ")", ":", "# type: () -> None", "pyproject_toml_data", "=", "load_pyproject_toml", "(", "self", ".", "use_pep517", ",", "self", ".", "pyproject_toml_path", ",", "self", ".", "setup_py_path", ",", "str", "(", "self", ")", ...
[ 494, 4 ]
[ 520, 9 ]
python
en
['en', 'en', 'en']
True
InstallRequirement._generate_metadata
(self)
Invokes metadata generator functions, with the required arguments.
Invokes metadata generator functions, with the required arguments.
def _generate_metadata(self): # type: () -> str """Invokes metadata generator functions, with the required arguments. """ if not self.use_pep517: assert self.unpacked_source_directory return generate_metadata_legacy( build_env=self.build_env, ...
[ "def", "_generate_metadata", "(", "self", ")", ":", "# type: () -> str", "if", "not", "self", ".", "use_pep517", ":", "assert", "self", ".", "unpacked_source_directory", "return", "generate_metadata_legacy", "(", "build_env", "=", "self", ".", "build_env", ",", "s...
[ 522, 4 ]
[ 542, 9 ]
python
en
['en', 'en', 'en']
True
InstallRequirement.prepare_metadata
(self)
Ensure that project metadata is available. Under PEP 517, call the backend hook to prepare the metadata. Under legacy processing, call setup.py egg-info.
Ensure that project metadata is available.
def prepare_metadata(self): # type: () -> None """Ensure that project metadata is available. Under PEP 517, call the backend hook to prepare the metadata. Under legacy processing, call setup.py egg-info. """ assert self.source_dir with indent_log(): ...
[ "def", "prepare_metadata", "(", "self", ")", ":", "# type: () -> None", "assert", "self", ".", "source_dir", "with", "indent_log", "(", ")", ":", "self", ".", "metadata_directory", "=", "self", ".", "_generate_metadata", "(", ")", "# Act on the newly generated metad...
[ 544, 4 ]
[ 562, 44 ]
python
en
['en', 'en', 'en']
True
InstallRequirement.ensure_has_source_dir
( self, parent_dir, autodelete=False, parallel_builds=False, )
Ensure that a source_dir is set. This will create a temporary build dir if the name of the requirement isn't known yet. :param parent_dir: The ideal pip parent_dir for the source_dir. Generally src_dir for editables and build_dir for sdists. :return: self.source_dir ...
Ensure that a source_dir is set.
def ensure_has_source_dir( self, parent_dir, autodelete=False, parallel_builds=False, ): # type: (str, bool, bool) -> None """Ensure that a source_dir is set. This will create a temporary build dir if the name of the requirement isn't known yet. ...
[ "def", "ensure_has_source_dir", "(", "self", ",", "parent_dir", ",", "autodelete", "=", "False", ",", "parallel_builds", "=", "False", ",", ")", ":", "# type: (str, bool, bool) -> None", "if", "self", ".", "source_dir", "is", "None", ":", "self", ".", "source_di...
[ 595, 4 ]
[ 616, 13 ]
python
en
['en', 'fr', 'en']
True
InstallRequirement.uninstall
(self, auto_confirm=False, verbose=False)
Uninstall the distribution currently satisfying this requirement. Prompts before removing or modifying files unless ``auto_confirm`` is True. Refuses to delete or modify files outside of ``sys.prefix`` - thus uninstallation within a virtual environment can only modify ...
Uninstall the distribution currently satisfying this requirement.
def uninstall(self, auto_confirm=False, verbose=False): # type: (bool, bool) -> Optional[UninstallPathSet] """ Uninstall the distribution currently satisfying this requirement. Prompts before removing or modifying files unless ``auto_confirm`` is True. Refuses to delete...
[ "def", "uninstall", "(", "self", ",", "auto_confirm", "=", "False", ",", "verbose", "=", "False", ")", ":", "# type: (bool, bool) -> Optional[UninstallPathSet]", "assert", "self", ".", "req", "dist", "=", "get_distribution", "(", "self", ".", "req", ".", "name",...
[ 663, 4 ]
[ 686, 34 ]
python
en
['en', 'error', 'th']
False
InstallRequirement.archive
(self, build_dir)
Saves archive to provided build_dir. Used for saving downloaded VCS requirements as part of `pip download`.
Saves archive to provided build_dir.
def archive(self, build_dir): # type: (Optional[str]) -> None """Saves archive to provided build_dir. Used for saving downloaded VCS requirements as part of `pip download`. """ assert self.source_dir if build_dir is None: return create_archive = True...
[ "def", "archive", "(", "self", ",", "build_dir", ")", ":", "# type: (Optional[str]) -> None", "assert", "self", ".", "source_dir", "if", "build_dir", "is", "None", ":", "return", "create_archive", "=", "True", "archive_name", "=", "'{}-{}.zip'", ".", "format", "...
[ 705, 4 ]
[ 766, 59 ]
python
en
['en', 'en', 'en']
True
random_result
(*kwargs)
Random objective.
Random objective.
def random_result(*kwargs): """Random objective.""" return round(random.random(),3) * 100
[ "def", "random_result", "(", "*", "kwargs", ")", ":", "return", "round", "(", "random", ".", "random", "(", ")", ",", "3", ")", "*", "100" ]
[ 19, 0 ]
[ 22, 41 ]
python
en
['en', 'mg', 'en']
False
ForeignObjectRel.target_field
(self)
When filtering against this relation, returns the field on the remote model against which the filtering should happen.
When filtering against this relation, returns the field on the remote model against which the filtering should happen.
def target_field(self): """ When filtering against this relation, returns the field on the remote model against which the filtering should happen. """ target_fields = self.get_path_info()[-1].target_fields if len(target_fields) > 1: raise exceptions.FieldError...
[ "def", "target_field", "(", "self", ")", ":", "target_fields", "=", "self", ".", "get_path_info", "(", ")", "[", "-", "1", "]", ".", "target_fields", "if", "len", "(", "target_fields", ")", ">", "1", ":", "raise", "exceptions", ".", "FieldError", "(", ...
[ 79, 4 ]
[ 87, 31 ]
python
en
['en', 'error', 'th']
False
ForeignObjectRel.get_choices
(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH)
Return choices with a default blank choices included, for use as SelectField choices for this field. Analog of django.db.models.fields.Field.get_choices(), provided initially for utilization by RelatedFieldListFilter.
Return choices with a default blank choices included, for use as SelectField choices for this field.
def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH): """ Return choices with a default blank choices included, for use as SelectField choices for this field. Analog of django.db.models.fields.Field.get_choices(), provided initially for utilization by Relate...
[ "def", "get_choices", "(", "self", ",", "include_blank", "=", "True", ",", "blank_choice", "=", "BLANK_CHOICE_DASH", ")", ":", "return", "(", "blank_choice", "if", "include_blank", "else", "[", "]", ")", "+", "[", "(", "x", ".", "_get_pk_val", "(", ")", ...
[ 129, 4 ]
[ 139, 9 ]
python
en
['en', 'error', 'th']
False
ForeignObjectRel.is_hidden
(self)
Should the related object be hidden?
Should the related object be hidden?
def is_hidden(self): "Should the related object be hidden?" return bool(self.related_name) and self.related_name[-1] == '+'
[ "def", "is_hidden", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "related_name", ")", "and", "self", ".", "related_name", "[", "-", "1", "]", "==", "'+'" ]
[ 141, 4 ]
[ 143, 71 ]
python
en
['en', 'en', 'en']
True
ForeignObjectRel.set_field_name
(self)
Set the related field's name, this is not available until later stages of app loading, so set_field_name is called from set_attributes_from_rel()
Set the related field's name, this is not available until later stages of app loading, so set_field_name is called from set_attributes_from_rel()
def set_field_name(self): """ Set the related field's name, this is not available until later stages of app loading, so set_field_name is called from set_attributes_from_rel() """ # By default foreign object doesn't relate to any remote field (for # example custom...
[ "def", "set_field_name", "(", "self", ")", ":", "# By default foreign object doesn't relate to any remote field (for", "# example custom multicolumn joins currently have no remote field).", "self", ".", "field_name", "=", "None" ]
[ 151, 4 ]
[ 159, 30 ]
python
en
['en', 'error', 'th']
False
ManyToOneRel.get_related_field
(self)
Return the Field in the 'to' object to which this relationship is tied.
Return the Field in the 'to' object to which this relationship is tied.
def get_related_field(self): """ Return the Field in the 'to' object to which this relationship is tied. """ field = self.model._meta.get_field(self.field_name) if not field.concrete: raise exceptions.FieldDoesNotExist("No related field named '%s'" % self.field_name) ...
[ "def", "get_related_field", "(", "self", ")", ":", "field", "=", "self", ".", "model", ".", "_meta", ".", "get_field", "(", "self", ".", "field_name", ")", "if", "not", "field", ".", "concrete", ":", "raise", "exceptions", ".", "FieldDoesNotExist", "(", ...
[ 218, 4 ]
[ 225, 20 ]
python
en
['en', 'error', 'th']
False
ManyToManyRel.get_related_field
(self)
Return the field in the 'to' object to which this relationship is tied. Provided for symmetry with ManyToOneRel.
Return the field in the 'to' object to which this relationship is tied. Provided for symmetry with ManyToOneRel.
def get_related_field(self): """ Return the field in the 'to' object to which this relationship is tied. Provided for symmetry with ManyToOneRel. """ opts = self.through._meta if self.through_fields: field = opts.get_field(self.through_fields[0]) else:...
[ "def", "get_related_field", "(", "self", ")", ":", "opts", "=", "self", ".", "through", ".", "_meta", "if", "self", ".", "through_fields", ":", "field", "=", "opts", ".", "get_field", "(", "self", ".", "through_fields", "[", "0", "]", ")", "else", ":",...
[ 282, 4 ]
[ 295, 46 ]
python
en
['en', 'error', 'th']
False
ArmaJump.pdf
(self, X, Y)
Conditional probability density function p(y|x) of the underlying probability model Args: X: x to be conditioned on - numpy array of shape (n_points, ndim_x) Y: y target values for witch the pdf shall be evaluated - numpy array of shape (n_points, ndim_y) Returns: p(X|Y) conditional density...
Conditional probability density function p(y|x) of the underlying probability model
def pdf(self, X, Y): """ Conditional probability density function p(y|x) of the underlying probability model Args: X: x to be conditioned on - numpy array of shape (n_points, ndim_x) Y: y target values for witch the pdf shall be evaluated - numpy array of shape (n_points, ndim_y) Returns: ...
[ "def", "pdf", "(", "self", ",", "X", ",", "Y", ")", ":", "X", ",", "Y", "=", "self", ".", "_handle_input_dimensionality", "(", "X", ",", "Y", ")", "mean", "=", "self", ".", "arma_c", "*", "(", "1", "-", "self", ".", "arma_a1", ")", "+", "self",...
[ 42, 2 ]
[ 55, 99 ]
python
en
['en', 'en', 'en']
True
ArmaJump.cdf
(self, X, Y)
Conditional cumulated probability density function P(Y < y | x) of the underlying probability model Args: X: x to be conditioned on - numpy array of shape (n_points, ndim_x) Y: y target values for witch the cdf shall be evaluated - numpy array of shape (n_points, ndim_y) Returns: ...
Conditional cumulated probability density function P(Y < y | x) of the underlying probability model
def cdf(self, X, Y): """ Conditional cumulated probability density function P(Y < y | x) of the underlying probability model Args: X: x to be conditioned on - numpy array of shape (n_points, ndim_x) Y: y target values for witch the cdf shall be evaluated - numpy array of shape (n_points...
[ "def", "cdf", "(", "self", ",", "X", ",", "Y", ")", ":", "X", ",", "Y", "=", "self", ".", "_handle_input_dimensionality", "(", "X", ",", "Y", ")", "mean", "=", "self", ".", "arma_c", "*", "(", "1", "-", "self", ".", "arma_a1", ")", "+", "self",...
[ 57, 2 ]
[ 70, 99 ]
python
en
['en', 'en', 'en']
True
ArmaJump.simulate_conditional
(self, X)
Draws random samples from the conditional distribution Args: X: x to be conditioned on when drawing a sample from y ~ p(y|x) - numpy array of shape (n_samples, ndim_x) Returns: Conditional random samples y drawn from p(y|x) - numpy array of shape (n_samples, ndim_y)
Draws random samples from the conditional distribution
def simulate_conditional(self, X): """ Draws random samples from the conditional distribution Args: X: x to be conditioned on when drawing a sample from y ~ p(y|x) - numpy array of shape (n_samples, ndim_x) Returns: Conditional random samples y drawn from p(y|x) - numpy array of shape (n_sampl...
[ "def", "simulate_conditional", "(", "self", ",", "X", ")", ":", "mean", "=", "self", ".", "arma_c", "*", "(", "1", "-", "self", ".", "arma_a1", ")", "+", "self", ".", "arma_a1", "*", "X", "y_ar", "=", "self", ".", "random_state", ".", "normal", "("...
[ 72, 2 ]
[ 89, 89 ]
python
en
['en', 'en', 'en']
True
ArmaJump.simulate
(self, x_0=0, n_samples=1000, burn_in=100)
Draws random samples from the unconditional distribution p(x,y) Args: n_samples: (int) number of samples to be drawn from the conditional distribution Returns: (X,Y) - random samples drawn from p(x,y) - numpy arrays of shape (n_samples, ndim_x) and (n_samples, ndim_y)
Draws random samples from the unconditional distribution p(x,y)
def simulate(self, x_0=0, n_samples=1000, burn_in=100): """ Draws random samples from the unconditional distribution p(x,y) Args: n_samples: (int) number of samples to be drawn from the conditional distribution Returns: (X,Y) - random samples drawn from p(x,y) - numpy arrays of sha...
[ "def", "simulate", "(", "self", ",", "x_0", "=", "0", ",", "n_samples", "=", "1000", ",", "burn_in", "=", "100", ")", ":", "self", ".", "eps", "=", "self", ".", "random_state", ".", "normal", "(", "scale", "=", "self", ".", "std", ",", "size", "=...
[ 91, 2 ]
[ 111, 79 ]
python
en
['en', 'en', 'en']
True
ArmaJump.mean_
(self, x_cond, n_samples=None)
Conditional mean of the distribution Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y)
Conditional mean of the distribution Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
def mean_(self, x_cond, n_samples=None): """ Conditional mean of the distribution Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y) """ means = np.zeros((x_c...
[ "def", "mean_", "(", "self", ",", "x_cond", ",", "n_samples", "=", "None", ")", ":", "means", "=", "np", ".", "zeros", "(", "(", "x_cond", ".", "shape", "[", "0", "]", ",", "self", ".", "ndim_y", ")", ")", "for", "i", "in", "range", "(", "x_con...
[ 113, 2 ]
[ 126, 16 ]
python
en
['en', 'en', 'en']
True
ArmaJump.covariance
(self, x_cond, n_samples=None)
Covariance of the distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Covariances Cov[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y, ndim_y)
Covariance of the distribution conditioned on x_cond
def covariance(self, x_cond, n_samples=None): """ Covariance of the distribution conditioned on x_cond Args: x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) Returns: Covariances Cov[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim...
[ "def", "covariance", "(", "self", ",", "x_cond", ",", "n_samples", "=", "None", ")", ":", "covs", "=", "np", ".", "zeros", "(", "(", "x_cond", ".", "shape", "[", "0", "]", ",", "self", ".", "ndim_y", ",", "self", ".", "ndim_y", ")", ")", "for", ...
[ 128, 2 ]
[ 147, 15 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__init__
(self, ptr, z=False)
Initializes from a GEOS pointer.
Initializes from a GEOS pointer.
def __init__(self, ptr, z=False): "Initializes from a GEOS pointer." if not isinstance(ptr, CS_PTR): raise TypeError('Coordinate sequence should initialize with a CS_PTR.') self._ptr = ptr self._z = z
[ "def", "__init__", "(", "self", ",", "ptr", ",", "z", "=", "False", ")", ":", "if", "not", "isinstance", "(", "ptr", ",", "CS_PTR", ")", ":", "raise", "TypeError", "(", "'Coordinate sequence should initialize with a CS_PTR.'", ")", "self", ".", "_ptr", "=", ...
[ 20, 4 ]
[ 25, 19 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__iter__
(self)
Iterates over each point in the coordinate sequence.
Iterates over each point in the coordinate sequence.
def __iter__(self): "Iterates over each point in the coordinate sequence." for i in range(self.size): yield self[i]
[ "def", "__iter__", "(", "self", ")", ":", "for", "i", "in", "range", "(", "self", ".", "size", ")", ":", "yield", "self", "[", "i", "]" ]
[ 27, 4 ]
[ 30, 25 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__len__
(self)
Returns the number of points in the coordinate sequence.
Returns the number of points in the coordinate sequence.
def __len__(self): "Returns the number of points in the coordinate sequence." return int(self.size)
[ "def", "__len__", "(", "self", ")", ":", "return", "int", "(", "self", ".", "size", ")" ]
[ 32, 4 ]
[ 34, 29 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__str__
(self)
Returns the string representation of the coordinate sequence.
Returns the string representation of the coordinate sequence.
def __str__(self): "Returns the string representation of the coordinate sequence." return str(self.tuple)
[ "def", "__str__", "(", "self", ")", ":", "return", "str", "(", "self", ".", "tuple", ")" ]
[ 36, 4 ]
[ 38, 30 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__getitem__
(self, index)
Returns the coordinate sequence value at the given index.
Returns the coordinate sequence value at the given index.
def __getitem__(self, index): "Returns the coordinate sequence value at the given index." coords = [self.getX(index), self.getY(index)] if self.dims == 3 and self._z: coords.append(self.getZ(index)) return tuple(coords)
[ "def", "__getitem__", "(", "self", ",", "index", ")", ":", "coords", "=", "[", "self", ".", "getX", "(", "index", ")", ",", "self", ".", "getY", "(", "index", ")", "]", "if", "self", ".", "dims", "==", "3", "and", "self", ".", "_z", ":", "coord...
[ 40, 4 ]
[ 45, 28 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.__setitem__
(self, index, value)
Sets the coordinate sequence value at the given index.
Sets the coordinate sequence value at the given index.
def __setitem__(self, index, value): "Sets the coordinate sequence value at the given index." # Checking the input value if isinstance(value, (list, tuple)): pass elif numpy and isinstance(value, numpy.ndarray): pass else: raise TypeError('Must...
[ "def", "__setitem__", "(", "self", ",", "index", ",", "value", ")", ":", "# Checking the input value", "if", "isinstance", "(", "value", ",", "(", "list", ",", "tuple", ")", ")", ":", "pass", "elif", "numpy", "and", "isinstance", "(", "value", ",", "nump...
[ 47, 4 ]
[ 69, 38 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq._checkindex
(self, index)
Checks the given index.
Checks the given index.
def _checkindex(self, index): "Checks the given index." sz = self.size if (sz < 1) or (index < 0) or (index >= sz): raise IndexError('invalid GEOS Geometry index: %s' % str(index))
[ "def", "_checkindex", "(", "self", ",", "index", ")", ":", "sz", "=", "self", ".", "size", "if", "(", "sz", "<", "1", ")", "or", "(", "index", "<", "0", ")", "or", "(", "index", ">=", "sz", ")", ":", "raise", "IndexError", "(", "'invalid GEOS Geo...
[ 72, 4 ]
[ 76, 76 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq._checkdim
(self, dim)
Checks the given dimension.
Checks the given dimension.
def _checkdim(self, dim): "Checks the given dimension." if dim < 0 or dim > 2: raise GEOSException('invalid ordinate dimension "%d"' % dim)
[ "def", "_checkdim", "(", "self", ",", "dim", ")", ":", "if", "dim", "<", "0", "or", "dim", ">", "2", ":", "raise", "GEOSException", "(", "'invalid ordinate dimension \"%d\"'", "%", "dim", ")" ]
[ 78, 4 ]
[ 81, 72 ]
python
en
['en', 'it', 'en']
True
GEOSCoordSeq.getOrdinate
(self, dimension, index)
Returns the value for the given dimension and index.
Returns the value for the given dimension and index.
def getOrdinate(self, dimension, index): "Returns the value for the given dimension and index." self._checkindex(index) self._checkdim(dimension) return capi.cs_getordinate(self.ptr, index, dimension, byref(c_double()))
[ "def", "getOrdinate", "(", "self", ",", "dimension", ",", "index", ")", ":", "self", ".", "_checkindex", "(", "index", ")", "self", ".", "_checkdim", "(", "dimension", ")", "return", "capi", ".", "cs_getordinate", "(", "self", ".", "ptr", ",", "index", ...
[ 84, 4 ]
[ 88, 81 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.setOrdinate
(self, dimension, index, value)
Sets the value for the given dimension and index.
Sets the value for the given dimension and index.
def setOrdinate(self, dimension, index, value): "Sets the value for the given dimension and index." self._checkindex(index) self._checkdim(dimension) capi.cs_setordinate(self.ptr, index, dimension, value)
[ "def", "setOrdinate", "(", "self", ",", "dimension", ",", "index", ",", "value", ")", ":", "self", ".", "_checkindex", "(", "index", ")", "self", ".", "_checkdim", "(", "dimension", ")", "capi", ".", "cs_setordinate", "(", "self", ".", "ptr", ",", "ind...
[ 90, 4 ]
[ 94, 62 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.getX
(self, index)
Get the X value at the index.
Get the X value at the index.
def getX(self, index): "Get the X value at the index." return self.getOrdinate(0, index)
[ "def", "getX", "(", "self", ",", "index", ")", ":", "return", "self", ".", "getOrdinate", "(", "0", ",", "index", ")" ]
[ 96, 4 ]
[ 98, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.setX
(self, index, value)
Set X with the value at the given index.
Set X with the value at the given index.
def setX(self, index, value): "Set X with the value at the given index." self.setOrdinate(0, index, value)
[ "def", "setX", "(", "self", ",", "index", ",", "value", ")", ":", "self", ".", "setOrdinate", "(", "0", ",", "index", ",", "value", ")" ]
[ 100, 4 ]
[ 102, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.getY
(self, index)
Get the Y value at the given index.
Get the Y value at the given index.
def getY(self, index): "Get the Y value at the given index." return self.getOrdinate(1, index)
[ "def", "getY", "(", "self", ",", "index", ")", ":", "return", "self", ".", "getOrdinate", "(", "1", ",", "index", ")" ]
[ 104, 4 ]
[ 106, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.setY
(self, index, value)
Set Y with the value at the given index.
Set Y with the value at the given index.
def setY(self, index, value): "Set Y with the value at the given index." self.setOrdinate(1, index, value)
[ "def", "setY", "(", "self", ",", "index", ",", "value", ")", ":", "self", ".", "setOrdinate", "(", "1", ",", "index", ",", "value", ")" ]
[ 108, 4 ]
[ 110, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.getZ
(self, index)
Get Z with the value at the given index.
Get Z with the value at the given index.
def getZ(self, index): "Get Z with the value at the given index." return self.getOrdinate(2, index)
[ "def", "getZ", "(", "self", ",", "index", ")", ":", "return", "self", ".", "getOrdinate", "(", "2", ",", "index", ")" ]
[ 112, 4 ]
[ 114, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.setZ
(self, index, value)
Set Z with the value at the given index.
Set Z with the value at the given index.
def setZ(self, index, value): "Set Z with the value at the given index." self.setOrdinate(2, index, value)
[ "def", "setZ", "(", "self", ",", "index", ",", "value", ")", ":", "self", ".", "setOrdinate", "(", "2", ",", "index", ",", "value", ")" ]
[ 116, 4 ]
[ 118, 41 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.size
(self)
Returns the size of this coordinate sequence.
Returns the size of this coordinate sequence.
def size(self): "Returns the size of this coordinate sequence." return capi.cs_getsize(self.ptr, byref(c_uint()))
[ "def", "size", "(", "self", ")", ":", "return", "capi", ".", "cs_getsize", "(", "self", ".", "ptr", ",", "byref", "(", "c_uint", "(", ")", ")", ")" ]
[ 122, 4 ]
[ 124, 57 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.dims
(self)
Returns the dimensions of this coordinate sequence.
Returns the dimensions of this coordinate sequence.
def dims(self): "Returns the dimensions of this coordinate sequence." return capi.cs_getdims(self.ptr, byref(c_uint()))
[ "def", "dims", "(", "self", ")", ":", "return", "capi", ".", "cs_getdims", "(", "self", ".", "ptr", ",", "byref", "(", "c_uint", "(", ")", ")", ")" ]
[ 127, 4 ]
[ 129, 57 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.hasz
(self)
Returns whether this coordinate sequence is 3D. This property value is inherited from the parent Geometry.
Returns whether this coordinate sequence is 3D. This property value is inherited from the parent Geometry.
def hasz(self): """ Returns whether this coordinate sequence is 3D. This property value is inherited from the parent Geometry. """ return self._z
[ "def", "hasz", "(", "self", ")", ":", "return", "self", ".", "_z" ]
[ 132, 4 ]
[ 137, 22 ]
python
en
['en', 'error', 'th']
False
GEOSCoordSeq.clone
(self)
Clones this coordinate sequence.
Clones this coordinate sequence.
def clone(self): "Clones this coordinate sequence." return GEOSCoordSeq(capi.cs_clone(self.ptr), self.hasz)
[ "def", "clone", "(", "self", ")", ":", "return", "GEOSCoordSeq", "(", "capi", ".", "cs_clone", "(", "self", ".", "ptr", ")", ",", "self", ".", "hasz", ")" ]
[ 140, 4 ]
[ 142, 63 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.kml
(self)
Returns the KML representation for the coordinates.
Returns the KML representation for the coordinates.
def kml(self): "Returns the KML representation for the coordinates." # Getting the substitution string depending on whether the coordinates have # a Z dimension. if self.hasz: substr = '%s,%s,%s ' else: substr = '%s,%s,0 ' return '<coordinates>%s<...
[ "def", "kml", "(", "self", ")", ":", "# Getting the substitution string depending on whether the coordinates have", "# a Z dimension.", "if", "self", ".", "hasz", ":", "substr", "=", "'%s,%s,%s '", "else", ":", "substr", "=", "'%s,%s,0 '", "return", "'<coordinates>%s</co...
[ 145, 4 ]
[ 154, 71 ]
python
en
['en', 'en', 'en']
True
GEOSCoordSeq.tuple
(self)
Returns a tuple version of this coordinate sequence.
Returns a tuple version of this coordinate sequence.
def tuple(self): "Returns a tuple version of this coordinate sequence." n = self.size if n == 1: return self[0] else: return tuple(self[i] for i in range(n))
[ "def", "tuple", "(", "self", ")", ":", "n", "=", "self", ".", "size", "if", "n", "==", "1", ":", "return", "self", "[", "0", "]", "else", ":", "return", "tuple", "(", "self", "[", "i", "]", "for", "i", "in", "range", "(", "n", ")", ")" ]
[ 157, 4 ]
[ 163, 51 ]
python
en
['en', 'en', 'en']
True
validate_pem
(data, min_keys=0, max_keys=None, min_certs=0, max_certs=None)
Validate the given PEM data is valid and contains the required numbers of keys and certificates. Return a list of PEM objects, where each object is a dict with the following keys: - 'all': The entire string for the PEM object including BEGIN/END lines. - 'type': The type of PEM object ('PR...
Validate the given PEM data is valid and contains the required numbers of keys and certificates.
def validate_pem(data, min_keys=0, max_keys=None, min_certs=0, max_certs=None): """ Validate the given PEM data is valid and contains the required numbers of keys and certificates. Return a list of PEM objects, where each object is a dict with the following keys: - 'all': The entire string fo...
[ "def", "validate_pem", "(", "data", ",", "min_keys", "=", "0", ",", "max_keys", "=", "None", ",", "min_certs", "=", "0", ",", "max_certs", "=", "None", ")", ":", "# Map the X in BEGIN X PRIVATE KEY to the key type (ssh-keygen -t).", "# Tower jobs using OPENSSH format pr...
[ 19, 0 ]
[ 155, 22 ]
python
en
['en', 'error', 'th']
False
validate_private_key
(data)
Validate that data contains exactly one private key.
Validate that data contains exactly one private key.
def validate_private_key(data): """ Validate that data contains exactly one private key. """ return validate_pem(data, min_keys=1, max_keys=1, max_certs=0)
[ "def", "validate_private_key", "(", "data", ")", ":", "return", "validate_pem", "(", "data", ",", "min_keys", "=", "1", ",", "max_keys", "=", "1", ",", "max_certs", "=", "0", ")" ]
[ 158, 0 ]
[ 162, 66 ]
python
en
['en', 'error', 'th']
False
validate_certificate
(data)
Validate that data contains one or more certificates. Adds BEGIN/END lines if necessary.
Validate that data contains one or more certificates. Adds BEGIN/END lines if necessary.
def validate_certificate(data): """ Validate that data contains one or more certificates. Adds BEGIN/END lines if necessary. """ if 'BEGIN ' not in data: data = "-----BEGIN CERTIFICATE-----\n{}".format(data) if 'END ' not in data: data = "{}\n-----END CERTIFICATE-----\n".format(d...
[ "def", "validate_certificate", "(", "data", ")", ":", "if", "'BEGIN '", "not", "in", "data", ":", "data", "=", "\"-----BEGIN CERTIFICATE-----\\n{}\"", ".", "format", "(", "data", ")", "if", "'END '", "not", "in", "data", ":", "data", "=", "\"{}\\n-----END CERT...
[ 165, 0 ]
[ 174, 54 ]
python
en
['en', 'error', 'th']
False
validate_ssh_private_key
(data)
Validate that data contains at least one private key and optionally certificates; should handle any valid options for ssh_private_key on a credential.
Validate that data contains at least one private key and optionally certificates; should handle any valid options for ssh_private_key on a credential.
def validate_ssh_private_key(data): """ Validate that data contains at least one private key and optionally certificates; should handle any valid options for ssh_private_key on a credential. """ return validate_pem(data, min_keys=1)
[ "def", "validate_ssh_private_key", "(", "data", ")", ":", "return", "validate_pem", "(", "data", ",", "min_keys", "=", "1", ")" ]
[ 177, 0 ]
[ 183, 41 ]
python
en
['en', 'error', 'th']
False
vars_validate_or_raise
(vars_str)
Validate that fields like extra_vars or variables on resources like job templates, inventories, or hosts are either an acceptable blank string, or are valid JSON or YAML dict
Validate that fields like extra_vars or variables on resources like job templates, inventories, or hosts are either an acceptable blank string, or are valid JSON or YAML dict
def vars_validate_or_raise(vars_str): """ Validate that fields like extra_vars or variables on resources like job templates, inventories, or hosts are either an acceptable blank string, or are valid JSON or YAML dict """ try: parse_yaml_or_json(vars_str, silent_failure=False) ret...
[ "def", "vars_validate_or_raise", "(", "vars_str", ")", ":", "try", ":", "parse_yaml_or_json", "(", "vars_str", ",", "silent_failure", "=", "False", ")", "return", "vars_str", "except", "ParseError", "as", "e", ":", "raise", "RestValidationError", "(", "str", "("...
[ 186, 0 ]
[ 196, 41 ]
python
en
['en', 'error', 'th']
False
validate_container_image_name
(value)
from https://github.com/distribution/distribution/blob/af8ac809336c2316c81b08605d92d94f8670ad15/reference/reference.go#L4 Grammar reference := name [ ":" tag ] [ "@" digest ] name := [domain '/'] path-component ['/' path-component]* domain ...
from https://github.com/distribution/distribution/blob/af8ac809336c2316c81b08605d92d94f8670ad15/reference/reference.go#L4
def validate_container_image_name(value): """ from https://github.com/distribution/distribution/blob/af8ac809336c2316c81b08605d92d94f8670ad15/reference/reference.go#L4 Grammar reference := name [ ":" tag ] [ "@" digest ] name := [domain '/'] path-co...
[ "def", "validate_container_image_name", "(", "value", ")", ":", "# fmt: off", "regex", "=", "re", ".", "compile", "(", "r\"\"\"\n ^\n ( # name\n (?: # domain (optional)\n (?:\n [a-zA-Z0-9] ...
[ 199, 0 ]
[ 288, 82 ]
python
en
['en', 'error', 'th']
False
rms_invalid
(rms, noise, low_bound=1, high_bound=50)
Is the RMS value of an image outside the plausible range? :param rms: RMS value of an image, can be computed with tkp.quality.statistics.rms :param noise: Theoretical noise level of instrument, can be calculated with tkp.lofar.noise.noise_level :param low_bound: multi...
Is the RMS value of an image outside the plausible range?
def rms_invalid(rms, noise, low_bound=1, high_bound=50): """ Is the RMS value of an image outside the plausible range? :param rms: RMS value of an image, can be computed with tkp.quality.statistics.rms :param noise: Theoretical noise level of instrument, can be calculated with ...
[ "def", "rms_invalid", "(", "rms", ",", "noise", ",", "low_bound", "=", "1", ",", "high_bound", "=", "50", ")", ":", "if", "(", "rms", "<", "noise", "*", "low_bound", ")", "or", "(", "rms", ">", "noise", "*", "high_bound", ")", ":", "ratio", "=", ...
[ 7, 0 ]
[ 24, 20 ]
python
en
['en', 'error', 'th']
False
rms
(data)
Returns the RMS of the data about the median. Args: data: a numpy array
Returns the RMS of the data about the median. Args: data: a numpy array
def rms(data): """Returns the RMS of the data about the median. Args: data: a numpy array """ data -= numpy.median(data) return numpy.sqrt(numpy.power(data, 2).sum()/len(data))
[ "def", "rms", "(", "data", ")", ":", "data", "-=", "numpy", ".", "median", "(", "data", ")", "return", "numpy", ".", "sqrt", "(", "numpy", ".", "power", "(", "data", ",", "2", ")", ".", "sum", "(", ")", "/", "len", "(", "data", ")", ")" ]
[ 27, 0 ]
[ 33, 59 ]
python
en
['en', 'en', 'en']
True
clip
(data, sigma=3)
Remove all values above a threshold from the array. Uses iterative clipping at sigma value until nothing more is getting clipped. Args: data: a numpy array
Remove all values above a threshold from the array. Uses iterative clipping at sigma value until nothing more is getting clipped. Args: data: a numpy array
def clip(data, sigma=3): """Remove all values above a threshold from the array. Uses iterative clipping at sigma value until nothing more is getting clipped. Args: data: a numpy array """ raveled = data.ravel() median = numpy.median(raveled) std = numpy.std(raveled) newdata = rav...
[ "def", "clip", "(", "data", ",", "sigma", "=", "3", ")", ":", "raveled", "=", "data", ".", "ravel", "(", ")", "median", "=", "numpy", ".", "median", "(", "raveled", ")", "std", "=", "numpy", ".", "std", "(", "raveled", ")", "newdata", "=", "ravel...
[ 36, 0 ]
[ 49, 22 ]
python
en
['en', 'en', 'en']
True
subregion
(data, f=4)
Returns the inner region of a image, according to f. Resulting area is 4/(f*f) of the original. Args: data: a numpy array
Returns the inner region of a image, according to f.
def subregion(data, f=4): """Returns the inner region of a image, according to f. Resulting area is 4/(f*f) of the original. Args: data: a numpy array """ x, y = data.shape return data[(x/2 - x/f):(x/2 + x/f), (y/2 - y/f):(y/2 + y/f)]
[ "def", "subregion", "(", "data", ",", "f", "=", "4", ")", ":", "x", ",", "y", "=", "data", ".", "shape", "return", "data", "[", "(", "x", "/", "2", "-", "x", "/", "f", ")", ":", "(", "x", "/", "2", "+", "x", "/", "f", ")", ",", "(", "...
[ 52, 0 ]
[ 60, 65 ]
python
en
['en', 'en', 'en']
True
rms_with_clipped_subregion
(data, rms_est_sigma=3, rms_est_fraction=4)
RMS for quality-control. Root mean square value calculated from central region of an image. We sigma-clip the input-data in an attempt to exclude source-pixels and keep only background-pixels. Args: data: A numpy array rms_est_sigma: sigma value used for clipping rms_est_f...
RMS for quality-control.
def rms_with_clipped_subregion(data, rms_est_sigma=3, rms_est_fraction=4): """ RMS for quality-control. Root mean square value calculated from central region of an image. We sigma-clip the input-data in an attempt to exclude source-pixels and keep only background-pixels. Args: data: A ...
[ "def", "rms_with_clipped_subregion", "(", "data", ",", "rms_est_sigma", "=", "3", ",", "rms_est_fraction", "=", "4", ")", ":", "return", "rms", "(", "clip", "(", "subregion", "(", "data", ",", "rms_est_fraction", ")", ",", "rms_est_sigma", ")", ")" ]
[ 63, 0 ]
[ 78, 70 ]
python
en
['en', 'error', 'th']
False
reject_basic_rms
(image_id, session, est_sigma=4, rms_max=100., rms_min=0.0)
Check if the RMS value of an image lies within a range predetermined at the start of a pipeline run. args: image_id (int): database ID of the image we want to check session (sqlalchemy.orm.session.Session): the database session est_sigma (float): sigma multiplication factor ...
Check if the RMS value of an image lies within a range predetermined at the start of a pipeline run. args: image_id (int): database ID of the image we want to check session (sqlalchemy.orm.session.Session): the database session est_sigma (float): sigma multiplication factor ...
def reject_basic_rms(image_id, session, est_sigma=4, rms_max=100., rms_min=0.0): """Check if the RMS value of an image lies within a range predetermined at the start of a pipeline run. args: image_id (int): database ID of the image we want to check session (sqlalchemy.orm.session.Sessio...
[ "def", "reject_basic_rms", "(", "image_id", ",", "session", ",", "est_sigma", "=", "4", ",", "rms_max", "=", "100.", ",", "rms_min", "=", "0.0", ")", ":", "image", "=", "session", ".", "query", "(", "Image", ")", ".", "filter", "(", "Image", ".", "id...
[ 80, 0 ]
[ 98, 72 ]
python
en
['en', 'en', 'en']
True
reject_historical_rms
(image_id, session, history=100, est_sigma=4, rms_max=100., rms_min=0.0, rej_sigma=3.0)
Check if the RMS value of an image lies within a range defined by a gaussian fit on the histogram calculated from the last x RMS values in this subband. Upper and lower bound are then controlled by est_sigma multiplied with the sigma of the gaussian. args: image_id (int): database ID of th...
Check if the RMS value of an image lies within a range defined by a gaussian fit on the histogram calculated from the last x RMS values in this subband. Upper and lower bound are then controlled by est_sigma multiplied with the sigma of the gaussian.
def reject_historical_rms(image_id, session, history=100, est_sigma=4, rms_max=100., rms_min=0.0, rej_sigma=3.0): """ Check if the RMS value of an image lies within a range defined by a gaussian fit on the histogram calculated from the last x RMS values in this subband. Upper and lower bound are then co...
[ "def", "reject_historical_rms", "(", "image_id", ",", "session", ",", "history", "=", "100", ",", "est_sigma", "=", "4", ",", "rms_max", "=", "100.", ",", "rms_min", "=", "0.0", ",", "rej_sigma", "=", "3.0", ")", ":", "image", "=", "session", ".", "que...
[ 102, 0 ]
[ 135, 69 ]
python
en
['en', 'error', 'th']
False
dictfetchall
(cursor: connection.cursor)
Returns all rows from a cursor as a dict
Returns all rows from a cursor as a dict
def dictfetchall(cursor: connection.cursor) -> List[Dict[str, Any]]: "Returns all rows from a cursor as a dict" desc = cursor.description return [dict(zip((col[0] for col in desc), row)) for row in cursor.fetchall()]
[ "def", "dictfetchall", "(", "cursor", ":", "connection", ".", "cursor", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "desc", "=", "cursor", ".", "description", "return", "[", "dict", "(", "zip", "(", "(", "col", "[", "0", ...
[ 578, 0 ]
[ 581, 82 ]
python
en
['en', 'en', 'en']
True
Command.compile_messages
(self, locations)
Locations is a list of tuples: [(directory, file), ...]
Locations is a list of tuples: [(directory, file), ...]
def compile_messages(self, locations): """ Locations is a list of tuples: [(directory, file), ...] """ for i, (dirpath, f) in enumerate(locations): if self.verbosity > 0: self.stdout.write('processing file %s in %s\n' % (f, dirpath)) po_path = os.p...
[ "def", "compile_messages", "(", "self", ",", "locations", ")", ":", "for", "i", ",", "(", "dirpath", ",", "f", ")", "in", "enumerate", "(", "locations", ")", ":", "if", "self", ".", "verbosity", ">", "0", ":", "self", ".", "stdout", ".", "write", "...
[ 104, 4 ]
[ 133, 39 ]
python
en
['en', 'error', 'th']
False
is_appengine_sandbox
()
Reports if the app is running in the first generation sandbox. The second generation runtimes are technically still in a sandbox, but it is much less restrictive, so generally you shouldn't need to check for it. see https://cloud.google.com/appengine/docs/standard/runtimes
Reports if the app is running in the first generation sandbox.
def is_appengine_sandbox(): """Reports if the app is running in the first generation sandbox. The second generation runtimes are technically still in a sandbox, but it is much less restrictive, so generally you shouldn't need to check for it. see https://cloud.google.com/appengine/docs/standard/runtime...
[ "def", "is_appengine_sandbox", "(", ")", ":", "return", "is_appengine", "(", ")", "and", "os", ".", "environ", "[", "\"APPENGINE_RUNTIME\"", "]", "==", "\"python27\"" ]
[ 11, 0 ]
[ 18, 75 ]
python
en
['en', 'en', 'en']
True
is_prod_appengine_mvms
()
Deprecated.
Deprecated.
def is_prod_appengine_mvms(): """Deprecated.""" return False
[ "def", "is_prod_appengine_mvms", "(", ")", ":", "return", "False" ]
[ 33, 0 ]
[ 35, 16 ]
python
en
['en', 'la', 'it']
False
ListFilter.has_output
(self)
Returns True if some choices would be output for this filter.
Returns True if some choices would be output for this filter.
def has_output(self): """ Returns True if some choices would be output for this filter. """ raise NotImplementedError('subclasses of ListFilter must provide a has_output() method')
[ "def", "has_output", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of ListFilter must provide a has_output() method'", ")" ]
[ 33, 4 ]
[ 37, 96 ]
python
en
['en', 'error', 'th']
False
ListFilter.choices
(self, changelist)
Returns choices ready to be output in the template. `changelist` is the ChangeList to be displayed.
Returns choices ready to be output in the template.
def choices(self, changelist): """ Returns choices ready to be output in the template. `changelist` is the ChangeList to be displayed. """ raise NotImplementedError('subclasses of ListFilter must provide a choices() method')
[ "def", "choices", "(", "self", ",", "changelist", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of ListFilter must provide a choices() method'", ")" ]
[ 39, 4 ]
[ 45, 93 ]
python
en
['en', 'error', 'th']
False
ListFilter.queryset
(self, request, queryset)
Returns the filtered queryset.
Returns the filtered queryset.
def queryset(self, request, queryset): """ Returns the filtered queryset. """ raise NotImplementedError('subclasses of ListFilter must provide a queryset() method')
[ "def", "queryset", "(", "self", ",", "request", ",", "queryset", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of ListFilter must provide a queryset() method'", ")" ]
[ 47, 4 ]
[ 51, 94 ]
python
en
['en', 'error', 'th']
False
ListFilter.expected_parameters
(self)
Returns the list of parameter names that are expected from the request's query string and that will be used by this filter.
Returns the list of parameter names that are expected from the request's query string and that will be used by this filter.
def expected_parameters(self): """ Returns the list of parameter names that are expected from the request's query string and that will be used by this filter. """ raise NotImplementedError('subclasses of ListFilter must provide an expected_parameters() method')
[ "def", "expected_parameters", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of ListFilter must provide an expected_parameters() method'", ")" ]
[ 53, 4 ]
[ 58, 106 ]
python
en
['en', 'error', 'th']
False
SimpleListFilter.value
(self)
Returns the value (in string format) provided in the request's query string for this filter, if any. If the value wasn't provided then returns None.
Returns the value (in string format) provided in the request's query string for this filter, if any. If the value wasn't provided then returns None.
def value(self): """ Returns the value (in string format) provided in the request's query string for this filter, if any. If the value wasn't provided then returns None. """ return self.used_parameters.get(self.parameter_name)
[ "def", "value", "(", "self", ")", ":", "return", "self", ".", "used_parameters", ".", "get", "(", "self", ".", "parameter_name", ")" ]
[ 83, 4 ]
[ 89, 60 ]
python
en
['en', 'error', 'th']
False
SimpleListFilter.lookups
(self, request, model_admin)
Must be overridden to return a list of tuples (value, verbose value)
Must be overridden to return a list of tuples (value, verbose value)
def lookups(self, request, model_admin): """ Must be overridden to return a list of tuples (value, verbose value) """ raise NotImplementedError( 'The SimpleListFilter.lookups() method must be overridden to ' 'return a list of tuples (value, verbose value)')
[ "def", "lookups", "(", "self", ",", "request", ",", "model_admin", ")", ":", "raise", "NotImplementedError", "(", "'The SimpleListFilter.lookups() method must be overridden to '", "'return a list of tuples (value, verbose value)'", ")" ]
[ 91, 4 ]
[ 97, 61 ]
python
en
['en', 'error', 'th']
False
RelatedFieldListFilter.include_empty_choice
(self)
Return True if a "(None)" choice should be included, which filters out everything except empty relationships.
Return True if a "(None)" choice should be included, which filters out everything except empty relationships.
def include_empty_choice(self): """ Return True if a "(None)" choice should be included, which filters out everything except empty relationships. """ return self.field.null or (self.field.is_relation and self.field.many_to_many)
[ "def", "include_empty_choice", "(", "self", ")", ":", "return", "self", ".", "field", ".", "null", "or", "(", "self", ".", "field", ".", "is_relation", "and", "self", ".", "field", ".", "many_to_many", ")" ]
[ 178, 4 ]
[ 183, 86 ]
python
en
['en', 'error', 'th']
False
register_handler
(handler)
Install application-specific WMF image handler. :param handler: Handler object.
Install application-specific WMF image handler.
def register_handler(handler): """ Install application-specific WMF image handler. :param handler: Handler object. """ global _handler _handler = handler
[ "def", "register_handler", "(", "handler", ")", ":", "global", "_handler", "_handler", "=", "handler" ]
[ 30, 0 ]
[ 37, 22 ]
python
en
['en', 'error', 'th']
False
get_python_version
()
Return a string containing the major and minor Python version, leaving off the patchlevel. Sample return values could be '1.5' or '2.2'.
Return a string containing the major and minor Python version, leaving off the patchlevel. Sample return values could be '1.5' or '2.2'.
def get_python_version(): """Return a string containing the major and minor Python version, leaving off the patchlevel. Sample return values could be '1.5' or '2.2'. """ return '%d.%d' % sys.version_info[:2]
[ "def", "get_python_version", "(", ")", ":", "return", "'%d.%d'", "%", "sys", ".", "version_info", "[", ":", "2", "]" ]
[ 80, 0 ]
[ 85, 41 ]
python
en
['en', 'en', 'en']
True
get_python_inc
(plat_specific=0, prefix=None)
Return the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header files (namely pyconfig.h). If 'prefix' is supplied,...
Return the directory containing installed Python header files.
def get_python_inc(plat_specific=0, prefix=None): """Return the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header fil...
[ "def", "get_python_inc", "(", "plat_specific", "=", "0", ",", "prefix", "=", "None", ")", ":", "if", "prefix", "is", "None", ":", "prefix", "=", "plat_specific", "and", "BASE_EXEC_PREFIX", "or", "BASE_PREFIX", "if", "IS_PYPY", ":", "return", "os", ".", "pa...
[ 88, 0 ]
[ 127, 41 ]
python
en
['en', 'en', 'en']
True
get_python_lib
(plat_specific=0, standard_lib=0, prefix=None)
Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the platform-shared library directory. If 'standard_...
Return the directory containing the Python library (standard or site additions).
def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): """Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; ot...
[ "def", "get_python_lib", "(", "plat_specific", "=", "0", ",", "standard_lib", "=", "0", ",", "prefix", "=", "None", ")", ":", "if", "IS_PYPY", ":", "# PyPy-specific schema", "if", "prefix", "is", "None", ":", "prefix", "=", "PREFIX", "if", "standard_lib", ...
[ 130, 0 ]
[ 180, 41 ]
python
en
['en', 'en', 'en']
True
customize_compiler
(compiler)
Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile.
Do any platform-specific customization of a CCompiler instance.
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": if sys.platform == "darwin": ...
[ "def", "customize_compiler", "(", "compiler", ")", ":", "if", "compiler", ".", "compiler_type", "==", "\"unix\"", ":", "if", "sys", ".", "platform", "==", "\"darwin\"", ":", "# Perform first-time customization of compiler-related", "# config vars on OS X now that we know we...
[ 184, 0 ]
[ 254, 52 ]
python
en
['en', 'en', 'en']
True
get_config_h_filename
()
Return full pathname of installed pyconfig.h file.
Return full pathname of installed pyconfig.h file.
def get_config_h_filename(): """Return full pathname of installed pyconfig.h file.""" if python_build: if os.name == "nt": inc_dir = os.path.join(_sys_home or project_base, "PC") else: inc_dir = _sys_home or project_base else: inc_dir = get_python_inc(plat_spe...
[ "def", "get_config_h_filename", "(", ")", ":", "if", "python_build", ":", "if", "os", ".", "name", "==", "\"nt\"", ":", "inc_dir", "=", "os", ".", "path", ".", "join", "(", "_sys_home", "or", "project_base", ",", "\"PC\"", ")", "else", ":", "inc_dir", ...
[ 257, 0 ]
[ 267, 46 ]
python
en
['en', 'en', 'en']
True
get_makefile_filename
()
Return full pathname of installed Makefile from the Python build.
Return full pathname of installed Makefile from the Python build.
def get_makefile_filename(): """Return full pathname of installed Makefile from the Python build.""" if python_build: return os.path.join(_sys_home or project_base, "Makefile") lib_dir = get_python_lib(plat_specific=0, standard_lib=1) config_file = 'config-{}{}'.format(get_python_version(), buil...
[ "def", "get_makefile_filename", "(", ")", ":", "if", "python_build", ":", "return", "os", ".", "path", ".", "join", "(", "_sys_home", "or", "project_base", ",", "\"Makefile\"", ")", "lib_dir", "=", "get_python_lib", "(", "plat_specific", "=", "0", ",", "stan...
[ 270, 0 ]
[ 278, 57 ]
python
en
['en', 'en', 'en']
True
parse_config_h
(fp, g=None)
Parse a config.h-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary.
Parse a config.h-style file.
def parse_config_h(fp, g=None): """Parse a config.h-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ if g is None: g = {} define_rx = re.compile("#define ([A-...
[ "def", "parse_config_h", "(", "fp", ",", "g", "=", "None", ")", ":", "if", "g", "is", "None", ":", "g", "=", "{", "}", "define_rx", "=", "re", ".", "compile", "(", "\"#define ([A-Z][A-Za-z0-9_]+) (.*)\\n\"", ")", "undef_rx", "=", "re", ".", "compile", ...
[ 281, 0 ]
[ 307, 12 ]
python
en
['es', 'en', 'en']
True
parse_makefile
(fn, g=None)
Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary.
Parse a Makefile-style file.
def parse_makefile(fn, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ from distutils.text_file import TextFile fp = TextFile(fn, strip_...
[ "def", "parse_makefile", "(", "fn", ",", "g", "=", "None", ")", ":", "from", "distutils", ".", "text_file", "import", "TextFile", "fp", "=", "TextFile", "(", "fn", ",", "strip_comments", "=", "1", ",", "skip_blanks", "=", "1", ",", "join_lines", "=", "...
[ 316, 0 ]
[ 419, 12 ]
python
en
['en', 'en', 'en']
True
expand_makefile_vars
(s, vars)
Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in 'string' according to 'vars' (a dictionary mapping variable names to values). Variables not present in 'vars' are silently expanded to the empty string. The variable values in 'vars' should not contain further variable expansions; if 'vars'...
Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in 'string' according to 'vars' (a dictionary mapping variable names to values). Variables not present in 'vars' are silently expanded to the empty string. The variable values in 'vars' should not contain further variable expansions; if 'vars'...
def expand_makefile_vars(s, vars): """Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in 'string' according to 'vars' (a dictionary mapping variable names to values). Variables not present in 'vars' are silently expanded to the empty string. The variable values in 'vars' should not contain ...
[ "def", "expand_makefile_vars", "(", "s", ",", "vars", ")", ":", "# This algorithm does multiple expansion, so if vars['foo'] contains", "# \"${bar}\", it will expand ${foo} to ${bar}, and then expand", "# ${bar}... and so forth. This is fine as long as 'vars' comes from", "# 'parse_makefile()...
[ 422, 0 ]
[ 444, 12 ]
python
en
['en', 'en', 'en']
True
_init_posix
()
Initialize the module as appropriate for POSIX systems.
Initialize the module as appropriate for POSIX systems.
def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" # _sysconfigdata is generated at build time, see the sysconfig module name = os.environ.get('_PYTHON_SYSCONFIGDATA_NAME', '_sysconfigdata_{abi}_{platform}_{multiarch}'.format( abi=sys.abiflags, platform=...
[ "def", "_init_posix", "(", ")", ":", "# _sysconfigdata is generated at build time, see the sysconfig module", "name", "=", "os", ".", "environ", ".", "get", "(", "'_PYTHON_SYSCONFIGDATA_NAME'", ",", "'_sysconfigdata_{abi}_{platform}_{multiarch}'", ".", "format", "(", "abi", ...
[ 449, 0 ]
[ 467, 40 ]
python
en
['en', 'en', 'en']
True
_init_nt
()
Initialize the module as appropriate for NT
Initialize the module as appropriate for NT
def _init_nt(): """Initialize the module as appropriate for NT""" g = {} # set basic install directories g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) # XXX hmmm.. a normal install puts include files here g['...
[ "def", "_init_nt", "(", ")", ":", "g", "=", "{", "}", "# set basic install directories", "g", "[", "'LIBDEST'", "]", "=", "get_python_lib", "(", "plat_specific", "=", "0", ",", "standard_lib", "=", "1", ")", "g", "[", "'BINLIBDEST'", "]", "=", "get_python_...
[ 470, 0 ]
[ 486, 20 ]
python
en
['en', 'en', 'en']
True
get_config_vars
(*args)
With no arguments, return a dictionary of all configuration variables relevant for the current platform. Generally this includes everything needed to build extensions and install both pure modules and extensions. On Unix, this means every variable defined in Python's installed Makefile; on Windows it'...
With no arguments, return a dictionary of all configuration variables relevant for the current platform. Generally this includes everything needed to build extensions and install both pure modules and extensions. On Unix, this means every variable defined in Python's installed Makefile; on Windows it'...
def get_config_vars(*args): """With no arguments, return a dictionary of all configuration variables relevant for the current platform. Generally this includes everything needed to build extensions and install both pure modules and extensions. On Unix, this means every variable defined in Python's ...
[ "def", "get_config_vars", "(", "*", "args", ")", ":", "global", "_config_vars", "if", "_config_vars", "is", "None", ":", "func", "=", "globals", "(", ")", ".", "get", "(", "\"_init_\"", "+", "os", ".", "name", ")", "if", "func", ":", "func", "(", ")"...
[ 489, 0 ]
[ 562, 27 ]
python
en
['en', 'en', 'en']
True
get_config_var
(name)
Return the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name)
Return the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name)
def get_config_var(name): """Return the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name) """ if name == 'SO': import warnings warnings.warn('SO is deprecated, use EXT_SUFFIX', DeprecationWarning, 2) return...
[ "def", "get_config_var", "(", "name", ")", ":", "if", "name", "==", "'SO'", ":", "import", "warnings", "warnings", ".", "warn", "(", "'SO is deprecated, use EXT_SUFFIX'", ",", "DeprecationWarning", ",", "2", ")", "return", "get_config_vars", "(", ")", ".", "ge...
[ 564, 0 ]
[ 572, 38 ]
python
en
['en', 'en', 'en']
True
direct_url_as_pep440_direct_reference
(direct_url, name)
Convert a DirectUrl to a pip requirement string.
Convert a DirectUrl to a pip requirement string.
def direct_url_as_pep440_direct_reference(direct_url, name): # type: (DirectUrl, str) -> str """Convert a DirectUrl to a pip requirement string.""" direct_url.validate() # if invalid, this is a pip bug requirement = name + " @ " fragments = [] if isinstance(direct_url.info, VcsInfo): re...
[ "def", "direct_url_as_pep440_direct_reference", "(", "direct_url", ",", "name", ")", ":", "# type: (DirectUrl, str) -> str", "direct_url", ".", "validate", "(", ")", "# if invalid, this is a pip bug", "requirement", "=", "name", "+", "\" @ \"", "fragments", "=", "[", "]...
[ 29, 0 ]
[ 50, 22 ]
python
en
['en', 'en', 'en']
True
dist_get_direct_url
(dist)
Obtain a DirectUrl from a pkg_resource.Distribution. Returns None if the distribution has no `direct_url.json` metadata, or if `direct_url.json` is invalid.
Obtain a DirectUrl from a pkg_resource.Distribution.
def dist_get_direct_url(dist): # type: (Distribution) -> Optional[DirectUrl] """Obtain a DirectUrl from a pkg_resource.Distribution. Returns None if the distribution has no `direct_url.json` metadata, or if `direct_url.json` is invalid. """ if not dist.has_metadata(DIRECT_URL_METADATA_NAME): ...
[ "def", "dist_get_direct_url", "(", "dist", ")", ":", "# type: (Distribution) -> Optional[DirectUrl]", "if", "not", "dist", ".", "has_metadata", "(", "DIRECT_URL_METADATA_NAME", ")", ":", "return", "None", "try", ":", "return", "DirectUrl", ".", "from_json", "(", "di...
[ 103, 0 ]
[ 125, 19 ]
python
en
['en', 'en', 'en']
True
colorize
(text='', opts=(), **kwargs)
Returns your text, enclosed in ANSI graphics codes. Depends on the keyword arguments 'fg' and 'bg', and the contents of the opts tuple/list. Returns the RESET code if no parameters are given. Valid colors: 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white' Valid o...
Returns your text, enclosed in ANSI graphics codes.
def colorize(text='', opts=(), **kwargs): """ Returns your text, enclosed in ANSI graphics codes. Depends on the keyword arguments 'fg' and 'bg', and the contents of the opts tuple/list. Returns the RESET code if no parameters are given. Valid colors: 'black', 'red', 'green', 'yellow'...
[ "def", "colorize", "(", "text", "=", "''", ",", "opts", "=", "(", ")", ",", "*", "*", "kwargs", ")", ":", "code_list", "=", "[", "]", "if", "text", "==", "''", "and", "len", "(", "opts", ")", "==", "1", "and", "opts", "[", "0", "]", "==", "...
[ 14, 0 ]
[ 56, 68 ]
python
en
['en', 'error', 'th']
False
make_style
(opts=(), **kwargs)
Returns a function with default parameters for colorize() Example: bold_red = make_style(opts=('bold',), fg='red') print(bold_red('hello')) KEYWORD = make_style(fg='yellow') COMMENT = make_style(fg='blue', opts=('bold',))
Returns a function with default parameters for colorize()
def make_style(opts=(), **kwargs): """ Returns a function with default parameters for colorize() Example: bold_red = make_style(opts=('bold',), fg='red') print(bold_red('hello')) KEYWORD = make_style(fg='yellow') COMMENT = make_style(fg='blue', opts=('bold',)) """ re...
[ "def", "make_style", "(", "opts", "=", "(", ")", ",", "*", "*", "kwargs", ")", ":", "return", "lambda", "text", ":", "colorize", "(", "text", ",", "opts", ",", "*", "*", "kwargs", ")" ]
[ 59, 0 ]
[ 69, 54 ]
python
en
['en', 'error', 'th']
False
parse_color_setting
(config_string)
Parse a DJANGO_COLORS environment variable to produce the system palette The general form of a palette definition is: "palette;role=fg;role=fg/bg;role=fg,option,option;role=fg/bg,option,option" where: palette is a named palette; one of 'light', 'dark', or 'nocolor'. role is a named st...
Parse a DJANGO_COLORS environment variable to produce the system palette
def parse_color_setting(config_string): """Parse a DJANGO_COLORS environment variable to produce the system palette The general form of a palette definition is: "palette;role=fg;role=fg/bg;role=fg,option,option;role=fg/bg,option,option" where: palette is a named palette; one of 'light', '...
[ "def", "parse_color_setting", "(", "config_string", ")", ":", "if", "not", "config_string", ":", "return", "PALETTES", "[", "DEFAULT_PALETTE", "]", "# Split the color configuration into parts", "parts", "=", "config_string", ".", "lower", "(", ")", ".", "split", "("...
[ 138, 0 ]
[ 216, 18 ]
python
en
['en', 'en', 'en']
True
pretty_name
(name)
Converts 'first_name' to 'First name
Converts 'first_name' to 'First name
def pretty_name(name): """Converts 'first_name' to 'First name'""" if not name: return '' return name.replace('_', ' ').capitalize()
[ "def", "pretty_name", "(", "name", ")", ":", "if", "not", "name", ":", "return", "''", "return", "name", ".", "replace", "(", "'_'", ",", "' '", ")", ".", "capitalize", "(", ")" ]
[ 18, 0 ]
[ 22, 46 ]
python
en
['en', 'en', 'en']
True
flatatt
(attrs)
Convert a dictionary of attributes to a single string. The returned string will contain a leading space followed by key="value", XML-style pairs. In the case of a boolean value, the key will appear without a value. It is assumed that the keys do not need to be XML-escaped. If the passed dictionary ...
Convert a dictionary of attributes to a single string. The returned string will contain a leading space followed by key="value", XML-style pairs. In the case of a boolean value, the key will appear without a value. It is assumed that the keys do not need to be XML-escaped. If the passed dictionary ...
def flatatt(attrs): """ Convert a dictionary of attributes to a single string. The returned string will contain a leading space followed by key="value", XML-style pairs. In the case of a boolean value, the key will appear without a value. It is assumed that the keys do not need to be XML-escaped...
[ "def", "flatatt", "(", "attrs", ")", ":", "key_value_attrs", "=", "[", "]", "boolean_attrs", "=", "[", "]", "for", "attr", ",", "value", "in", "attrs", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "if", "val...
[ 25, 0 ]
[ 48, 5 ]
python
en
['en', 'error', 'th']
False
from_current_timezone
(value)
When time zone support is enabled, convert naive datetimes entered in the current time zone to aware datetimes.
When time zone support is enabled, convert naive datetimes entered in the current time zone to aware datetimes.
def from_current_timezone(value): """ When time zone support is enabled, convert naive datetimes entered in the current time zone to aware datetimes. """ if settings.USE_TZ and value is not None and timezone.is_naive(value): current_timezone = timezone.get_current_timezone() try: ...
[ "def", "from_current_timezone", "(", "value", ")", ":", "if", "settings", ".", "USE_TZ", "and", "value", "is", "not", "None", "and", "timezone", ".", "is_naive", "(", "value", ")", ":", "current_timezone", "=", "timezone", ".", "get_current_timezone", "(", "...
[ 160, 0 ]
[ 181, 16 ]
python
en
['en', 'error', 'th']
False