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
_init_worker
(counter)
Switch to databases dedicated to this worker. This helper lives at module-level because of the multiprocessing module's requirements.
Switch to databases dedicated to this worker.
def _init_worker(counter): """ Switch to databases dedicated to this worker. This helper lives at module-level because of the multiprocessing module's requirements. """ global _worker_id with counter.get_lock(): counter.value += 1 _worker_id = counter.value for alias ...
[ "def", "_init_worker", "(", "counter", ")", ":", "global", "_worker_id", "with", "counter", ".", "get_lock", "(", ")", ":", "counter", ".", "value", "+=", "1", "_worker_id", "=", "counter", ".", "value", "for", "alias", "in", "connections", ":", "connectio...
[ 312, 0 ]
[ 334, 26 ]
python
en
['en', 'error', 'th']
False
_run_subsuite
(args)
Run a suite of tests with a RemoteTestRunner and return a RemoteTestResult. This helper lives at module-level and its arguments are wrapped in a tuple because of the multiprocessing module's requirements.
Run a suite of tests with a RemoteTestRunner and return a RemoteTestResult.
def _run_subsuite(args): """ Run a suite of tests with a RemoteTestRunner and return a RemoteTestResult. This helper lives at module-level and its arguments are wrapped in a tuple because of the multiprocessing module's requirements. """ runner_class, subsuite_index, subsuite, failfast = args ...
[ "def", "_run_subsuite", "(", "args", ")", ":", "runner_class", ",", "subsuite_index", ",", "subsuite", ",", "failfast", "=", "args", "runner", "=", "runner_class", "(", "failfast", "=", "failfast", ")", "result", "=", "runner", ".", "run", "(", "subsuite", ...
[ 337, 0 ]
[ 347, 40 ]
python
en
['en', 'error', 'th']
False
is_discoverable
(label)
Check if a test label points to a Python package or file directory. Relative labels like "." and ".." are seen as directories.
Check if a test label points to a Python package or file directory.
def is_discoverable(label): """ Check if a test label points to a Python package or file directory. Relative labels like "." and ".." are seen as directories. """ try: mod = import_module(label) except (ImportError, TypeError): pass else: return hasattr(mod, '__path_...
[ "def", "is_discoverable", "(", "label", ")", ":", "try", ":", "mod", "=", "import_module", "(", "label", ")", "except", "(", "ImportError", ",", "TypeError", ")", ":", "pass", "else", ":", "return", "hasattr", "(", "mod", ",", "'__path__'", ")", "return"...
[ 746, 0 ]
[ 759, 48 ]
python
en
['en', 'error', 'th']
False
reorder_suite
(suite, classes, reverse=False)
Reorder a test suite by test type. `classes` is a sequence of types All tests of type classes[0] are placed first, then tests of type classes[1], etc. Tests with no match in classes are placed last. If `reverse` is True, sort tests within classes in opposite order but don't reverse test clas...
Reorder a test suite by test type.
def reorder_suite(suite, classes, reverse=False): """ Reorder a test suite by test type. `classes` is a sequence of types All tests of type classes[0] are placed first, then tests of type classes[1], etc. Tests with no match in classes are placed last. If `reverse` is True, sort tests within ...
[ "def", "reorder_suite", "(", "suite", ",", "classes", ",", "reverse", "=", "False", ")", ":", "class_count", "=", "len", "(", "classes", ")", "suite_class", "=", "type", "(", "suite", ")", "bins", "=", "[", "OrderedSet", "(", ")", "for", "i", "in", "...
[ 762, 0 ]
[ 781, 26 ]
python
en
['en', 'error', 'th']
False
partition_suite_by_type
(suite, classes, bins, reverse=False)
Partition a test suite by test type. Also prevent duplicated tests. classes is a sequence of types bins is a sequence of TestSuites, one more than classes reverse changes the ordering of tests within bins Tests of type classes[i] are added to bins[i], tests with no match found in classes are ...
Partition a test suite by test type. Also prevent duplicated tests.
def partition_suite_by_type(suite, classes, bins, reverse=False): """ Partition a test suite by test type. Also prevent duplicated tests. classes is a sequence of types bins is a sequence of TestSuites, one more than classes reverse changes the ordering of tests within bins Tests of type class...
[ "def", "partition_suite_by_type", "(", "suite", ",", "classes", ",", "bins", ",", "reverse", "=", "False", ")", ":", "suite_class", "=", "type", "(", "suite", ")", "if", "reverse", ":", "suite", "=", "reversed", "(", "tuple", "(", "suite", ")", ")", "f...
[ 784, 0 ]
[ 807, 34 ]
python
en
['en', 'error', 'th']
False
partition_suite_by_case
(suite)
Partition a test suite by test case, preserving the order of tests.
Partition a test suite by test case, preserving the order of tests.
def partition_suite_by_case(suite): """Partition a test suite by test case, preserving the order of tests.""" groups = [] suite_class = type(suite) for test_type, test_group in itertools.groupby(suite, type): if issubclass(test_type, unittest.TestCase): groups.append(suite_class(test...
[ "def", "partition_suite_by_case", "(", "suite", ")", ":", "groups", "=", "[", "]", "suite_class", "=", "type", "(", "suite", ")", "for", "test_type", ",", "test_group", "in", "itertools", ".", "groupby", "(", "suite", ",", "type", ")", ":", "if", "issubc...
[ 810, 0 ]
[ 820, 17 ]
python
en
['en', 'en', 'en']
True
RemoteTestResult._confirm_picklable
(self, obj)
Confirm that obj can be pickled and unpickled as multiprocessing will need to pickle the exception in the child process and unpickle it in the parent process. Let the exception rise, if not.
Confirm that obj can be pickled and unpickled as multiprocessing will need to pickle the exception in the child process and unpickle it in the parent process. Let the exception rise, if not.
def _confirm_picklable(self, obj): """ Confirm that obj can be pickled and unpickled as multiprocessing will need to pickle the exception in the child process and unpickle it in the parent process. Let the exception rise, if not. """ pickle.loads(pickle.dumps(obj))
[ "def", "_confirm_picklable", "(", "self", ",", "obj", ")", ":", "pickle", ".", "loads", "(", "pickle", ".", "dumps", "(", "obj", ")", ")" ]
[ 135, 4 ]
[ 141, 39 ]
python
en
['en', 'error', 'th']
False
ParallelTestSuite.run
(self, result)
Distribute test cases across workers. Return an identifier of each test case with its result in order to use imap_unordered to show results as soon as they're available. To minimize pickling errors when getting results from workers: - pass back numeric indexes in self.subsuit...
Distribute test cases across workers.
def run(self, result): """ Distribute test cases across workers. Return an identifier of each test case with its result in order to use imap_unordered to show results as soon as they're available. To minimize pickling errors when getting results from workers: - pass ba...
[ "def", "run", "(", "self", ",", "result", ")", ":", "counter", "=", "multiprocessing", ".", "Value", "(", "ctypes", ".", "c_int", ",", "0", ")", "pool", "=", "multiprocessing", ".", "Pool", "(", "processes", "=", "self", ".", "processes", ",", "initial...
[ 377, 4 ]
[ 429, 21 ]
python
en
['en', 'error', 'th']
False
DiscoverRunner.teardown_databases
(self, old_config, **kwargs)
Destroy all the non-mirror databases.
Destroy all the non-mirror databases.
def teardown_databases(self, old_config, **kwargs): """Destroy all the non-mirror databases.""" _teardown_databases( old_config, verbosity=self.verbosity, parallel=self.parallel, keepdb=self.keepdb, )
[ "def", "teardown_databases", "(", "self", ",", "old_config", ",", "*", "*", "kwargs", ")", ":", "_teardown_databases", "(", "old_config", ",", "verbosity", "=", "self", ".", "verbosity", ",", "parallel", "=", "self", ".", "parallel", ",", "keepdb", "=", "s...
[ 671, 4 ]
[ 678, 9 ]
python
en
['en', 'en', 'en']
True
DiscoverRunner.run_tests
(self, test_labels, extra_tests=None, **kwargs)
Run the unit tests for all the test labels in the provided list. Test labels should be dotted Python paths to test modules, test classes, or test methods. A list of 'extra' tests may also be provided; these tests will be added to the test suite. Return the number of t...
Run the unit tests for all the test labels in the provided list.
def run_tests(self, test_labels, extra_tests=None, **kwargs): """ Run the unit tests for all the test labels in the provided list. Test labels should be dotted Python paths to test modules, test classes, or test methods. A list of 'extra' tests may also be provided; these tests...
[ "def", "run_tests", "(", "self", ",", "test_labels", ",", "extra_tests", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "setup_test_environment", "(", ")", "suite", "=", "self", ".", "build_suite", "(", "test_labels", ",", "extra_tests", ")",...
[ 708, 4 ]
[ 743, 47 ]
python
en
['en', 'error', 'th']
False
DatabaseOperations.fetch_returned_insert_rows
(self, cursor)
Given a cursor object that has just performed an INSERT...RETURNING statement into a table, return the tuple of returned data.
Given a cursor object that has just performed an INSERT...RETURNING statement into a table, return the tuple of returned data.
def fetch_returned_insert_rows(self, cursor): """ Given a cursor object that has just performed an INSERT...RETURNING statement into a table, return the tuple of returned data. """ return cursor.fetchall()
[ "def", "fetch_returned_insert_rows", "(", "self", ",", "cursor", ")", ":", "return", "cursor", ".", "fetchall", "(", ")" ]
[ 144, 4 ]
[ 149, 32 ]
python
en
['en', 'error', 'th']
False
DatabaseOperations.force_no_ordering
(self)
"ORDER BY NULL" prevents MySQL from implicitly ordering by grouped columns. If no ordering would otherwise be applied, we don't want any implicit sorting going on.
"ORDER BY NULL" prevents MySQL from implicitly ordering by grouped columns. If no ordering would otherwise be applied, we don't want any implicit sorting going on.
def force_no_ordering(self): """ "ORDER BY NULL" prevents MySQL from implicitly ordering by grouped columns. If no ordering would otherwise be applied, we don't want any implicit sorting going on. """ return [(None, ("NULL", [], False))]
[ "def", "force_no_ordering", "(", "self", ")", ":", "return", "[", "(", "None", ",", "(", "\"NULL\"", ",", "[", "]", ",", "False", ")", ")", "]" ]
[ 154, 4 ]
[ 160, 44 ]
python
en
['en', 'error', 'th']
False
MyPredictor.__init__
(self, model)
Stores artifacts for prediction. Only initialized via `from_path`.
Stores artifacts for prediction. Only initialized via `from_path`.
def __init__(self, model): """Stores artifacts for prediction. Only initialized via `from_path`. """ self._model = model
[ "def", "__init__", "(", "self", ",", "model", ")", ":", "self", ".", "_model", "=", "model" ]
[ 7, 4 ]
[ 10, 27 ]
python
en
['en', 'en', 'en']
True
MyPredictor.predict
(self, instances, **kwargs)
Performs custom prediction. Preprocesses inputs, then performs prediction using the trained scikit-learn model. Args: instances: A list of prediction input instances. **kwargs: A dictionary of keyword args provided as additional fields on the predict req...
Performs custom prediction.
def predict(self, instances, **kwargs): """Performs custom prediction. Preprocesses inputs, then performs prediction using the trained scikit-learn model. Args: instances: A list of prediction input instances. **kwargs: A dictionary of keyword args provided as a...
[ "def", "predict", "(", "self", ",", "instances", ",", "*", "*", "kwargs", ")", ":", "inputs", "=", "np", ".", "asarray", "(", "instances", ")", "outputs", "=", "self", ".", "_model", ".", "predict_proba", "(", "inputs", ")", "return", "outputs", ".", ...
[ 12, 4 ]
[ 28, 31 ]
python
en
['sl', 'sr', 'en']
False
MyPredictor.from_path
(cls, model_dir)
Creates an instance of MyPredictor using the given path. This loads artifacts that have been copied from your model directory in Cloud Storage. MyPredictor uses them during prediction. Args: model_dir: The local directory that contains the trained scikit-learn model...
Creates an instance of MyPredictor using the given path.
def from_path(cls, model_dir): """Creates an instance of MyPredictor using the given path. This loads artifacts that have been copied from your model directory in Cloud Storage. MyPredictor uses them during prediction. Args: model_dir: The local directory that contains the ...
[ "def", "from_path", "(", "cls", ",", "model_dir", ")", ":", "model_path", "=", "os", ".", "path", ".", "join", "(", "model_dir", ",", "'model.pkl'", ")", "with", "open", "(", "model_path", ",", "'rb'", ")", "as", "f", ":", "model", "=", "pickle", "."...
[ 31, 4 ]
[ 51, 25 ]
python
en
['en', 'en', 'en']
True
Command.sync_apps
(self, connection, app_labels)
Run the old syncdb-style operation on a list of app_labels.
Run the old syncdb-style operation on a list of app_labels.
def sync_apps(self, connection, app_labels): """Run the old syncdb-style operation on a list of app_labels.""" with connection.cursor() as cursor: tables = connection.introspection.table_names(cursor) # Build the manifest of apps and models that are to be synchronized. all_m...
[ "def", "sync_apps", "(", "self", ",", "connection", ",", "app_labels", ")", ":", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "tables", "=", "connection", ".", "introspection", ".", "table_names", "(", "cursor", ")", "# Build the manif...
[ 305, 4 ]
[ 352, 64 ]
python
en
['en', 'en', 'en']
True
Command.describe_operation
(operation, backwards)
Return a string that describes a migration operation for --plan.
Return a string that describes a migration operation for --plan.
def describe_operation(operation, backwards): """Return a string that describes a migration operation for --plan.""" prefix = '' is_error = False if hasattr(operation, 'code'): code = operation.reverse_code if backwards else operation.code action = (code.__doc__ o...
[ "def", "describe_operation", "(", "operation", ",", "backwards", ")", ":", "prefix", "=", "''", "is_error", "=", "False", "if", "hasattr", "(", "operation", ",", "'code'", ")", ":", "code", "=", "operation", ".", "reverse_code", "if", "backwards", "else", ...
[ 355, 4 ]
[ 376, 76 ]
python
en
['en', 'en', 'en']
True
run
(argv=None)
The main function which creates the pipeline and runs it.
The main function which creates the pipeline and runs it.
def run(argv=None): """The main function which creates the pipeline and runs it.""" parser = argparse.ArgumentParser() # Add the arguments needed for this specific Dataflow job. parser.add_argument( '--input', dest='input', required=True, help='Input file to read. This can be a local f...
[ "def", "run", "(", "argv", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "# Add the arguments needed for this specific Dataflow job.", "parser", ".", "add_argument", "(", "'--input'", ",", "dest", "=", "'input'", ",", "required...
[ 61, 0 ]
[ 114, 93 ]
python
en
['en', 'en', 'en']
True
RowTransformer.parse
(self, row)
This method translates a single delimited record into a dictionary which can be loaded into BigQuery. It also adds filename and load_dt fields to the dictionary.
This method translates a single delimited record into a dictionary which can be loaded into BigQuery. It also adds filename and load_dt fields to the dictionary.
def parse(self, row): """This method translates a single delimited record into a dictionary which can be loaded into BigQuery. It also adds filename and load_dt fields to the dictionary.""" # Strip out the return characters and quote characters. values = re.split(self.delimiter,...
[ "def", "parse", "(", "self", ",", "row", ")", ":", "# Strip out the return characters and quote characters.", "values", "=", "re", ".", "split", "(", "self", ".", "delimiter", ",", "re", ".", "sub", "(", "r'[\\r\\n\"]'", ",", "''", ",", "row", ")", ")", "r...
[ 42, 4 ]
[ 58, 18 ]
python
en
['en', 'en', 'en']
True
RandomRec.__init__
(self, train_file, test_file, uniform=True, output_file=None, sep='\t', output_sep='\t', random_seed=None)
Random recommendation for Rating Prediction This algorithm predicts ratings for each user-item Usage:: >> RandomRec(train, test).compute() :param train_file: File which contains the train set. This file needs to have at least 3 columns (user item feedba...
Random recommendation for Rating Prediction This algorithm predicts ratings for each user-item Usage:: >> RandomRec(train, test).compute() :param train_file: File which contains the train set. This file needs to have at least 3 columns (user item feedba...
def __init__(self, train_file, test_file, uniform=True, output_file=None, sep='\t', output_sep='\t', random_seed=None): """ Random recommendation for Rating Prediction This algorithm predicts ratings for each user-item Usage:: >> RandomRec(train, test).compute() ...
[ "def", "__init__", "(", "self", ",", "train_file", ",", "test_file", ",", "uniform", "=", "True", ",", "output_file", "=", "None", ",", "sep", "=", "'\\t'", ",", "output_sep", "=", "'\\t'", ",", "random_seed", "=", "None", ")", ":", "super", "(", "Rand...
[ 19, 4 ]
[ 66, 52 ]
python
en
['en', 'ja', 'th']
False
RandomRec.compute
(self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t')
Extends compute method from BaseRatingPrediction. Method to run recommender algorithm :param verbose: Print recommender and database information :type verbose: bool, default True :param metrics: List of evaluation measures :type metrics: list, default None :p...
Extends compute method from BaseRatingPrediction. Method to run recommender algorithm :param verbose: Print recommender and database information :type verbose: bool, default True :param metrics: List of evaluation measures :type metrics: list, default None :p...
def compute(self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t'): """ Extends compute method from BaseRatingPrediction. Method to run recommender algorithm :param verbose: Print recommender and database information :type verbose: bool, default ...
[ "def", "compute", "(", "self", ",", "verbose", "=", "True", ",", "metrics", "=", "None", ",", "verbose_evaluation", "=", "True", ",", "as_table", "=", "False", ",", "table_sep", "=", "'\\t'", ")", ":", "super", "(", "RandomRec", ",", "self", ")", ".", ...
[ 90, 4 ]
[ 123, 94 ]
python
en
['en', 'ja', 'th']
False
abort
(status, *args, **kwargs)
Raises an :py:exc:`HTTPException` for the given status code or WSGI application:: abort(404) # 404 Not Found abort(Response('Hello World')) Can be passed a WSGI application or a status code. If a status code is given it's looked up in the list of exceptions and will raise that except...
Raises an :py:exc:`HTTPException` for the given status code or WSGI application::
def abort(status, *args, **kwargs): """Raises an :py:exc:`HTTPException` for the given status code or WSGI application:: abort(404) # 404 Not Found abort(Response('Hello World')) Can be passed a WSGI application or a status code. If a status code is given it's looked up in the list o...
[ "def", "abort", "(", "status", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "_aborter", "(", "status", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 755, 0 ]
[ 771, 44 ]
python
en
['en', 'en', 'en']
True
MethodNotAllowed.__init__
(self, valid_methods=None, description=None)
Takes an optional list of valid http methods starting with werkzeug 0.3 the list will be mandatory.
Takes an optional list of valid http methods starting with werkzeug 0.3 the list will be mandatory.
def __init__(self, valid_methods=None, description=None): """Takes an optional list of valid http methods starting with werkzeug 0.3 the list will be mandatory.""" HTTPException.__init__(self, description) self.valid_methods = valid_methods
[ "def", "__init__", "(", "self", ",", "valid_methods", "=", "None", ",", "description", "=", "None", ")", ":", "HTTPException", ".", "__init__", "(", "self", ",", "description", ")", "self", ".", "valid_methods", "=", "valid_methods" ]
[ 347, 4 ]
[ 351, 42 ]
python
en
['en', 'en', 'en']
True
RequestedRangeNotSatisfiable.__init__
(self, length=None, units="bytes", description=None)
Takes an optional `Content-Range` header value based on ``length`` parameter.
Takes an optional `Content-Range` header value based on ``length`` parameter.
def __init__(self, length=None, units="bytes", description=None): """Takes an optional `Content-Range` header value based on ``length`` parameter. """ HTTPException.__init__(self, description) self.length = length self.units = units
[ "def", "__init__", "(", "self", ",", "length", "=", "None", ",", "units", "=", "\"bytes\"", ",", "description", "=", "None", ")", ":", "HTTPException", ".", "__init__", "(", "self", ",", "description", ")", "self", ".", "length", "=", "length", "self", ...
[ 496, 4 ]
[ 502, 26 ]
python
en
['en', 'en', 'en']
True
before_nothing
(retry_state: "RetryCallState")
Before call strategy that does nothing.
Before call strategy that does nothing.
def before_nothing(retry_state: "RetryCallState") -> None: """Before call strategy that does nothing."""
[ "def", "before_nothing", "(", "retry_state", ":", "\"RetryCallState\"", ")", "->", "None", ":" ]
[ 26, 0 ]
[ 27, 49 ]
python
en
['en', 'en', 'en']
True
before_log
(logger: "logging.Logger", log_level: int)
Before call strategy that logs to some logger the attempt.
Before call strategy that logs to some logger the attempt.
def before_log(logger: "logging.Logger", log_level: int) -> typing.Callable[["RetryCallState"], None]: """Before call strategy that logs to some logger the attempt.""" def log_it(retry_state: "RetryCallState") -> None: logger.log( log_level, f"Starting call to '{_utils.get_callb...
[ "def", "before_log", "(", "logger", ":", "\"logging.Logger\"", ",", "log_level", ":", "int", ")", "->", "typing", ".", "Callable", "[", "[", "\"RetryCallState\"", "]", ",", "None", "]", ":", "def", "log_it", "(", "retry_state", ":", "\"RetryCallState\"", ")"...
[ 30, 0 ]
[ 40, 17 ]
python
en
['en', 'en', 'en']
True
CurrentThreadExecutor.run_until_future
(self, future)
Runs the code in the work queue until a result is available from the future. Should be run from the thread the executor is initialised in.
Runs the code in the work queue until a result is available from the future. Should be run from the thread the executor is initialised in.
def run_until_future(self, future): """ Runs the code in the work queue until a result is available from the future. Should be run from the thread the executor is initialised in. """ # Check we're in the right thread if threading.current_thread() != self._work_thread: ...
[ "def", "run_until_future", "(", "self", ",", "future", ")", ":", "# Check we're in the right thread", "if", "threading", ".", "current_thread", "(", ")", "!=", "self", ".", "_work_thread", ":", "raise", "RuntimeError", "(", "\"You cannot run CurrentThreadExecutor from a...
[ 42, 4 ]
[ 64, 31 ]
python
en
['en', 'error', 'th']
False
Wheel.__init__
(self, filename: str)
:raises InvalidWheelFilename: when the filename is invalid for a wheel
:raises InvalidWheelFilename: when the filename is invalid for a wheel
def __init__(self, filename: str) -> None: """ :raises InvalidWheelFilename: when the filename is invalid for a wheel """ wheel_info = self.wheel_file_re.match(filename) if not wheel_info: raise InvalidWheelFilename( f"{filename} is not a valid wheel f...
[ "def", "__init__", "(", "self", ",", "filename", ":", "str", ")", "->", "None", ":", "wheel_info", "=", "self", ".", "wheel_file_re", ".", "match", "(", "filename", ")", "if", "not", "wheel_info", ":", "raise", "InvalidWheelFilename", "(", "f\"{filename} is ...
[ 21, 4 ]
[ 44, 9 ]
python
en
['en', 'error', 'th']
False
Wheel.get_formatted_file_tags
(self)
Return the wheel's tags as a sorted list of strings.
Return the wheel's tags as a sorted list of strings.
def get_formatted_file_tags(self) -> List[str]: """Return the wheel's tags as a sorted list of strings.""" return sorted(str(tag) for tag in self.file_tags)
[ "def", "get_formatted_file_tags", "(", "self", ")", "->", "List", "[", "str", "]", ":", "return", "sorted", "(", "str", "(", "tag", ")", "for", "tag", "in", "self", ".", "file_tags", ")" ]
[ 46, 4 ]
[ 48, 57 ]
python
en
['en', 'en', 'en']
True
Wheel.support_index_min
(self, tags: List[Tag])
Return the lowest index that one of the wheel's file_tag combinations achieves in the given list of supported tags. For example, if there are 8 supported tags and one of the file tags is first in the list, then return 0. :param tags: the PEP 425 tags to check the wheel against, in orde...
Return the lowest index that one of the wheel's file_tag combinations achieves in the given list of supported tags.
def support_index_min(self, tags: List[Tag]) -> int: """Return the lowest index that one of the wheel's file_tag combinations achieves in the given list of supported tags. For example, if there are 8 supported tags and one of the file tags is first in the list, then return 0. :...
[ "def", "support_index_min", "(", "self", ",", "tags", ":", "List", "[", "Tag", "]", ")", "->", "int", ":", "return", "min", "(", "tags", ".", "index", "(", "tag", ")", "for", "tag", "in", "self", ".", "file_tags", "if", "tag", "in", "tags", ")" ]
[ 50, 4 ]
[ 63, 76 ]
python
en
['en', 'en', 'en']
True
Wheel.find_most_preferred_tag
( self, tags: List[Tag], tag_to_priority: Dict[Tag, int] )
Return the priority of the most preferred tag that one of the wheel's file tag combinations achieves in the given list of supported tags using the given tag_to_priority mapping, where lower priorities are more-preferred. This is used in place of support_index_min in some cases in order to avoid...
Return the priority of the most preferred tag that one of the wheel's file tag combinations achieves in the given list of supported tags using the given tag_to_priority mapping, where lower priorities are more-preferred.
def find_most_preferred_tag( self, tags: List[Tag], tag_to_priority: Dict[Tag, int] ) -> int: """Return the priority of the most preferred tag that one of the wheel's file tag combinations achieves in the given list of supported tags using the given tag_to_priority mapping, where low...
[ "def", "find_most_preferred_tag", "(", "self", ",", "tags", ":", "List", "[", "Tag", "]", ",", "tag_to_priority", ":", "Dict", "[", "Tag", ",", "int", "]", ")", "->", "int", ":", "return", "min", "(", "tag_to_priority", "[", "tag", "]", "for", "tag", ...
[ 65, 4 ]
[ 84, 9 ]
python
en
['en', 'en', 'en']
True
Wheel.supported
(self, tags: Iterable[Tag])
Return whether the wheel is compatible with one of the given tags. :param tags: the PEP 425 tags to check the wheel against.
Return whether the wheel is compatible with one of the given tags.
def supported(self, tags: Iterable[Tag]) -> bool: """Return whether the wheel is compatible with one of the given tags. :param tags: the PEP 425 tags to check the wheel against. """ return not self.file_tags.isdisjoint(tags)
[ "def", "supported", "(", "self", ",", "tags", ":", "Iterable", "[", "Tag", "]", ")", "->", "bool", ":", "return", "not", "self", ".", "file_tags", ".", "isdisjoint", "(", "tags", ")" ]
[ 86, 4 ]
[ 91, 50 ]
python
en
['en', 'en', 'en']
True
dc
(result, reference)
r""" Dice coefficient Computes the Dice coefficient (also known as Sorensen index) between the binary objects in two images. The metric is defined as .. math:: DC=\frac{2|A\cap B|}{|A|+|B|} , where :math:`A` is the first and :math:`B` the second set of samples (here: binary objects)...
r""" Dice coefficient
def dc(result, reference): r""" Dice coefficient Computes the Dice coefficient (also known as Sorensen index) between the binary objects in two images. The metric is defined as .. math:: DC=\frac{2|A\cap B|}{|A|+|B|} , where :math:`A` is the first and :math:`B` the second set of...
[ "def", "dc", "(", "result", ",", "reference", ")", ":", "result", "=", "np", ".", "atleast_1d", "(", "result", ".", "astype", "(", "np", ".", "bool", ")", ")", "reference", "=", "np", ".", "atleast_1d", "(", "reference", ".", "astype", "(", "np", "...
[ 14, 0 ]
[ 61, 13 ]
python
cy
['en', 'cy', 'hi']
False
jc
(result, reference)
Jaccard coefficient Computes the Jaccard coefficient between the binary objects in two images. Parameters ---------- result: array_like Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere else. referen...
Jaccard coefficient
def jc(result, reference): """ Jaccard coefficient Computes the Jaccard coefficient between the binary objects in two images. Parameters ---------- result: array_like Input data containing objects. Can be any type but will be converted into binary: background where 0, o...
[ "def", "jc", "(", "result", ",", "reference", ")", ":", "result", "=", "np", ".", "atleast_1d", "(", "result", ".", "astype", "(", "np", ".", "bool", ")", ")", "reference", "=", "np", ".", "atleast_1d", "(", "reference", ".", "astype", "(", "np", "...
[ 64, 0 ]
[ 97, 13 ]
python
en
['en', 'error', 'th']
False
precision
(result, reference)
Precison. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere else. reference : array_like Input data containing objects. Can be any type but will be converted ...
Precison.
def precision(result, reference): """ Precison. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere else. reference : array_like Input data containing objects. C...
[ "def", "precision", "(", "result", ",", "reference", ")", ":", "result", "=", "np", ".", "atleast_1d", "(", "result", ".", "astype", "(", "np", ".", "bool", ")", ")", "reference", "=", "np", ".", "atleast_1d", "(", "reference", ".", "astype", "(", "n...
[ 100, 0 ]
[ 145, 20 ]
python
en
['en', 'error', 'th']
False
recall
(result, reference)
Recall. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere else. reference : array_like Input data containing objects. Can be any type but will be converted ...
Recall.
def recall(result, reference): """ Recall. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere else. reference : array_like Input data containing objects. Can be...
[ "def", "recall", "(", "result", ",", "reference", ")", ":", "result", "=", "np", ".", "atleast_1d", "(", "result", ".", "astype", "(", "np", ".", "bool", ")", ")", "reference", "=", "np", ".", "atleast_1d", "(", "reference", ".", "astype", "(", "np",...
[ 148, 0 ]
[ 193, 17 ]
python
en
['en', 'error', 'th']
False
sensitivity
(result, reference)
Sensitivity. Same as :func:`recall`, see there for a detailed description. See also -------- :func:`specificity`
Sensitivity. Same as :func:`recall`, see there for a detailed description.
def sensitivity(result, reference): """ Sensitivity. Same as :func:`recall`, see there for a detailed description. See also -------- :func:`specificity` """ return recall(result, reference)
[ "def", "sensitivity", "(", "result", ",", "reference", ")", ":", "return", "recall", "(", "result", ",", "reference", ")" ]
[ 196, 0 ]
[ 205, 36 ]
python
en
['en', 'error', 'th']
False
specificity
(result, reference)
Specificity. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere else. reference : array_like Input data containing objects. Can be any type but will be converted ...
Specificity.
def specificity(result, reference): """ Specificity. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere else. reference : array_like Input data containing objec...
[ "def", "specificity", "(", "result", ",", "reference", ")", ":", "result", "=", "np", ".", "atleast_1d", "(", "result", ".", "astype", "(", "np", ".", "bool", ")", ")", "reference", "=", "np", ".", "atleast_1d", "(", "reference", ".", "astype", "(", ...
[ 208, 0 ]
[ 253, 22 ]
python
en
['en', 'error', 'th']
False
true_negative_rate
(result, reference)
True negative rate. Same as :func:`sensitivity`, see there for a detailed description. See also -------- :func:`true_positive_rate` :func:`positive_predictive_value`
True negative rate. Same as :func:`sensitivity`, see there for a detailed description.
def true_negative_rate(result, reference): """ True negative rate. Same as :func:`sensitivity`, see there for a detailed description. See also -------- :func:`true_positive_rate` :func:`positive_predictive_value` """ return sensitivity(result, reference)
[ "def", "true_negative_rate", "(", "result", ",", "reference", ")", ":", "return", "sensitivity", "(", "result", ",", "reference", ")" ]
[ 256, 0 ]
[ 266, 41 ]
python
en
['en', 'error', 'th']
False
true_positive_rate
(result, reference)
True positive rate. Same as :func:`recall`, see there for a detailed description. See also -------- :func:`positive_predictive_value` :func:`true_negative_rate`
True positive rate. Same as :func:`recall`, see there for a detailed description.
def true_positive_rate(result, reference): """ True positive rate. Same as :func:`recall`, see there for a detailed description. See also -------- :func:`positive_predictive_value` :func:`true_negative_rate` """ return recall(result, reference)
[ "def", "true_positive_rate", "(", "result", ",", "reference", ")", ":", "return", "recall", "(", "result", ",", "reference", ")" ]
[ 269, 0 ]
[ 279, 36 ]
python
en
['en', 'error', 'th']
False
positive_predictive_value
(result, reference)
Positive predictive value. Same as :func:`precision`, see there for a detailed description. See also -------- :func:`true_positive_rate` :func:`true_negative_rate`
Positive predictive value. Same as :func:`precision`, see there for a detailed description.
def positive_predictive_value(result, reference): """ Positive predictive value. Same as :func:`precision`, see there for a detailed description. See also -------- :func:`true_positive_rate` :func:`true_negative_rate` """ return precision(result, reference)
[ "def", "positive_predictive_value", "(", "result", ",", "reference", ")", ":", "return", "precision", "(", "result", ",", "reference", ")" ]
[ 282, 0 ]
[ 292, 39 ]
python
en
['en', 'error', 'th']
False
hd
(result, reference, voxelspacing=None, connectivity=1)
Hausdorff Distance. Computes the (symmetric) Hausdorff Distance (HD) between the binary objects in two images. It is defined as the maximum surface distance between the objects. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be conver...
Hausdorff Distance.
def hd(result, reference, voxelspacing=None, connectivity=1): """ Hausdorff Distance. Computes the (symmetric) Hausdorff Distance (HD) between the binary objects in two images. It is defined as the maximum surface distance between the objects. Parameters ---------- result : array_like ...
[ "def", "hd", "(", "result", ",", "reference", ",", "voxelspacing", "=", "None", ",", "connectivity", "=", "1", ")", ":", "hd1", "=", "__surface_distances", "(", "result", ",", "reference", ",", "voxelspacing", ",", "connectivity", ")", ".", "max", "(", "...
[ 295, 0 ]
[ 340, 13 ]
python
en
['en', 'error', 'th']
False
assd
(result, reference, voxelspacing=None, connectivity=1)
Average symmetric surface distance. Computes the average symmetric surface distance (ASD) between the binary objects in two images. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be converted into binary: background where 0, o...
Average symmetric surface distance.
def assd(result, reference, voxelspacing=None, connectivity=1): """ Average symmetric surface distance. Computes the average symmetric surface distance (ASD) between the binary objects in two images. Parameters ---------- result : array_like Input data containing objects. Can be an...
[ "def", "assd", "(", "result", ",", "reference", ",", "voxelspacing", "=", "None", ",", "connectivity", "=", "1", ")", ":", "assd", "=", "np", ".", "mean", "(", "(", "asd", "(", "result", ",", "reference", ",", "voxelspacing", ",", "connectivity", ")", ...
[ 343, 0 ]
[ 396, 15 ]
python
en
['en', 'error', 'th']
False
asd
(result, reference, voxelspacing=None, connectivity=1)
Average surface distance metric. Computes the average surface distance (ASD) between the binary objects in two images. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere ...
Average surface distance metric.
def asd(result, reference, voxelspacing=None, connectivity=1): """ Average surface distance metric. Computes the average surface distance (ASD) between the binary objects in two images. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be...
[ "def", "asd", "(", "result", ",", "reference", ",", "voxelspacing", "=", "None", ",", "connectivity", "=", "1", ")", ":", "sds", "=", "__surface_distances", "(", "result", ",", "reference", ",", "voxelspacing", ",", "connectivity", ")", "asd", "=", "sds", ...
[ 399, 0 ]
[ 506, 14 ]
python
en
['en', 'error', 'th']
False
ravd
(result, reference)
Relative absolute volume difference. Compute the relative absolute volume difference between the (joined) binary objects in the two images. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be converted into binary: background wh...
Relative absolute volume difference.
def ravd(result, reference): """ Relative absolute volume difference. Compute the relative absolute volume difference between the (joined) binary objects in the two images. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be converte...
[ "def", "ravd", "(", "result", ",", "reference", ")", ":", "result", "=", "np", ".", "atleast_1d", "(", "result", ".", "astype", "(", "np", ".", "bool", ")", ")", "reference", "=", "np", ".", "atleast_1d", "(", "reference", ".", "astype", "(", "np", ...
[ 509, 0 ]
[ 594, 38 ]
python
en
['en', 'error', 'th']
False
volume_correlation
(results, references)
r""" Volume correlation. Computes the linear correlation in binary object volume between the contents of the successive binary images supplied. Measured through the Pearson product-moment correlation coefficient. Parameters ---------- results : sequence of array_like Ordered list o...
r""" Volume correlation.
def volume_correlation(results, references): r""" Volume correlation. Computes the linear correlation in binary object volume between the contents of the successive binary images supplied. Measured through the Pearson product-moment correlation coefficient. Parameters ---------- result...
[ "def", "volume_correlation", "(", "results", ",", "references", ")", ":", "results", "=", "np", ".", "atleast_2d", "(", "np", ".", "array", "(", "results", ")", ".", "astype", "(", "np", ".", "bool", ")", ")", "references", "=", "np", ".", "atleast_2d"...
[ 597, 0 ]
[ 629, 56 ]
python
cy
['en', 'cy', 'hi']
False
volume_change_correlation
(results, references)
r""" Volume change correlation. Computes the linear correlation of change in binary object volume between the contents of the successive binary images supplied. Measured through the Pearson product-moment correlation coefficient. Parameters ---------- results : sequence of array_like ...
r""" Volume change correlation.
def volume_change_correlation(results, references): r""" Volume change correlation. Computes the linear correlation of change in binary object volume between the contents of the successive binary images supplied. Measured through the Pearson product-moment correlation coefficient. Parameters ...
[ "def", "volume_change_correlation", "(", "results", ",", "references", ")", ":", "results", "=", "np", ".", "atleast_2d", "(", "np", ".", "array", "(", "results", ")", ".", "astype", "(", "np", ".", "bool", ")", ")", "references", "=", "np", ".", "atle...
[ 632, 0 ]
[ 668, 47 ]
python
cy
['en', 'cy', 'hi']
False
obj_assd
(result, reference, voxelspacing=None, connectivity=1)
Average symmetric surface distance. Computes the average symmetric surface distance (ASSD) between the binary objects in two images. Parameters ---------- result : array_like Input data containing objects. Can be any type but will be converted into binary: background where 0, ...
Average symmetric surface distance.
def obj_assd(result, reference, voxelspacing=None, connectivity=1): """ Average symmetric surface distance. Computes the average symmetric surface distance (ASSD) between the binary objects in two images. Parameters ---------- result : array_like Input data containing objects. Can ...
[ "def", "obj_assd", "(", "result", ",", "reference", ",", "voxelspacing", "=", "None", ",", "connectivity", "=", "1", ")", ":", "assd", "=", "np", ".", "mean", "(", "(", "obj_asd", "(", "result", ",", "reference", ",", "voxelspacing", ",", "connectivity",...
[ 671, 0 ]
[ 724, 15 ]
python
en
['en', 'error', 'th']
False
obj_asd
(result, reference, voxelspacing=None, connectivity=1)
Average surface distance between objects. First correspondences between distinct binary objects in reference and result are established. Then the average surface distance is only computed between corresponding objects. Correspondence is defined as unique and at least one voxel overlap. Parameters...
Average surface distance between objects.
def obj_asd(result, reference, voxelspacing=None, connectivity=1): """ Average surface distance between objects. First correspondences between distinct binary objects in reference and result are established. Then the average surface distance is only computed between corresponding objects. Correspon...
[ "def", "obj_asd", "(", "result", ",", "reference", ",", "voxelspacing", "=", "None", ",", "connectivity", "=", "1", ")", ":", "sds", "=", "list", "(", ")", "labelmap1", ",", "labelmap2", ",", "_a", ",", "_b", ",", "mapping", "=", "__distinct_binary_objec...
[ 727, 0 ]
[ 867, 14 ]
python
en
['en', 'error', 'th']
False
obj_fpr
(result, reference, connectivity=1)
The false positive rate of distinct binary object detection. The false positive rates gives a percentage measure of how many distinct binary objects in the second array do not exists in the first array. A partial overlap (of minimum one voxel) is here considered sufficient. In cases where two dis...
The false positive rate of distinct binary object detection.
def obj_fpr(result, reference, connectivity=1): """ The false positive rate of distinct binary object detection. The false positive rates gives a percentage measure of how many distinct binary objects in the second array do not exists in the first array. A partial overlap (of minimum one voxel) is ...
[ "def", "obj_fpr", "(", "result", ",", "reference", ",", "connectivity", "=", "1", ")", ":", "_", ",", "_", ",", "_", ",", "n_obj_reference", ",", "mapping", "=", "__distinct_binary_object_correspondences", "(", "reference", ",", "result", ",", "connectivity", ...
[ 870, 0 ]
[ 979, 68 ]
python
en
['en', 'error', 'th']
False
obj_tpr
(result, reference, connectivity=1)
The true positive rate of distinct binary object detection. The true positive rates gives a percentage measure of how many distinct binary objects in the first array also exists in the second array. A partial overlap (of minimum one voxel) is here considered sufficient. In cases where two distinc...
The true positive rate of distinct binary object detection.
def obj_tpr(result, reference, connectivity=1): """ The true positive rate of distinct binary object detection. The true positive rates gives a percentage measure of how many distinct binary objects in the first array also exists in the second array. A partial overlap (of minimum one voxel) is here...
[ "def", "obj_tpr", "(", "result", ",", "reference", ",", "connectivity", "=", "1", ")", ":", "_", ",", "_", ",", "n_obj_result", ",", "_", ",", "mapping", "=", "__distinct_binary_object_correspondences", "(", "reference", ",", "result", ",", "connectivity", "...
[ 982, 0 ]
[ 1090, 45 ]
python
en
['en', 'error', 'th']
False
__distinct_binary_object_correspondences
(reference, result, connectivity=1)
Determines all distinct (where connectivity is defined by the connectivity parameter passed to scipy's `generate_binary_structure`) binary objects in both of the input parameters and returns a 1to1 mapping from the labelled objects in reference to the corresponding (whereas a one-voxel overlap suffices...
Determines all distinct (where connectivity is defined by the connectivity parameter passed to scipy's `generate_binary_structure`) binary objects in both of the input parameters and returns a 1to1 mapping from the labelled objects in reference to the corresponding (whereas a one-voxel overlap suffices...
def __distinct_binary_object_correspondences(reference, result, connectivity=1): """ Determines all distinct (where connectivity is defined by the connectivity parameter passed to scipy's `generate_binary_structure`) binary objects in both of the input parameters and returns a 1to1 mapping from the labe...
[ "def", "__distinct_binary_object_correspondences", "(", "reference", ",", "result", ",", "connectivity", "=", "1", ")", ":", "result", "=", "np", ".", "atleast_1d", "(", "result", ".", "astype", "(", "np", ".", "bool", ")", ")", "reference", "=", "np", "."...
[ 1093, 0 ]
[ 1148, 71 ]
python
en
['en', 'error', 'th']
False
__surface_distances
(result, reference, voxelspacing=None, connectivity=1)
The distances between the surface voxel of binary objects in result and their nearest partner surface voxel of a binary object in reference.
The distances between the surface voxel of binary objects in result and their nearest partner surface voxel of a binary object in reference.
def __surface_distances(result, reference, voxelspacing=None, connectivity=1): """ The distances between the surface voxel of binary objects in result and their nearest partner surface voxel of a binary object in reference. """ result = np.atleast_1d(result.astype(np.bool)) reference = np.atleas...
[ "def", "__surface_distances", "(", "result", ",", "reference", ",", "voxelspacing", "=", "None", ",", "connectivity", "=", "1", ")", ":", "result", "=", "np", ".", "atleast_1d", "(", "result", ".", "astype", "(", "np", ".", "bool", ")", ")", "reference",...
[ 1151, 0 ]
[ 1183, 14 ]
python
en
['en', 'error', 'th']
False
__combine_windows
(w1, w2)
Joins two windows (defined by tuple of slices) such that their maximum combined extend is covered by the new returned window.
Joins two windows (defined by tuple of slices) such that their maximum combined extend is covered by the new returned window.
def __combine_windows(w1, w2): """ Joins two windows (defined by tuple of slices) such that their maximum combined extend is covered by the new returned window. """ res = [] for s1, s2 in zip(w1, w2): res.append(slice(min(s1.start, s2.start), max(s1.stop, s2.stop))) return tuple(res)
[ "def", "__combine_windows", "(", "w1", ",", "w2", ")", ":", "res", "=", "[", "]", "for", "s1", ",", "s2", "in", "zip", "(", "w1", ",", "w2", ")", ":", "res", ".", "append", "(", "slice", "(", "min", "(", "s1", ".", "start", ",", "s2", ".", ...
[ 1186, 0 ]
[ 1194, 21 ]
python
en
['en', 'error', 'th']
False
LineString.__init__
(self, *args, **kwargs)
Initialize on the given sequence -- may take lists, tuples, NumPy arrays of X,Y pairs, or Point objects. If Point objects are used, ownership is _not_ transferred to the LineString object. Examples: ls = LineString((1, 1), (2, 2)) ls = LineString([(1, 1), (2, 2)]) ...
Initialize on the given sequence -- may take lists, tuples, NumPy arrays of X,Y pairs, or Point objects. If Point objects are used, ownership is _not_ transferred to the LineString object.
def __init__(self, *args, **kwargs): """ Initialize on the given sequence -- may take lists, tuples, NumPy arrays of X,Y pairs, or Point objects. If Point objects are used, ownership is _not_ transferred to the LineString object. Examples: ls = LineString((1, 1), (2, 2...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# If only one argument provided, set the coords array appropriately", "if", "len", "(", "args", ")", "==", "1", ":", "coords", "=", "args", "[", "0", "]", "else", ":", "c...
[ 13, 4 ]
[ 89, 60 ]
python
en
['en', 'error', 'th']
False
LineString.__iter__
(self)
Allow iteration over this LineString.
Allow iteration over this LineString.
def __iter__(self): "Allow iteration over this LineString." for i in range(len(self)): yield self[i]
[ "def", "__iter__", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ")", ")", ":", "yield", "self", "[", "i", "]" ]
[ 91, 4 ]
[ 94, 25 ]
python
en
['en', 'en', 'en']
True
LineString.__len__
(self)
Return the number of points in this LineString.
Return the number of points in this LineString.
def __len__(self): "Return the number of points in this LineString." return len(self._cs)
[ "def", "__len__", "(", "self", ")", ":", "return", "len", "(", "self", ".", "_cs", ")" ]
[ 96, 4 ]
[ 98, 28 ]
python
en
['en', 'en', 'en']
True
LineString.tuple
(self)
Return a tuple version of the geometry from the coordinate sequence.
Return a tuple version of the geometry from the coordinate sequence.
def tuple(self): "Return a tuple version of the geometry from the coordinate sequence." return self._cs.tuple
[ "def", "tuple", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "tuple" ]
[ 135, 4 ]
[ 137, 29 ]
python
en
['en', 'en', 'en']
True
LineString._listarr
(self, func)
Return a sequence (list) corresponding with the given function. Return a numpy array if possible.
Return a sequence (list) corresponding with the given function. Return a numpy array if possible.
def _listarr(self, func): """ Return a sequence (list) corresponding with the given function. Return a numpy array if possible. """ lst = [func(i) for i in range(len(self))] if numpy: return numpy.array(lst) # ARRRR! else: return lst
[ "def", "_listarr", "(", "self", ",", "func", ")", ":", "lst", "=", "[", "func", "(", "i", ")", "for", "i", "in", "range", "(", "len", "(", "self", ")", ")", "]", "if", "numpy", ":", "return", "numpy", ".", "array", "(", "lst", ")", "# ARRRR!", ...
[ 140, 4 ]
[ 149, 22 ]
python
en
['en', 'error', 'th']
False
LineString.array
(self)
Return a numpy array for the LineString.
Return a numpy array for the LineString.
def array(self): "Return a numpy array for the LineString." return self._listarr(self._cs.__getitem__)
[ "def", "array", "(", "self", ")", ":", "return", "self", ".", "_listarr", "(", "self", ".", "_cs", ".", "__getitem__", ")" ]
[ 152, 4 ]
[ 154, 50 ]
python
en
['en', 'en', 'en']
True
LineString.x
(self)
Return a list or numpy array of the X variable.
Return a list or numpy array of the X variable.
def x(self): "Return a list or numpy array of the X variable." return self._listarr(self._cs.getX)
[ "def", "x", "(", "self", ")", ":", "return", "self", ".", "_listarr", "(", "self", ".", "_cs", ".", "getX", ")" ]
[ 157, 4 ]
[ 159, 43 ]
python
en
['en', 'ga', 'en']
True
LineString.y
(self)
Return a list or numpy array of the Y variable.
Return a list or numpy array of the Y variable.
def y(self): "Return a list or numpy array of the Y variable." return self._listarr(self._cs.getY)
[ "def", "y", "(", "self", ")", ":", "return", "self", ".", "_listarr", "(", "self", ".", "_cs", ".", "getY", ")" ]
[ 162, 4 ]
[ 164, 43 ]
python
en
['en', 'en', 'en']
True
LineString.z
(self)
Return a list or numpy array of the Z variable.
Return a list or numpy array of the Z variable.
def z(self): "Return a list or numpy array of the Z variable." if not self.hasz: return None else: return self._listarr(self._cs.getZ)
[ "def", "z", "(", "self", ")", ":", "if", "not", "self", ".", "hasz", ":", "return", "None", "else", ":", "return", "self", ".", "_listarr", "(", "self", ".", "_cs", ".", "getZ", ")" ]
[ 167, 4 ]
[ 172, 47 ]
python
en
['en', 'ga', 'en']
True
CacheAdapter.get
(self, public_id, type, resource_type, transformation, format)
Gets value specified by parameters :param public_id: The public ID of the resource :param type: The storage type :param resource_type: The type of the resource :param transformation: The transformation string :param format: The format of the...
Gets value specified by parameters
def get(self, public_id, type, resource_type, transformation, format): """ Gets value specified by parameters :param public_id: The public ID of the resource :param type: The storage type :param resource_type: The type of the resource :param transforma...
[ "def", "get", "(", "self", ",", "public_id", ",", "type", ",", "resource_type", ",", "transformation", ",", "format", ")", ":", "raise", "NotImplementedError" ]
[ 10, 4 ]
[ 22, 33 ]
python
en
['en', 'error', 'th']
False
CacheAdapter.set
(self, public_id, type, resource_type, transformation, format, value)
Sets value specified by parameters :param public_id: The public ID of the resource :param type: The storage type :param resource_type: The type of the resource :param transformation: The transformation string :param format: The format of the...
Sets value specified by parameters
def set(self, public_id, type, resource_type, transformation, format, value): """ Sets value specified by parameters :param public_id: The public ID of the resource :param type: The storage type :param resource_type: The type of the resource :param tra...
[ "def", "set", "(", "self", ",", "public_id", ",", "type", ",", "resource_type", ",", "transformation", ",", "format", ",", "value", ")", ":", "raise", "NotImplementedError" ]
[ 25, 4 ]
[ 38, 33 ]
python
en
['en', 'error', 'th']
False
CacheAdapter.delete
(self, public_id, type, resource_type, transformation, format)
Deletes entry specified by parameters :param public_id: The public ID of the resource :param type: The storage type :param resource_type: The type of the resource :param transformation: The transformation string :param format: The format of ...
Deletes entry specified by parameters
def delete(self, public_id, type, resource_type, transformation, format): """ Deletes entry specified by parameters :param public_id: The public ID of the resource :param type: The storage type :param resource_type: The type of the resource :param tran...
[ "def", "delete", "(", "self", ",", "public_id", ",", "type", ",", "resource_type", ",", "transformation", ",", "format", ")", ":", "raise", "NotImplementedError" ]
[ 41, 4 ]
[ 53, 33 ]
python
en
['en', 'error', 'th']
False
CacheAdapter.flush_all
(self)
Flushes all entries from cache :return: bool True on success or False on failure
Flushes all entries from cache
def flush_all(self): """ Flushes all entries from cache :return: bool True on success or False on failure """ raise NotImplementedError
[ "def", "flush_all", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 56, 4 ]
[ 62, 33 ]
python
en
['en', 'error', 'th']
False
formset_factory
(form, formset=BaseFormSet, extra=1, can_order=False, can_delete=False, max_num=None, validate_max=False, min_num=None, validate_min=False, absolute_max=None, can_delete_extra=True)
Return a FormSet for the given form class.
Return a FormSet for the given form class.
def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False, can_delete=False, max_num=None, validate_max=False, min_num=None, validate_min=False, absolute_max=None, can_delete_extra=True): """Return a FormSet for the given form class.""" i...
[ "def", "formset_factory", "(", "form", ",", "formset", "=", "BaseFormSet", ",", "extra", "=", "1", ",", "can_order", "=", "False", ",", "can_delete", "=", "False", ",", "max_num", "=", "None", ",", "validate_max", "=", "False", ",", "min_num", "=", "None...
[ 459, 0 ]
[ 489, 61 ]
python
en
['en', 'en', 'en']
True
all_valid
(formsets)
Validate every formset and return True if all are valid.
Validate every formset and return True if all are valid.
def all_valid(formsets): """Validate every formset and return True if all are valid.""" # List comprehension ensures is_valid() is called for all formsets. return all([formset.is_valid() for formset in formsets])
[ "def", "all_valid", "(", "formsets", ")", ":", "# List comprehension ensures is_valid() is called for all formsets.", "return", "all", "(", "[", "formset", ".", "is_valid", "(", ")", "for", "formset", "in", "formsets", "]", ")" ]
[ 492, 0 ]
[ 495, 60 ]
python
en
['en', 'en', 'en']
True
make_model_tuple
(model)
Take a model or a string of the form "app_label.ModelName" and return a corresponding ("app_label", "modelname") tuple. If a tuple is passed in, assume it's a valid model tuple already and return it unchanged.
Take a model or a string of the form "app_label.ModelName" and return a corresponding ("app_label", "modelname") tuple. If a tuple is passed in, assume it's a valid model tuple already and return it unchanged.
def make_model_tuple(model): """ Take a model or a string of the form "app_label.ModelName" and return a corresponding ("app_label", "modelname") tuple. If a tuple is passed in, assume it's a valid model tuple already and return it unchanged. """ try: if isinstance(model, tuple): ...
[ "def", "make_model_tuple", "(", "model", ")", ":", "try", ":", "if", "isinstance", "(", "model", ",", "tuple", ")", ":", "model_tuple", "=", "model", "elif", "isinstance", "(", "model", ",", "str", ")", ":", "app_label", ",", "model_name", "=", "model", ...
[ 4, 0 ]
[ 24, 9 ]
python
en
['en', 'error', 'th']
False
resolve_callables
(mapping)
Generate key/value pairs for the given mapping where the values are evaluated if they're callable.
Generate key/value pairs for the given mapping where the values are evaluated if they're callable.
def resolve_callables(mapping): """ Generate key/value pairs for the given mapping where the values are evaluated if they're callable. """ for k, v in mapping.items(): yield k, v() if callable(v) else v
[ "def", "resolve_callables", "(", "mapping", ")", ":", "for", "k", ",", "v", "in", "mapping", ".", "items", "(", ")", ":", "yield", "k", ",", "v", "(", ")", "if", "callable", "(", "v", ")", "else", "v" ]
[ 27, 0 ]
[ 33, 42 ]
python
en
['en', 'error', 'th']
False
EmailBackend.send_messages
(self, email_messages)
Write all messages to the stream in a thread-safe way.
Write all messages to the stream in a thread-safe way.
def send_messages(self, email_messages): """Write all messages to the stream in a thread-safe way.""" if not email_messages: return msg_count = 0 with self._lock: try: stream_created = self.open() for message in email_messages: ...
[ "def", "send_messages", "(", "self", ",", "email_messages", ")", ":", "if", "not", "email_messages", ":", "return", "msg_count", "=", "0", "with", "self", ".", "_lock", ":", "try", ":", "stream_created", "=", "self", ".", "open", "(", ")", "for", "messag...
[ 24, 4 ]
[ 41, 24 ]
python
en
['en', 'en', 'en']
True
DatabaseWrapper.disable_constraint_checking
(self)
Disable foreign key checks, primarily for use in adding rows with forward references. Always return True to indicate constraint checks need to be re-enabled.
Disable foreign key checks, primarily for use in adding rows with forward references. Always return True to indicate constraint checks need to be re-enabled.
def disable_constraint_checking(self): """ Disable foreign key checks, primarily for use in adding rows with forward references. Always return True to indicate constraint checks need to be re-enabled. """ with self.cursor() as cursor: cursor.execute('SET forei...
[ "def", "disable_constraint_checking", "(", "self", ")", ":", "with", "self", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "'SET foreign_key_checks=0'", ")", "return", "True" ]
[ 273, 4 ]
[ 281, 19 ]
python
en
['en', 'error', 'th']
False
DatabaseWrapper.enable_constraint_checking
(self)
Re-enable foreign key checks after they have been disabled.
Re-enable foreign key checks after they have been disabled.
def enable_constraint_checking(self): """ Re-enable foreign key checks after they have been disabled. """ # Override needs_rollback in case constraint_checks_disabled is # nested inside transaction.atomic. self.needs_rollback, needs_rollback = False, self.needs_rollback ...
[ "def", "enable_constraint_checking", "(", "self", ")", ":", "# Override needs_rollback in case constraint_checks_disabled is", "# nested inside transaction.atomic.", "self", ".", "needs_rollback", ",", "needs_rollback", "=", "False", ",", "self", ".", "needs_rollback", "try", ...
[ 283, 4 ]
[ 294, 48 ]
python
en
['en', 'error', 'th']
False
DatabaseWrapper.check_constraints
(self, table_names=None)
Check each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows with invalid references were entered while constraint ...
Check each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows with invalid references were entered while constraint ...
def check_constraints(self, table_names=None): """ Check each table name in `table_names` for rows with invalid foreign key references. This method is intended to be used in conjunction with `disable_constraint_checking()` and `enable_constraint_checking()`, to determine if rows ...
[ "def", "check_constraints", "(", "self", ",", "table_names", "=", "None", ")", ":", "with", "self", ".", "cursor", "(", ")", "as", "cursor", ":", "if", "table_names", "is", "None", ":", "table_names", "=", "self", ".", "introspection", ".", "table_names", ...
[ 296, 4 ]
[ 334, 25 ]
python
en
['en', 'error', 'th']
False
DatabaseWrapper.check_constraints
(self, table_names=None)
Check constraints by setting them to immediate. Return them to deferred afterward.
Check constraints by setting them to immediate. Return them to deferred afterward.
def check_constraints(self, table_names=None): """ Check constraints by setting them to immediate. Return them to deferred afterward. """ with self.cursor() as cursor: cursor.execute('SET CONSTRAINTS ALL IMMEDIATE') cursor.execute('SET CONSTRAINTS ALL DEFE...
[ "def", "check_constraints", "(", "self", ",", "table_names", "=", "None", ")", ":", "with", "self", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "'SET CONSTRAINTS ALL IMMEDIATE'", ")", "cursor", ".", "execute", "(", "'SET CONS...
[ 278, 4 ]
[ 285, 58 ]
python
en
['en', 'error', 'th']
False
update_proxy_model_permissions
(apps, schema_editor, reverse=False)
Update the content_type of proxy model permissions to use the ContentType of the proxy model.
Update the content_type of proxy model permissions to use the ContentType of the proxy model.
def update_proxy_model_permissions(apps, schema_editor, reverse=False): """ Update the content_type of proxy model permissions to use the ContentType of the proxy model. """ style = color_style() Permission = apps.get_model('auth', 'Permission') ContentType = apps.get_model('contenttypes', '...
[ "def", "update_proxy_model_permissions", "(", "apps", ",", "schema_editor", ",", "reverse", "=", "False", ")", ":", "style", "=", "color_style", "(", ")", "Permission", "=", "apps", ".", "get_model", "(", "'auth'", ",", "'Permission'", ")", "ContentType", "=",...
[ 16, 0 ]
[ 50, 102 ]
python
en
['en', 'error', 'th']
False
revert_proxy_model_permissions
(apps, schema_editor)
Update the content_type of proxy model permissions to use the ContentType of the concrete model.
Update the content_type of proxy model permissions to use the ContentType of the concrete model.
def revert_proxy_model_permissions(apps, schema_editor): """ Update the content_type of proxy model permissions to use the ContentType of the concrete model. """ update_proxy_model_permissions(apps, schema_editor, reverse=True)
[ "def", "revert_proxy_model_permissions", "(", "apps", ",", "schema_editor", ")", ":", "update_proxy_model_permissions", "(", "apps", ",", "schema_editor", ",", "reverse", "=", "True", ")" ]
[ 53, 0 ]
[ 58, 69 ]
python
en
['en', 'error', 'th']
False
StatementSplitter._reset
(self)
Set the filter attributes to its default values
Set the filter attributes to its default values
def _reset(self): """Set the filter attributes to its default values""" self._in_declare = False self._is_create = False self._begin_depth = 0 self.consume_ws = False self.tokens = [] self.level = 0
[ "def", "_reset", "(", "self", ")", ":", "self", ".", "_in_declare", "=", "False", "self", ".", "_is_create", "=", "False", "self", ".", "_begin_depth", "=", "0", "self", ".", "consume_ws", "=", "False", "self", ".", "tokens", "=", "[", "]", "self", "...
[ 16, 4 ]
[ 24, 22 ]
python
en
['en', 'en', 'en']
True
StatementSplitter._change_splitlevel
(self, ttype, value)
Get the new split level (increase, decrease or remain equal)
Get the new split level (increase, decrease or remain equal)
def _change_splitlevel(self, ttype, value): """Get the new split level (increase, decrease or remain equal)""" # parenthesis increase/decrease a level if ttype is T.Punctuation and value == '(': return 1 elif ttype is T.Punctuation and value == ')': return -1 ...
[ "def", "_change_splitlevel", "(", "self", ",", "ttype", ",", "value", ")", ":", "# parenthesis increase/decrease a level", "if", "ttype", "is", "T", ".", "Punctuation", "and", "value", "==", "'('", ":", "return", "1", "elif", "ttype", "is", "T", ".", "Punctu...
[ 26, 4 ]
[ 76, 16 ]
python
en
['en', 'en', 'en']
True
StatementSplitter.process
(self, stream)
Process the stream
Process the stream
def process(self, stream): """Process the stream""" EOS_TTYPE = T.Whitespace, T.Comment.Single # Run over all stream tokens for ttype, value in stream: # Yield token if we finished a statement and there's no whitespaces # It will count newline token as a non whit...
[ "def", "process", "(", "self", ",", "stream", ")", ":", "EOS_TTYPE", "=", "T", ".", "Whitespace", ",", "T", ".", "Comment", ".", "Single", "# Run over all stream tokens", "for", "ttype", ",", "value", "in", "stream", ":", "# Yield token if we finished a statemen...
[ 78, 4 ]
[ 106, 44 ]
python
en
['en', 'zh', 'en']
True
build_networks
( state_shape, action_size, learning_rate, critic_weight, hidden_neurons, entropy)
Creates Actor Critic Neural Networks. Creates a two hidden-layer Policy Gradient Neural Network. The loss function is altered to be a log-likelihood function weighted by an action's advantage. Args: space_shape: a tuple of ints representing the observation space. action_size (int): the...
Creates Actor Critic Neural Networks.
def build_networks( state_shape, action_size, learning_rate, critic_weight, hidden_neurons, entropy): """Creates Actor Critic Neural Networks. Creates a two hidden-layer Policy Gradient Neural Network. The loss function is altered to be a log-likelihood function weighted by an action's ...
[ "def", "build_networks", "(", "state_shape", ",", "action_size", ",", "learning_rate", ",", "critic_weight", ",", "hidden_neurons", ",", "entropy", ")", ":", "state_input", "=", "layers", ".", "Input", "(", "state_shape", ",", "name", "=", "'frames'", ")", "ad...
[ 30, 0 ]
[ 74, 32 ]
python
en
['en', 'en', 'en']
True
Memory.add
(self, experience)
Adds an experience into the memory buffer. Args: experience: (state, action, reward, state_prime_value, done) tuple.
Adds an experience into the memory buffer.
def add(self, experience): """Adds an experience into the memory buffer. Args: experience: (state, action, reward, state_prime_value, done) tuple. """ self.buffer.append(experience)
[ "def", "add", "(", "self", ",", "experience", ")", ":", "self", ".", "buffer", ".", "append", "(", "experience", ")" ]
[ 89, 4 ]
[ 95, 38 ]
python
en
['en', 'en', 'en']
True
Memory.sample
(self)
Returns formated experiences and clears the buffer. Returns: (list): A tuple of lists with structure [ [states], [actions], [rewards], [state_prime_values], [dones] ]
Returns formated experiences and clears the buffer.
def sample(self): """Returns formated experiences and clears the buffer. Returns: (list): A tuple of lists with structure [ [states], [actions], [rewards], [state_prime_values], [dones] ] """ # Columns have different data types, so numpy array wou...
[ "def", "sample", "(", "self", ")", ":", "# Columns have different data types, so numpy array would be awkward.", "batch", "=", "np", ".", "array", "(", "self", ".", "buffer", ")", ".", "T", ".", "tolist", "(", ")", "states_mb", "=", "np", ".", "array", "(", ...
[ 100, 4 ]
[ 116, 68 ]
python
en
['en', 'en', 'en']
True
Agent.__init__
(self, actor, critic, policy, memory, action_size)
Initializes the agent with DQN and memory sub-classes. Args: network: A neural network created from deep_q_network(). memory: A Memory class object. epsilon_decay (float): The rate at which to decay random actions. action_size (int): The number of possible action...
Initializes the agent with DQN and memory sub-classes.
def __init__(self, actor, critic, policy, memory, action_size): """Initializes the agent with DQN and memory sub-classes. Args: network: A neural network created from deep_q_network(). memory: A Memory class object. epsilon_decay (float): The rate at which to decay r...
[ "def", "__init__", "(", "self", ",", "actor", ",", "critic", ",", "policy", ",", "memory", ",", "action_size", ")", ":", "self", ".", "actor", "=", "actor", "self", ".", "critic", "=", "critic", "self", ".", "policy", "=", "policy", "self", ".", "act...
[ 121, 4 ]
[ 134, 28 ]
python
en
['en', 'en', 'en']
True
Agent.act
(self, state)
Selects an action for the agent to take given a game state. Args: state (list of numbers): The state of the environment to act on. traning (bool): True if the agent is training. Returns: (int) The index of the action to take.
Selects an action for the agent to take given a game state.
def act(self, state): """Selects an action for the agent to take given a game state. Args: state (list of numbers): The state of the environment to act on. traning (bool): True if the agent is training. Returns: (int) The index of the action to take. ...
[ "def", "act", "(", "self", ",", "state", ")", ":", "# If not acting randomly, take action with highest predicted value.", "state_batch", "=", "np", ".", "expand_dims", "(", "state", ",", "axis", "=", "0", ")", "probabilities", "=", "self", ".", "policy", ".", "p...
[ 136, 4 ]
[ 150, 21 ]
python
en
['en', 'en', 'en']
True
Agent.learn
(self)
Trains the Deep Q Network based on stored experiences.
Trains the Deep Q Network based on stored experiences.
def learn(self): """Trains the Deep Q Network based on stored experiences.""" gamma = self.memory.gamma experiences = self.memory.sample() state_mb, action_mb, reward_mb, dones_mb, next_value = experiences # One hot enocde actions actions = np.zeros([len(action_mb), self...
[ "def", "learn", "(", "self", ")", ":", "gamma", "=", "self", ".", "memory", ".", "gamma", "experiences", "=", "self", ".", "memory", ".", "sample", "(", ")", "state_mb", ",", "action_mb", ",", "reward_mb", ",", "dones_mb", ",", "next_value", "=", "expe...
[ 152, 4 ]
[ 167, 59 ]
python
en
['en', 'en', 'en']
True
observations_to_float_rgb
(scene: np.ndarray, user_input: Tuple[Tuple[int, int], ...] = (), is_solved: Optional[bool] = None)
Convert an observation as returned by a simulator to an image.
Convert an observation as returned by a simulator to an image.
def observations_to_float_rgb(scene: np.ndarray, user_input: Tuple[Tuple[int, int], ...] = (), is_solved: Optional[bool] = None) -> np.ndarray: """Convert an observation as returned by a simulator to an image.""" return _to_float(observations_to_uint8_...
[ "def", "observations_to_float_rgb", "(", "scene", ":", "np", ".", "ndarray", ",", "user_input", ":", "Tuple", "[", "Tuple", "[", "int", ",", "int", "]", ",", "...", "]", "=", "(", ")", ",", "is_solved", ":", "Optional", "[", "bool", "]", "=", "None",...
[ 56, 0 ]
[ 60, 77 ]
python
en
['en', 'en', 'en']
True
observations_to_uint8_rgb
(scene: np.ndarray, user_input: Tuple[Tuple[int, int], ...] = (), is_solved: Optional[bool] = None)
Convert an observation as returned by a simulator to an image.
Convert an observation as returned by a simulator to an image.
def observations_to_uint8_rgb(scene: np.ndarray, user_input: Tuple[Tuple[int, int], ...] = (), is_solved: Optional[bool] = None) -> np.ndarray: """Convert an observation as returned by a simulator to an image.""" base_image = WAD_COLORS[scene] for ...
[ "def", "observations_to_uint8_rgb", "(", "scene", ":", "np", ".", "ndarray", ",", "user_input", ":", "Tuple", "[", "Tuple", "[", "int", ",", "int", "]", ",", "...", "]", "=", "(", ")", ",", "is_solved", ":", "Optional", "[", "bool", "]", "=", "None",...
[ 63, 0 ]
[ 79, 21 ]
python
en
['en', 'en', 'en']
True
save_observation_series_to_gif
(batched_observation_series_rows, fpath, solved_states=None, solved_wrt_step=False, pad_frames=True, fps=10)
Saves a list of arrays of intermediate scenes as a gif. Args: batched_observation_series_rows: [[[video1, video2, ..., videoB]], (B = batch size) [another row of frames, typically corresponding to earlier one] ] Each video is TxHxW, in the PHYRE format (not R...
Saves a list of arrays of intermediate scenes as a gif. Args: batched_observation_series_rows: [[[video1, video2, ..., videoB]], (B = batch size) [another row of frames, typically corresponding to earlier one] ] Each video is TxHxW, in the PHYRE format (not R...
def save_observation_series_to_gif(batched_observation_series_rows, fpath, solved_states=None, solved_wrt_step=False, pad_frames=True, fps=10): ...
[ "def", "save_observation_series_to_gif", "(", "batched_observation_series_rows", ",", "fpath", ",", "solved_states", "=", "None", ",", "solved_wrt_step", "=", "False", ",", "pad_frames", "=", "True", ",", "fps", "=", "10", ")", ":", "max_steps", "=", "max", "(",...
[ 92, 0 ]
[ 135, 50 ]
python
en
['en', 'en', 'en']
True
compose_gifs_compact
(input_fpathes, output_fpath)
Create progressin for first and last frames over time.
Create progressin for first and last frames over time.
def compose_gifs_compact(input_fpathes, output_fpath): """Create progressin for first and last frames over time.""" first_and_last_per_batch_id = [] for fname in input_fpathes: data = imageio.mimread(fname) data = np.concatenate([data[0], data[-1]], axis=0) first_and_last_per_batch_i...
[ "def", "compose_gifs_compact", "(", "input_fpathes", ",", "output_fpath", ")", ":", "first_and_last_per_batch_id", "=", "[", "]", "for", "fname", "in", "input_fpathes", ":", "data", "=", "imageio", ".", "mimread", "(", "fname", ")", "data", "=", "np", ".", "...
[ 138, 0 ]
[ 146, 67 ]
python
en
['en', 'en', 'en']
True
compose_gifs
(input_fpathes, output_fpath)
Concatenate and sync all gifs.
Concatenate and sync all gifs.
def compose_gifs(input_fpathes, output_fpath): """Concatenate and sync all gifs.""" all_data = [] for fname in input_fpathes: all_data.append(imageio.mimread(fname)) max_timestamps = max(len(data) for data in all_data) def _pad(data): return data + [data[-1]] * (max_timestamps - len...
[ "def", "compose_gifs", "(", "input_fpathes", ",", "output_fpath", ")", ":", "all_data", "=", "[", "]", "for", "fname", "in", "input_fpathes", ":", "all_data", ".", "append", "(", "imageio", ".", "mimread", "(", "fname", ")", ")", "max_timestamps", "=", "ma...
[ 149, 0 ]
[ 160, 44 ]
python
en
['en', 'en', 'en']
True
timesince
(d, now=None, reversed=False, time_strings=None, depth=2)
Take two datetime objects and return the time between d and now as a nicely formatted string, e.g. "10 minutes". If d occurs after now, return "0 minutes". Units used are years, months, weeks, days, hours, and minutes. Seconds and microseconds are ignored. Up to `depth` adjacent units will be ...
Take two datetime objects and return the time between d and now as a nicely formatted string, e.g. "10 minutes". If d occurs after now, return "0 minutes".
def timesince(d, now=None, reversed=False, time_strings=None, depth=2): """ Take two datetime objects and return the time between d and now as a nicely formatted string, e.g. "10 minutes". If d occurs after now, return "0 minutes". Units used are years, months, weeks, days, hours, and minutes. ...
[ "def", "timesince", "(", "d", ",", "now", "=", "None", ",", "reversed", "=", "False", ",", "time_strings", "=", "None", ",", "depth", "=", "2", ")", ":", "if", "time_strings", "is", "None", ":", "time_strings", "=", "TIME_STRINGS", "if", "depth", "<=",...
[ 26, 0 ]
[ 93, 37 ]
python
en
['en', 'error', 'th']
False
timeuntil
(d, now=None, time_strings=None, depth=2)
Like timesince, but return a string measuring the time until the given time.
Like timesince, but return a string measuring the time until the given time.
def timeuntil(d, now=None, time_strings=None, depth=2): """ Like timesince, but return a string measuring the time until the given time. """ return timesince(d, now, reversed=True, time_strings=time_strings, depth=depth)
[ "def", "timeuntil", "(", "d", ",", "now", "=", "None", ",", "time_strings", "=", "None", ",", "depth", "=", "2", ")", ":", "return", "timesince", "(", "d", ",", "now", ",", "reversed", "=", "True", ",", "time_strings", "=", "time_strings", ",", "dept...
[ 96, 0 ]
[ 100, 83 ]
python
en
['en', 'error', 'th']
False
compress_kml
(kml)
Return compressed KMZ from the given KML string.
Return compressed KMZ from the given KML string.
def compress_kml(kml): "Return compressed KMZ from the given KML string." kmz = BytesIO() with zipfile.ZipFile(kmz, 'a', zipfile.ZIP_DEFLATED) as zf: zf.writestr('doc.kml', kml.encode(settings.DEFAULT_CHARSET)) kmz.seek(0) return kmz.read()
[ "def", "compress_kml", "(", "kml", ")", ":", "kmz", "=", "BytesIO", "(", ")", "with", "zipfile", ".", "ZipFile", "(", "kmz", ",", "'a'", ",", "zipfile", ".", "ZIP_DEFLATED", ")", "as", "zf", ":", "zf", ".", "writestr", "(", "'doc.kml'", ",", "kml", ...
[ 14, 0 ]
[ 20, 21 ]
python
en
['en', 'en', 'en']
True
render_to_kml
(*args, **kwargs)
Render the response as KML (using the correct MIME type).
Render the response as KML (using the correct MIME type).
def render_to_kml(*args, **kwargs): "Render the response as KML (using the correct MIME type)." return HttpResponse( loader.render_to_string(*args, **kwargs), content_type='application/vnd.google-earth.kml+xml', )
[ "def", "render_to_kml", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "HttpResponse", "(", "loader", ".", "render_to_string", "(", "*", "args", ",", "*", "*", "kwargs", ")", ",", "content_type", "=", "'application/vnd.google-earth.kml+xml'", ...
[ 23, 0 ]
[ 28, 5 ]
python
en
['en', 'en', 'en']
True
render_to_kmz
(*args, **kwargs)
Compress the KML content and return as KMZ (using the correct MIME type).
Compress the KML content and return as KMZ (using the correct MIME type).
def render_to_kmz(*args, **kwargs): """ Compress the KML content and return as KMZ (using the correct MIME type). """ return HttpResponse( compress_kml(loader.render_to_string(*args, **kwargs)), content_type='application/vnd.google-earth.kmz', )
[ "def", "render_to_kmz", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "HttpResponse", "(", "compress_kml", "(", "loader", ".", "render_to_string", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")", ",", "content_type", "=", "'applicati...
[ 31, 0 ]
[ 39, 5 ]
python
en
['en', 'error', 'th']
False
BitString.asNumbers
(self)
Get |ASN.1| value as a sequence of 8-bit integers. If |ASN.1| object length is not a multiple of 8, result will be left-padded with zeros.
Get |ASN.1| value as a sequence of 8-bit integers.
def asNumbers(self): """Get |ASN.1| value as a sequence of 8-bit integers. If |ASN.1| object length is not a multiple of 8, result will be left-padded with zeros. """ return tuple(octets.octs2ints(self.asOctets()))
[ "def", "asNumbers", "(", "self", ")", ":", "return", "tuple", "(", "octets", ".", "octs2ints", "(", "self", ".", "asOctets", "(", ")", ")", ")" ]
[ 564, 4 ]
[ 570, 55 ]
python
en
['en', 'lb', 'en']
True
BitString.asOctets
(self)
Get |ASN.1| value as a sequence of octets. If |ASN.1| object length is not a multiple of 8, result will be left-padded with zeros.
Get |ASN.1| value as a sequence of octets.
def asOctets(self): """Get |ASN.1| value as a sequence of octets. If |ASN.1| object length is not a multiple of 8, result will be left-padded with zeros. """ return integer.to_bytes(self._value, length=len(self))
[ "def", "asOctets", "(", "self", ")", ":", "return", "integer", ".", "to_bytes", "(", "self", ".", "_value", ",", "length", "=", "len", "(", "self", ")", ")" ]
[ 572, 4 ]
[ 578, 62 ]
python
en
['en', 'en', 'en']
True
BitString.asInteger
(self)
Get |ASN.1| value as a single integer value.
Get |ASN.1| value as a single integer value.
def asInteger(self): """Get |ASN.1| value as a single integer value. """ return self._value
[ "def", "asInteger", "(", "self", ")", ":", "return", "self", ".", "_value" ]
[ 580, 4 ]
[ 583, 26 ]
python
en
['en', 'sv', 'en']
True