id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
11,900
toastdriven/restless
restless/tnd.py
TornadoResource.as_view
def as_view(cls, view_type, *init_args, **init_kwargs): """ Return a subclass of tornado.web.RequestHandler and apply required setting. """ global _method new_cls = type( cls.__name__ + '_' + _BridgeMixin.__name__ + '_restless', (_BridgeMixin, cls...
python
def as_view(cls, view_type, *init_args, **init_kwargs): """ Return a subclass of tornado.web.RequestHandler and apply required setting. """ global _method new_cls = type( cls.__name__ + '_' + _BridgeMixin.__name__ + '_restless', (_BridgeMixin, cls...
[ "def", "as_view", "(", "cls", ",", "view_type", ",", "*", "init_args", ",", "*", "*", "init_kwargs", ")", ":", "global", "_method", "new_cls", "=", "type", "(", "cls", ".", "__name__", "+", "'_'", "+", "_BridgeMixin", ".", "__name__", "+", "'_restless'",...
Return a subclass of tornado.web.RequestHandler and apply required setting.
[ "Return", "a", "subclass", "of", "tornado", ".", "web", ".", "RequestHandler", "and", "apply", "required", "setting", "." ]
661593b7b43c42d1bc508dec795356297991255e
https://github.com/toastdriven/restless/blob/661593b7b43c42d1bc508dec795356297991255e/restless/tnd.py#L95-L123
11,901
toastdriven/restless
restless/tnd.py
TornadoResource.handle
def handle(self, endpoint, *args, **kwargs): """ almost identical to Resource.handle, except the way we handle the return value of view_method. """ method = self.request_method() try: if not method in self.http_methods.get(endpoint, {}): raise...
python
def handle(self, endpoint, *args, **kwargs): """ almost identical to Resource.handle, except the way we handle the return value of view_method. """ method = self.request_method() try: if not method in self.http_methods.get(endpoint, {}): raise...
[ "def", "handle", "(", "self", ",", "endpoint", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "method", "=", "self", ".", "request_method", "(", ")", "try", ":", "if", "not", "method", "in", "self", ".", "http_methods", ".", "get", "(", "endp...
almost identical to Resource.handle, except the way we handle the return value of view_method.
[ "almost", "identical", "to", "Resource", ".", "handle", "except", "the", "way", "we", "handle", "the", "return", "value", "of", "view_method", "." ]
661593b7b43c42d1bc508dec795356297991255e
https://github.com/toastdriven/restless/blob/661593b7b43c42d1bc508dec795356297991255e/restless/tnd.py#L147-L177
11,902
toastdriven/restless
restless/preparers.py
FieldsPreparer.prepare
def prepare(self, data): """ Handles transforming the provided data into the fielded data that should be exposed to the end user. Uses the ``lookup_data`` method to traverse dotted paths. Returns a dictionary of data as the response. """ result = {} if ...
python
def prepare(self, data): """ Handles transforming the provided data into the fielded data that should be exposed to the end user. Uses the ``lookup_data`` method to traverse dotted paths. Returns a dictionary of data as the response. """ result = {} if ...
[ "def", "prepare", "(", "self", ",", "data", ")", ":", "result", "=", "{", "}", "if", "not", "self", ".", "fields", ":", "# No fields specified. Serialize everything.", "return", "data", "for", "fieldname", ",", "lookup", "in", "self", ".", "fields", ".", "...
Handles transforming the provided data into the fielded data that should be exposed to the end user. Uses the ``lookup_data`` method to traverse dotted paths. Returns a dictionary of data as the response.
[ "Handles", "transforming", "the", "provided", "data", "into", "the", "fielded", "data", "that", "should", "be", "exposed", "to", "the", "end", "user", "." ]
661593b7b43c42d1bc508dec795356297991255e
https://github.com/toastdriven/restless/blob/661593b7b43c42d1bc508dec795356297991255e/restless/preparers.py#L42-L63
11,903
toastdriven/restless
restless/preparers.py
FieldsPreparer.lookup_data
def lookup_data(self, lookup, data): """ Given a lookup string, attempts to descend through nested data looking for the value. Can work with either dictionary-alikes or objects (or any combination of those). Lookups should be a string. If it is a dotted path, it will be...
python
def lookup_data(self, lookup, data): """ Given a lookup string, attempts to descend through nested data looking for the value. Can work with either dictionary-alikes or objects (or any combination of those). Lookups should be a string. If it is a dotted path, it will be...
[ "def", "lookup_data", "(", "self", ",", "lookup", ",", "data", ")", ":", "value", "=", "data", "parts", "=", "lookup", ".", "split", "(", "'.'", ")", "if", "not", "parts", "or", "not", "parts", "[", "0", "]", ":", "return", "value", "part", "=", ...
Given a lookup string, attempts to descend through nested data looking for the value. Can work with either dictionary-alikes or objects (or any combination of those). Lookups should be a string. If it is a dotted path, it will be split on ``.`` & it will traverse through to fin...
[ "Given", "a", "lookup", "string", "attempts", "to", "descend", "through", "nested", "data", "looking", "for", "the", "value", "." ]
661593b7b43c42d1bc508dec795356297991255e
https://github.com/toastdriven/restless/blob/661593b7b43c42d1bc508dec795356297991255e/restless/preparers.py#L65-L123
11,904
toastdriven/restless
restless/preparers.py
CollectionSubPreparer.prepare
def prepare(self, data): """ Handles passing each item in the collection data to the configured subpreparer. Uses a loop and the ``get_inner_data`` method to provide the correct item of the data. Returns a list of data as the response. """ result = [] ...
python
def prepare(self, data): """ Handles passing each item in the collection data to the configured subpreparer. Uses a loop and the ``get_inner_data`` method to provide the correct item of the data. Returns a list of data as the response. """ result = [] ...
[ "def", "prepare", "(", "self", ",", "data", ")", ":", "result", "=", "[", "]", "for", "item", "in", "self", ".", "get_inner_data", "(", "data", ")", ":", "result", ".", "append", "(", "self", ".", "preparer", ".", "prepare", "(", "item", ")", ")", ...
Handles passing each item in the collection data to the configured subpreparer. Uses a loop and the ``get_inner_data`` method to provide the correct item of the data. Returns a list of data as the response.
[ "Handles", "passing", "each", "item", "in", "the", "collection", "data", "to", "the", "configured", "subpreparer", "." ]
661593b7b43c42d1bc508dec795356297991255e
https://github.com/toastdriven/restless/blob/661593b7b43c42d1bc508dec795356297991255e/restless/preparers.py#L201-L216
11,905
toastdriven/restless
restless/dj.py
DjangoResource.build_url_name
def build_url_name(cls, name, name_prefix=None): """ Given a ``name`` & an optional ``name_prefix``, this generates a name for a URL. :param name: The name for the URL (ex. 'detail') :type name: string :param name_prefix: (Optional) A prefix for the URL's name (for ...
python
def build_url_name(cls, name, name_prefix=None): """ Given a ``name`` & an optional ``name_prefix``, this generates a name for a URL. :param name: The name for the URL (ex. 'detail') :type name: string :param name_prefix: (Optional) A prefix for the URL's name (for ...
[ "def", "build_url_name", "(", "cls", ",", "name", ",", "name_prefix", "=", "None", ")", ":", "if", "name_prefix", "is", "None", ":", "name_prefix", "=", "'api_{}'", ".", "format", "(", "cls", ".", "__name__", ".", "replace", "(", "'Resource'", ",", "''",...
Given a ``name`` & an optional ``name_prefix``, this generates a name for a URL. :param name: The name for the URL (ex. 'detail') :type name: string :param name_prefix: (Optional) A prefix for the URL's name (for resolving). The default is ``None``, which will autocreate a ...
[ "Given", "a", "name", "&", "an", "optional", "name_prefix", "this", "generates", "a", "name", "for", "a", "URL", "." ]
661593b7b43c42d1bc508dec795356297991255e
https://github.com/toastdriven/restless/blob/661593b7b43c42d1bc508dec795356297991255e/restless/dj.py#L90-L113
11,906
toastdriven/restless
restless/fl.py
FlaskResource.build_endpoint_name
def build_endpoint_name(cls, name, endpoint_prefix=None): """ Given a ``name`` & an optional ``endpoint_prefix``, this generates a name for a URL. :param name: The name for the URL (ex. 'detail') :type name: string :param endpoint_prefix: (Optional) A prefix for the URL...
python
def build_endpoint_name(cls, name, endpoint_prefix=None): """ Given a ``name`` & an optional ``endpoint_prefix``, this generates a name for a URL. :param name: The name for the URL (ex. 'detail') :type name: string :param endpoint_prefix: (Optional) A prefix for the URL...
[ "def", "build_endpoint_name", "(", "cls", ",", "name", ",", "endpoint_prefix", "=", "None", ")", ":", "if", "endpoint_prefix", "is", "None", ":", "endpoint_prefix", "=", "'api_{}'", ".", "format", "(", "cls", ".", "__name__", ".", "replace", "(", "'Resource'...
Given a ``name`` & an optional ``endpoint_prefix``, this generates a name for a URL. :param name: The name for the URL (ex. 'detail') :type name: string :param endpoint_prefix: (Optional) A prefix for the URL's name (for resolving). The default is ``None``, which will autoc...
[ "Given", "a", "name", "&", "an", "optional", "endpoint_prefix", "this", "generates", "a", "name", "for", "a", "URL", "." ]
661593b7b43c42d1bc508dec795356297991255e
https://github.com/toastdriven/restless/blob/661593b7b43c42d1bc508dec795356297991255e/restless/fl.py#L59-L82
11,907
toastdriven/restless
restless/pyr.py
PyramidResource.build_routename
def build_routename(cls, name, routename_prefix=None): """ Given a ``name`` & an optional ``routename_prefix``, this generates a name for a URL. :param name: The name for the URL (ex. 'detail') :type name: string :param routename_prefix: (Optional) A prefix for the URL'...
python
def build_routename(cls, name, routename_prefix=None): """ Given a ``name`` & an optional ``routename_prefix``, this generates a name for a URL. :param name: The name for the URL (ex. 'detail') :type name: string :param routename_prefix: (Optional) A prefix for the URL'...
[ "def", "build_routename", "(", "cls", ",", "name", ",", "routename_prefix", "=", "None", ")", ":", "if", "routename_prefix", "is", "None", ":", "routename_prefix", "=", "'api_{}'", ".", "format", "(", "cls", ".", "__name__", ".", "replace", "(", "'Resource'"...
Given a ``name`` & an optional ``routename_prefix``, this generates a name for a URL. :param name: The name for the URL (ex. 'detail') :type name: string :param routename_prefix: (Optional) A prefix for the URL's name (for resolving). The default is ``None``, which will aut...
[ "Given", "a", "name", "&", "an", "optional", "routename_prefix", "this", "generates", "a", "name", "for", "a", "URL", "." ]
661593b7b43c42d1bc508dec795356297991255e
https://github.com/toastdriven/restless/blob/661593b7b43c42d1bc508dec795356297991255e/restless/pyr.py#L41-L64
11,908
toastdriven/restless
restless/pyr.py
PyramidResource.add_views
def add_views(cls, config, rule_prefix, routename_prefix=None): """ A convenience method for registering the routes and views in pyramid. This automatically adds a list and detail endpoint to your routes. :param config: The pyramid ``Configurator`` object for your app. :type co...
python
def add_views(cls, config, rule_prefix, routename_prefix=None): """ A convenience method for registering the routes and views in pyramid. This automatically adds a list and detail endpoint to your routes. :param config: The pyramid ``Configurator`` object for your app. :type co...
[ "def", "add_views", "(", "cls", ",", "config", ",", "rule_prefix", ",", "routename_prefix", "=", "None", ")", ":", "methods", "=", "(", "'GET'", ",", "'POST'", ",", "'PUT'", ",", "'DELETE'", ")", "config", ".", "add_route", "(", "cls", ".", "build_routen...
A convenience method for registering the routes and views in pyramid. This automatically adds a list and detail endpoint to your routes. :param config: The pyramid ``Configurator`` object for your app. :type config: ``pyramid.config.Configurator`` :param rule_prefix: The start of the ...
[ "A", "convenience", "method", "for", "registering", "the", "routes", "and", "views", "in", "pyramid", "." ]
661593b7b43c42d1bc508dec795356297991255e
https://github.com/toastdriven/restless/blob/661593b7b43c42d1bc508dec795356297991255e/restless/pyr.py#L67-L107
11,909
toastdriven/restless
restless/serializers.py
JSONSerializer.deserialize
def deserialize(self, body): """ The low-level deserialization. Underpins ``deserialize``, ``deserialize_list`` & ``deserialize_detail``. Has no built-in smarts, simply loads the JSON. :param body: The body of the current request :type body: string :re...
python
def deserialize(self, body): """ The low-level deserialization. Underpins ``deserialize``, ``deserialize_list`` & ``deserialize_detail``. Has no built-in smarts, simply loads the JSON. :param body: The body of the current request :type body: string :re...
[ "def", "deserialize", "(", "self", ",", "body", ")", ":", "try", ":", "if", "isinstance", "(", "body", ",", "bytes", ")", ":", "return", "json", ".", "loads", "(", "body", ".", "decode", "(", "'utf-8'", ")", ")", "return", "json", ".", "loads", "("...
The low-level deserialization. Underpins ``deserialize``, ``deserialize_list`` & ``deserialize_detail``. Has no built-in smarts, simply loads the JSON. :param body: The body of the current request :type body: string :returns: The deserialized data :rtype: ``li...
[ "The", "low", "-", "level", "deserialization", "." ]
661593b7b43c42d1bc508dec795356297991255e
https://github.com/toastdriven/restless/blob/661593b7b43c42d1bc508dec795356297991255e/restless/serializers.py#L47-L67
11,910
mila-iqia/fuel
fuel/converters/mnist.py
convert_mnist
def convert_mnist(directory, output_directory, output_filename=None, dtype=None): """Converts the MNIST dataset to HDF5. Converts the MNIST dataset to an HDF5 dataset compatible with :class:`fuel.datasets.MNIST`. The converted dataset is saved as 'mnist.hdf5'. This method assumes...
python
def convert_mnist(directory, output_directory, output_filename=None, dtype=None): """Converts the MNIST dataset to HDF5. Converts the MNIST dataset to an HDF5 dataset compatible with :class:`fuel.datasets.MNIST`. The converted dataset is saved as 'mnist.hdf5'. This method assumes...
[ "def", "convert_mnist", "(", "directory", ",", "output_directory", ",", "output_filename", "=", "None", ",", "dtype", "=", "None", ")", ":", "if", "not", "output_filename", ":", "if", "dtype", ":", "output_filename", "=", "'mnist_{}.hdf5'", ".", "format", "(",...
Converts the MNIST dataset to HDF5. Converts the MNIST dataset to an HDF5 dataset compatible with :class:`fuel.datasets.MNIST`. The converted dataset is saved as 'mnist.hdf5'. This method assumes the existence of the following files: `train-images-idx3-ubyte.gz`, `train-labels-idx1-ubyte.gz` `...
[ "Converts", "the", "MNIST", "dataset", "to", "HDF5", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/mnist.py#L22-L92
11,911
mila-iqia/fuel
fuel/converters/mnist.py
fill_subparser
def fill_subparser(subparser): """Sets up a subparser to convert the MNIST dataset files. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `mnist` command. """ subparser.add_argument( "--dtype", help="dtype to save to; by default, images...
python
def fill_subparser(subparser): """Sets up a subparser to convert the MNIST dataset files. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `mnist` command. """ subparser.add_argument( "--dtype", help="dtype to save to; by default, images...
[ "def", "fill_subparser", "(", "subparser", ")", ":", "subparser", ".", "add_argument", "(", "\"--dtype\"", ",", "help", "=", "\"dtype to save to; by default, images will be \"", "+", "\"returned in their original unsigned byte format\"", ",", "choices", "=", "(", "'float32'...
Sets up a subparser to convert the MNIST dataset files. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `mnist` command.
[ "Sets", "up", "a", "subparser", "to", "convert", "the", "MNIST", "dataset", "files", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/mnist.py#L95-L108
11,912
mila-iqia/fuel
fuel/converters/mnist.py
read_mnist_images
def read_mnist_images(filename, dtype=None): """Read MNIST images from the original ubyte file format. Parameters ---------- filename : str Filename/path from which to read images. dtype : 'float32', 'float64', or 'bool' If unspecified, images will be returned in their original ...
python
def read_mnist_images(filename, dtype=None): """Read MNIST images from the original ubyte file format. Parameters ---------- filename : str Filename/path from which to read images. dtype : 'float32', 'float64', or 'bool' If unspecified, images will be returned in their original ...
[ "def", "read_mnist_images", "(", "filename", ",", "dtype", "=", "None", ")", ":", "with", "gzip", ".", "open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "magic", ",", "number", ",", "rows", ",", "cols", "=", "struct", ".", "unpack", "(", "...
Read MNIST images from the original ubyte file format. Parameters ---------- filename : str Filename/path from which to read images. dtype : 'float32', 'float64', or 'bool' If unspecified, images will be returned in their original unsigned byte format. Returns ------- ...
[ "Read", "MNIST", "images", "from", "the", "original", "ubyte", "file", "format", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/mnist.py#L111-L159
11,913
mila-iqia/fuel
fuel/converters/mnist.py
read_mnist_labels
def read_mnist_labels(filename): """Read MNIST labels from the original ubyte file format. Parameters ---------- filename : str Filename/path from which to read labels. Returns ------- labels : :class:`~numpy.ndarray`, shape (nlabels, 1) A one-dimensional unsigned byte arra...
python
def read_mnist_labels(filename): """Read MNIST labels from the original ubyte file format. Parameters ---------- filename : str Filename/path from which to read labels. Returns ------- labels : :class:`~numpy.ndarray`, shape (nlabels, 1) A one-dimensional unsigned byte arra...
[ "def", "read_mnist_labels", "(", "filename", ")", ":", "with", "gzip", ".", "open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "magic", ",", "_", "=", "struct", ".", "unpack", "(", "'>ii'", ",", "f", ".", "read", "(", "8", ")", ")", "if",...
Read MNIST labels from the original ubyte file format. Parameters ---------- filename : str Filename/path from which to read labels. Returns ------- labels : :class:`~numpy.ndarray`, shape (nlabels, 1) A one-dimensional unsigned byte array containing the labels as integ...
[ "Read", "MNIST", "labels", "from", "the", "original", "ubyte", "file", "format", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/mnist.py#L162-L183
11,914
mila-iqia/fuel
fuel/converters/ilsvrc2010.py
prepare_hdf5_file
def prepare_hdf5_file(hdf5_file, n_train, n_valid, n_test): """Create datasets within a given HDF5 file. Parameters ---------- hdf5_file : :class:`h5py.File` instance HDF5 file handle to which to write. n_train : int The number of training set examples. n_valid : int The...
python
def prepare_hdf5_file(hdf5_file, n_train, n_valid, n_test): """Create datasets within a given HDF5 file. Parameters ---------- hdf5_file : :class:`h5py.File` instance HDF5 file handle to which to write. n_train : int The number of training set examples. n_valid : int The...
[ "def", "prepare_hdf5_file", "(", "hdf5_file", ",", "n_train", ",", "n_valid", ",", "n_test", ")", ":", "n_total", "=", "n_train", "+", "n_valid", "+", "n_test", "splits", "=", "create_splits", "(", "n_train", ",", "n_valid", ",", "n_test", ")", "hdf5_file", ...
Create datasets within a given HDF5 file. Parameters ---------- hdf5_file : :class:`h5py.File` instance HDF5 file handle to which to write. n_train : int The number of training set examples. n_valid : int The number of validation set examples. n_test : int The nu...
[ "Create", "datasets", "within", "a", "given", "HDF5", "file", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/ilsvrc2010.py#L179-L201
11,915
mila-iqia/fuel
fuel/converters/ilsvrc2010.py
process_train_set
def process_train_set(hdf5_file, train_archive, patch_archive, n_train, wnid_map, shuffle_seed=None): """Process the ILSVRC2010 training set. Parameters ---------- hdf5_file : :class:`h5py.File` instance HDF5 file handle to which to write. Assumes `features`, `targets` ...
python
def process_train_set(hdf5_file, train_archive, patch_archive, n_train, wnid_map, shuffle_seed=None): """Process the ILSVRC2010 training set. Parameters ---------- hdf5_file : :class:`h5py.File` instance HDF5 file handle to which to write. Assumes `features`, `targets` ...
[ "def", "process_train_set", "(", "hdf5_file", ",", "train_archive", ",", "patch_archive", ",", "n_train", ",", "wnid_map", ",", "shuffle_seed", "=", "None", ")", ":", "producer", "=", "partial", "(", "train_set_producer", ",", "train_archive", "=", "train_archive"...
Process the ILSVRC2010 training set. Parameters ---------- hdf5_file : :class:`h5py.File` instance HDF5 file handle to which to write. Assumes `features`, `targets` and `filenames` already exist and have first dimension larger than `n_train`. train_archive : str or file-like ob...
[ "Process", "the", "ILSVRC2010", "training", "set", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/ilsvrc2010.py#L204-L232
11,916
mila-iqia/fuel
fuel/converters/ilsvrc2010.py
image_consumer
def image_consumer(socket, hdf5_file, num_expected, shuffle_seed=None, offset=0): """Fill an HDF5 file with incoming images from a socket. Parameters ---------- socket : :class:`zmq.Socket` PULL socket on which to receive images. hdf5_file : :class:`h5py.File` instance ...
python
def image_consumer(socket, hdf5_file, num_expected, shuffle_seed=None, offset=0): """Fill an HDF5 file with incoming images from a socket. Parameters ---------- socket : :class:`zmq.Socket` PULL socket on which to receive images. hdf5_file : :class:`h5py.File` instance ...
[ "def", "image_consumer", "(", "socket", ",", "hdf5_file", ",", "num_expected", ",", "shuffle_seed", "=", "None", ",", "offset", "=", "0", ")", ":", "with", "progress_bar", "(", "'images'", ",", "maxval", "=", "num_expected", ")", "as", "pb", ":", "if", "...
Fill an HDF5 file with incoming images from a socket. Parameters ---------- socket : :class:`zmq.Socket` PULL socket on which to receive images. hdf5_file : :class:`h5py.File` instance HDF5 file handle to which to write. Assumes `features`, `targets` and `filenames` already exis...
[ "Fill", "an", "HDF5", "file", "with", "incoming", "images", "from", "a", "socket", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/ilsvrc2010.py#L283-L316
11,917
mila-iqia/fuel
fuel/converters/ilsvrc2010.py
process_other_set
def process_other_set(hdf5_file, which_set, image_archive, patch_archive, groundtruth, offset): """Process the validation or test set. Parameters ---------- hdf5_file : :class:`h5py.File` instance HDF5 file handle to which to write. Assumes `features`, `targets` an...
python
def process_other_set(hdf5_file, which_set, image_archive, patch_archive, groundtruth, offset): """Process the validation or test set. Parameters ---------- hdf5_file : :class:`h5py.File` instance HDF5 file handle to which to write. Assumes `features`, `targets` an...
[ "def", "process_other_set", "(", "hdf5_file", ",", "which_set", ",", "image_archive", ",", "patch_archive", ",", "groundtruth", ",", "offset", ")", ":", "producer", "=", "partial", "(", "other_set_producer", ",", "image_archive", "=", "image_archive", ",", "patch_...
Process the validation or test set. Parameters ---------- hdf5_file : :class:`h5py.File` instance HDF5 file handle to which to write. Assumes `features`, `targets` and `filenames` already exist and have first dimension larger than `sum(images_per_class)`. which_set : str ...
[ "Process", "the", "validation", "or", "test", "set", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/ilsvrc2010.py#L319-L349
11,918
mila-iqia/fuel
fuel/converters/ilsvrc2010.py
load_from_tar_or_patch
def load_from_tar_or_patch(tar, image_filename, patch_images): """Do everything necessary to process an image inside a TAR. Parameters ---------- tar : `TarFile` instance The tar from which to read `image_filename`. image_filename : str Fully-qualified path inside of `tar` from whic...
python
def load_from_tar_or_patch(tar, image_filename, patch_images): """Do everything necessary to process an image inside a TAR. Parameters ---------- tar : `TarFile` instance The tar from which to read `image_filename`. image_filename : str Fully-qualified path inside of `tar` from whic...
[ "def", "load_from_tar_or_patch", "(", "tar", ",", "image_filename", ",", "patch_images", ")", ":", "patched", "=", "True", "image_bytes", "=", "patch_images", ".", "get", "(", "os", ".", "path", ".", "basename", "(", "image_filename", ")", ",", "None", ")", ...
Do everything necessary to process an image inside a TAR. Parameters ---------- tar : `TarFile` instance The tar from which to read `image_filename`. image_filename : str Fully-qualified path inside of `tar` from which to read an image file. patch_images : dict A dic...
[ "Do", "everything", "necessary", "to", "process", "an", "image", "inside", "a", "TAR", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/ilsvrc2010.py#L390-L426
11,919
mila-iqia/fuel
fuel/converters/ilsvrc2010.py
read_devkit
def read_devkit(f): """Read relevant information from the development kit archive. Parameters ---------- f : str or file-like object The filename or file-handle for the gzipped TAR archive containing the ILSVRC2010 development kit. Returns ------- synsets : ndarray, 1-dimen...
python
def read_devkit(f): """Read relevant information from the development kit archive. Parameters ---------- f : str or file-like object The filename or file-handle for the gzipped TAR archive containing the ILSVRC2010 development kit. Returns ------- synsets : ndarray, 1-dimen...
[ "def", "read_devkit", "(", "f", ")", ":", "with", "tar_open", "(", "f", ")", "as", "tar", ":", "# Metadata table containing class hierarchy, textual descriptions, etc.", "meta_mat", "=", "tar", ".", "extractfile", "(", "DEVKIT_META_PATH", ")", "synsets", ",", "cost_...
Read relevant information from the development kit archive. Parameters ---------- f : str or file-like object The filename or file-handle for the gzipped TAR archive containing the ILSVRC2010 development kit. Returns ------- synsets : ndarray, 1-dimensional, compound dtype ...
[ "Read", "relevant", "information", "from", "the", "development", "kit", "archive", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/ilsvrc2010.py#L429-L458
11,920
mila-iqia/fuel
fuel/converters/ilsvrc2010.py
extract_patch_images
def extract_patch_images(f, which_set): """Extracts a dict of the "patch images" for ILSVRC2010. Parameters ---------- f : str or file-like object The filename or file-handle to the patch images TAR file. which_set : str Which set of images to extract. One of 'train', 'valid', 'test...
python
def extract_patch_images(f, which_set): """Extracts a dict of the "patch images" for ILSVRC2010. Parameters ---------- f : str or file-like object The filename or file-handle to the patch images TAR file. which_set : str Which set of images to extract. One of 'train', 'valid', 'test...
[ "def", "extract_patch_images", "(", "f", ",", "which_set", ")", ":", "if", "which_set", "not", "in", "(", "'train'", ",", "'valid'", ",", "'test'", ")", ":", "raise", "ValueError", "(", "'which_set must be one of train, valid, or test'", ")", "which_set", "=", "...
Extracts a dict of the "patch images" for ILSVRC2010. Parameters ---------- f : str or file-like object The filename or file-handle to the patch images TAR file. which_set : str Which set of images to extract. One of 'train', 'valid', 'test'. Returns ------- dict A ...
[ "Extracts", "a", "dict", "of", "the", "patch", "images", "for", "ILSVRC2010", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/ilsvrc2010.py#L533-L573
11,921
mila-iqia/fuel
fuel/converters/cifar10.py
convert_cifar10
def convert_cifar10(directory, output_directory, output_filename='cifar10.hdf5'): """Converts the CIFAR-10 dataset to HDF5. Converts the CIFAR-10 dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CIFAR10`. The converted dataset is saved as 'cifar10.hdf5'. It assu...
python
def convert_cifar10(directory, output_directory, output_filename='cifar10.hdf5'): """Converts the CIFAR-10 dataset to HDF5. Converts the CIFAR-10 dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CIFAR10`. The converted dataset is saved as 'cifar10.hdf5'. It assu...
[ "def", "convert_cifar10", "(", "directory", ",", "output_directory", ",", "output_filename", "=", "'cifar10.hdf5'", ")", ":", "output_path", "=", "os", ".", "path", ".", "join", "(", "output_directory", ",", "output_filename", ")", "h5file", "=", "h5py", ".", ...
Converts the CIFAR-10 dataset to HDF5. Converts the CIFAR-10 dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CIFAR10`. The converted dataset is saved as 'cifar10.hdf5'. It assumes the existence of the following file: * `cifar-10-python.tar.gz` Parameters ---------- d...
[ "Converts", "the", "CIFAR", "-", "10", "dataset", "to", "HDF5", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/cifar10.py#L15-L97
11,922
mila-iqia/fuel
fuel/converters/base.py
check_exists
def check_exists(required_files): """Decorator that checks if required files exist before running. Parameters ---------- required_files : list of str A list of strings indicating the filenames of regular files (not directories) that should be found in the input directory (which ...
python
def check_exists(required_files): """Decorator that checks if required files exist before running. Parameters ---------- required_files : list of str A list of strings indicating the filenames of regular files (not directories) that should be found in the input directory (which ...
[ "def", "check_exists", "(", "required_files", ")", ":", "def", "function_wrapper", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapped", "(", "directory", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "missing", "=", "[", "]", "...
Decorator that checks if required files exist before running. Parameters ---------- required_files : list of str A list of strings indicating the filenames of regular files (not directories) that should be found in the input directory (which is the first argument to the wrapped func...
[ "Decorator", "that", "checks", "if", "required", "files", "exist", "before", "running", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/base.py#L13-L47
11,923
mila-iqia/fuel
fuel/converters/base.py
fill_hdf5_file
def fill_hdf5_file(h5file, data): """Fills an HDF5 file in a H5PYDataset-compatible manner. Parameters ---------- h5file : :class:`h5py.File` File handle for an HDF5 file. data : tuple of tuple One element per split/source pair. Each element consists of a tuple of (split_nam...
python
def fill_hdf5_file(h5file, data): """Fills an HDF5 file in a H5PYDataset-compatible manner. Parameters ---------- h5file : :class:`h5py.File` File handle for an HDF5 file. data : tuple of tuple One element per split/source pair. Each element consists of a tuple of (split_nam...
[ "def", "fill_hdf5_file", "(", "h5file", ",", "data", ")", ":", "# Check that all sources for a split have the same length", "split_names", "=", "set", "(", "split_tuple", "[", "0", "]", "for", "split_tuple", "in", "data", ")", "for", "name", "in", "split_names", "...
Fills an HDF5 file in a H5PYDataset-compatible manner. Parameters ---------- h5file : :class:`h5py.File` File handle for an HDF5 file. data : tuple of tuple One element per split/source pair. Each element consists of a tuple of (split_name, source_name, data_array, comment), whe...
[ "Fills", "an", "HDF5", "file", "in", "a", "H5PYDataset", "-", "compatible", "manner", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/base.py#L50-L103
11,924
mila-iqia/fuel
fuel/converters/base.py
progress_bar
def progress_bar(name, maxval, prefix='Converting'): """Manages a progress bar for a conversion. Parameters ---------- name : str Name of the file being converted. maxval : int Total number of steps for the conversion. """ widgets = ['{} {}: '.format(prefix, name), Percenta...
python
def progress_bar(name, maxval, prefix='Converting'): """Manages a progress bar for a conversion. Parameters ---------- name : str Name of the file being converted. maxval : int Total number of steps for the conversion. """ widgets = ['{} {}: '.format(prefix, name), Percenta...
[ "def", "progress_bar", "(", "name", ",", "maxval", ",", "prefix", "=", "'Converting'", ")", ":", "widgets", "=", "[", "'{} {}: '", ".", "format", "(", "prefix", ",", "name", ")", ",", "Percentage", "(", ")", ",", "' '", ",", "Bar", "(", "marker", "="...
Manages a progress bar for a conversion. Parameters ---------- name : str Name of the file being converted. maxval : int Total number of steps for the conversion.
[ "Manages", "a", "progress", "bar", "for", "a", "conversion", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/base.py#L107-L125
11,925
mila-iqia/fuel
fuel/converters/iris.py
convert_iris
def convert_iris(directory, output_directory, output_filename='iris.hdf5'): """Convert the Iris dataset to HDF5. Converts the Iris dataset to an HDF5 dataset compatible with :class:`fuel.datasets.Iris`. The converted dataset is saved as 'iris.hdf5'. This method assumes the existence of the file `ir...
python
def convert_iris(directory, output_directory, output_filename='iris.hdf5'): """Convert the Iris dataset to HDF5. Converts the Iris dataset to an HDF5 dataset compatible with :class:`fuel.datasets.Iris`. The converted dataset is saved as 'iris.hdf5'. This method assumes the existence of the file `ir...
[ "def", "convert_iris", "(", "directory", ",", "output_directory", ",", "output_filename", "=", "'iris.hdf5'", ")", ":", "classes", "=", "{", "b'Iris-setosa'", ":", "0", ",", "b'Iris-versicolor'", ":", "1", ",", "b'Iris-virginica'", ":", "2", "}", "data", "=", ...
Convert the Iris dataset to HDF5. Converts the Iris dataset to an HDF5 dataset compatible with :class:`fuel.datasets.Iris`. The converted dataset is saved as 'iris.hdf5'. This method assumes the existence of the file `iris.data`. Parameters ---------- directory : str Directory in w...
[ "Convert", "the", "Iris", "dataset", "to", "HDF5", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/iris.py#L9-L54
11,926
mila-iqia/fuel
fuel/downloaders/ilsvrc2012.py
fill_subparser
def fill_subparser(subparser): """Sets up a subparser to download the ILSVRC2012 dataset files. Note that you will need to use `--url-prefix` to download the non-public files (namely, the TARs of images). This is a single prefix that is common to all distributed files, which you can obtain by regis...
python
def fill_subparser(subparser): """Sets up a subparser to download the ILSVRC2012 dataset files. Note that you will need to use `--url-prefix` to download the non-public files (namely, the TARs of images). This is a single prefix that is common to all distributed files, which you can obtain by regis...
[ "def", "fill_subparser", "(", "subparser", ")", ":", "urls", "=", "(", "[", "None", "]", "*", "len", "(", "ALL_FILES", ")", ")", "filenames", "=", "list", "(", "ALL_FILES", ")", "subparser", ".", "set_defaults", "(", "urls", "=", "urls", ",", "filename...
Sets up a subparser to download the ILSVRC2012 dataset files. Note that you will need to use `--url-prefix` to download the non-public files (namely, the TARs of images). This is a single prefix that is common to all distributed files, which you can obtain by registering at the ImageNet website [DOWNLO...
[ "Sets", "up", "a", "subparser", "to", "download", "the", "ILSVRC2012", "dataset", "files", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/downloaders/ilsvrc2012.py#L5-L32
11,927
mila-iqia/fuel
fuel/transformers/sequences.py
Window._get_target_index
def _get_target_index(self): """Return the index where the target window starts.""" return (self.index + self.source_window * (not self.overlapping) + self.offset)
python
def _get_target_index(self): """Return the index where the target window starts.""" return (self.index + self.source_window * (not self.overlapping) + self.offset)
[ "def", "_get_target_index", "(", "self", ")", ":", "return", "(", "self", ".", "index", "+", "self", ".", "source_window", "*", "(", "not", "self", ".", "overlapping", ")", "+", "self", ".", "offset", ")" ]
Return the index where the target window starts.
[ "Return", "the", "index", "where", "the", "target", "window", "starts", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/transformers/sequences.py#L66-L69
11,928
mila-iqia/fuel
fuel/transformers/sequences.py
Window._get_end_index
def _get_end_index(self): """Return the end of both windows.""" return max(self.index + self.source_window, self._get_target_index() + self.target_window)
python
def _get_end_index(self): """Return the end of both windows.""" return max(self.index + self.source_window, self._get_target_index() + self.target_window)
[ "def", "_get_end_index", "(", "self", ")", ":", "return", "max", "(", "self", ".", "index", "+", "self", ".", "source_window", ",", "self", ".", "_get_target_index", "(", ")", "+", "self", ".", "target_window", ")" ]
Return the end of both windows.
[ "Return", "the", "end", "of", "both", "windows", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/transformers/sequences.py#L71-L74
11,929
mila-iqia/fuel
fuel/converters/svhn.py
convert_svhn
def convert_svhn(which_format, directory, output_directory, output_filename=None): """Converts the SVHN dataset to HDF5. Converts the SVHN dataset [SVHN] to an HDF5 dataset compatible with :class:`fuel.datasets.SVHN`. The converted dataset is saved as 'svhn_format_1.hdf5' or 'svhn_form...
python
def convert_svhn(which_format, directory, output_directory, output_filename=None): """Converts the SVHN dataset to HDF5. Converts the SVHN dataset [SVHN] to an HDF5 dataset compatible with :class:`fuel.datasets.SVHN`. The converted dataset is saved as 'svhn_format_1.hdf5' or 'svhn_form...
[ "def", "convert_svhn", "(", "which_format", ",", "directory", ",", "output_directory", ",", "output_filename", "=", "None", ")", ":", "if", "which_format", "not", "in", "(", "1", ",", "2", ")", ":", "raise", "ValueError", "(", "\"SVHN format needs to be either 1...
Converts the SVHN dataset to HDF5. Converts the SVHN dataset [SVHN] to an HDF5 dataset compatible with :class:`fuel.datasets.SVHN`. The converted dataset is saved as 'svhn_format_1.hdf5' or 'svhn_format_2.hdf5', depending on the `which_format` argument. .. [SVHN] Yuval Netzer, Tao Wang, Adam Coate...
[ "Converts", "the", "SVHN", "dataset", "to", "HDF5", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/svhn.py#L327-L369
11,930
mila-iqia/fuel
fuel/utils/formats.py
open_
def open_(filename, mode='r', encoding=None): """Open a text file with encoding and optional gzip compression. Note that on legacy Python any encoding other than ``None`` or opening GZipped files will return an unpicklable file-like object. Parameters ---------- filename : str The file...
python
def open_(filename, mode='r', encoding=None): """Open a text file with encoding and optional gzip compression. Note that on legacy Python any encoding other than ``None`` or opening GZipped files will return an unpicklable file-like object. Parameters ---------- filename : str The file...
[ "def", "open_", "(", "filename", ",", "mode", "=", "'r'", ",", "encoding", "=", "None", ")", ":", "if", "filename", ".", "endswith", "(", "'.gz'", ")", ":", "if", "six", ".", "PY2", ":", "zf", "=", "io", ".", "BufferedReader", "(", "gzip", ".", "...
Open a text file with encoding and optional gzip compression. Note that on legacy Python any encoding other than ``None`` or opening GZipped files will return an unpicklable file-like object. Parameters ---------- filename : str The filename to read. mode : str, optional The mo...
[ "Open", "a", "text", "file", "with", "encoding", "and", "optional", "gzip", "compression", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/formats.py#L9-L45
11,931
mila-iqia/fuel
fuel/utils/formats.py
tar_open
def tar_open(f): """Open either a filename or a file-like object as a TarFile. Parameters ---------- f : str or file-like object The filename or file-like object from which to read. Returns ------- TarFile A `TarFile` instance. """ if isinstance(f, six.string_types...
python
def tar_open(f): """Open either a filename or a file-like object as a TarFile. Parameters ---------- f : str or file-like object The filename or file-like object from which to read. Returns ------- TarFile A `TarFile` instance. """ if isinstance(f, six.string_types...
[ "def", "tar_open", "(", "f", ")", ":", "if", "isinstance", "(", "f", ",", "six", ".", "string_types", ")", ":", "return", "tarfile", ".", "open", "(", "name", "=", "f", ")", "else", ":", "return", "tarfile", ".", "open", "(", "fileobj", "=", "f", ...
Open either a filename or a file-like object as a TarFile. Parameters ---------- f : str or file-like object The filename or file-like object from which to read. Returns ------- TarFile A `TarFile` instance.
[ "Open", "either", "a", "filename", "or", "a", "file", "-", "like", "object", "as", "a", "TarFile", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/formats.py#L48-L65
11,932
mila-iqia/fuel
fuel/utils/cache.py
copy_from_server_to_local
def copy_from_server_to_local(dataset_remote_dir, dataset_local_dir, remote_fname, local_fname): """Copies a remote file locally. Parameters ---------- remote_fname : str Remote file to copy local_fname : str Path and name of the local copy to be made o...
python
def copy_from_server_to_local(dataset_remote_dir, dataset_local_dir, remote_fname, local_fname): """Copies a remote file locally. Parameters ---------- remote_fname : str Remote file to copy local_fname : str Path and name of the local copy to be made o...
[ "def", "copy_from_server_to_local", "(", "dataset_remote_dir", ",", "dataset_local_dir", ",", "remote_fname", ",", "local_fname", ")", ":", "log", ".", "debug", "(", "\"Copying file `{}` to a local directory `{}`.\"", ".", "format", "(", "remote_fname", ",", "dataset_loca...
Copies a remote file locally. Parameters ---------- remote_fname : str Remote file to copy local_fname : str Path and name of the local copy to be made of the remote file.
[ "Copies", "a", "remote", "file", "locally", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/cache.py#L217-L269
11,933
mila-iqia/fuel
fuel/converters/adult.py
convert_to_one_hot
def convert_to_one_hot(y): """ converts y into one hot reprsentation. Parameters ---------- y : list A list containing continous integer values. Returns ------- one_hot : numpy.ndarray A numpy.ndarray object, which is one-hot representation of y. """ max_value ...
python
def convert_to_one_hot(y): """ converts y into one hot reprsentation. Parameters ---------- y : list A list containing continous integer values. Returns ------- one_hot : numpy.ndarray A numpy.ndarray object, which is one-hot representation of y. """ max_value ...
[ "def", "convert_to_one_hot", "(", "y", ")", ":", "max_value", "=", "max", "(", "y", ")", "min_value", "=", "min", "(", "y", ")", "length", "=", "len", "(", "y", ")", "one_hot", "=", "numpy", ".", "zeros", "(", "(", "length", ",", "(", "max_value", ...
converts y into one hot reprsentation. Parameters ---------- y : list A list containing continous integer values. Returns ------- one_hot : numpy.ndarray A numpy.ndarray object, which is one-hot representation of y.
[ "converts", "y", "into", "one", "hot", "reprsentation", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/adult.py#L9-L29
11,934
mila-iqia/fuel
fuel/converters/binarized_mnist.py
convert_binarized_mnist
def convert_binarized_mnist(directory, output_directory, output_filename='binarized_mnist.hdf5'): """Converts the binarized MNIST dataset to HDF5. Converts the binarized MNIST dataset used in R. Salakhutdinov's DBN paper [DBN] to an HDF5 dataset compatible with :class:`fuel....
python
def convert_binarized_mnist(directory, output_directory, output_filename='binarized_mnist.hdf5'): """Converts the binarized MNIST dataset to HDF5. Converts the binarized MNIST dataset used in R. Salakhutdinov's DBN paper [DBN] to an HDF5 dataset compatible with :class:`fuel....
[ "def", "convert_binarized_mnist", "(", "directory", ",", "output_directory", ",", "output_filename", "=", "'binarized_mnist.hdf5'", ")", ":", "output_path", "=", "os", ".", "path", ".", "join", "(", "output_directory", ",", "output_filename", ")", "h5file", "=", "...
Converts the binarized MNIST dataset to HDF5. Converts the binarized MNIST dataset used in R. Salakhutdinov's DBN paper [DBN] to an HDF5 dataset compatible with :class:`fuel.datasets.BinarizedMNIST`. The converted dataset is saved as 'binarized_mnist.hdf5'. This method assumes the existence of the...
[ "Converts", "the", "binarized", "MNIST", "dataset", "to", "HDF5", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/binarized_mnist.py#L17-L71
11,935
mila-iqia/fuel
fuel/downloaders/cifar10.py
fill_subparser
def fill_subparser(subparser): """Sets up a subparser to download the CIFAR-10 dataset file. The CIFAR-10 dataset file is downloaded from Alex Krizhevsky's website [ALEX]. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `cifar10` command. ...
python
def fill_subparser(subparser): """Sets up a subparser to download the CIFAR-10 dataset file. The CIFAR-10 dataset file is downloaded from Alex Krizhevsky's website [ALEX]. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `cifar10` command. ...
[ "def", "fill_subparser", "(", "subparser", ")", ":", "url", "=", "'http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz'", "filename", "=", "'cifar-10-python.tar.gz'", "subparser", ".", "set_defaults", "(", "urls", "=", "[", "url", "]", ",", "filenames", "=", "[", ...
Sets up a subparser to download the CIFAR-10 dataset file. The CIFAR-10 dataset file is downloaded from Alex Krizhevsky's website [ALEX]. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `cifar10` command.
[ "Sets", "up", "a", "subparser", "to", "download", "the", "CIFAR", "-", "10", "dataset", "file", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/downloaders/cifar10.py#L4-L19
11,936
mila-iqia/fuel
fuel/converters/celeba.py
convert_celeba_aligned_cropped
def convert_celeba_aligned_cropped(directory, output_directory, output_filename=OUTPUT_FILENAME): """Converts the aligned and cropped CelebA dataset to HDF5. Converts the CelebA dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CelebA`. The converted datase...
python
def convert_celeba_aligned_cropped(directory, output_directory, output_filename=OUTPUT_FILENAME): """Converts the aligned and cropped CelebA dataset to HDF5. Converts the CelebA dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CelebA`. The converted datase...
[ "def", "convert_celeba_aligned_cropped", "(", "directory", ",", "output_directory", ",", "output_filename", "=", "OUTPUT_FILENAME", ")", ":", "output_path", "=", "os", ".", "path", ".", "join", "(", "output_directory", ",", "output_filename", ")", "h5file", "=", "...
Converts the aligned and cropped CelebA dataset to HDF5. Converts the CelebA dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CelebA`. The converted dataset is saved as 'celeba_aligned_cropped.hdf5'. It assumes the existence of the following files: * `img_align_celeba.zip` * `...
[ "Converts", "the", "aligned", "and", "cropped", "CelebA", "dataset", "to", "HDF5", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/celeba.py#L55-L102
11,937
mila-iqia/fuel
fuel/converters/celeba.py
convert_celeba
def convert_celeba(which_format, directory, output_directory, output_filename=None): """Converts the CelebA dataset to HDF5. Converts the CelebA dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CelebA`. The converted dataset is saved as 'celeba_aligned_cropped.hdf5' o...
python
def convert_celeba(which_format, directory, output_directory, output_filename=None): """Converts the CelebA dataset to HDF5. Converts the CelebA dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CelebA`. The converted dataset is saved as 'celeba_aligned_cropped.hdf5' o...
[ "def", "convert_celeba", "(", "which_format", ",", "directory", ",", "output_directory", ",", "output_filename", "=", "None", ")", ":", "if", "which_format", "not", "in", "(", "'aligned_cropped'", ",", "'64'", ")", ":", "raise", "ValueError", "(", "\"CelebA form...
Converts the CelebA dataset to HDF5. Converts the CelebA dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CelebA`. The converted dataset is saved as 'celeba_aligned_cropped.hdf5' or 'celeba_64.hdf5', depending on the `which_format` argument. Parameters ---------- which_form...
[ "Converts", "the", "CelebA", "dataset", "to", "HDF5", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/celeba.py#L159-L198
11,938
mila-iqia/fuel
fuel/utils/disk.py
disk_usage
def disk_usage(path): """Return free usage about the given path, in bytes. Parameters ---------- path : str Folder for which to return disk usage Returns ------- output : tuple Tuple containing total space in the folder and currently used space in the folder ""...
python
def disk_usage(path): """Return free usage about the given path, in bytes. Parameters ---------- path : str Folder for which to return disk usage Returns ------- output : tuple Tuple containing total space in the folder and currently used space in the folder ""...
[ "def", "disk_usage", "(", "path", ")", ":", "st", "=", "os", ".", "statvfs", "(", "path", ")", "total", "=", "st", ".", "f_blocks", "*", "st", ".", "f_frsize", "used", "=", "(", "st", ".", "f_blocks", "-", "st", ".", "f_bfree", ")", "*", "st", ...
Return free usage about the given path, in bytes. Parameters ---------- path : str Folder for which to return disk usage Returns ------- output : tuple Tuple containing total space in the folder and currently used space in the folder
[ "Return", "free", "usage", "about", "the", "given", "path", "in", "bytes", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/disk.py#L39-L57
11,939
mila-iqia/fuel
fuel/utils/disk.py
safe_mkdir
def safe_mkdir(folder_name, force_perm=None): """Create the specified folder. If the parent folders do not exist, they are also created. If the folder already exists, nothing is done. Parameters ---------- folder_name : str Name of the folder to create. force_perm : str Mod...
python
def safe_mkdir(folder_name, force_perm=None): """Create the specified folder. If the parent folders do not exist, they are also created. If the folder already exists, nothing is done. Parameters ---------- folder_name : str Name of the folder to create. force_perm : str Mod...
[ "def", "safe_mkdir", "(", "folder_name", ",", "force_perm", "=", "None", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "folder_name", ")", ":", "return", "intermediary_folders", "=", "folder_name", ".", "split", "(", "os", ".", "path", ".", "sep...
Create the specified folder. If the parent folders do not exist, they are also created. If the folder already exists, nothing is done. Parameters ---------- folder_name : str Name of the folder to create. force_perm : str Mode to use for folder creation.
[ "Create", "the", "specified", "folder", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/disk.py#L60-L93
11,940
mila-iqia/fuel
fuel/utils/disk.py
check_enough_space
def check_enough_space(dataset_local_dir, remote_fname, local_fname, max_disk_usage=0.9): """Check if the given local folder has enough space. Check if the given local folder has enough space to store the specified remote file. Parameters ---------- remote_fname : str ...
python
def check_enough_space(dataset_local_dir, remote_fname, local_fname, max_disk_usage=0.9): """Check if the given local folder has enough space. Check if the given local folder has enough space to store the specified remote file. Parameters ---------- remote_fname : str ...
[ "def", "check_enough_space", "(", "dataset_local_dir", ",", "remote_fname", ",", "local_fname", ",", "max_disk_usage", "=", "0.9", ")", ":", "storage_need", "=", "os", ".", "path", ".", "getsize", "(", "remote_fname", ")", "storage_total", ",", "storage_used", "...
Check if the given local folder has enough space. Check if the given local folder has enough space to store the specified remote file. Parameters ---------- remote_fname : str Path to the remote file remote_fname : str Path to the local folder max_disk_usage : float ...
[ "Check", "if", "the", "given", "local", "folder", "has", "enough", "space", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/disk.py#L96-L126
11,941
mila-iqia/fuel
fuel/converters/cifar100.py
convert_cifar100
def convert_cifar100(directory, output_directory, output_filename='cifar100.hdf5'): """Converts the CIFAR-100 dataset to HDF5. Converts the CIFAR-100 dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CIFAR100`. The converted dataset is saved as 'cifar100.hdf5'. ...
python
def convert_cifar100(directory, output_directory, output_filename='cifar100.hdf5'): """Converts the CIFAR-100 dataset to HDF5. Converts the CIFAR-100 dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CIFAR100`. The converted dataset is saved as 'cifar100.hdf5'. ...
[ "def", "convert_cifar100", "(", "directory", ",", "output_directory", ",", "output_filename", "=", "'cifar100.hdf5'", ")", ":", "output_path", "=", "os", ".", "path", ".", "join", "(", "output_directory", ",", "output_filename", ")", "h5file", "=", "h5py", ".", ...
Converts the CIFAR-100 dataset to HDF5. Converts the CIFAR-100 dataset to an HDF5 dataset compatible with :class:`fuel.datasets.CIFAR100`. The converted dataset is saved as 'cifar100.hdf5'. This method assumes the existence of the following file: `cifar-100-python.tar.gz` Parameters -----...
[ "Converts", "the", "CIFAR", "-", "100", "dataset", "to", "HDF5", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/cifar100.py#L15-L95
11,942
mila-iqia/fuel
fuel/transformers/__init__.py
ExpectsAxisLabels.verify_axis_labels
def verify_axis_labels(self, expected, actual, source_name): """Verify that axis labels for a given source are as expected. Parameters ---------- expected : tuple A tuple of strings representing the expected axis labels. actual : tuple or None A tuple of ...
python
def verify_axis_labels(self, expected, actual, source_name): """Verify that axis labels for a given source are as expected. Parameters ---------- expected : tuple A tuple of strings representing the expected axis labels. actual : tuple or None A tuple of ...
[ "def", "verify_axis_labels", "(", "self", ",", "expected", ",", "actual", ",", "source_name", ")", ":", "if", "not", "getattr", "(", "self", ",", "'_checked_axis_labels'", ",", "False", ")", ":", "self", ".", "_checked_axis_labels", "=", "defaultdict", "(", ...
Verify that axis labels for a given source are as expected. Parameters ---------- expected : tuple A tuple of strings representing the expected axis labels. actual : tuple or None A tuple of strings representing the actual axis labels, or `None` if th...
[ "Verify", "that", "axis", "labels", "for", "a", "given", "source", "are", "as", "expected", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/transformers/__init__.py#L34-L67
11,943
mila-iqia/fuel
fuel/transformers/__init__.py
Batch.get_data
def get_data(self, request=None): """Get data from the dataset.""" if request is None: raise ValueError data = [[] for _ in self.sources] for i in range(request): try: for source_data, example in zip( data, next(self.child_e...
python
def get_data(self, request=None): """Get data from the dataset.""" if request is None: raise ValueError data = [[] for _ in self.sources] for i in range(request): try: for source_data, example in zip( data, next(self.child_e...
[ "def", "get_data", "(", "self", ",", "request", "=", "None", ")", ":", "if", "request", "is", "None", ":", "raise", "ValueError", "data", "=", "[", "[", "]", "for", "_", "in", "self", ".", "sources", "]", "for", "i", "in", "range", "(", "request", ...
Get data from the dataset.
[ "Get", "data", "from", "the", "dataset", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/transformers/__init__.py#L608-L626
11,944
mila-iqia/fuel
fuel/utils/parallel.py
_producer_wrapper
def _producer_wrapper(f, port, addr='tcp://127.0.0.1'): """A shim that sets up a socket and starts the producer callable. Parameters ---------- f : callable Callable that takes a single argument, a handle for a ZeroMQ PUSH socket. Must be picklable. port : int The port on wh...
python
def _producer_wrapper(f, port, addr='tcp://127.0.0.1'): """A shim that sets up a socket and starts the producer callable. Parameters ---------- f : callable Callable that takes a single argument, a handle for a ZeroMQ PUSH socket. Must be picklable. port : int The port on wh...
[ "def", "_producer_wrapper", "(", "f", ",", "port", ",", "addr", "=", "'tcp://127.0.0.1'", ")", ":", "try", ":", "context", "=", "zmq", ".", "Context", "(", ")", "socket", "=", "context", ".", "socket", "(", "zmq", ".", "PUSH", ")", "socket", ".", "co...
A shim that sets up a socket and starts the producer callable. Parameters ---------- f : callable Callable that takes a single argument, a handle for a ZeroMQ PUSH socket. Must be picklable. port : int The port on which the socket should connect. addr : str, optional ...
[ "A", "shim", "that", "sets", "up", "a", "socket", "and", "starts", "the", "producer", "callable", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/parallel.py#L14-L36
11,945
mila-iqia/fuel
fuel/utils/parallel.py
_spawn_producer
def _spawn_producer(f, port, addr='tcp://127.0.0.1'): """Start a process that sends results on a PUSH socket. Parameters ---------- f : callable Callable that takes a single argument, a handle for a ZeroMQ PUSH socket. Must be picklable. Returns ------- process : multiproce...
python
def _spawn_producer(f, port, addr='tcp://127.0.0.1'): """Start a process that sends results on a PUSH socket. Parameters ---------- f : callable Callable that takes a single argument, a handle for a ZeroMQ PUSH socket. Must be picklable. Returns ------- process : multiproce...
[ "def", "_spawn_producer", "(", "f", ",", "port", ",", "addr", "=", "'tcp://127.0.0.1'", ")", ":", "process", "=", "Process", "(", "target", "=", "_producer_wrapper", ",", "args", "=", "(", "f", ",", "port", ",", "addr", ")", ")", "process", ".", "start...
Start a process that sends results on a PUSH socket. Parameters ---------- f : callable Callable that takes a single argument, a handle for a ZeroMQ PUSH socket. Must be picklable. Returns ------- process : multiprocessing.Process The process handle of the created produ...
[ "Start", "a", "process", "that", "sends", "results", "on", "a", "PUSH", "socket", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/parallel.py#L39-L56
11,946
mila-iqia/fuel
fuel/utils/parallel.py
producer_consumer
def producer_consumer(producer, consumer, addr='tcp://127.0.0.1', port=None, context=None): """A producer-consumer pattern. Parameters ---------- producer : callable Callable that takes a single argument, a handle for a ZeroMQ PUSH socket. Must be picklable. co...
python
def producer_consumer(producer, consumer, addr='tcp://127.0.0.1', port=None, context=None): """A producer-consumer pattern. Parameters ---------- producer : callable Callable that takes a single argument, a handle for a ZeroMQ PUSH socket. Must be picklable. co...
[ "def", "producer_consumer", "(", "producer", ",", "consumer", ",", "addr", "=", "'tcp://127.0.0.1'", ",", "port", "=", "None", ",", "context", "=", "None", ")", ":", "context_created", "=", "False", "if", "context", "is", "None", ":", "context_created", "=",...
A producer-consumer pattern. Parameters ---------- producer : callable Callable that takes a single argument, a handle for a ZeroMQ PUSH socket. Must be picklable. consumer : callable Callable that takes a single argument, a handle for a ZeroMQ PULL socket. addr : st...
[ "A", "producer", "-", "consumer", "pattern", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/parallel.py#L59-L113
11,947
mila-iqia/fuel
fuel/converters/dogs_vs_cats.py
convert_dogs_vs_cats
def convert_dogs_vs_cats(directory, output_directory, output_filename='dogs_vs_cats.hdf5'): """Converts the Dogs vs. Cats dataset to HDF5. Converts the Dogs vs. Cats dataset to an HDF5 dataset compatible with :class:`fuel.datasets.dogs_vs_cats`. The converted dataset is saved as ...
python
def convert_dogs_vs_cats(directory, output_directory, output_filename='dogs_vs_cats.hdf5'): """Converts the Dogs vs. Cats dataset to HDF5. Converts the Dogs vs. Cats dataset to an HDF5 dataset compatible with :class:`fuel.datasets.dogs_vs_cats`. The converted dataset is saved as ...
[ "def", "convert_dogs_vs_cats", "(", "directory", ",", "output_directory", ",", "output_filename", "=", "'dogs_vs_cats.hdf5'", ")", ":", "# Prepare output file", "output_path", "=", "os", ".", "path", ".", "join", "(", "output_directory", ",", "output_filename", ")", ...
Converts the Dogs vs. Cats dataset to HDF5. Converts the Dogs vs. Cats dataset to an HDF5 dataset compatible with :class:`fuel.datasets.dogs_vs_cats`. The converted dataset is saved as 'dogs_vs_cats.hdf5'. It assumes the existence of the following files: * `dogs_vs_cats.train.zip` * `dogs_vs_...
[ "Converts", "the", "Dogs", "vs", ".", "Cats", "dataset", "to", "HDF5", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/dogs_vs_cats.py#L16-L113
11,948
mila-iqia/fuel
fuel/bin/fuel_download.py
main
def main(args=None): """Entry point for `fuel-download` script. This function can also be imported and used from Python. Parameters ---------- args : iterable, optional (default: None) A list of arguments that will be passed to Fuel's downloading utility. If this argument is not sp...
python
def main(args=None): """Entry point for `fuel-download` script. This function can also be imported and used from Python. Parameters ---------- args : iterable, optional (default: None) A list of arguments that will be passed to Fuel's downloading utility. If this argument is not sp...
[ "def", "main", "(", "args", "=", "None", ")", ":", "built_in_datasets", "=", "dict", "(", "downloaders", ".", "all_downloaders", ")", "if", "fuel", ".", "config", ".", "extra_downloaders", ":", "for", "name", "in", "fuel", ".", "config", ".", "extra_downlo...
Entry point for `fuel-download` script. This function can also be imported and used from Python. Parameters ---------- args : iterable, optional (default: None) A list of arguments that will be passed to Fuel's downloading utility. If this argument is not specified, `sys.argv[1:]` will...
[ "Entry", "point", "for", "fuel", "-", "download", "script", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/bin/fuel_download.py#L19-L64
11,949
mila-iqia/fuel
fuel/downloaders/mnist.py
fill_subparser
def fill_subparser(subparser): """Sets up a subparser to download the MNIST dataset files. The following MNIST dataset files are downloaded from Yann LeCun's website [LECUN]: `train-images-idx3-ubyte.gz`, `train-labels-idx1-ubyte.gz`, `t10k-images-idx3-ubyte.gz`, `t10k-labels-idx1-ubyte.gz`. P...
python
def fill_subparser(subparser): """Sets up a subparser to download the MNIST dataset files. The following MNIST dataset files are downloaded from Yann LeCun's website [LECUN]: `train-images-idx3-ubyte.gz`, `train-labels-idx1-ubyte.gz`, `t10k-images-idx3-ubyte.gz`, `t10k-labels-idx1-ubyte.gz`. P...
[ "def", "fill_subparser", "(", "subparser", ")", ":", "filenames", "=", "[", "'train-images-idx3-ubyte.gz'", ",", "'train-labels-idx1-ubyte.gz'", ",", "'t10k-images-idx3-ubyte.gz'", ",", "'t10k-labels-idx1-ubyte.gz'", "]", "urls", "=", "[", "'http://yann.lecun.com/exdb/mnist/'...
Sets up a subparser to download the MNIST dataset files. The following MNIST dataset files are downloaded from Yann LeCun's website [LECUN]: `train-images-idx3-ubyte.gz`, `train-labels-idx1-ubyte.gz`, `t10k-images-idx3-ubyte.gz`, `t10k-labels-idx1-ubyte.gz`. Parameters ---------- subparser...
[ "Sets", "up", "a", "subparser", "to", "download", "the", "MNIST", "dataset", "files", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/downloaders/mnist.py#L4-L22
11,950
mila-iqia/fuel
fuel/bin/fuel_info.py
main
def main(args=None): """Entry point for `fuel-info` script. This function can also be imported and used from Python. Parameters ---------- args : iterable, optional (default: None) A list of arguments that will be passed to Fuel's information utility. If this argument is not specif...
python
def main(args=None): """Entry point for `fuel-info` script. This function can also be imported and used from Python. Parameters ---------- args : iterable, optional (default: None) A list of arguments that will be passed to Fuel's information utility. If this argument is not specif...
[ "def", "main", "(", "args", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Extracts metadata from a Fuel-converted HDF5 file.'", ")", "parser", ".", "add_argument", "(", "\"filename\"", ",", "help", "=", "\"HDF5...
Entry point for `fuel-info` script. This function can also be imported and used from Python. Parameters ---------- args : iterable, optional (default: None) A list of arguments that will be passed to Fuel's information utility. If this argument is not specified, `sys.argv[1:]` will ...
[ "Entry", "point", "for", "fuel", "-", "info", "script", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/bin/fuel_info.py#L22-L51
11,951
mila-iqia/fuel
fuel/converters/caltech101_silhouettes.py
convert_silhouettes
def convert_silhouettes(size, directory, output_directory, output_filename=None): """ Convert the CalTech 101 Silhouettes Datasets. Parameters ---------- size : {16, 28} Convert either the 16x16 or 28x28 sized version of the dataset. directory : str Directory...
python
def convert_silhouettes(size, directory, output_directory, output_filename=None): """ Convert the CalTech 101 Silhouettes Datasets. Parameters ---------- size : {16, 28} Convert either the 16x16 or 28x28 sized version of the dataset. directory : str Directory...
[ "def", "convert_silhouettes", "(", "size", ",", "directory", ",", "output_directory", ",", "output_filename", "=", "None", ")", ":", "if", "size", "not", "in", "(", "16", ",", "28", ")", ":", "raise", "ValueError", "(", "'size must be 16 or 28'", ")", "if", ...
Convert the CalTech 101 Silhouettes Datasets. Parameters ---------- size : {16, 28} Convert either the 16x16 or 28x28 sized version of the dataset. directory : str Directory in which the required input files reside. output_filename : str Where to save the converted dataset.
[ "Convert", "the", "CalTech", "101", "Silhouettes", "Datasets", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/caltech101_silhouettes.py#L9-L61
11,952
mila-iqia/fuel
fuel/schemes.py
cross_validation
def cross_validation(scheme_class, num_examples, num_folds, strict=True, **kwargs): """Return pairs of schemes to be used for cross-validation. Parameters ---------- scheme_class : subclass of :class:`IndexScheme` or :class:`BatchScheme` The type of the returned schemes. Th...
python
def cross_validation(scheme_class, num_examples, num_folds, strict=True, **kwargs): """Return pairs of schemes to be used for cross-validation. Parameters ---------- scheme_class : subclass of :class:`IndexScheme` or :class:`BatchScheme` The type of the returned schemes. Th...
[ "def", "cross_validation", "(", "scheme_class", ",", "num_examples", ",", "num_folds", ",", "strict", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "strict", "and", "num_examples", "%", "num_folds", "!=", "0", ":", "raise", "ValueError", "(", "(", ...
Return pairs of schemes to be used for cross-validation. Parameters ---------- scheme_class : subclass of :class:`IndexScheme` or :class:`BatchScheme` The type of the returned schemes. The constructor is called with an iterator and `**kwargs` as arguments. num_examples : int The...
[ "Return", "pairs", "of", "schemes", "to", "be", "used", "for", "cross", "-", "validation", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/schemes.py#L260-L305
11,953
mila-iqia/fuel
fuel/bin/fuel_convert.py
main
def main(args=None): """Entry point for `fuel-convert` script. This function can also be imported and used from Python. Parameters ---------- args : iterable, optional (default: None) A list of arguments that will be passed to Fuel's conversion utility. If this argument is not spec...
python
def main(args=None): """Entry point for `fuel-convert` script. This function can also be imported and used from Python. Parameters ---------- args : iterable, optional (default: None) A list of arguments that will be passed to Fuel's conversion utility. If this argument is not spec...
[ "def", "main", "(", "args", "=", "None", ")", ":", "built_in_datasets", "=", "dict", "(", "converters", ".", "all_converters", ")", "if", "fuel", ".", "config", ".", "extra_converters", ":", "for", "name", "in", "fuel", ".", "config", ".", "extra_converter...
Entry point for `fuel-convert` script. This function can also be imported and used from Python. Parameters ---------- args : iterable, optional (default: None) A list of arguments that will be passed to Fuel's conversion utility. If this argument is not specified, `sys.argv[1:]` will ...
[ "Entry", "point", "for", "fuel", "-", "convert", "script", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/bin/fuel_convert.py#L24-L98
11,954
mila-iqia/fuel
fuel/utils/lock.py
refresh_lock
def refresh_lock(lock_file): """'Refresh' an existing lock. 'Refresh' an existing lock by re-writing the file containing the owner's unique id, using a new (randomly generated) id, which is also returned. """ unique_id = '%s_%s_%s' % ( os.getpid(), ''.join([str(random.randint(0...
python
def refresh_lock(lock_file): """'Refresh' an existing lock. 'Refresh' an existing lock by re-writing the file containing the owner's unique id, using a new (randomly generated) id, which is also returned. """ unique_id = '%s_%s_%s' % ( os.getpid(), ''.join([str(random.randint(0...
[ "def", "refresh_lock", "(", "lock_file", ")", ":", "unique_id", "=", "'%s_%s_%s'", "%", "(", "os", ".", "getpid", "(", ")", ",", "''", ".", "join", "(", "[", "str", "(", "random", ".", "randint", "(", "0", ",", "9", ")", ")", "for", "i", "in", ...
Refresh' an existing lock. 'Refresh' an existing lock by re-writing the file containing the owner's unique id, using a new (randomly generated) id, which is also returned.
[ "Refresh", "an", "existing", "lock", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/lock.py#L95-L118
11,955
mila-iqia/fuel
fuel/utils/lock.py
get_lock
def get_lock(lock_dir, **kw): """Obtain lock on compilation directory. Parameters ---------- lock_dir : str Lock directory. kw : dict Additional arguments to be forwarded to the `lock` function when acquiring the lock. Notes ----- We can lock only on 1 directory...
python
def get_lock(lock_dir, **kw): """Obtain lock on compilation directory. Parameters ---------- lock_dir : str Lock directory. kw : dict Additional arguments to be forwarded to the `lock` function when acquiring the lock. Notes ----- We can lock only on 1 directory...
[ "def", "get_lock", "(", "lock_dir", ",", "*", "*", "kw", ")", ":", "if", "not", "hasattr", "(", "get_lock", ",", "'n_lock'", ")", ":", "# Initialization.", "get_lock", ".", "n_lock", "=", "0", "if", "not", "hasattr", "(", "get_lock", ",", "'lock_is_enabl...
Obtain lock on compilation directory. Parameters ---------- lock_dir : str Lock directory. kw : dict Additional arguments to be forwarded to the `lock` function when acquiring the lock. Notes ----- We can lock only on 1 directory at a time.
[ "Obtain", "lock", "on", "compilation", "directory", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/lock.py#L297-L356
11,956
mila-iqia/fuel
fuel/utils/lock.py
release_lock
def release_lock(): """Release lock on compilation directory.""" get_lock.n_lock -= 1 assert get_lock.n_lock >= 0 # Only really release lock once all lock requests have ended. if get_lock.lock_is_enabled and get_lock.n_lock == 0: get_lock.start_time = None get_lock.unlocker.unlock()
python
def release_lock(): """Release lock on compilation directory.""" get_lock.n_lock -= 1 assert get_lock.n_lock >= 0 # Only really release lock once all lock requests have ended. if get_lock.lock_is_enabled and get_lock.n_lock == 0: get_lock.start_time = None get_lock.unlocker.unlock()
[ "def", "release_lock", "(", ")", ":", "get_lock", ".", "n_lock", "-=", "1", "assert", "get_lock", ".", "n_lock", ">=", "0", "# Only really release lock once all lock requests have ended.", "if", "get_lock", ".", "lock_is_enabled", "and", "get_lock", ".", "n_lock", "...
Release lock on compilation directory.
[ "Release", "lock", "on", "compilation", "directory", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/lock.py#L359-L366
11,957
mila-iqia/fuel
fuel/utils/lock.py
release_readlock
def release_readlock(lockdir_name): """Release a previously obtained readlock. Parameters ---------- lockdir_name : str Name of the previously obtained readlock """ # Make sure the lock still exists before deleting it if os.path.exists(lockdir_name) and os.path.isdir(lockdir_name):...
python
def release_readlock(lockdir_name): """Release a previously obtained readlock. Parameters ---------- lockdir_name : str Name of the previously obtained readlock """ # Make sure the lock still exists before deleting it if os.path.exists(lockdir_name) and os.path.isdir(lockdir_name):...
[ "def", "release_readlock", "(", "lockdir_name", ")", ":", "# Make sure the lock still exists before deleting it", "if", "os", ".", "path", ".", "exists", "(", "lockdir_name", ")", "and", "os", ".", "path", ".", "isdir", "(", "lockdir_name", ")", ":", "os", ".", ...
Release a previously obtained readlock. Parameters ---------- lockdir_name : str Name of the previously obtained readlock
[ "Release", "a", "previously", "obtained", "readlock", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/lock.py#L392-L403
11,958
mila-iqia/fuel
fuel/utils/lock.py
get_readlock
def get_readlock(pid, path): """Obtain a readlock on a file. Parameters ---------- path : str Name of the file on which to obtain a readlock """ timestamp = int(time.time() * 1e6) lockdir_name = "%s.readlock.%i.%i" % (path, pid, timestamp) os.mkdir(lockdir_name) # Register...
python
def get_readlock(pid, path): """Obtain a readlock on a file. Parameters ---------- path : str Name of the file on which to obtain a readlock """ timestamp = int(time.time() * 1e6) lockdir_name = "%s.readlock.%i.%i" % (path, pid, timestamp) os.mkdir(lockdir_name) # Register...
[ "def", "get_readlock", "(", "pid", ",", "path", ")", ":", "timestamp", "=", "int", "(", "time", ".", "time", "(", ")", "*", "1e6", ")", "lockdir_name", "=", "\"%s.readlock.%i.%i\"", "%", "(", "path", ",", "pid", ",", "timestamp", ")", "os", ".", "mkd...
Obtain a readlock on a file. Parameters ---------- path : str Name of the file on which to obtain a readlock
[ "Obtain", "a", "readlock", "on", "a", "file", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/lock.py#L406-L420
11,959
mila-iqia/fuel
fuel/utils/lock.py
Unlocker.unlock
def unlock(self): """Remove current lock. This function does not crash if it is unable to properly delete the lock file and directory. The reason is that it should be allowed for multiple jobs running in parallel to unlock the same directory at the same time (e.g. when reaching ...
python
def unlock(self): """Remove current lock. This function does not crash if it is unable to properly delete the lock file and directory. The reason is that it should be allowed for multiple jobs running in parallel to unlock the same directory at the same time (e.g. when reaching ...
[ "def", "unlock", "(", "self", ")", ":", "# If any error occurs, we assume this is because someone else tried to", "# unlock this directory at the same time.", "# Note that it is important not to have both remove statements within", "# the same try/except block. The reason is that while the attempt...
Remove current lock. This function does not crash if it is unable to properly delete the lock file and directory. The reason is that it should be allowed for multiple jobs running in parallel to unlock the same directory at the same time (e.g. when reaching their timeout limit).
[ "Remove", "current", "lock", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/lock.py#L69-L92
11,960
mila-iqia/fuel
fuel/downloaders/base.py
filename_from_url
def filename_from_url(url, path=None): """Parses a URL to determine a file name. Parameters ---------- url : str URL to parse. """ r = requests.get(url, stream=True) if 'Content-Disposition' in r.headers: filename = re.findall(r'filename=([^;]+)', ...
python
def filename_from_url(url, path=None): """Parses a URL to determine a file name. Parameters ---------- url : str URL to parse. """ r = requests.get(url, stream=True) if 'Content-Disposition' in r.headers: filename = re.findall(r'filename=([^;]+)', ...
[ "def", "filename_from_url", "(", "url", ",", "path", "=", "None", ")", ":", "r", "=", "requests", ".", "get", "(", "url", ",", "stream", "=", "True", ")", "if", "'Content-Disposition'", "in", "r", ".", "headers", ":", "filename", "=", "re", ".", "fin...
Parses a URL to determine a file name. Parameters ---------- url : str URL to parse.
[ "Parses", "a", "URL", "to", "determine", "a", "file", "name", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/downloaders/base.py#L39-L54
11,961
mila-iqia/fuel
fuel/downloaders/base.py
download
def download(url, file_handle, chunk_size=1024): """Downloads a given URL to a specific file. Parameters ---------- url : str URL to download. file_handle : file Where to save the downloaded URL. """ r = requests.get(url, stream=True) total_length = r.headers.get('conte...
python
def download(url, file_handle, chunk_size=1024): """Downloads a given URL to a specific file. Parameters ---------- url : str URL to download. file_handle : file Where to save the downloaded URL. """ r = requests.get(url, stream=True) total_length = r.headers.get('conte...
[ "def", "download", "(", "url", ",", "file_handle", ",", "chunk_size", "=", "1024", ")", ":", "r", "=", "requests", ".", "get", "(", "url", ",", "stream", "=", "True", ")", "total_length", "=", "r", ".", "headers", ".", "get", "(", "'content-length'", ...
Downloads a given URL to a specific file. Parameters ---------- url : str URL to download. file_handle : file Where to save the downloaded URL.
[ "Downloads", "a", "given", "URL", "to", "a", "specific", "file", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/downloaders/base.py#L57-L79
11,962
mila-iqia/fuel
fuel/downloaders/base.py
default_downloader
def default_downloader(directory, urls, filenames, url_prefix=None, clear=False): """Downloads or clears files from URLs and filenames. Parameters ---------- directory : str The directory in which downloaded files are saved. urls : list A list of URLs to downl...
python
def default_downloader(directory, urls, filenames, url_prefix=None, clear=False): """Downloads or clears files from URLs and filenames. Parameters ---------- directory : str The directory in which downloaded files are saved. urls : list A list of URLs to downl...
[ "def", "default_downloader", "(", "directory", ",", "urls", ",", "filenames", ",", "url_prefix", "=", "None", ",", "clear", "=", "False", ")", ":", "# Parse file names from URL if not provided", "for", "i", ",", "url", "in", "enumerate", "(", "urls", ")", ":",...
Downloads or clears files from URLs and filenames. Parameters ---------- directory : str The directory in which downloaded files are saved. urls : list A list of URLs to download. filenames : list A list of file names for the corresponding URLs. url_prefix : str, optiona...
[ "Downloads", "or", "clears", "files", "from", "URLs", "and", "filenames", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/downloaders/base.py#L96-L140
11,963
mila-iqia/fuel
fuel/utils/__init__.py
find_in_data_path
def find_in_data_path(filename): """Searches for a file within Fuel's data path. This function loops over all paths defined in Fuel's data path and returns the first path in which the file is found. Parameters ---------- filename : str Name of the file to find. Returns -------...
python
def find_in_data_path(filename): """Searches for a file within Fuel's data path. This function loops over all paths defined in Fuel's data path and returns the first path in which the file is found. Parameters ---------- filename : str Name of the file to find. Returns -------...
[ "def", "find_in_data_path", "(", "filename", ")", ":", "for", "path", "in", "config", ".", "data_path", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", "os", ".", "path", ".", "expandvars", "(", "path", ")", ")", "file_path", "=", "os", ...
Searches for a file within Fuel's data path. This function loops over all paths defined in Fuel's data path and returns the first path in which the file is found. Parameters ---------- filename : str Name of the file to find. Returns ------- file_path : str Path to the...
[ "Searches", "for", "a", "file", "within", "Fuel", "s", "data", "path", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/__init__.py#L406-L434
11,964
mila-iqia/fuel
fuel/utils/__init__.py
lazy_property_factory
def lazy_property_factory(lazy_property): """Create properties that perform lazy loading of attributes.""" def lazy_property_getter(self): if not hasattr(self, '_' + lazy_property): self.load() if not hasattr(self, '_' + lazy_property): raise ValueError("{} wasn't loaded"...
python
def lazy_property_factory(lazy_property): """Create properties that perform lazy loading of attributes.""" def lazy_property_getter(self): if not hasattr(self, '_' + lazy_property): self.load() if not hasattr(self, '_' + lazy_property): raise ValueError("{} wasn't loaded"...
[ "def", "lazy_property_factory", "(", "lazy_property", ")", ":", "def", "lazy_property_getter", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_'", "+", "lazy_property", ")", ":", "self", ".", "load", "(", ")", "if", "not", "hasattr", ...
Create properties that perform lazy loading of attributes.
[ "Create", "properties", "that", "perform", "lazy", "loading", "of", "attributes", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/__init__.py#L437-L449
11,965
mila-iqia/fuel
fuel/utils/__init__.py
do_not_pickle_attributes
def do_not_pickle_attributes(*lazy_properties): r"""Decorator to assign non-pickable properties. Used to assign properties which will not be pickled on some class. This decorator creates a series of properties whose values won't be serialized; instead, their values will be reloaded (e.g. from disk) by ...
python
def do_not_pickle_attributes(*lazy_properties): r"""Decorator to assign non-pickable properties. Used to assign properties which will not be pickled on some class. This decorator creates a series of properties whose values won't be serialized; instead, their values will be reloaded (e.g. from disk) by ...
[ "def", "do_not_pickle_attributes", "(", "*", "lazy_properties", ")", ":", "def", "wrap_class", "(", "cls", ")", ":", "if", "not", "hasattr", "(", "cls", ",", "'load'", ")", ":", "raise", "ValueError", "(", "\"no load method implemented\"", ")", "# Attach the laz...
r"""Decorator to assign non-pickable properties. Used to assign properties which will not be pickled on some class. This decorator creates a series of properties whose values won't be serialized; instead, their values will be reloaded (e.g. from disk) by the :meth:`load` function after deserializing th...
[ "r", "Decorator", "to", "assign", "non", "-", "pickable", "properties", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/__init__.py#L452-L513
11,966
mila-iqia/fuel
fuel/utils/__init__.py
Subset.sorted_fancy_indexing
def sorted_fancy_indexing(indexable, request): """Safe fancy indexing. Some objects, such as h5py datasets, only support list indexing if the list is sorted. This static method adds support for unsorted list indexing by sorting the requested indices, accessing the corresponding...
python
def sorted_fancy_indexing(indexable, request): """Safe fancy indexing. Some objects, such as h5py datasets, only support list indexing if the list is sorted. This static method adds support for unsorted list indexing by sorting the requested indices, accessing the corresponding...
[ "def", "sorted_fancy_indexing", "(", "indexable", ",", "request", ")", ":", "if", "len", "(", "request", ")", ">", "1", ":", "indices", "=", "numpy", ".", "argsort", "(", "request", ")", "data", "=", "numpy", ".", "empty", "(", "shape", "=", "(", "le...
Safe fancy indexing. Some objects, such as h5py datasets, only support list indexing if the list is sorted. This static method adds support for unsorted list indexing by sorting the requested indices, accessing the corresponding elements and re-shuffling the result. Pa...
[ "Safe", "fancy", "indexing", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/__init__.py#L175-L200
11,967
mila-iqia/fuel
fuel/utils/__init__.py
Subset.slice_to_numerical_args
def slice_to_numerical_args(slice_, num_examples): """Translate a slice's attributes into numerical attributes. Parameters ---------- slice_ : :class:`slice` Slice for which numerical attributes are wanted. num_examples : int Number of examples in the ind...
python
def slice_to_numerical_args(slice_, num_examples): """Translate a slice's attributes into numerical attributes. Parameters ---------- slice_ : :class:`slice` Slice for which numerical attributes are wanted. num_examples : int Number of examples in the ind...
[ "def", "slice_to_numerical_args", "(", "slice_", ",", "num_examples", ")", ":", "start", "=", "slice_", ".", "start", "if", "slice_", ".", "start", "is", "not", "None", "else", "0", "stop", "=", "slice_", ".", "stop", "if", "slice_", ".", "stop", "is", ...
Translate a slice's attributes into numerical attributes. Parameters ---------- slice_ : :class:`slice` Slice for which numerical attributes are wanted. num_examples : int Number of examples in the indexable that is to be sliced through. This determin...
[ "Translate", "a", "slice", "s", "attributes", "into", "numerical", "attributes", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/__init__.py#L203-L219
11,968
mila-iqia/fuel
fuel/utils/__init__.py
Subset.get_list_representation
def get_list_representation(self): """Returns this subset's representation as a list of indices.""" if self.is_list: return self.list_or_slice else: return self[list(range(self.num_examples))]
python
def get_list_representation(self): """Returns this subset's representation as a list of indices.""" if self.is_list: return self.list_or_slice else: return self[list(range(self.num_examples))]
[ "def", "get_list_representation", "(", "self", ")", ":", "if", "self", ".", "is_list", ":", "return", "self", ".", "list_or_slice", "else", ":", "return", "self", "[", "list", "(", "range", "(", "self", ".", "num_examples", ")", ")", "]" ]
Returns this subset's representation as a list of indices.
[ "Returns", "this", "subset", "s", "representation", "as", "a", "list", "of", "indices", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/__init__.py#L221-L226
11,969
mila-iqia/fuel
fuel/utils/__init__.py
Subset.index_within_subset
def index_within_subset(self, indexable, subset_request, sort_indices=False): """Index an indexable object within the context of this subset. Parameters ---------- indexable : indexable object The object to index through. subset_request : ...
python
def index_within_subset(self, indexable, subset_request, sort_indices=False): """Index an indexable object within the context of this subset. Parameters ---------- indexable : indexable object The object to index through. subset_request : ...
[ "def", "index_within_subset", "(", "self", ",", "indexable", ",", "subset_request", ",", "sort_indices", "=", "False", ")", ":", "# Translate the request within the context of this subset to a", "# request to the indexable object", "if", "isinstance", "(", "subset_request", "...
Index an indexable object within the context of this subset. Parameters ---------- indexable : indexable object The object to index through. subset_request : :class:`list` or :class:`slice` List of positive integer indices or slice that constitutes th...
[ "Index", "an", "indexable", "object", "within", "the", "context", "of", "this", "subset", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/__init__.py#L228-L266
11,970
mila-iqia/fuel
fuel/utils/__init__.py
Subset.num_examples
def num_examples(self): """The number of examples this subset spans.""" if self.is_list: return len(self.list_or_slice) else: start, stop, step = self.slice_to_numerical_args( self.list_or_slice, self.original_num_examples) return stop - start
python
def num_examples(self): """The number of examples this subset spans.""" if self.is_list: return len(self.list_or_slice) else: start, stop, step = self.slice_to_numerical_args( self.list_or_slice, self.original_num_examples) return stop - start
[ "def", "num_examples", "(", "self", ")", ":", "if", "self", ".", "is_list", ":", "return", "len", "(", "self", ".", "list_or_slice", ")", "else", ":", "start", ",", "stop", ",", "step", "=", "self", ".", "slice_to_numerical_args", "(", "self", ".", "li...
The number of examples this subset spans.
[ "The", "number", "of", "examples", "this", "subset", "spans", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/utils/__init__.py#L290-L297
11,971
mila-iqia/fuel
fuel/streams.py
DataStream.get_epoch_iterator
def get_epoch_iterator(self, **kwargs): """Get an epoch iterator for the data stream.""" if not self._fresh_state: self.next_epoch() else: self._fresh_state = False return super(DataStream, self).get_epoch_iterator(**kwargs)
python
def get_epoch_iterator(self, **kwargs): """Get an epoch iterator for the data stream.""" if not self._fresh_state: self.next_epoch() else: self._fresh_state = False return super(DataStream, self).get_epoch_iterator(**kwargs)
[ "def", "get_epoch_iterator", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "_fresh_state", ":", "self", ".", "next_epoch", "(", ")", "else", ":", "self", ".", "_fresh_state", "=", "False", "return", "super", "(", "DataStream",...
Get an epoch iterator for the data stream.
[ "Get", "an", "epoch", "iterator", "for", "the", "data", "stream", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/streams.py#L172-L178
11,972
mila-iqia/fuel
fuel/downloaders/binarized_mnist.py
fill_subparser
def fill_subparser(subparser): """Sets up a subparser to download the binarized MNIST dataset files. The binarized MNIST dataset files (`binarized_mnist_{train,valid,test}.amat`) are downloaded from Hugo Larochelle's website [HUGO]. .. [HUGO] http://www.cs.toronto.edu/~larocheh/public/datasets/ ...
python
def fill_subparser(subparser): """Sets up a subparser to download the binarized MNIST dataset files. The binarized MNIST dataset files (`binarized_mnist_{train,valid,test}.amat`) are downloaded from Hugo Larochelle's website [HUGO]. .. [HUGO] http://www.cs.toronto.edu/~larocheh/public/datasets/ ...
[ "def", "fill_subparser", "(", "subparser", ")", ":", "sets", "=", "[", "'train'", ",", "'valid'", ",", "'test'", "]", "urls", "=", "[", "'http://www.cs.toronto.edu/~larocheh/public/datasets/'", "+", "'binarized_mnist/binarized_mnist_{}.amat'", ".", "format", "(", "s",...
Sets up a subparser to download the binarized MNIST dataset files. The binarized MNIST dataset files (`binarized_mnist_{train,valid,test}.amat`) are downloaded from Hugo Larochelle's website [HUGO]. .. [HUGO] http://www.cs.toronto.edu/~larocheh/public/datasets/ binarized_mnist/binarized_mnist_{...
[ "Sets", "up", "a", "subparser", "to", "download", "the", "binarized", "MNIST", "dataset", "files", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/downloaders/binarized_mnist.py#L4-L25
11,973
mila-iqia/fuel
fuel/downloaders/youtube_audio.py
download
def download(directory, youtube_id, clear=False): """Download the audio of a YouTube video. The audio is downloaded in the highest available quality. Progress is printed to `stdout`. The file is named `youtube_id.m4a`, where `youtube_id` is the 11-character code identifiying the YouTube video (can ...
python
def download(directory, youtube_id, clear=False): """Download the audio of a YouTube video. The audio is downloaded in the highest available quality. Progress is printed to `stdout`. The file is named `youtube_id.m4a`, where `youtube_id` is the 11-character code identifiying the YouTube video (can ...
[ "def", "download", "(", "directory", ",", "youtube_id", ",", "clear", "=", "False", ")", ":", "filepath", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "'{}.m4a'", ".", "format", "(", "youtube_id", ")", ")", "if", "clear", ":", "os", "....
Download the audio of a YouTube video. The audio is downloaded in the highest available quality. Progress is printed to `stdout`. The file is named `youtube_id.m4a`, where `youtube_id` is the 11-character code identifiying the YouTube video (can be determined from the URL). Parameters --------...
[ "Download", "the", "audio", "of", "a", "YouTube", "video", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/downloaders/youtube_audio.py#L10-L38
11,974
mila-iqia/fuel
fuel/downloaders/youtube_audio.py
fill_subparser
def fill_subparser(subparser): """Sets up a subparser to download audio of YouTube videos. Adds the compulsory `--youtube-id` flag. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `youtube_audio` command. """ subparser.add_argument( ...
python
def fill_subparser(subparser): """Sets up a subparser to download audio of YouTube videos. Adds the compulsory `--youtube-id` flag. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `youtube_audio` command. """ subparser.add_argument( ...
[ "def", "fill_subparser", "(", "subparser", ")", ":", "subparser", ".", "add_argument", "(", "'--youtube-id'", ",", "type", "=", "str", ",", "required", "=", "True", ",", "help", "=", "(", "\"The YouTube ID of the video from which to extract audio, \"", "\"usually an 1...
Sets up a subparser to download audio of YouTube videos. Adds the compulsory `--youtube-id` flag. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `youtube_audio` command.
[ "Sets", "up", "a", "subparser", "to", "download", "audio", "of", "YouTube", "videos", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/downloaders/youtube_audio.py#L41-L57
11,975
mila-iqia/fuel
fuel/converters/youtube_audio.py
convert_youtube_audio
def convert_youtube_audio(directory, output_directory, youtube_id, channels, sample, output_filename=None): """Converts downloaded YouTube audio to HDF5 format. Requires `ffmpeg` to be installed and available on the command line (i.e. available on your `PATH`). Parameters ...
python
def convert_youtube_audio(directory, output_directory, youtube_id, channels, sample, output_filename=None): """Converts downloaded YouTube audio to HDF5 format. Requires `ffmpeg` to be installed and available on the command line (i.e. available on your `PATH`). Parameters ...
[ "def", "convert_youtube_audio", "(", "directory", ",", "output_directory", ",", "youtube_id", ",", "channels", ",", "sample", ",", "output_filename", "=", "None", ")", ":", "input_file", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "'{}.m4a'", ...
Converts downloaded YouTube audio to HDF5 format. Requires `ffmpeg` to be installed and available on the command line (i.e. available on your `PATH`). Parameters ---------- directory : str Directory in which input files reside. output_directory : str Directory in which to save ...
[ "Converts", "downloaded", "YouTube", "audio", "to", "HDF5", "format", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/youtube_audio.py#L11-L62
11,976
mila-iqia/fuel
fuel/converters/youtube_audio.py
fill_subparser
def fill_subparser(subparser): """Sets up a subparser to convert YouTube audio files. Adds the compulsory `--youtube-id` flag as well as the optional `sample` and `channels` flags. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `youtube_audio`...
python
def fill_subparser(subparser): """Sets up a subparser to convert YouTube audio files. Adds the compulsory `--youtube-id` flag as well as the optional `sample` and `channels` flags. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `youtube_audio`...
[ "def", "fill_subparser", "(", "subparser", ")", ":", "subparser", ".", "add_argument", "(", "'--youtube-id'", ",", "type", "=", "str", ",", "required", "=", "True", ",", "help", "=", "(", "\"The YouTube ID of the video from which to extract audio, \"", "\"usually an 1...
Sets up a subparser to convert YouTube audio files. Adds the compulsory `--youtube-id` flag as well as the optional `sample` and `channels` flags. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `youtube_audio` command.
[ "Sets", "up", "a", "subparser", "to", "convert", "YouTube", "audio", "files", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/youtube_audio.py#L65-L93
11,977
mila-iqia/fuel
fuel/converters/ilsvrc2012.py
convert_ilsvrc2012
def convert_ilsvrc2012(directory, output_directory, output_filename='ilsvrc2012.hdf5', shuffle_seed=config.default_seed): """Converter for data from the ILSVRC 2012 competition. Source files for this dataset can be obtained by registering at [ILSVRC2012WEB]. ...
python
def convert_ilsvrc2012(directory, output_directory, output_filename='ilsvrc2012.hdf5', shuffle_seed=config.default_seed): """Converter for data from the ILSVRC 2012 competition. Source files for this dataset can be obtained by registering at [ILSVRC2012WEB]. ...
[ "def", "convert_ilsvrc2012", "(", "directory", ",", "output_directory", ",", "output_filename", "=", "'ilsvrc2012.hdf5'", ",", "shuffle_seed", "=", "config", ".", "default_seed", ")", ":", "devkit_path", "=", "os", ".", "path", ".", "join", "(", "directory", ","...
Converter for data from the ILSVRC 2012 competition. Source files for this dataset can be obtained by registering at [ILSVRC2012WEB]. Parameters ---------- input_directory : str Path from which to read raw data files. output_directory : str Path to which to save the HDF5 file. ...
[ "Converter", "for", "data", "from", "the", "ILSVRC", "2012", "competition", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/ilsvrc2012.py#L35-L78
11,978
mila-iqia/fuel
fuel/converters/ilsvrc2012.py
fill_subparser
def fill_subparser(subparser): """Sets up a subparser to convert the ILSVRC2012 dataset files. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `ilsvrc2012` command. """ subparser.add_argument( "--shuffle-seed", help="Seed to use for ran...
python
def fill_subparser(subparser): """Sets up a subparser to convert the ILSVRC2012 dataset files. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `ilsvrc2012` command. """ subparser.add_argument( "--shuffle-seed", help="Seed to use for ran...
[ "def", "fill_subparser", "(", "subparser", ")", ":", "subparser", ".", "add_argument", "(", "\"--shuffle-seed\"", ",", "help", "=", "\"Seed to use for randomizing order of the \"", "\"training set on disk.\"", ",", "default", "=", "config", ".", "default_seed", ",", "ty...
Sets up a subparser to convert the ILSVRC2012 dataset files. Parameters ---------- subparser : :class:`argparse.ArgumentParser` Subparser handling the `ilsvrc2012` command.
[ "Sets", "up", "a", "subparser", "to", "convert", "the", "ILSVRC2012", "dataset", "files", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/ilsvrc2012.py#L81-L94
11,979
mila-iqia/fuel
fuel/converters/ilsvrc2012.py
read_metadata_mat_file
def read_metadata_mat_file(meta_mat): """Read ILSVRC2012 metadata from the distributed MAT file. Parameters ---------- meta_mat : str or file-like object The filename or file-handle for `meta.mat` from the ILSVRC2012 development kit. Returns ------- synsets : ndarray, 1-dim...
python
def read_metadata_mat_file(meta_mat): """Read ILSVRC2012 metadata from the distributed MAT file. Parameters ---------- meta_mat : str or file-like object The filename or file-handle for `meta.mat` from the ILSVRC2012 development kit. Returns ------- synsets : ndarray, 1-dim...
[ "def", "read_metadata_mat_file", "(", "meta_mat", ")", ":", "mat", "=", "loadmat", "(", "meta_mat", ",", "squeeze_me", "=", "True", ")", "synsets", "=", "mat", "[", "'synsets'", "]", "new_dtype", "=", "numpy", ".", "dtype", "(", "[", "(", "'ILSVRC2012_ID'"...
Read ILSVRC2012 metadata from the distributed MAT file. Parameters ---------- meta_mat : str or file-like object The filename or file-handle for `meta.mat` from the ILSVRC2012 development kit. Returns ------- synsets : ndarray, 1-dimensional, compound dtype A table cont...
[ "Read", "ILSVRC2012", "metadata", "from", "the", "distributed", "MAT", "file", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/ilsvrc2012.py#L231-L294
11,980
mila-iqia/fuel
fuel/config_parser.py
multiple_paths_parser
def multiple_paths_parser(value): """Parses data_path argument. Parameters ---------- value : str a string of data paths separated by ":". Returns ------- value : list a list of strings indicating each data paths. """ if isinstance(value, six.string_types): ...
python
def multiple_paths_parser(value): """Parses data_path argument. Parameters ---------- value : str a string of data paths separated by ":". Returns ------- value : list a list of strings indicating each data paths. """ if isinstance(value, six.string_types): ...
[ "def", "multiple_paths_parser", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "value", "=", "value", ".", "split", "(", "os", ".", "path", ".", "pathsep", ")", "return", "value" ]
Parses data_path argument. Parameters ---------- value : str a string of data paths separated by ":". Returns ------- value : list a list of strings indicating each data paths.
[ "Parses", "data_path", "argument", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/config_parser.py#L108-L124
11,981
mila-iqia/fuel
fuel/config_parser.py
Configuration.add_config
def add_config(self, key, type_, default=NOT_SET, env_var=None): """Add a configuration setting. Parameters ---------- key : str The name of the configuration setting. This must be a valid Python attribute name i.e. alphanumeric with underscores. type : f...
python
def add_config(self, key, type_, default=NOT_SET, env_var=None): """Add a configuration setting. Parameters ---------- key : str The name of the configuration setting. This must be a valid Python attribute name i.e. alphanumeric with underscores. type : f...
[ "def", "add_config", "(", "self", ",", "key", ",", "type_", ",", "default", "=", "NOT_SET", ",", "env_var", "=", "None", ")", ":", "self", ".", "config", "[", "key", "]", "=", "{", "'type'", ":", "type_", "}", "if", "env_var", "is", "not", "None", ...
Add a configuration setting. Parameters ---------- key : str The name of the configuration setting. This must be a valid Python attribute name i.e. alphanumeric with underscores. type : function A function such as ``float``, ``int`` or ``str`` which t...
[ "Add", "a", "configuration", "setting", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/config_parser.py#L168-L196
11,982
mila-iqia/fuel
fuel/server.py
send_arrays
def send_arrays(socket, arrays, stop=False): """Send NumPy arrays using the buffer interface and some metadata. Parameters ---------- socket : :class:`zmq.Socket` The socket to send data over. arrays : list A list of :class:`numpy.ndarray` to transfer. stop : bool, optional ...
python
def send_arrays(socket, arrays, stop=False): """Send NumPy arrays using the buffer interface and some metadata. Parameters ---------- socket : :class:`zmq.Socket` The socket to send data over. arrays : list A list of :class:`numpy.ndarray` to transfer. stop : bool, optional ...
[ "def", "send_arrays", "(", "socket", ",", "arrays", ",", "stop", "=", "False", ")", ":", "if", "arrays", ":", "# The buffer protocol only works on contiguous arrays", "arrays", "=", "[", "numpy", ".", "ascontiguousarray", "(", "array", ")", "for", "array", "in",...
Send NumPy arrays using the buffer interface and some metadata. Parameters ---------- socket : :class:`zmq.Socket` The socket to send data over. arrays : list A list of :class:`numpy.ndarray` to transfer. stop : bool, optional Instead of sending a series of NumPy arrays, sen...
[ "Send", "NumPy", "arrays", "using", "the", "buffer", "interface", "and", "some", "metadata", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/server.py#L12-L45
11,983
mila-iqia/fuel
fuel/server.py
recv_arrays
def recv_arrays(socket): """Receive a list of NumPy arrays. Parameters ---------- socket : :class:`zmq.Socket` The socket to receive the arrays on. Returns ------- list A list of :class:`numpy.ndarray` objects. Raises ------ StopIteration If the first J...
python
def recv_arrays(socket): """Receive a list of NumPy arrays. Parameters ---------- socket : :class:`zmq.Socket` The socket to receive the arrays on. Returns ------- list A list of :class:`numpy.ndarray` objects. Raises ------ StopIteration If the first J...
[ "def", "recv_arrays", "(", "socket", ")", ":", "headers", "=", "socket", ".", "recv_json", "(", ")", "if", "'stop'", "in", "headers", ":", "raise", "StopIteration", "arrays", "=", "[", "]", "for", "header", "in", "headers", ":", "data", "=", "socket", ...
Receive a list of NumPy arrays. Parameters ---------- socket : :class:`zmq.Socket` The socket to receive the arrays on. Returns ------- list A list of :class:`numpy.ndarray` objects. Raises ------ StopIteration If the first JSON object received contains the...
[ "Receive", "a", "list", "of", "NumPy", "arrays", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/server.py#L48-L81
11,984
mila-iqia/fuel
fuel/server.py
start_server
def start_server(data_stream, port=5557, hwm=10): """Start a data processing server. This command starts a server in the current process that performs the actual data processing (by retrieving data from the given data stream). It also starts a second process, the broker, which mediates between the ...
python
def start_server(data_stream, port=5557, hwm=10): """Start a data processing server. This command starts a server in the current process that performs the actual data processing (by retrieving data from the given data stream). It also starts a second process, the broker, which mediates between the ...
[ "def", "start_server", "(", "data_stream", ",", "port", "=", "5557", ",", "hwm", "=", "10", ")", ":", "logging", ".", "basicConfig", "(", "level", "=", "'INFO'", ")", "context", "=", "zmq", ".", "Context", "(", ")", "socket", "=", "context", ".", "so...
Start a data processing server. This command starts a server in the current process that performs the actual data processing (by retrieving data from the given data stream). It also starts a second process, the broker, which mediates between the server and the client. The broker also keeps a buffer of ...
[ "Start", "a", "data", "processing", "server", "." ]
1d6292dc25e3a115544237e392e61bff6631d23c
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/server.py#L84-L131
11,985
apacha/OMR-Datasets
omrdatasettools/image_generators/HomusImageGenerator.py
HomusImageGenerator.create_images
def create_images(raw_data_directory: str, destination_directory: str, stroke_thicknesses: List[int], canvas_width: int = None, canvas_height: int = None, staff_line_spacing: int = 14, sta...
python
def create_images(raw_data_directory: str, destination_directory: str, stroke_thicknesses: List[int], canvas_width: int = None, canvas_height: int = None, staff_line_spacing: int = 14, sta...
[ "def", "create_images", "(", "raw_data_directory", ":", "str", ",", "destination_directory", ":", "str", ",", "stroke_thicknesses", ":", "List", "[", "int", "]", ",", "canvas_width", ":", "int", "=", "None", ",", "canvas_height", ":", "int", "=", "None", ","...
Creates a visual representation of the Homus Dataset by parsing all text-files and the symbols as specified by the parameters by drawing lines that connect the points from each stroke of each symbol. Each symbol will be drawn in the center of a fixed canvas, specified by width and height. :par...
[ "Creates", "a", "visual", "representation", "of", "the", "Homus", "Dataset", "by", "parsing", "all", "text", "-", "files", "and", "the", "symbols", "as", "specified", "by", "the", "parameters", "by", "drawing", "lines", "that", "connect", "the", "points", "f...
d0a22a03ae35caeef211729efa340e1ec0e01ea5
https://github.com/apacha/OMR-Datasets/blob/d0a22a03ae35caeef211729efa340e1ec0e01ea5/omrdatasettools/image_generators/HomusImageGenerator.py#L13-L105
11,986
apacha/OMR-Datasets
omrdatasettools/image_generators/MuscimaPlusPlusImageGenerator.py
MuscimaPlusPlusImageGenerator.extract_and_render_all_symbol_masks
def extract_and_render_all_symbol_masks(self, raw_data_directory: str, destination_directory: str): """ Extracts all symbols from the raw XML documents and generates individual symbols from the masks :param raw_data_directory: The directory, that contains the xml-files and matching images ...
python
def extract_and_render_all_symbol_masks(self, raw_data_directory: str, destination_directory: str): """ Extracts all symbols from the raw XML documents and generates individual symbols from the masks :param raw_data_directory: The directory, that contains the xml-files and matching images ...
[ "def", "extract_and_render_all_symbol_masks", "(", "self", ",", "raw_data_directory", ":", "str", ",", "destination_directory", ":", "str", ")", ":", "print", "(", "\"Extracting Symbols from Muscima++ Dataset...\"", ")", "xml_files", "=", "self", ".", "get_all_xml_file_pa...
Extracts all symbols from the raw XML documents and generates individual symbols from the masks :param raw_data_directory: The directory, that contains the xml-files and matching images :param destination_directory: The directory, in which the symbols should be generated into. One sub-folder per ...
[ "Extracts", "all", "symbols", "from", "the", "raw", "XML", "documents", "and", "generates", "individual", "symbols", "from", "the", "masks" ]
d0a22a03ae35caeef211729efa340e1ec0e01ea5
https://github.com/apacha/OMR-Datasets/blob/d0a22a03ae35caeef211729efa340e1ec0e01ea5/omrdatasettools/image_generators/MuscimaPlusPlusImageGenerator.py#L23-L35
11,987
apacha/OMR-Datasets
omrdatasettools/converters/ImageColorInverter.py
ImageColorInverter.invert_images
def invert_images(self, image_directory: str, image_file_ending: str = "*.bmp"): """ In-situ converts the white on black images of a directory to black on white images :param image_directory: The directory, that contains the images :param image_file_ending: The pattern for finding files...
python
def invert_images(self, image_directory: str, image_file_ending: str = "*.bmp"): """ In-situ converts the white on black images of a directory to black on white images :param image_directory: The directory, that contains the images :param image_file_ending: The pattern for finding files...
[ "def", "invert_images", "(", "self", ",", "image_directory", ":", "str", ",", "image_file_ending", ":", "str", "=", "\"*.bmp\"", ")", ":", "image_paths", "=", "[", "y", "for", "x", "in", "os", ".", "walk", "(", "image_directory", ")", "for", "y", "in", ...
In-situ converts the white on black images of a directory to black on white images :param image_directory: The directory, that contains the images :param image_file_ending: The pattern for finding files in the image_directory
[ "In", "-", "situ", "converts", "the", "white", "on", "black", "images", "of", "a", "directory", "to", "black", "on", "white", "images" ]
d0a22a03ae35caeef211729efa340e1ec0e01ea5
https://github.com/apacha/OMR-Datasets/blob/d0a22a03ae35caeef211729efa340e1ec0e01ea5/omrdatasettools/converters/ImageColorInverter.py#L15-L26
11,988
apacha/OMR-Datasets
omrdatasettools/image_generators/CapitanImageGenerator.py
CapitanImageGenerator.create_capitan_images
def create_capitan_images(self, raw_data_directory: str, destination_directory: str, stroke_thicknesses: List[int]) -> None: """ Creates a visual representation of the Capitan strokes by parsing all text-files and the symbols as specified ...
python
def create_capitan_images(self, raw_data_directory: str, destination_directory: str, stroke_thicknesses: List[int]) -> None: """ Creates a visual representation of the Capitan strokes by parsing all text-files and the symbols as specified ...
[ "def", "create_capitan_images", "(", "self", ",", "raw_data_directory", ":", "str", ",", "destination_directory", ":", "str", ",", "stroke_thicknesses", ":", "List", "[", "int", "]", ")", "->", "None", ":", "symbols", "=", "self", ".", "load_capitan_symbols", ...
Creates a visual representation of the Capitan strokes by parsing all text-files and the symbols as specified by the parameters by drawing lines that connect the points from each stroke of each symbol. :param raw_data_directory: The directory, that contains the raw capitan dataset :param destin...
[ "Creates", "a", "visual", "representation", "of", "the", "Capitan", "strokes", "by", "parsing", "all", "text", "-", "files", "and", "the", "symbols", "as", "specified", "by", "the", "parameters", "by", "drawing", "lines", "that", "connect", "the", "points", ...
d0a22a03ae35caeef211729efa340e1ec0e01ea5
https://github.com/apacha/OMR-Datasets/blob/d0a22a03ae35caeef211729efa340e1ec0e01ea5/omrdatasettools/image_generators/CapitanImageGenerator.py#L13-L29
11,989
apacha/OMR-Datasets
omrdatasettools/image_generators/CapitanImageGenerator.py
CapitanImageGenerator.draw_capitan_stroke_images
def draw_capitan_stroke_images(self, symbols: List[CapitanSymbol], destination_directory: str, stroke_thicknesses: List[int]) -> None: """ Creates a visual representation of the Capitan strokes by drawing lines that connect the points...
python
def draw_capitan_stroke_images(self, symbols: List[CapitanSymbol], destination_directory: str, stroke_thicknesses: List[int]) -> None: """ Creates a visual representation of the Capitan strokes by drawing lines that connect the points...
[ "def", "draw_capitan_stroke_images", "(", "self", ",", "symbols", ":", "List", "[", "CapitanSymbol", "]", ",", "destination_directory", ":", "str", ",", "stroke_thicknesses", ":", "List", "[", "int", "]", ")", "->", "None", ":", "total_number_of_symbols", "=", ...
Creates a visual representation of the Capitan strokes by drawing lines that connect the points from each stroke of each symbol. :param symbols: The list of parsed Capitan-symbols :param destination_directory: The directory, in which the symbols should be generated into. One sub-folder per ...
[ "Creates", "a", "visual", "representation", "of", "the", "Capitan", "strokes", "by", "drawing", "lines", "that", "connect", "the", "points", "from", "each", "stroke", "of", "each", "symbol", "." ]
d0a22a03ae35caeef211729efa340e1ec0e01ea5
https://github.com/apacha/OMR-Datasets/blob/d0a22a03ae35caeef211729efa340e1ec0e01ea5/omrdatasettools/image_generators/CapitanImageGenerator.py#L44-L82
11,990
apacha/OMR-Datasets
omrdatasettools/image_generators/Rectangle.py
Rectangle.overlap
def overlap(r1: 'Rectangle', r2: 'Rectangle'): """ Overlapping rectangles overlap both horizontally & vertically """ h_overlaps = (r1.left <= r2.right) and (r1.right >= r2.left) v_overlaps = (r1.bottom >= r2.top) and (r1.top <= r2.bottom) return h_overlaps and v_overlaps
python
def overlap(r1: 'Rectangle', r2: 'Rectangle'): """ Overlapping rectangles overlap both horizontally & vertically """ h_overlaps = (r1.left <= r2.right) and (r1.right >= r2.left) v_overlaps = (r1.bottom >= r2.top) and (r1.top <= r2.bottom) return h_overlaps and v_overlaps
[ "def", "overlap", "(", "r1", ":", "'Rectangle'", ",", "r2", ":", "'Rectangle'", ")", ":", "h_overlaps", "=", "(", "r1", ".", "left", "<=", "r2", ".", "right", ")", "and", "(", "r1", ".", "right", ">=", "r2", ".", "left", ")", "v_overlaps", "=", "...
Overlapping rectangles overlap both horizontally & vertically
[ "Overlapping", "rectangles", "overlap", "both", "horizontally", "&", "vertically" ]
d0a22a03ae35caeef211729efa340e1ec0e01ea5
https://github.com/apacha/OMR-Datasets/blob/d0a22a03ae35caeef211729efa340e1ec0e01ea5/omrdatasettools/image_generators/Rectangle.py#L18-L24
11,991
apacha/OMR-Datasets
omrdatasettools/image_generators/AudiverisOmrImageGenerator.py
AudiverisOmrImageGenerator.extract_symbols
def extract_symbols(self, raw_data_directory: str, destination_directory: str): """ Extracts the symbols from the raw XML documents and matching images of the Audiveris OMR dataset into individual symbols :param raw_data_directory: The directory, that contains the xml-files and matching...
python
def extract_symbols(self, raw_data_directory: str, destination_directory: str): """ Extracts the symbols from the raw XML documents and matching images of the Audiveris OMR dataset into individual symbols :param raw_data_directory: The directory, that contains the xml-files and matching...
[ "def", "extract_symbols", "(", "self", ",", "raw_data_directory", ":", "str", ",", "destination_directory", ":", "str", ")", ":", "print", "(", "\"Extracting Symbols from Audiveris OMR Dataset...\"", ")", "all_xml_files", "=", "[", "y", "for", "x", "in", "os", "."...
Extracts the symbols from the raw XML documents and matching images of the Audiveris OMR dataset into individual symbols :param raw_data_directory: The directory, that contains the xml-files and matching images :param destination_directory: The directory, in which the symbols should be generate...
[ "Extracts", "the", "symbols", "from", "the", "raw", "XML", "documents", "and", "matching", "images", "of", "the", "Audiveris", "OMR", "dataset", "into", "individual", "symbols" ]
d0a22a03ae35caeef211729efa340e1ec0e01ea5
https://github.com/apacha/OMR-Datasets/blob/d0a22a03ae35caeef211729efa340e1ec0e01ea5/omrdatasettools/image_generators/AudiverisOmrImageGenerator.py#L16-L35
11,992
apacha/OMR-Datasets
omrdatasettools/image_generators/HomusSymbol.py
HomusSymbol.initialize_from_string
def initialize_from_string(content: str) -> 'HomusSymbol': """ Create and initializes a new symbol from a string :param content: The content of a symbol as read from the text-file :return: The initialized symbol :rtype: HomusSymbol """ if content is None or cont...
python
def initialize_from_string(content: str) -> 'HomusSymbol': """ Create and initializes a new symbol from a string :param content: The content of a symbol as read from the text-file :return: The initialized symbol :rtype: HomusSymbol """ if content is None or cont...
[ "def", "initialize_from_string", "(", "content", ":", "str", ")", "->", "'HomusSymbol'", ":", "if", "content", "is", "None", "or", "content", "is", "\"\"", ":", "return", "None", "lines", "=", "content", ".", "splitlines", "(", ")", "min_x", "=", "sys", ...
Create and initializes a new symbol from a string :param content: The content of a symbol as read from the text-file :return: The initialized symbol :rtype: HomusSymbol
[ "Create", "and", "initializes", "a", "new", "symbol", "from", "a", "string" ]
d0a22a03ae35caeef211729efa340e1ec0e01ea5
https://github.com/apacha/OMR-Datasets/blob/d0a22a03ae35caeef211729efa340e1ec0e01ea5/omrdatasettools/image_generators/HomusSymbol.py#L21-L62
11,993
apacha/OMR-Datasets
omrdatasettools/image_generators/HomusSymbol.py
HomusSymbol.draw_into_bitmap
def draw_into_bitmap(self, export_path: ExportPath, stroke_thickness: int, margin: int = 0) -> None: """ Draws the symbol in the original size that it has plus an optional margin :param export_path: The path, where the symbols should be created on disk :param stroke_thickness: Pen-thick...
python
def draw_into_bitmap(self, export_path: ExportPath, stroke_thickness: int, margin: int = 0) -> None: """ Draws the symbol in the original size that it has plus an optional margin :param export_path: The path, where the symbols should be created on disk :param stroke_thickness: Pen-thick...
[ "def", "draw_into_bitmap", "(", "self", ",", "export_path", ":", "ExportPath", ",", "stroke_thickness", ":", "int", ",", "margin", ":", "int", "=", "0", ")", "->", "None", ":", "self", ".", "draw_onto_canvas", "(", "export_path", ",", "stroke_thickness", ","...
Draws the symbol in the original size that it has plus an optional margin :param export_path: The path, where the symbols should be created on disk :param stroke_thickness: Pen-thickness for drawing the symbol in pixels :param margin: An optional margin for each symbol
[ "Draws", "the", "symbol", "in", "the", "original", "size", "that", "it", "has", "plus", "an", "optional", "margin" ]
d0a22a03ae35caeef211729efa340e1ec0e01ea5
https://github.com/apacha/OMR-Datasets/blob/d0a22a03ae35caeef211729efa340e1ec0e01ea5/omrdatasettools/image_generators/HomusSymbol.py#L64-L76
11,994
apacha/OMR-Datasets
omrdatasettools/image_generators/HomusSymbol.py
HomusSymbol.draw_onto_canvas
def draw_onto_canvas(self, export_path: ExportPath, stroke_thickness: int, margin: int, destination_width: int, destination_height: int, staff_line_spacing: int = 14, staff_line_vertical_offsets: List[int] = None, bounding_boxes: dict = None, ra...
python
def draw_onto_canvas(self, export_path: ExportPath, stroke_thickness: int, margin: int, destination_width: int, destination_height: int, staff_line_spacing: int = 14, staff_line_vertical_offsets: List[int] = None, bounding_boxes: dict = None, ra...
[ "def", "draw_onto_canvas", "(", "self", ",", "export_path", ":", "ExportPath", ",", "stroke_thickness", ":", "int", ",", "margin", ":", "int", ",", "destination_width", ":", "int", ",", "destination_height", ":", "int", ",", "staff_line_spacing", ":", "int", "...
Draws the symbol onto a canvas with a fixed size :param bounding_boxes: The dictionary into which the bounding-boxes will be added of each generated image :param export_path: The path, where the symbols should be created on disk :param stroke_thickness: :param margin: :param des...
[ "Draws", "the", "symbol", "onto", "a", "canvas", "with", "a", "fixed", "size" ]
d0a22a03ae35caeef211729efa340e1ec0e01ea5
https://github.com/apacha/OMR-Datasets/blob/d0a22a03ae35caeef211729efa340e1ec0e01ea5/omrdatasettools/image_generators/HomusSymbol.py#L78-L148
11,995
datascopeanalytics/scrubadub
scrubadub/import_magic.py
update_locals
def update_locals(locals_instance, instance_iterator, *args, **kwargs): """import all of the detector classes into the local namespace to make it easy to do things like `import scrubadub.detectors.NameDetector` without having to add each new ``Detector`` or ``Filth`` """ # http://stackoverflow.com/a...
python
def update_locals(locals_instance, instance_iterator, *args, **kwargs): """import all of the detector classes into the local namespace to make it easy to do things like `import scrubadub.detectors.NameDetector` without having to add each new ``Detector`` or ``Filth`` """ # http://stackoverflow.com/a...
[ "def", "update_locals", "(", "locals_instance", ",", "instance_iterator", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# http://stackoverflow.com/a/4526709/564709", "# http://stackoverflow.com/a/511059/564709", "for", "instance", "in", "instance_iterator", "(", "...
import all of the detector classes into the local namespace to make it easy to do things like `import scrubadub.detectors.NameDetector` without having to add each new ``Detector`` or ``Filth``
[ "import", "all", "of", "the", "detector", "classes", "into", "the", "local", "namespace", "to", "make", "it", "easy", "to", "do", "things", "like", "import", "scrubadub", ".", "detectors", ".", "NameDetector", "without", "having", "to", "add", "each", "new",...
914bda49a16130b44af43df6a2f84755477c407c
https://github.com/datascopeanalytics/scrubadub/blob/914bda49a16130b44af43df6a2f84755477c407c/scrubadub/import_magic.py#L34-L42
11,996
datascopeanalytics/scrubadub
scrubadub/filth/__init__.py
iter_filth_clss
def iter_filth_clss(): """Iterate over all of the filths that are included in this sub-package. This is a convenience method for capturing all new Filth that are added over time. """ return iter_subclasses( os.path.dirname(os.path.abspath(__file__)), Filth, _is_abstract_filth...
python
def iter_filth_clss(): """Iterate over all of the filths that are included in this sub-package. This is a convenience method for capturing all new Filth that are added over time. """ return iter_subclasses( os.path.dirname(os.path.abspath(__file__)), Filth, _is_abstract_filth...
[ "def", "iter_filth_clss", "(", ")", ":", "return", "iter_subclasses", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "Filth", ",", "_is_abstract_filth", ",", ")" ]
Iterate over all of the filths that are included in this sub-package. This is a convenience method for capturing all new Filth that are added over time.
[ "Iterate", "over", "all", "of", "the", "filths", "that", "are", "included", "in", "this", "sub", "-", "package", ".", "This", "is", "a", "convenience", "method", "for", "capturing", "all", "new", "Filth", "that", "are", "added", "over", "time", "." ]
914bda49a16130b44af43df6a2f84755477c407c
https://github.com/datascopeanalytics/scrubadub/blob/914bda49a16130b44af43df6a2f84755477c407c/scrubadub/filth/__init__.py#L13-L22
11,997
datascopeanalytics/scrubadub
scrubadub/filth/__init__.py
iter_filths
def iter_filths(): """Iterate over all instances of filth""" for filth_cls in iter_filth_clss(): if issubclass(filth_cls, RegexFilth): m = next(re.finditer(r"\s+", "fake pattern string")) yield filth_cls(m) else: yield filth_cls()
python
def iter_filths(): """Iterate over all instances of filth""" for filth_cls in iter_filth_clss(): if issubclass(filth_cls, RegexFilth): m = next(re.finditer(r"\s+", "fake pattern string")) yield filth_cls(m) else: yield filth_cls()
[ "def", "iter_filths", "(", ")", ":", "for", "filth_cls", "in", "iter_filth_clss", "(", ")", ":", "if", "issubclass", "(", "filth_cls", ",", "RegexFilth", ")", ":", "m", "=", "next", "(", "re", ".", "finditer", "(", "r\"\\s+\"", ",", "\"fake pattern string\...
Iterate over all instances of filth
[ "Iterate", "over", "all", "instances", "of", "filth" ]
914bda49a16130b44af43df6a2f84755477c407c
https://github.com/datascopeanalytics/scrubadub/blob/914bda49a16130b44af43df6a2f84755477c407c/scrubadub/filth/__init__.py#L25-L32
11,998
datascopeanalytics/scrubadub
scrubadub/filth/base.py
MergedFilth._update_content
def _update_content(self, other_filth): """this updates the bounds, text and placeholder for the merged filth """ if self.end < other_filth.beg or other_filth.end < self.beg: raise exceptions.FilthMergeError( "a_filth goes from [%s, %s) and b_filth goes from [...
python
def _update_content(self, other_filth): """this updates the bounds, text and placeholder for the merged filth """ if self.end < other_filth.beg or other_filth.end < self.beg: raise exceptions.FilthMergeError( "a_filth goes from [%s, %s) and b_filth goes from [...
[ "def", "_update_content", "(", "self", ",", "other_filth", ")", ":", "if", "self", ".", "end", "<", "other_filth", ".", "beg", "or", "other_filth", ".", "end", "<", "self", ".", "beg", ":", "raise", "exceptions", ".", "FilthMergeError", "(", "\"a_filth goe...
this updates the bounds, text and placeholder for the merged filth
[ "this", "updates", "the", "bounds", "text", "and", "placeholder", "for", "the", "merged", "filth" ]
914bda49a16130b44af43df6a2f84755477c407c
https://github.com/datascopeanalytics/scrubadub/blob/914bda49a16130b44af43df6a2f84755477c407c/scrubadub/filth/base.py#L65-L94
11,999
datascopeanalytics/scrubadub
scrubadub/scrubbers.py
Scrubber.add_detector
def add_detector(self, detector_cls): """Add a ``Detector`` to scrubadub""" if not issubclass(detector_cls, detectors.base.Detector): raise TypeError(( '"%(detector_cls)s" is not a subclass of Detector' ) % locals()) # TODO: should add tests to make sure f...
python
def add_detector(self, detector_cls): """Add a ``Detector`` to scrubadub""" if not issubclass(detector_cls, detectors.base.Detector): raise TypeError(( '"%(detector_cls)s" is not a subclass of Detector' ) % locals()) # TODO: should add tests to make sure f...
[ "def", "add_detector", "(", "self", ",", "detector_cls", ")", ":", "if", "not", "issubclass", "(", "detector_cls", ",", "detectors", ".", "base", ".", "Detector", ")", ":", "raise", "TypeError", "(", "(", "'\"%(detector_cls)s\" is not a subclass of Detector'", ")"...
Add a ``Detector`` to scrubadub
[ "Add", "a", "Detector", "to", "scrubadub" ]
914bda49a16130b44af43df6a2f84755477c407c
https://github.com/datascopeanalytics/scrubadub/blob/914bda49a16130b44af43df6a2f84755477c407c/scrubadub/scrubbers.py#L24-L38