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
LineString._listarr
(self, func)
Internal routine that returns a sequence (list) corresponding with the given function.
Internal routine that returns a sequence (list) corresponding with the given function.
def _listarr(self, func): """ Internal routine that returns a sequence (list) corresponding with the given function. """ return [func(self.ptr, i) for i in xrange(len(self))]
[ "def", "_listarr", "(", "self", ",", "func", ")", ":", "return", "[", "func", "(", "self", ".", "ptr", ",", "i", ")", "for", "i", "in", "xrange", "(", "len", "(", "self", ")", ")", "]" ]
[ 561, 4 ]
[ 566, 61 ]
python
en
['en', 'error', 'th']
False
LineString.x
(self)
Returns the X coordinates in a list.
Returns the X coordinates in a list.
def x(self): "Returns the X coordinates in a list." return self._listarr(capi.getx)
[ "def", "x", "(", "self", ")", ":", "return", "self", ".", "_listarr", "(", "capi", ".", "getx", ")" ]
[ 569, 4 ]
[ 571, 39 ]
python
en
['en', 'en', 'en']
True
LineString.y
(self)
Returns the Y coordinates in a list.
Returns the Y coordinates in a list.
def y(self): "Returns the Y coordinates in a list." return self._listarr(capi.gety)
[ "def", "y", "(", "self", ")", ":", "return", "self", ".", "_listarr", "(", "capi", ".", "gety", ")" ]
[ 574, 4 ]
[ 576, 39 ]
python
en
['en', 'en', 'en']
True
LineString.z
(self)
Returns the Z coordinates in a list.
Returns the Z coordinates in a list.
def z(self): "Returns the Z coordinates in a list." if self.coord_dim == 3: return self._listarr(capi.getz)
[ "def", "z", "(", "self", ")", ":", "if", "self", ".", "coord_dim", "==", "3", ":", "return", "self", ".", "_listarr", "(", "capi", ".", "getz", ")" ]
[ 579, 4 ]
[ 582, 43 ]
python
en
['en', 'en', 'en']
True
Polygon.__len__
(self)
The number of interior rings in this Polygon.
The number of interior rings in this Polygon.
def __len__(self): "The number of interior rings in this Polygon." return self.geom_count
[ "def", "__len__", "(", "self", ")", ":", "return", "self", ".", "geom_count" ]
[ 592, 4 ]
[ 594, 30 ]
python
en
['en', 'en', 'en']
True
Polygon.__iter__
(self)
Iterates through each ring in the Polygon.
Iterates through each ring in the Polygon.
def __iter__(self): "Iterates through each ring in the Polygon." for i in xrange(self.geom_count): yield self[i]
[ "def", "__iter__", "(", "self", ")", ":", "for", "i", "in", "xrange", "(", "self", ".", "geom_count", ")", ":", "yield", "self", "[", "i", "]" ]
[ 596, 4 ]
[ 599, 25 ]
python
en
['en', 'en', 'en']
True
Polygon.__getitem__
(self, index)
Gets the ring at the specified index.
Gets the ring at the specified index.
def __getitem__(self, index): "Gets the ring at the specified index." if index < 0 or index >= self.geom_count: raise OGRIndexError('index out of range: %s' % index) else: return OGRGeometry(capi.clone_geom(capi.get_geom_ref(self.ptr, index)), self.srs)
[ "def", "__getitem__", "(", "self", ",", "index", ")", ":", "if", "index", "<", "0", "or", "index", ">=", "self", ".", "geom_count", ":", "raise", "OGRIndexError", "(", "'index out of range: %s'", "%", "index", ")", "else", ":", "return", "OGRGeometry", "("...
[ 601, 4 ]
[ 606, 93 ]
python
en
['en', 'en', 'en']
True
Polygon.shell
(self)
Returns the shell of this Polygon.
Returns the shell of this Polygon.
def shell(self): "Returns the shell of this Polygon." return self[0] # First ring is the shell
[ "def", "shell", "(", "self", ")", ":", "return", "self", "[", "0", "]", "# First ring is the shell" ]
[ 610, 4 ]
[ 612, 49 ]
python
en
['en', 'en', 'en']
True
Polygon.tuple
(self)
Returns a tuple of LinearRing coordinate tuples.
Returns a tuple of LinearRing coordinate tuples.
def tuple(self): "Returns a tuple of LinearRing coordinate tuples." return tuple(self[i].tuple for i in xrange(self.geom_count))
[ "def", "tuple", "(", "self", ")", ":", "return", "tuple", "(", "self", "[", "i", "]", ".", "tuple", "for", "i", "in", "xrange", "(", "self", ".", "geom_count", ")", ")" ]
[ 616, 4 ]
[ 618, 68 ]
python
en
['en', 'en', 'en']
True
Polygon.point_count
(self)
The number of Points in this Polygon.
The number of Points in this Polygon.
def point_count(self): "The number of Points in this Polygon." # Summing up the number of points in each ring of the Polygon. return sum(self[i].point_count for i in xrange(self.geom_count))
[ "def", "point_count", "(", "self", ")", ":", "# Summing up the number of points in each ring of the Polygon.", "return", "sum", "(", "self", "[", "i", "]", ".", "point_count", "for", "i", "in", "xrange", "(", "self", ".", "geom_count", ")", ")" ]
[ 622, 4 ]
[ 625, 72 ]
python
en
['en', 'en', 'en']
True
Polygon.centroid
(self)
Returns the centroid (a Point) of this Polygon.
Returns the centroid (a Point) of this Polygon.
def centroid(self): "Returns the centroid (a Point) of this Polygon." # The centroid is a Point, create a geometry for this. p = OGRGeometry(OGRGeomType('Point')) capi.get_centroid(self.ptr, p.ptr) return p
[ "def", "centroid", "(", "self", ")", ":", "# The centroid is a Point, create a geometry for this.", "p", "=", "OGRGeometry", "(", "OGRGeomType", "(", "'Point'", ")", ")", "capi", ".", "get_centroid", "(", "self", ".", "ptr", ",", "p", ".", "ptr", ")", "return"...
[ 628, 4 ]
[ 633, 16 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.__getitem__
(self, index)
Gets the Geometry at the specified index.
Gets the Geometry at the specified index.
def __getitem__(self, index): "Gets the Geometry at the specified index." if index < 0 or index >= self.geom_count: raise OGRIndexError('index out of range: %s' % index) else: return OGRGeometry(capi.clone_geom(capi.get_geom_ref(self.ptr, index)), self.srs)
[ "def", "__getitem__", "(", "self", ",", "index", ")", ":", "if", "index", "<", "0", "or", "index", ">=", "self", ".", "geom_count", ":", "raise", "OGRIndexError", "(", "'index out of range: %s'", "%", "index", ")", "else", ":", "return", "OGRGeometry", "("...
[ 640, 4 ]
[ 645, 93 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.__iter__
(self)
Iterates over each Geometry.
Iterates over each Geometry.
def __iter__(self): "Iterates over each Geometry." for i in xrange(self.geom_count): yield self[i]
[ "def", "__iter__", "(", "self", ")", ":", "for", "i", "in", "xrange", "(", "self", ".", "geom_count", ")", ":", "yield", "self", "[", "i", "]" ]
[ 647, 4 ]
[ 650, 25 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.__len__
(self)
The number of geometries in this Geometry Collection.
The number of geometries in this Geometry Collection.
def __len__(self): "The number of geometries in this Geometry Collection." return self.geom_count
[ "def", "__len__", "(", "self", ")", ":", "return", "self", ".", "geom_count" ]
[ 652, 4 ]
[ 654, 30 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.add
(self, geom)
Add the geometry to this Geometry Collection.
Add the geometry to this Geometry Collection.
def add(self, geom): "Add the geometry to this Geometry Collection." if isinstance(geom, OGRGeometry): if isinstance(geom, self.__class__): for g in geom: capi.add_geom(self.ptr, g.ptr) else: capi.add_geom(self.ptr, geom.ptr) ...
[ "def", "add", "(", "self", ",", "geom", ")", ":", "if", "isinstance", "(", "geom", ",", "OGRGeometry", ")", ":", "if", "isinstance", "(", "geom", ",", "self", ".", "__class__", ")", ":", "for", "g", "in", "geom", ":", "capi", ".", "add_geom", "(", ...
[ 656, 4 ]
[ 668, 58 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.point_count
(self)
The number of Points in this Geometry Collection.
The number of Points in this Geometry Collection.
def point_count(self): "The number of Points in this Geometry Collection." # Summing up the number of points in each geometry in this collection return sum(self[i].point_count for i in xrange(self.geom_count))
[ "def", "point_count", "(", "self", ")", ":", "# Summing up the number of points in each geometry in this collection", "return", "sum", "(", "self", "[", "i", "]", ".", "point_count", "for", "i", "in", "xrange", "(", "self", ".", "geom_count", ")", ")" ]
[ 671, 4 ]
[ 674, 72 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.tuple
(self)
Returns a tuple representation of this Geometry Collection.
Returns a tuple representation of this Geometry Collection.
def tuple(self): "Returns a tuple representation of this Geometry Collection." return tuple(self[i].tuple for i in xrange(self.geom_count))
[ "def", "tuple", "(", "self", ")", ":", "return", "tuple", "(", "self", "[", "i", "]", ".", "tuple", "for", "i", "in", "xrange", "(", "self", ".", "geom_count", ")", ")" ]
[ 677, 4 ]
[ 679, 68 ]
python
en
['en', 'en', 'en']
True
setup_tutorial
()
Helper function to check correct configuration of tf for tutorial :return: True if setup checks completed
Helper function to check correct configuration of tf for tutorial :return: True if setup checks completed
def setup_tutorial(): """ Helper function to check correct configuration of tf for tutorial :return: True if setup checks completed """ # Set TF random seed to improve reproducibility tf.set_random_seed(1234) return True
[ "def", "setup_tutorial", "(", ")", ":", "# Set TF random seed to improve reproducibility", "tf", ".", "set_random_seed", "(", "1234", ")", "return", "True" ]
[ 46, 0 ]
[ 55, 15 ]
python
en
['en', 'error', 'th']
False
prep_bbox
( sess, x, y, x_train, y_train, x_test, y_test, nb_epochs, batch_size, learning_rate, rng, nb_classes=10, img_rows=28, img_cols=28, nchannels=1, )
Define and train a model that simulates the "remote" black-box oracle described in the original paper. :param sess: the TF session :param x: the input placeholder for MNIST :param y: the ouput placeholder for MNIST :param x_train: the training data for the oracle :param y_train: the trainin...
Define and train a model that simulates the "remote" black-box oracle described in the original paper. :param sess: the TF session :param x: the input placeholder for MNIST :param y: the ouput placeholder for MNIST :param x_train: the training data for the oracle :param y_train: the trainin...
def prep_bbox( sess, x, y, x_train, y_train, x_test, y_test, nb_epochs, batch_size, learning_rate, rng, nb_classes=10, img_rows=28, img_cols=28, nchannels=1, ): """ Define and train a model that simulates the "remote" black-box oracle described in ...
[ "def", "prep_bbox", "(", "sess", ",", "x", ",", "y", ",", "x_train", ",", "y_train", ",", "x_test", ",", "y_test", ",", "nb_epochs", ",", "batch_size", ",", "learning_rate", ",", "rng", ",", "nb_classes", "=", "10", ",", "img_rows", "=", "28", ",", "...
[ 58, 0 ]
[ 112, 39 ]
python
en
['en', 'error', 'th']
False
train_sub
( sess, x, y, bbox_preds, x_sub, y_sub, nb_classes, nb_epochs_s, batch_size, learning_rate, data_aug, lmbda, aug_batch_size, rng, img_rows=28, img_cols=28, nchannels=1, )
This function creates the substitute by alternatively augmenting the training data and training the substitute. :param sess: TF session :param x: input TF placeholder :param y: output TF placeholder :param bbox_preds: output of black-box model predictions :param x_sub: initial substitute tr...
This function creates the substitute by alternatively augmenting the training data and training the substitute. :param sess: TF session :param x: input TF placeholder :param y: output TF placeholder :param bbox_preds: output of black-box model predictions :param x_sub: initial substitute tr...
def train_sub( sess, x, y, bbox_preds, x_sub, y_sub, nb_classes, nb_epochs_s, batch_size, learning_rate, data_aug, lmbda, aug_batch_size, rng, img_rows=28, img_cols=28, nchannels=1, ): """ This function creates the substitute by alternatively ...
[ "def", "train_sub", "(", "sess", ",", "x", ",", "y", ",", "bbox_preds", ",", "x_sub", ",", "y_sub", ",", "nb_classes", ",", "nb_epochs_s", ",", "batch_size", ",", "learning_rate", ",", "data_aug", ",", "lmbda", ",", "aug_batch_size", ",", "rng", ",", "im...
[ 134, 0 ]
[ 223, 31 ]
python
en
['en', 'error', 'th']
False
mnist_blackbox
( train_start=0, train_end=60000, test_start=0, test_end=10000, nb_classes=NB_CLASSES, batch_size=BATCH_SIZE, learning_rate=LEARNING_RATE, nb_epochs=NB_EPOCHS, holdout=HOLDOUT, data_aug=DATA_AUG, nb_epochs_s=NB_EPOCHS_S, lmbda=LMBDA, aug_batch_size=AUG_BATCH_SIZE, )
MNIST tutorial for the black-box attack from arxiv.org/abs/1602.02697 :param train_start: index of first training set example :param train_end: index of last training set example :param test_start: index of first test set example :param test_end: index of last test set example :return: a dictio...
MNIST tutorial for the black-box attack from arxiv.org/abs/1602.02697 :param train_start: index of first training set example :param train_end: index of last training set example :param test_start: index of first test set example :param test_end: index of last test set example :return: a dictio...
def mnist_blackbox( train_start=0, train_end=60000, test_start=0, test_end=10000, nb_classes=NB_CLASSES, batch_size=BATCH_SIZE, learning_rate=LEARNING_RATE, nb_epochs=NB_EPOCHS, holdout=HOLDOUT, data_aug=DATA_AUG, nb_epochs_s=NB_EPOCHS_S, lmbda=LMBDA, aug_batch_size=A...
[ "def", "mnist_blackbox", "(", "train_start", "=", "0", ",", "train_end", "=", "60000", ",", "test_start", "=", "0", ",", "test_end", "=", "10000", ",", "nb_classes", "=", "NB_CLASSES", ",", "batch_size", "=", "BATCH_SIZE", ",", "learning_rate", "=", "LEARNIN...
[ 226, 0 ]
[ 363, 21 ]
python
en
['en', 'error', 'th']
False
index_page
(request)
Dummy index page
Dummy index page
def index_page(request): """Dummy index page""" return HttpResponse('<html><body>Dummy page</body></html>')
[ "def", "index_page", "(", "request", ")", ":", "return", "HttpResponse", "(", "'<html><body>Dummy page</body></html>'", ")" ]
[ 25, 0 ]
[ 27, 63 ]
python
en
['en', 'de', 'en']
True
redirect
(request)
Forces an HTTP redirect.
Forces an HTTP redirect.
def redirect(request): """ Forces an HTTP redirect. """ return HttpResponseRedirect("target/")
[ "def", "redirect", "(", "request", ")", ":", "return", "HttpResponseRedirect", "(", "\"target/\"", ")" ]
[ 73, 0 ]
[ 77, 42 ]
python
en
['en', 'error', 'th']
False
GeoFeedMixin.georss_coords
(self, coords)
In GeoRSS coordinate pairs are ordered by lat/lon and separated by a single white space. Given a tuple of coordinates, this will return a unicode GeoRSS representation.
In GeoRSS coordinate pairs are ordered by lat/lon and separated by a single white space. Given a tuple of coordinates, this will return a unicode GeoRSS representation.
def georss_coords(self, coords): """ In GeoRSS coordinate pairs are ordered by lat/lon and separated by a single white space. Given a tuple of coordinates, this will return a unicode GeoRSS representation. """ return ' '.join('%f %f' % (coord[1], coord[0]) for coord in c...
[ "def", "georss_coords", "(", "self", ",", "coords", ")", ":", "return", "' '", ".", "join", "(", "'%f %f'", "%", "(", "coord", "[", "1", "]", ",", "coord", "[", "0", "]", ")", "for", "coord", "in", "coords", ")" ]
[ 12, 4 ]
[ 18, 75 ]
python
en
['en', 'error', 'th']
False
GeoFeedMixin.add_georss_point
(self, handler, coords, w3c_geo=False)
Adds a GeoRSS point with the given coords using the given handler. Handles the differences between simple GeoRSS and the more popular W3C Geo specification.
Adds a GeoRSS point with the given coords using the given handler. Handles the differences between simple GeoRSS and the more popular W3C Geo specification.
def add_georss_point(self, handler, coords, w3c_geo=False): """ Adds a GeoRSS point with the given coords using the given handler. Handles the differences between simple GeoRSS and the more popular W3C Geo specification. """ if w3c_geo: lon, lat = coords[:2] ...
[ "def", "add_georss_point", "(", "self", ",", "handler", ",", "coords", ",", "w3c_geo", "=", "False", ")", ":", "if", "w3c_geo", ":", "lon", ",", "lat", "=", "coords", "[", ":", "2", "]", "handler", ".", "addQuickElement", "(", "'geo:lat'", ",", "'%f'",...
[ 20, 4 ]
[ 31, 82 ]
python
en
['en', 'error', 'th']
False
GeoFeedMixin.add_georss_element
(self, handler, item, w3c_geo=False)
This routine adds a GeoRSS XML element using the given item and handler.
This routine adds a GeoRSS XML element using the given item and handler.
def add_georss_element(self, handler, item, w3c_geo=False): """ This routine adds a GeoRSS XML element using the given item and handler. """ # Getting the Geometry object. geom = item.get('geometry', None) if geom is not None: if isinstance(geom, (list, tuple)...
[ "def", "add_georss_element", "(", "self", ",", "handler", ",", "item", ",", "w3c_geo", "=", "False", ")", ":", "# Getting the Geometry object.", "geom", "=", "item", ".", "get", "(", "'geometry'", ",", "None", ")", "if", "geom", "is", "not", "None", ":", ...
[ 33, 4 ]
[ 80, 94 ]
python
en
['en', 'error', 'th']
False
test_get_source
(shared_datadir, test_urls, test_repo)
should return correct subclass
should return correct subclass
def test_get_source(shared_datadir, test_urls, test_repo): """should return correct subclass""" test_path = shared_datadir / "esp8266_test_stub" local_stub = source.get_source(test_path) assert isinstance(local_stub, source.LocalStubSource) remote_stub = source.get_source("esp8266-test-stub") as...
[ "def", "test_get_source", "(", "shared_datadir", ",", "test_urls", ",", "test_repo", ")", ":", "test_path", "=", "shared_datadir", "/", "\"esp8266_test_stub\"", "local_stub", "=", "source", ".", "get_source", "(", "test_path", ")", "assert", "isinstance", "(", "lo...
[ 9, 0 ]
[ 18, 75 ]
python
en
['en', 'en', 'en']
True
test_source_ready
(shared_datadir, test_urls, tmp_path, mocker, test_archive, test_repo)
should prepare and resolve stub
should prepare and resolve stub
def test_source_ready(shared_datadir, test_urls, tmp_path, mocker, test_archive, test_repo): """should prepare and resolve stub""" # Test LocalStub ready test_path = shared_datadir / "esp8266_test_stub" local_stub = source.get_source(test_path) expected_path = local_stub.location.resolve() with ...
[ "def", "test_source_ready", "(", "shared_datadir", ",", "test_urls", ",", "tmp_path", ",", "mocker", ",", "test_archive", ",", "test_repo", ")", ":", "# Test LocalStub ready", "test_path", "=", "shared_datadir", "/", "\"esp8266_test_stub\"", "local_stub", "=", "source...
[ 21, 0 ]
[ 41, 52 ]
python
en
['en', 'en', 'en']
True
default_subprocess_runner
(cmd, cwd=None, extra_environ=None)
The default method of calling the wrapper subprocess.
The default method of calling the wrapper subprocess.
def default_subprocess_runner(cmd, cwd=None, extra_environ=None): """The default method of calling the wrapper subprocess.""" env = os.environ.copy() if extra_environ: env.update(extra_environ) check_call(cmd, cwd=cwd, env=env)
[ "def", "default_subprocess_runner", "(", "cmd", ",", "cwd", "=", "None", ",", "extra_environ", "=", "None", ")", ":", "env", "=", "os", ".", "environ", ".", "copy", "(", ")", "if", "extra_environ", ":", "env", ".", "update", "(", "extra_environ", ")", ...
[ 59, 0 ]
[ 65, 37 ]
python
en
['en', 'en', 'en']
True
quiet_subprocess_runner
(cmd, cwd=None, extra_environ=None)
A method of calling the wrapper subprocess while suppressing output.
A method of calling the wrapper subprocess while suppressing output.
def quiet_subprocess_runner(cmd, cwd=None, extra_environ=None): """A method of calling the wrapper subprocess while suppressing output.""" env = os.environ.copy() if extra_environ: env.update(extra_environ) check_output(cmd, cwd=cwd, env=env, stderr=STDOUT)
[ "def", "quiet_subprocess_runner", "(", "cmd", ",", "cwd", "=", "None", ",", "extra_environ", "=", "None", ")", ":", "env", "=", "os", ".", "environ", ".", "copy", "(", ")", "if", "extra_environ", ":", "env", ".", "update", "(", "extra_environ", ")", "c...
[ 68, 0 ]
[ 74, 54 ]
python
en
['en', 'en', 'en']
True
norm_and_check
(source_tree, requested)
Normalise and check a backend path. Ensure that the requested backend path is specified as a relative path, and resolves to a location under the given source tree. Return an absolute version of the requested path.
Normalise and check a backend path.
def norm_and_check(source_tree, requested): """Normalise and check a backend path. Ensure that the requested backend path is specified as a relative path, and resolves to a location under the given source tree. Return an absolute version of the requested path. """ if os.path.isabs(requested): ...
[ "def", "norm_and_check", "(", "source_tree", ",", "requested", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "requested", ")", ":", "raise", "ValueError", "(", "\"paths must be relative\"", ")", "abs_source", "=", "os", ".", "path", ".", "abspath", ...
[ 77, 0 ]
[ 98, 24 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.subprocess_runner
(self, runner)
A context manager for temporarily overriding the default subprocess runner.
A context manager for temporarily overriding the default subprocess runner.
def subprocess_runner(self, runner): """A context manager for temporarily overriding the default subprocess runner. """ prev = self._subprocess_runner self._subprocess_runner = runner try: yield finally: self._subprocess_runner = prev
[ "def", "subprocess_runner", "(", "self", ",", "runner", ")", ":", "prev", "=", "self", ".", "_subprocess_runner", "self", ".", "_subprocess_runner", "=", "runner", "try", ":", "yield", "finally", ":", "self", ".", "_subprocess_runner", "=", "prev" ]
[ 138, 4 ]
[ 147, 42 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.get_requires_for_build_wheel
(self, config_settings=None)
Identify packages required for building a wheel Returns a list of dependency specifications, e.g.: ["wheel >= 0.25", "setuptools"] This does not include requirements specified in pyproject.toml. It returns the result of calling the equivalently named hook in a subprocess. ...
Identify packages required for building a wheel
def get_requires_for_build_wheel(self, config_settings=None): """Identify packages required for building a wheel Returns a list of dependency specifications, e.g.: ["wheel >= 0.25", "setuptools"] This does not include requirements specified in pyproject.toml. It returns the...
[ "def", "get_requires_for_build_wheel", "(", "self", ",", "config_settings", "=", "None", ")", ":", "return", "self", ".", "_call_hook", "(", "'get_requires_for_build_wheel'", ",", "{", "'config_settings'", ":", "config_settings", "}", ")" ]
[ 149, 4 ]
[ 161, 10 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.prepare_metadata_for_build_wheel
( self, metadata_directory, config_settings=None, _allow_fallback=True)
Prepare a *.dist-info folder with metadata for this project. Returns the name of the newly created folder. If the build backend defines a hook with this name, it will be called in a subprocess. If not, the backend will be asked to build a wheel, and the dist-info extracted from that (u...
Prepare a *.dist-info folder with metadata for this project.
def prepare_metadata_for_build_wheel( self, metadata_directory, config_settings=None, _allow_fallback=True): """Prepare a *.dist-info folder with metadata for this project. Returns the name of the newly created folder. If the build backend defines a hook with this name,...
[ "def", "prepare_metadata_for_build_wheel", "(", "self", ",", "metadata_directory", ",", "config_settings", "=", "None", ",", "_allow_fallback", "=", "True", ")", ":", "return", "self", ".", "_call_hook", "(", "'prepare_metadata_for_build_wheel'", ",", "{", "'metadata_...
[ 163, 4 ]
[ 179, 10 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.build_wheel
( self, wheel_directory, config_settings=None, metadata_directory=None)
Build a wheel from this project. Returns the name of the newly created file. In general, this will call the 'build_wheel' hook in the backend. However, if that was previously called by 'prepare_metadata_for_build_wheel', and the same metadata_directory is used, the previously b...
Build a wheel from this project.
def build_wheel( self, wheel_directory, config_settings=None, metadata_directory=None): """Build a wheel from this project. Returns the name of the newly created file. In general, this will call the 'build_wheel' hook in the backend. However, if that was previou...
[ "def", "build_wheel", "(", "self", ",", "wheel_directory", ",", "config_settings", "=", "None", ",", "metadata_directory", "=", "None", ")", ":", "if", "metadata_directory", "is", "not", "None", ":", "metadata_directory", "=", "abspath", "(", "metadata_directory",...
[ 181, 4 ]
[ 199, 10 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.get_requires_for_build_sdist
(self, config_settings=None)
Identify packages required for building a wheel Returns a list of dependency specifications, e.g.: ["setuptools >= 26"] This does not include requirements specified in pyproject.toml. It returns the result of calling the equivalently named hook in a subprocess.
Identify packages required for building a wheel
def get_requires_for_build_sdist(self, config_settings=None): """Identify packages required for building a wheel Returns a list of dependency specifications, e.g.: ["setuptools >= 26"] This does not include requirements specified in pyproject.toml. It returns the result of ...
[ "def", "get_requires_for_build_sdist", "(", "self", ",", "config_settings", "=", "None", ")", ":", "return", "self", ".", "_call_hook", "(", "'get_requires_for_build_sdist'", ",", "{", "'config_settings'", ":", "config_settings", "}", ")" ]
[ 201, 4 ]
[ 213, 10 ]
python
en
['en', 'en', 'en']
True
Pep517HookCaller.build_sdist
(self, sdist_directory, config_settings=None)
Build an sdist from this project. Returns the name of the newly created file. This calls the 'build_sdist' backend hook in a subprocess.
Build an sdist from this project.
def build_sdist(self, sdist_directory, config_settings=None): """Build an sdist from this project. Returns the name of the newly created file. This calls the 'build_sdist' backend hook in a subprocess. """ return self._call_hook('build_sdist', { 'sdist_directory': a...
[ "def", "build_sdist", "(", "self", ",", "sdist_directory", ",", "config_settings", "=", "None", ")", ":", "return", "self", ".", "_call_hook", "(", "'build_sdist'", ",", "{", "'sdist_directory'", ":", "abspath", "(", "sdist_directory", ")", ",", "'config_setting...
[ 215, 4 ]
[ 225, 10 ]
python
en
['en', 'en', 'en']
True
ModelBackend._get_permissions
(self, user_obj, obj, from_name)
Returns the permissions of `user_obj` from `from_name`. `from_name` can be either "group" or "user" to return permissions from `_get_group_permissions` or `_get_user_permissions` respectively.
Returns the permissions of `user_obj` from `from_name`. `from_name` can be either "group" or "user" to return permissions from `_get_group_permissions` or `_get_user_permissions` respectively.
def _get_permissions(self, user_obj, obj, from_name): """ Returns the permissions of `user_obj` from `from_name`. `from_name` can be either "group" or "user" to return permissions from `_get_group_permissions` or `_get_user_permissions` respectively. """ if not user_obj.i...
[ "def", "_get_permissions", "(", "self", ",", "user_obj", ",", "obj", ",", "from_name", ")", ":", "if", "not", "user_obj", ".", "is_active", "or", "user_obj", ".", "is_anonymous", "(", ")", "or", "obj", "is", "not", "None", ":", "return", "set", "(", ")...
[ 31, 4 ]
[ 48, 49 ]
python
en
['en', 'error', 'th']
False
ModelBackend.get_user_permissions
(self, user_obj, obj=None)
Returns a set of permission strings the user `user_obj` has from their `user_permissions`.
Returns a set of permission strings the user `user_obj` has from their `user_permissions`.
def get_user_permissions(self, user_obj, obj=None): """ Returns a set of permission strings the user `user_obj` has from their `user_permissions`. """ return self._get_permissions(user_obj, obj, 'user')
[ "def", "get_user_permissions", "(", "self", ",", "user_obj", ",", "obj", "=", "None", ")", ":", "return", "self", ".", "_get_permissions", "(", "user_obj", ",", "obj", ",", "'user'", ")" ]
[ 50, 4 ]
[ 55, 59 ]
python
en
['en', 'error', 'th']
False
ModelBackend.get_group_permissions
(self, user_obj, obj=None)
Returns a set of permission strings the user `user_obj` has from the groups they belong.
Returns a set of permission strings the user `user_obj` has from the groups they belong.
def get_group_permissions(self, user_obj, obj=None): """ Returns a set of permission strings the user `user_obj` has from the groups they belong. """ return self._get_permissions(user_obj, obj, 'group')
[ "def", "get_group_permissions", "(", "self", ",", "user_obj", ",", "obj", "=", "None", ")", ":", "return", "self", ".", "_get_permissions", "(", "user_obj", ",", "obj", ",", "'group'", ")" ]
[ 57, 4 ]
[ 62, 60 ]
python
en
['en', 'error', 'th']
False
ModelBackend.has_module_perms
(self, user_obj, app_label)
Returns True if user_obj has any permissions in the given app_label.
Returns True if user_obj has any permissions in the given app_label.
def has_module_perms(self, user_obj, app_label): """ Returns True if user_obj has any permissions in the given app_label. """ if not user_obj.is_active: return False for perm in self.get_all_permissions(user_obj): if perm[:perm.index('.')] == app_label: ...
[ "def", "has_module_perms", "(", "self", ",", "user_obj", ",", "app_label", ")", ":", "if", "not", "user_obj", ".", "is_active", ":", "return", "False", "for", "perm", "in", "self", ".", "get_all_permissions", "(", "user_obj", ")", ":", "if", "perm", "[", ...
[ 77, 4 ]
[ 86, 20 ]
python
en
['en', 'error', 'th']
False
RemoteUserBackend.authenticate
(self, remote_user)
The username passed as ``remote_user`` is considered trusted. This method simply returns the ``User`` object with the given username, creating a new ``User`` object if ``create_unknown_user`` is ``True``. Returns None if ``create_unknown_user`` is ``False`` and a ``User`` obje...
The username passed as ``remote_user`` is considered trusted. This method simply returns the ``User`` object with the given username, creating a new ``User`` object if ``create_unknown_user`` is ``True``.
def authenticate(self, remote_user): """ The username passed as ``remote_user`` is considered trusted. This method simply returns the ``User`` object with the given username, creating a new ``User`` object if ``create_unknown_user`` is ``True``. Returns None if ``create_unknown...
[ "def", "authenticate", "(", "self", ",", "remote_user", ")", ":", "if", "not", "remote_user", ":", "return", "user", "=", "None", "username", "=", "self", ".", "clean_username", "(", "remote_user", ")", "UserModel", "=", "get_user_model", "(", ")", "# Note t...
[ 111, 4 ]
[ 141, 19 ]
python
en
['en', 'error', 'th']
False
RemoteUserBackend.clean_username
(self, username)
Performs any cleaning on the "username" prior to using it to get or create the user object. Returns the cleaned username. By default, returns the username unchanged.
Performs any cleaning on the "username" prior to using it to get or create the user object. Returns the cleaned username.
def clean_username(self, username): """ Performs any cleaning on the "username" prior to using it to get or create the user object. Returns the cleaned username. By default, returns the username unchanged. """ return username
[ "def", "clean_username", "(", "self", ",", "username", ")", ":", "return", "username" ]
[ 143, 4 ]
[ 150, 23 ]
python
en
['en', 'error', 'th']
False
RemoteUserBackend.configure_user
(self, user)
Configures a user after creation and returns the updated user. By default, returns the user unmodified.
Configures a user after creation and returns the updated user.
def configure_user(self, user): """ Configures a user after creation and returns the updated user. By default, returns the user unmodified. """ return user
[ "def", "configure_user", "(", "self", ",", "user", ")", ":", "return", "user" ]
[ 152, 4 ]
[ 158, 19 ]
python
en
['en', 'error', 'th']
False
send_event
( realm: Realm, event: Mapping[str, Any], users: Union[Iterable[int], Iterable[Mapping[str, Any]]] )
`users` is a list of user IDs, or in the case of `message` type events, a list of dicts describing the users and metadata about the user/message pair.
`users` is a list of user IDs, or in the case of `message` type events, a list of dicts describing the users and metadata about the user/message pair.
def send_event( realm: Realm, event: Mapping[str, Any], users: Union[Iterable[int], Iterable[Mapping[str, Any]]] ) -> None: """`users` is a list of user IDs, or in the case of `message` type events, a list of dicts describing the users and metadata about the user/message pair.""" port = get_tornado_...
[ "def", "send_event", "(", "realm", ":", "Realm", ",", "event", ":", "Mapping", "[", "str", ",", "Any", "]", ",", "users", ":", "Union", "[", "Iterable", "[", "int", "]", ",", "Iterable", "[", "Mapping", "[", "str", ",", "Any", "]", "]", "]", ")",...
[ 144, 0 ]
[ 155, 5 ]
python
en
['en', 'en', 'en']
True
Point.__init__
(self, x=None, y=None, z=None, srid=None)
The Point object may be initialized with either a tuple, or individual parameters. For example: >>> p = Point((5, 23)) # 2D point, passed in as a tuple >>> p = Point(5, 23, 8) # 3D point, passed in with individual parameters
The Point object may be initialized with either a tuple, or individual parameters.
def __init__(self, x=None, y=None, z=None, srid=None): """ The Point object may be initialized with either a tuple, or individual parameters. For example: >>> p = Point((5, 23)) # 2D point, passed in as a tuple >>> p = Point(5, 23, 8) # 3D point, passed in with individ...
[ "def", "__init__", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ",", "z", "=", "None", ",", "srid", "=", "None", ")", ":", "if", "x", "is", "None", ":", "coords", "=", "[", "]", "elif", "isinstance", "(", "x", ",", "(", "tuple",...
[ 13, 4 ]
[ 40, 42 ]
python
en
['en', 'error', 'th']
False
Point._create_point
(cls, ndim, coords)
Create a coordinate sequence, set X, Y, [Z], and create point
Create a coordinate sequence, set X, Y, [Z], and create point
def _create_point(cls, ndim, coords): """ Create a coordinate sequence, set X, Y, [Z], and create point """ if not ndim: return capi.create_point(None) if ndim < 2 or ndim > 3: raise TypeError('Invalid point dimension: %s' % ndim) cs = capi.creat...
[ "def", "_create_point", "(", "cls", ",", "ndim", ",", "coords", ")", ":", "if", "not", "ndim", ":", "return", "capi", ".", "create_point", "(", "None", ")", "if", "ndim", "<", "2", "or", "ndim", ">", "3", ":", "raise", "TypeError", "(", "'Invalid poi...
[ 56, 4 ]
[ 73, 36 ]
python
en
['en', 'error', 'th']
False
Point.__iter__
(self)
Iterate over coordinates of this Point.
Iterate over coordinates of this Point.
def __iter__(self): "Iterate over coordinates of this Point." 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
Point.__len__
(self)
Return the number of dimensions for this Point (either 0, 2 or 3).
Return the number of dimensions for this Point (either 0, 2 or 3).
def __len__(self): "Return the number of dimensions for this Point (either 0, 2 or 3)." if self.empty: return 0 if self.hasz: return 3 else: return 2
[ "def", "__len__", "(", "self", ")", ":", "if", "self", ".", "empty", ":", "return", "0", "if", "self", ".", "hasz", ":", "return", "3", "else", ":", "return", "2" ]
[ 96, 4 ]
[ 103, 20 ]
python
en
['en', 'en', 'en']
True
Point.x
(self)
Return the X component of the Point.
Return the X component of the Point.
def x(self): "Return the X component of the Point." return self._cs.getOrdinate(0, 0)
[ "def", "x", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "getOrdinate", "(", "0", ",", "0", ")" ]
[ 116, 4 ]
[ 118, 41 ]
python
en
['en', 'en', 'en']
True
Point.x
(self, value)
Set the X component of the Point.
Set the X component of the Point.
def x(self, value): "Set the X component of the Point." self._cs.setOrdinate(0, 0, value)
[ "def", "x", "(", "self", ",", "value", ")", ":", "self", ".", "_cs", ".", "setOrdinate", "(", "0", ",", "0", ",", "value", ")" ]
[ 121, 4 ]
[ 123, 41 ]
python
en
['en', 'en', 'en']
True
Point.y
(self)
Return the Y component of the Point.
Return the Y component of the Point.
def y(self): "Return the Y component of the Point." return self._cs.getOrdinate(1, 0)
[ "def", "y", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "getOrdinate", "(", "1", ",", "0", ")" ]
[ 126, 4 ]
[ 128, 41 ]
python
en
['en', 'en', 'en']
True
Point.y
(self, value)
Set the Y component of the Point.
Set the Y component of the Point.
def y(self, value): "Set the Y component of the Point." self._cs.setOrdinate(1, 0, value)
[ "def", "y", "(", "self", ",", "value", ")", ":", "self", ".", "_cs", ".", "setOrdinate", "(", "1", ",", "0", ",", "value", ")" ]
[ 131, 4 ]
[ 133, 41 ]
python
en
['en', 'en', 'en']
True
Point.z
(self)
Return the Z component of the Point.
Return the Z component of the Point.
def z(self): "Return the Z component of the Point." return self._cs.getOrdinate(2, 0) if self.hasz else None
[ "def", "z", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "getOrdinate", "(", "2", ",", "0", ")", "if", "self", ".", "hasz", "else", "None" ]
[ 136, 4 ]
[ 138, 64 ]
python
en
['en', 'en', 'en']
True
Point.z
(self, value)
Set the Z component of the Point.
Set the Z component of the Point.
def z(self, value): "Set the Z component of the Point." if not self.hasz: raise GEOSException('Cannot set Z on 2D Point.') self._cs.setOrdinate(2, 0, value)
[ "def", "z", "(", "self", ",", "value", ")", ":", "if", "not", "self", ".", "hasz", ":", "raise", "GEOSException", "(", "'Cannot set Z on 2D Point.'", ")", "self", ".", "_cs", ".", "setOrdinate", "(", "2", ",", "0", ",", "value", ")" ]
[ 141, 4 ]
[ 145, 41 ]
python
en
['en', 'en', 'en']
True
Point.tuple
(self)
Return a tuple of the point.
Return a tuple of the point.
def tuple(self): "Return a tuple of the point." return self._cs.tuple
[ "def", "tuple", "(", "self", ")", ":", "return", "self", ".", "_cs", ".", "tuple" ]
[ 149, 4 ]
[ 151, 29 ]
python
en
['en', 'en', 'en']
True
Point.tuple
(self, tup)
Set the coordinates of the point with the given tuple.
Set the coordinates of the point with the given tuple.
def tuple(self, tup): "Set the coordinates of the point with the given tuple." self._cs[0] = tup
[ "def", "tuple", "(", "self", ",", "tup", ")", ":", "self", ".", "_cs", "[", "0", "]", "=", "tup" ]
[ 154, 4 ]
[ 156, 25 ]
python
en
['en', 'en', 'en']
True
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", "(", ")" ]
[ 78, 4 ]
[ 83, 32 ]
python
en
['en', 'error', 'th']
False
DatabaseOperations.max_name_length
(self)
Return the maximum length of an identifier. The maximum length of an identifier is 63 by default, but can be changed by recompiling PostgreSQL after editing the NAMEDATALEN macro in src/include/pg_config_manual.h. This implementation returns 63, but can be overridden by a cust...
Return the maximum length of an identifier.
def max_name_length(self): """ Return the maximum length of an identifier. The maximum length of an identifier is 63 by default, but can be changed by recompiling PostgreSQL after editing the NAMEDATALEN macro in src/include/pg_config_manual.h. This implementation retur...
[ "def", "max_name_length", "(", "self", ")", ":", "return", "63" ]
[ 210, 4 ]
[ 221, 17 ]
python
en
['en', 'error', 'th']
False
parse_marker
(marker_string)
Parse a marker string and return a dictionary containing a marker expression. The dictionary will contain keys "op", "lhs" and "rhs" for non-terminals in the expression grammar, or strings. A string contained in quotes is to be interpreted as a literal string, and a string not contained in quotes is a...
Parse a marker string and return a dictionary containing a marker expression.
def parse_marker(marker_string): """ Parse a marker string and return a dictionary containing a marker expression. The dictionary will contain keys "op", "lhs" and "rhs" for non-terminals in the expression grammar, or strings. A string contained in quotes is to be interpreted as a literal string, a...
[ "def", "parse_marker", "(", "marker_string", ")", ":", "def", "marker_var", "(", "remaining", ")", ":", "# either identifier, or literal string", "m", "=", "IDENTIFIER", ".", "match", "(", "remaining", ")", "if", "m", ":", "result", "=", "m", ".", "groups", ...
[ 55, 0 ]
[ 141, 32 ]
python
en
['en', 'error', 'th']
False
parse_requirement
(req)
Parse a requirement passed in as a string. Return a Container whose attributes contain the various parts of the requirement.
Parse a requirement passed in as a string. Return a Container whose attributes contain the various parts of the requirement.
def parse_requirement(req): """ Parse a requirement passed in as a string. Return a Container whose attributes contain the various parts of the requirement. """ remaining = req.strip() if not remaining or remaining.startswith('#'): return None m = IDENTIFIER.match(remaining) if n...
[ "def", "parse_requirement", "(", "req", ")", ":", "remaining", "=", "req", ".", "strip", "(", ")", "if", "not", "remaining", "or", "remaining", ".", "startswith", "(", "'#'", ")", ":", "return", "None", "m", "=", "IDENTIFIER", ".", "match", "(", "remai...
[ 144, 0 ]
[ 262, 63 ]
python
en
['en', 'error', 'th']
False
get_resources_dests
(resources_root, rules)
Find destinations for resources files
Find destinations for resources files
def get_resources_dests(resources_root, rules): """Find destinations for resources files""" def get_rel_path(root, path): # normalizes and returns a lstripped-/-separated path root = root.replace(os.path.sep, '/') path = path.replace(os.path.sep, '/') assert path.startswith(root...
[ "def", "get_resources_dests", "(", "resources_root", ",", "rules", ")", ":", "def", "get_rel_path", "(", "root", ",", "path", ")", ":", "# normalizes and returns a lstripped-/-separated path", "root", "=", "root", ".", "replace", "(", "os", ".", "path", ".", "se...
[ 265, 0 ]
[ 288, 23 ]
python
en
['en', 'en', 'en']
True
convert_path
(pathname)
Return 'pathname' as a name that will work on the native filesystem. The path is split on '/' and put back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we ca...
Return 'pathname' as a name that will work on the native filesystem.
def convert_path(pathname): """Return 'pathname' as a name that will work on the native filesystem. The path is split on '/' and put back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to th...
[ "def", "convert_path", "(", "pathname", ")", ":", "if", "os", ".", "sep", "==", "'/'", ":", "return", "pathname", "if", "not", "pathname", ":", "return", "pathname", "if", "pathname", "[", "0", "]", "==", "'/'", ":", "raise", "ValueError", "(", "\"path...
[ 450, 0 ]
[ 474, 31 ]
python
en
['en', 'en', 'en']
True
get_cache_base
(suffix=None)
Return the default base location for distlib caches. If the directory does not exist, it is created. Use the suffix provided for the base directory, and default to '.distlib' if it isn't provided. On Windows, if LOCALAPPDATA is defined in the environment, then it is assumed to be a directory, and ...
Return the default base location for distlib caches. If the directory does not exist, it is created. Use the suffix provided for the base directory, and default to '.distlib' if it isn't provided.
def get_cache_base(suffix=None): """ Return the default base location for distlib caches. If the directory does not exist, it is created. Use the suffix provided for the base directory, and default to '.distlib' if it isn't provided. On Windows, if LOCALAPPDATA is defined in the environment, then i...
[ "def", "get_cache_base", "(", "suffix", "=", "None", ")", ":", "if", "suffix", "is", "None", ":", "suffix", "=", "'.distlib'", "if", "os", ".", "name", "==", "'nt'", "and", "'LOCALAPPDATA'", "in", "os", ".", "environ", ":", "result", "=", "os", ".", ...
[ 739, 0 ]
[ 777, 39 ]
python
en
['en', 'error', 'th']
False
path_to_cache_dir
(path)
Convert an absolute path to a directory name for use in a cache. The algorithm used is: #. On Windows, any ``':'`` in the drive is replaced with ``'---'``. #. Any occurrence of ``os.sep`` is replaced with ``'--'``. #. ``'.cache'`` is appended.
Convert an absolute path to a directory name for use in a cache.
def path_to_cache_dir(path): """ Convert an absolute path to a directory name for use in a cache. The algorithm used is: #. On Windows, any ``':'`` in the drive is replaced with ``'---'``. #. Any occurrence of ``os.sep`` is replaced with ``'--'``. #. ``'.cache'`` is appended. """ d, p ...
[ "def", "path_to_cache_dir", "(", "path", ")", ":", "d", ",", "p", "=", "os", ".", "path", ".", "splitdrive", "(", "os", ".", "path", ".", "abspath", "(", "path", ")", ")", "if", "d", ":", "d", "=", "d", ".", "replace", "(", "':'", ",", "'---'",...
[ 780, 0 ]
[ 794, 27 ]
python
en
['en', 'error', 'th']
False
split_filename
(filename, project_name=None)
Extract name, version, python version from a filename (no extension) Return name, version, pyver or None
Extract name, version, python version from a filename (no extension)
def split_filename(filename, project_name=None): """ Extract name, version, python version from a filename (no extension) Return name, version, pyver or None """ result = None pyver = None filename = unquote(filename).replace(' ', '-') m = PYTHON_VERSION.search(filename) if m: ...
[ "def", "split_filename", "(", "filename", ",", "project_name", "=", "None", ")", ":", "result", "=", "None", "pyver", "=", "None", "filename", "=", "unquote", "(", "filename", ")", ".", "replace", "(", "' '", ",", "'-'", ")", "m", "=", "PYTHON_VERSION", ...
[ 838, 0 ]
[ 860, 17 ]
python
en
['en', 'error', 'th']
False
parse_name_and_version
(p)
A utility method used to get name and version from a string. From e.g. a Provides-Dist value. :param p: A value in a form 'foo (1.0)' :return: The name and version as a tuple.
A utility method used to get name and version from a string.
def parse_name_and_version(p): """ A utility method used to get name and version from a string. From e.g. a Provides-Dist value. :param p: A value in a form 'foo (1.0)' :return: The name and version as a tuple. """ m = NAME_VERSION_RE.match(p) if not m: raise DistlibException('...
[ "def", "parse_name_and_version", "(", "p", ")", ":", "m", "=", "NAME_VERSION_RE", ".", "match", "(", "p", ")", "if", "not", "m", ":", "raise", "DistlibException", "(", "'Ill-formed name/version string: \\'%s\\''", "%", "p", ")", "d", "=", "m", ".", "groupdic...
[ 866, 0 ]
[ 879, 46 ]
python
en
['en', 'error', 'th']
False
zip_dir
(directory)
zip a directory tree into a BytesIO object
zip a directory tree into a BytesIO object
def zip_dir(directory): """zip a directory tree into a BytesIO object""" result = io.BytesIO() dlen = len(directory) with ZipFile(result, "w") as zf: for root, dirs, files in os.walk(directory): for name in files: full = os.path.join(root, name) rel = ...
[ "def", "zip_dir", "(", "directory", ")", ":", "result", "=", "io", ".", "BytesIO", "(", ")", "dlen", "=", "len", "(", "directory", ")", "with", "ZipFile", "(", "result", ",", "\"w\"", ")", "as", "zf", ":", "for", "root", ",", "dirs", ",", "files", ...
[ 1252, 0 ]
[ 1263, 17 ]
python
en
['en', 'en', 'en']
True
iglob
(path_glob)
Extended globbing function that supports ** and {opt1,opt2,opt3}.
Extended globbing function that supports ** and {opt1,opt2,opt3}.
def iglob(path_glob): """Extended globbing function that supports ** and {opt1,opt2,opt3}.""" if _CHECK_RECURSIVE_GLOB.search(path_glob): msg = """invalid glob %r: recursive glob "**" must be used alone""" raise ValueError(msg % path_glob) if _CHECK_MISMATCH_SET.search(path_glob): ms...
[ "def", "iglob", "(", "path_glob", ")", ":", "if", "_CHECK_RECURSIVE_GLOB", ".", "search", "(", "path_glob", ")", ":", "msg", "=", "\"\"\"invalid glob %r: recursive glob \"**\" must be used alone\"\"\"", "raise", "ValueError", "(", "msg", "%", "path_glob", ")", "if", ...
[ 1370, 0 ]
[ 1378, 28 ]
python
en
['en', 'en', 'en']
True
normalize_name
(name)
Normalize a python package name a la PEP 503
Normalize a python package name a la PEP 503
def normalize_name(name): """Normalize a python package name a la PEP 503""" # https://www.python.org/dev/peps/pep-0503/#normalized-names return re.sub('[-_.]+', '-', name).lower()
[ "def", "normalize_name", "(", "name", ")", ":", "# https://www.python.org/dev/peps/pep-0503/#normalized-names", "return", "re", ".", "sub", "(", "'[-_.]+'", ",", "'-'", ",", "name", ")", ".", "lower", "(", ")" ]
[ 1757, 0 ]
[ 1760, 46 ]
python
en
['es', 'en', 'en']
True
FileOperator.newer
(self, source, target)
Tell if the target is newer than the source. Returns true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target' doesn't. Returns false if both exist and 'target' is the same age or younger than 'source'. Raise PackagingFileError if 'source' ...
Tell if the target is newer than the source.
def newer(self, source, target): """Tell if the target is newer than the source. Returns true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target' doesn't. Returns false if both exist and 'target' is the same age or younger than 'so...
[ "def", "newer", "(", "self", ",", "source", ",", "target", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "source", ")", ":", "raise", "DistlibException", "(", "\"file '%r' does not exist\"", "%", "os", ".", "path", ".", "abspath", "(", ...
[ 492, 4 ]
[ 510, 66 ]
python
en
['en', 'en', 'en']
True
FileOperator.copy_file
(self, infile, outfile, check=True)
Copy a file respecting dry-run and force flags.
Copy a file respecting dry-run and force flags.
def copy_file(self, infile, outfile, check=True): """Copy a file respecting dry-run and force flags. """ self.ensure_dir(os.path.dirname(outfile)) logger.info('Copying %s to %s', infile, outfile) if not self.dry_run: msg = None if check: if...
[ "def", "copy_file", "(", "self", ",", "infile", ",", "outfile", ",", "check", "=", "True", ")", ":", "self", ".", "ensure_dir", "(", "os", ".", "path", ".", "dirname", "(", "outfile", ")", ")", "logger", ".", "info", "(", "'Copying %s to %s'", ",", "...
[ 512, 4 ]
[ 527, 39 ]
python
en
['en', 'en', 'en']
True
FileOperator.commit
(self)
Commit recorded changes, turn off recording, return changes.
Commit recorded changes, turn off recording, return changes.
def commit(self): """ Commit recorded changes, turn off recording, return changes. """ assert self.record result = self.files_written, self.dirs_created self._init_record() return result
[ "def", "commit", "(", "self", ")", ":", "assert", "self", ".", "record", "result", "=", "self", ".", "files_written", ",", "self", ".", "dirs_created", "self", ".", "_init_record", "(", ")", "return", "result" ]
[ 632, 4 ]
[ 640, 21 ]
python
en
['en', 'error', 'th']
False
Cache.__init__
(self, base)
Initialise an instance. :param base: The base directory where the cache should be located.
Initialise an instance.
def __init__(self, base): """ Initialise an instance. :param base: The base directory where the cache should be located. """ # we use 'isdir' instead of 'exists', because we want to # fail if there's a file with that name if not os.path.isdir(base): # pragma: no...
[ "def", "__init__", "(", "self", ",", "base", ")", ":", "# we use 'isdir' instead of 'exists', because we want to", "# fail if there's a file with that name", "if", "not", "os", ".", "path", ".", "isdir", "(", "base", ")", ":", "# pragma: no cover", "os", ".", "makedir...
[ 947, 4 ]
[ 959, 59 ]
python
en
['en', 'error', 'th']
False
Cache.prefix_to_dir
(self, prefix)
Converts a resource prefix to a directory name in the cache.
Converts a resource prefix to a directory name in the cache.
def prefix_to_dir(self, prefix): """ Converts a resource prefix to a directory name in the cache. """ return path_to_cache_dir(prefix)
[ "def", "prefix_to_dir", "(", "self", ",", "prefix", ")", ":", "return", "path_to_cache_dir", "(", "prefix", ")" ]
[ 961, 4 ]
[ 965, 40 ]
python
en
['en', 'error', 'th']
False
Cache.clear
(self)
Clear the cache.
Clear the cache.
def clear(self): """ Clear the cache. """ not_removed = [] for fn in os.listdir(self.base): fn = os.path.join(self.base, fn) try: if os.path.islink(fn) or os.path.isfile(fn): os.remove(fn) elif os.path.is...
[ "def", "clear", "(", "self", ")", ":", "not_removed", "=", "[", "]", "for", "fn", "in", "os", ".", "listdir", "(", "self", ".", "base", ")", ":", "fn", "=", "os", ".", "path", ".", "join", "(", "self", ".", "base", ",", "fn", ")", "try", ":",...
[ 967, 4 ]
[ 981, 26 ]
python
en
['en', 'error', 'th']
False
EventMixin.add
(self, event, subscriber, append=True)
Add a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be added (and called when the event is published). :param append: Whether to append or prepend the subscriber to an existing subscri...
Add a subscriber for an event.
def add(self, event, subscriber, append=True): """ Add a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be added (and called when the event is published). :param append: Whether to append or prepend th...
[ "def", "add", "(", "self", ",", "event", ",", "subscriber", ",", "append", "=", "True", ")", ":", "subs", "=", "self", ".", "_subscribers", "if", "event", "not", "in", "subs", ":", "subs", "[", "event", "]", "=", "deque", "(", "[", "subscriber", "]...
[ 991, 4 ]
[ 1009, 41 ]
python
en
['en', 'error', 'th']
False
EventMixin.remove
(self, event, subscriber)
Remove a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be removed.
Remove a subscriber for an event.
def remove(self, event, subscriber): """ Remove a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be removed. """ subs = self._subscribers if event not in subs: raise ValueError('No subscribers: %r' % ...
[ "def", "remove", "(", "self", ",", "event", ",", "subscriber", ")", ":", "subs", "=", "self", ".", "_subscribers", "if", "event", "not", "in", "subs", ":", "raise", "ValueError", "(", "'No subscribers: %r'", "%", "event", ")", "subs", "[", "event", "]", ...
[ 1011, 4 ]
[ 1021, 38 ]
python
en
['en', 'error', 'th']
False
EventMixin.get_subscribers
(self, event)
Return an iterator for the subscribers for an event. :param event: The event to return subscribers for.
Return an iterator for the subscribers for an event. :param event: The event to return subscribers for.
def get_subscribers(self, event): """ Return an iterator for the subscribers for an event. :param event: The event to return subscribers for. """ return iter(self._subscribers.get(event, ()))
[ "def", "get_subscribers", "(", "self", ",", "event", ")", ":", "return", "iter", "(", "self", ".", "_subscribers", ".", "get", "(", "event", ",", "(", ")", ")", ")" ]
[ 1023, 4 ]
[ 1028, 53 ]
python
en
['en', 'error', 'th']
False
EventMixin.publish
(self, event, *args, **kwargs)
Publish a event and return a list of values returned by its subscribers. :param event: The event to publish. :param args: The positional arguments to pass to the event's subscribers. :param kwargs: The keyword arguments to pass to the event's ...
Publish a event and return a list of values returned by its subscribers.
def publish(self, event, *args, **kwargs): """ Publish a event and return a list of values returned by its subscribers. :param event: The event to publish. :param args: The positional arguments to pass to the event's subscribers. :param kwargs: The k...
[ "def", "publish", "(", "self", ",", "event", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "[", "]", "for", "subscriber", "in", "self", ".", "get_subscribers", "(", "event", ")", ":", "try", ":", "value", "=", "subscriber", "(...
[ 1030, 4 ]
[ 1051, 21 ]
python
en
['en', 'error', 'th']
False
Configurator.inc_convert
(self, value)
Default converter for the inc:// protocol.
Default converter for the inc:// protocol.
def inc_convert(self, value): """Default converter for the inc:// protocol.""" if not os.path.isabs(value): value = os.path.join(self.base, value) with codecs.open(value, 'r', encoding='utf-8') as f: result = json.load(f) return result
[ "def", "inc_convert", "(", "self", ",", "value", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "value", ")", ":", "value", "=", "os", ".", "path", ".", "join", "(", "self", ".", "base", ",", "value", ")", "with", "codecs", ".", "...
[ 1702, 4 ]
[ 1708, 21 ]
python
en
['en', 'en', 'en']
True
SubprocessMixin.reader
(self, stream, context)
Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr.
Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr.
def reader(self, stream, context): """ Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr. """ progress = self.progress verbose = self.verbose while True: s = st...
[ "def", "reader", "(", "self", ",", "stream", ",", "context", ")", ":", "progress", "=", "self", ".", "progress", "verbose", "=", "self", ".", "verbose", "while", "True", ":", "s", "=", "stream", ".", "readline", "(", ")", "if", "not", "s", ":", "br...
[ 1719, 4 ]
[ 1738, 22 ]
python
en
['en', 'error', 'th']
False
show_formats
()
Print list of available formats (arguments to "--format" option).
Print list of available formats (arguments to "--format" option).
def show_formats(): """Print list of available formats (arguments to "--format" option). """ from distutils.fancy_getopt import FancyGetopt formats = [] for format in bdist.format_commands: formats.append(("formats=" + format, None, bdist.format_command[format][1])) ...
[ "def", "show_formats", "(", ")", ":", "from", "distutils", ".", "fancy_getopt", "import", "FancyGetopt", "formats", "=", "[", "]", "for", "format", "in", "bdist", ".", "format_commands", ":", "formats", ".", "append", "(", "(", "\"formats=\"", "+", "format",...
[ 11, 0 ]
[ 20, 72 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.pop
(self, key, default=__marker)
D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised.
D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised.
def pop(self, key, default=__marker): """D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. """ # Using the MutableMapping function directly fails due to the private marker. # Us...
[ "def", "pop", "(", "self", ",", "key", ",", "default", "=", "__marker", ")", ":", "# Using the MutableMapping function directly fails due to the private marker.", "# Using ordinary dict.pop would expose the internal structures.", "# So let's reinvent the wheel.", "try", ":", "value...
[ 190, 4 ]
[ 205, 24 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.add
(self, key, val)
Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz'
Adds a (name, value) pair, doesn't overwrite the value if it already exists.
def add(self, key, val): """Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' """ key_lower = key.lower() new_vals = [ke...
[ "def", "add", "(", "self", ",", "key", ",", "val", ")", ":", "key_lower", "=", "key", ".", "lower", "(", ")", "new_vals", "=", "[", "key", ",", "val", "]", "# Keep the common case aka no item present as fast as possible", "vals", "=", "self", ".", "_containe...
[ 213, 4 ]
[ 227, 28 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.extend
(self, *args, **kwargs)
Generic import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__
Generic import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__
def extend(self, *args, **kwargs): """Generic import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__ """ if len(args) > 1: raise TypeError( "extend...
[ "def", "extend", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", ">", "1", ":", "raise", "TypeError", "(", "\"extend() takes at most 1 positional \"", "\"arguments ({0} given)\"", ".", "format", "(", "len", ...
[ 229, 4 ]
[ 255, 32 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.getlist
(self, key, default=__marker)
Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.
Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.
def getlist(self, key, default=__marker): """Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.""" try: vals = self._container[key.lower()] except KeyError: if default is self.__marker: return [] ...
[ "def", "getlist", "(", "self", ",", "key", ",", "default", "=", "__marker", ")", ":", "try", ":", "vals", "=", "self", ".", "_container", "[", "key", ".", "lower", "(", ")", "]", "except", "KeyError", ":", "if", "default", "is", "self", ".", "__mar...
[ 257, 4 ]
[ 267, 27 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.iteritems
(self)
Iterate over all header lines, including duplicate ones.
Iterate over all header lines, including duplicate ones.
def iteritems(self): """Iterate over all header lines, including duplicate ones.""" for key in self: vals = self._container[key.lower()] for val in vals[1:]: yield vals[0], val
[ "def", "iteritems", "(", "self", ")", ":", "for", "key", "in", "self", ":", "vals", "=", "self", ".", "_container", "[", "key", ".", "lower", "(", ")", "]", "for", "val", "in", "vals", "[", "1", ":", "]", ":", "yield", "vals", "[", "0", "]", ...
[ 293, 4 ]
[ 298, 34 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.itermerged
(self)
Iterate over all headers, merging duplicate ones together.
Iterate over all headers, merging duplicate ones together.
def itermerged(self): """Iterate over all headers, merging duplicate ones together.""" for key in self: val = self._container[key.lower()] yield val[0], ", ".join(val[1:])
[ "def", "itermerged", "(", "self", ")", ":", "for", "key", "in", "self", ":", "val", "=", "self", ".", "_container", "[", "key", ".", "lower", "(", ")", "]", "yield", "val", "[", "0", "]", ",", "\", \"", ".", "join", "(", "val", "[", "1", ":", ...
[ 300, 4 ]
[ 304, 44 ]
python
en
['en', 'en', 'en']
True
HTTPHeaderDict.from_httplib
(cls, message)
Read headers from a Python 2 httplib message object.
Read headers from a Python 2 httplib message object.
def from_httplib(cls, message): # Python 2 """Read headers from a Python 2 httplib message object.""" # python2.7 does not expose a proper API for exporting multiheaders # efficiently. This function re-reads raw lines from the message # object and extracts the multiheaders properly. ...
[ "def", "from_httplib", "(", "cls", ",", "message", ")", ":", "# Python 2", "# python2.7 does not expose a proper API for exporting multiheaders", "# efficiently. This function re-reads raw lines from the message", "# object and extracts the multiheaders properly.", "obs_fold_continued_leader...
[ 310, 4 ]
[ 335, 27 ]
python
en
['en', 'en', 'en']
True
luhn
(candidate)
Checks a candidate number for validity according to the Luhn algorithm (used in validation of, for example, credit cards). Both numeric and string candidates are accepted.
Checks a candidate number for validity according to the Luhn algorithm (used in validation of, for example, credit cards). Both numeric and string candidates are accepted.
def luhn(candidate): """ Checks a candidate number for validity according to the Luhn algorithm (used in validation of, for example, credit cards). Both numeric and string candidates are accepted. """ if not isinstance(candidate, six.string_types): candidate = str(candidate) try: ...
[ "def", "luhn", "(", "candidate", ")", ":", "if", "not", "isinstance", "(", "candidate", ",", "six", ".", "string_types", ")", ":", "candidate", "=", "str", "(", "candidate", ")", "try", ":", "evens", "=", "sum", "(", "int", "(", "c", ")", "for", "c...
[ 11, 0 ]
[ 24, 20 ]
python
en
['en', 'error', 'th']
False
print_header
(text)
Prints header with given text and frame composed of '#' characters.
Prints header with given text and frame composed of '#' characters.
def print_header(text): """Prints header with given text and frame composed of '#' characters.""" print() print("#" * (len(text) + 4)) print("# " + text + " #") print("#" * (len(text) + 4)) print()
[ "def", "print_header", "(", "text", ")", ":", "print", "(", ")", "print", "(", "\"#\"", "*", "(", "len", "(", "text", ")", "+", "4", ")", ")", "print", "(", "\"# \"", "+", "text", "+", "\" #\"", ")", "print", "(", "\"#\"", "*", "(", "len", "(",...
[ 39, 0 ]
[ 45, 11 ]
python
en
['en', 'en', 'en']
True
save_dict_to_file
(filename, dictionary)
Saves dictionary as CSV file.
Saves dictionary as CSV file.
def save_dict_to_file(filename, dictionary): """Saves dictionary as CSV file.""" with open(filename, "w") as f: writer = csv.writer(f) for k, v in iteritems(dictionary): writer.writerow([str(k), str(v)])
[ "def", "save_dict_to_file", "(", "filename", ",", "dictionary", ")", ":", "with", "open", "(", "filename", ",", "\"w\"", ")", "as", "f", ":", "writer", "=", "csv", ".", "writer", "(", "f", ")", "for", "k", ",", "v", "in", "iteritems", "(", "dictionar...
[ 48, 0 ]
[ 53, 45 ]
python
en
['en', 'en', 'en']
True
main
(args)
Main function which runs master.
Main function which runs master.
def main(args): """Main function which runs master.""" if args.blacklisted_submissions: logging.warning("BLACKLISTED SUBMISSIONS: %s", args.blacklisted_submissions) if args.limited_dataset: logging.info("Using limited dataset: 3 batches * 10 images") max_dataset_num_images = 30 ...
[ "def", "main", "(", "args", ")", ":", "if", "args", ".", "blacklisted_submissions", ":", "logging", ".", "warning", "(", "\"BLACKLISTED SUBMISSIONS: %s\"", ",", "args", ".", "blacklisted_submissions", ")", "if", "args", ".", "limited_dataset", ":", "logging", "....
[ 817, 0 ]
[ 866, 20 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster.__init__
( self, storage_client, datastore_client, round_name, dataset_name, blacklisted_submissions="", results_dir="", num_defense_shards=None, verbose=False, batch_size=DEFAULT_BATCH_SIZE, max_dataset_num_images=None, )
Initializes EvaluationMaster. Args: storage_client: instance of eval_lib.CompetitionStorageClient datastore_client: instance of eval_lib.CompetitionDatastoreClient round_name: name of the current round dataset_name: name of the dataset, 'dev' or 'final' blackli...
Initializes EvaluationMaster.
def __init__( self, storage_client, datastore_client, round_name, dataset_name, blacklisted_submissions="", results_dir="", num_defense_shards=None, verbose=False, batch_size=DEFAULT_BATCH_SIZE, max_dataset_num_images=None, ): ...
[ "def", "__init__", "(", "self", ",", "storage_client", ",", "datastore_client", ",", "round_name", ",", "dataset_name", ",", "blacklisted_submissions", "=", "\"\"", ",", "results_dir", "=", "\"\"", ",", "num_defense_shards", "=", "None", ",", "verbose", "=", "Fa...
[ 59, 4 ]
[ 129, 9 ]
python
en
['pl', 'zu', 'en']
False
EvaluationMaster.ask_when_work_is_populated
(self, work)
When work is already populated asks whether we should continue. This method prints warning message that work is populated and asks whether user wants to continue or not. Args: work: instance of WorkPiecesBase Returns: True if we should continue and populate datasto...
When work is already populated asks whether we should continue.
def ask_when_work_is_populated(self, work): """When work is already populated asks whether we should continue. This method prints warning message that work is populated and asks whether user wants to continue or not. Args: work: instance of WorkPiecesBase Returns: ...
[ "def", "ask_when_work_is_populated", "(", "self", ",", "work", ")", ":", "work", ".", "read_all_from_datastore", "(", ")", "if", "work", ".", "work", ":", "print", "(", "\"Work is already written to datastore.\\n\"", "\"If you continue these data will be overwritten and \""...
[ 131, 4 ]
[ 155, 23 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster.prepare_attacks
(self)
Prepares all data needed for evaluation of attacks.
Prepares all data needed for evaluation of attacks.
def prepare_attacks(self): """Prepares all data needed for evaluation of attacks.""" print_header("PREPARING ATTACKS DATA") # verify that attacks data not written yet if not self.ask_when_work_is_populated(self.attack_work): return self.attack_work = eval_lib.AttackWo...
[ "def", "prepare_attacks", "(", "self", ")", ":", "print_header", "(", "\"PREPARING ATTACKS DATA\"", ")", "# verify that attacks data not written yet", "if", "not", "self", ".", "ask_when_work_is_populated", "(", "self", ".", "attack_work", ")", ":", "return", "self", ...
[ 157, 4 ]
[ 194, 35 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster.prepare_defenses
(self)
Prepares all data needed for evaluation of defenses.
Prepares all data needed for evaluation of defenses.
def prepare_defenses(self): """Prepares all data needed for evaluation of defenses.""" print_header("PREPARING DEFENSE DATA") # verify that defense data not written yet if not self.ask_when_work_is_populated(self.defense_work): return self.defense_work = eval_lib.Defe...
[ "def", "prepare_defenses", "(", "self", ")", ":", "print_header", "(", "\"PREPARING DEFENSE DATA\"", ")", "# verify that defense data not written yet", "if", "not", "self", ".", "ask_when_work_is_populated", "(", "self", ".", "defense_work", ")", ":", "return", "self", ...
[ 196, 4 ]
[ 224, 36 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster._save_work_results
(self, run_stats, scores, num_processed_images, filename)
Saves statistics about each submission. Saved statistics include score; number of completed and failed batches; min, max, average and median time needed to run one batch. Args: run_stats: dictionary with runtime statistics for submissions, can be generated by WorkPiecesBa...
Saves statistics about each submission.
def _save_work_results(self, run_stats, scores, num_processed_images, filename): """Saves statistics about each submission. Saved statistics include score; number of completed and failed batches; min, max, average and median time needed to run one batch. Args: run_stats: dict...
[ "def", "_save_work_results", "(", "self", ",", "run_stats", ",", "scores", ",", "num_processed_images", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "\"w\"", ")", "as", "f", ":", "writer", "=", "csv", ".", "writer", "(", "f", ")", "...
[ 226, 4 ]
[ 282, 17 ]
python
en
['en', 'en', 'en']
True
EvaluationMaster._save_sorted_results
(self, run_stats, scores, image_count, filename)
Saves sorted (by score) results of the evaluation. Args: run_stats: dictionary with runtime statistics for submissions, can be generated by WorkPiecesBase.compute_work_statistics scores: dictionary mapping submission ids to scores image_count: dictionary with number of...
Saves sorted (by score) results of the evaluation.
def _save_sorted_results(self, run_stats, scores, image_count, filename): """Saves sorted (by score) results of the evaluation. Args: run_stats: dictionary with runtime statistics for submissions, can be generated by WorkPiecesBase.compute_work_statistics scores: diction...
[ "def", "_save_sorted_results", "(", "self", ",", "run_stats", ",", "scores", ",", "image_count", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "\"w\"", ")", "as", "f", ":", "writer", "=", "csv", ".", "writer", "(", "f", ")", "writer"...
[ 284, 4 ]
[ 317, 17 ]
python
en
['en', 'en', 'en']
True