hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
⌀
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
62099bbf7b4837d22c33f0ea197cf63171b8328a
talkingscott/xpgdiff
xpgdiff.py
[ "MIT" ]
Python
print_functions_migration_ddl
null
def print_functions_migration_ddl(source_schema, target_schema): """ Prints DDL to migrate the functions in two schemas. :param source_schema: The source schema. :param target_schema: The target schema. """ print('--') print('-- FUNCTIONS') print('--') next_source_function = next_or...
Prints DDL to migrate the functions in two schemas. :param source_schema: The source schema. :param target_schema: The target schema.
Prints DDL to migrate the functions in two schemas.
[ "Prints", "DDL", "to", "migrate", "the", "functions", "in", "two", "schemas", "." ]
def print_functions_migration_ddl(source_schema, target_schema): print('--') print('-- FUNCTIONS') print('--') next_source_function = next_or_none(sorted(source_schema.functions, key=lambda f: f.fullname)) next_target_function = next_or_none(sorted(target_schema.functions, key=lambda f: f.fullname))...
[ "def", "print_functions_migration_ddl", "(", "source_schema", ",", "target_schema", ")", ":", "print", "(", "'--'", ")", "print", "(", "'-- FUNCTIONS'", ")", "print", "(", "'--'", ")", "next_source_function", "=", "next_or_none", "(", "sorted", "(", "source_schema...
Prints DDL to migrate the functions in two schemas.
[ "Prints", "DDL", "to", "migrate", "the", "functions", "in", "two", "schemas", "." ]
[ "\"\"\"\n Prints DDL to migrate the functions in two schemas.\n\n :param source_schema: The source schema.\n :param target_schema: The target schema.\n \"\"\"" ]
[ { "param": "source_schema", "type": null }, { "param": "target_schema", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "source_schema", "type": null, "docstring": "The source schema.", "docstring_tokens": [ "The", "source", "schema", "." ], "default": null, "is_optional": null }, { ...
62099bbf7b4837d22c33f0ea197cf63171b8328a
talkingscott/xpgdiff
xpgdiff.py
[ "MIT" ]
Python
print_schema_migration_ddl
null
def print_schema_migration_ddl(source_schema, target_schema): """ Prints the migration DDL for two schemas. The DDL will migrate a database with the source schema to one with the target schema. :param source_schema: The source schema. :param target_schema: The target schema. """ print_sche...
Prints the migration DDL for two schemas. The DDL will migrate a database with the source schema to one with the target schema. :param source_schema: The source schema. :param target_schema: The target schema.
Prints the migration DDL for two schemas. The DDL will migrate a database with the source schema to one with the target schema.
[ "Prints", "the", "migration", "DDL", "for", "two", "schemas", ".", "The", "DDL", "will", "migrate", "a", "database", "with", "the", "source", "schema", "to", "one", "with", "the", "target", "schema", "." ]
def print_schema_migration_ddl(source_schema, target_schema): print_schema_banner(source_schema) print_tables_migration_ddl(source_schema, target_schema) print() print_views_migration_ddl(source_schema, target_schema) print() print_functions_migration_ddl(source_schema, target_schema)
[ "def", "print_schema_migration_ddl", "(", "source_schema", ",", "target_schema", ")", ":", "print_schema_banner", "(", "source_schema", ")", "print_tables_migration_ddl", "(", "source_schema", ",", "target_schema", ")", "print", "(", ")", "print_views_migration_ddl", "(",...
Prints the migration DDL for two schemas.
[ "Prints", "the", "migration", "DDL", "for", "two", "schemas", "." ]
[ "\"\"\"\n Prints the migration DDL for two schemas. The DDL will migrate\n a database with the source schema to one with the target schema.\n\n :param source_schema: The source schema.\n :param target_schema: The target schema.\n \"\"\"" ]
[ { "param": "source_schema", "type": null }, { "param": "target_schema", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "source_schema", "type": null, "docstring": "The source schema.", "docstring_tokens": [ "The", "source", "schema", "." ], "default": null, "is_optional": null }, { ...
62099bbf7b4837d22c33f0ea197cf63171b8328a
talkingscott/xpgdiff
xpgdiff.py
[ "MIT" ]
Python
print_schemas_migration_ddl
null
def print_schemas_migration_ddl(source_schemas, target_schemas): """ Prints the migration DDL for two lists of schemas. The DDL will migrate a database with the source schemas to one with the target schemas. :param source_schemas: The source schemas. :param target_schemas: The target schemas. ...
Prints the migration DDL for two lists of schemas. The DDL will migrate a database with the source schemas to one with the target schemas. :param source_schemas: The source schemas. :param target_schemas: The target schemas.
Prints the migration DDL for two lists of schemas. The DDL will migrate a database with the source schemas to one with the target schemas.
[ "Prints", "the", "migration", "DDL", "for", "two", "lists", "of", "schemas", ".", "The", "DDL", "will", "migrate", "a", "database", "with", "the", "source", "schemas", "to", "one", "with", "the", "target", "schemas", "." ]
def print_schemas_migration_ddl(source_schemas, target_schemas): next_source_schema = next_or_none(sorted(source_schemas, key=lambda f: f.name)) next_target_schema = next_or_none(sorted(target_schemas, key=lambda f: f.name)) source_schema = next_source_schema() target_schema = next_target_schema() w...
[ "def", "print_schemas_migration_ddl", "(", "source_schemas", ",", "target_schemas", ")", ":", "next_source_schema", "=", "next_or_none", "(", "sorted", "(", "source_schemas", ",", "key", "=", "lambda", "f", ":", "f", ".", "name", ")", ")", "next_target_schema", ...
Prints the migration DDL for two lists of schemas.
[ "Prints", "the", "migration", "DDL", "for", "two", "lists", "of", "schemas", "." ]
[ "\"\"\"\n Prints the migration DDL for two lists of schemas. The DDL will migrate\n a database with the source schemas to one with the target schemas.\n\n :param source_schemas: The source schemas.\n :param target_schemas: The target schemas.\n \"\"\"" ]
[ { "param": "source_schemas", "type": null }, { "param": "target_schemas", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "source_schemas", "type": null, "docstring": "The source schemas.", "docstring_tokens": [ "The", "source", "schemas", "." ], "default": null, "is_optional": null }, { ...
62099bbf7b4837d22c33f0ea197cf63171b8328a
talkingscott/xpgdiff
xpgdiff.py
[ "MIT" ]
Python
print_schema_ddl
null
def print_schema_ddl(schema): """ Prints the DDL to create all objects in a schema. :param schema: The schema """ for table in schema.tables: print(str(table)) print() for table in schema.tables: for foreign_key in table.foreign_keys: print(foreign_key.addst...
Prints the DDL to create all objects in a schema. :param schema: The schema
Prints the DDL to create all objects in a schema.
[ "Prints", "the", "DDL", "to", "create", "all", "objects", "in", "a", "schema", "." ]
def print_schema_ddl(schema): for table in schema.tables: print(str(table)) print() for table in schema.tables: for foreign_key in table.foreign_keys: print(foreign_key.addstr()) print() for view in schema.views: print(str(view)) print() for functi...
[ "def", "print_schema_ddl", "(", "schema", ")", ":", "for", "table", "in", "schema", ".", "tables", ":", "print", "(", "str", "(", "table", ")", ")", "print", "(", ")", "for", "table", "in", "schema", ".", "tables", ":", "for", "foreign_key", "in", "t...
Prints the DDL to create all objects in a schema.
[ "Prints", "the", "DDL", "to", "create", "all", "objects", "in", "a", "schema", "." ]
[ "\"\"\"\n Prints the DDL to create all objects in a schema.\n\n :param schema: The schema\n \"\"\"" ]
[ { "param": "schema", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "schema", "type": null, "docstring": null, "docstring_tokens": [ "None" ], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
62099bbf7b4837d22c33f0ea197cf63171b8328a
talkingscott/xpgdiff
xpgdiff.py
[ "MIT" ]
Python
print_schema_banner
null
def print_schema_banner(schema): """ Prints a banner to call out the schema name. :param schema: The schema """ print('-- *************************************') print('-- * SCHEMA: ' + schema.name) print('-- *************************************')
Prints a banner to call out the schema name. :param schema: The schema
Prints a banner to call out the schema name.
[ "Prints", "a", "banner", "to", "call", "out", "the", "schema", "name", "." ]
def print_schema_banner(schema): print('-- *************************************') print('-- * SCHEMA: ' + schema.name) print('-- *************************************')
[ "def", "print_schema_banner", "(", "schema", ")", ":", "print", "(", "'-- *************************************'", ")", "print", "(", "'-- * SCHEMA: '", "+", "schema", ".", "name", ")", "print", "(", "'-- *************************************'", ")" ]
Prints a banner to call out the schema name.
[ "Prints", "a", "banner", "to", "call", "out", "the", "schema", "name", "." ]
[ "\"\"\"\n Prints a banner to call out the schema name.\n\n :param schema: The schema\n \"\"\"" ]
[ { "param": "schema", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "schema", "type": null, "docstring": null, "docstring_tokens": [ "None" ], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c7d9921ad438f79bc932b24c6b9baa89f135ffab
Py-AMS/pyams-batching
src/pyams_batching/batch.py
[ "ZPL-2.1" ]
Python
first_neighbours_last
<not_specific>
def first_neighbours_last(batches, current_batch_idx, nb_left, nb_right): """Build a sublist from a large batch list. This is used to display batch links for a large table. arguments: * :param batches: a large sequence (may be a batches as well) * :param current_batch_idx: index of the current b...
Build a sublist from a large batch list. This is used to display batch links for a large table. arguments: * :param batches: a large sequence (may be a batches as well) * :param current_batch_idx: index of the current batch or item * :param nb_left: number of neighbours before the current batch...
Build a sublist from a large batch list. This is used to display batch links for a large table. The returned list gives: the first batch a None separator if necessary left neighbours of the current batch the current batch right neighbours of the current batch a None separator if necessary the last batch
[ "Build", "a", "sublist", "from", "a", "large", "batch", "list", ".", "This", "is", "used", "to", "display", "batch", "links", "for", "a", "large", "table", ".", "The", "returned", "list", "gives", ":", "the", "first", "batch", "a", "None", "separator", ...
def first_neighbours_last(batches, current_batch_idx, nb_left, nb_right): sublist = [] first_idx = 0 last_idx = len(batches) - 1 assert 0 <= current_batch_idx <= last_idx assert nb_left >= 0 and nb_right >= 0 prev_idx = current_batch_idx - nb_left next_idx = current_batch_idx + 1 first_b...
[ "def", "first_neighbours_last", "(", "batches", ",", "current_batch_idx", ",", "nb_left", ",", "nb_right", ")", ":", "sublist", "=", "[", "]", "first_idx", "=", "0", "last_idx", "=", "len", "(", "batches", ")", "-", "1", "assert", "0", "<=", "current_batch...
Build a sublist from a large batch list.
[ "Build", "a", "sublist", "from", "a", "large", "batch", "list", "." ]
[ "\"\"\"Build a sublist from a large batch list.\n\n This is used to display batch links for a large table.\n\n arguments:\n * :param batches: a large sequence (may be a batches as well)\n * :param current_batch_idx: index of the current batch or item\n * :param nb_left: number of neighbours before...
[ { "param": "batches", "type": null }, { "param": "current_batch_idx", "type": null }, { "param": "nb_left", "type": null }, { "param": "nb_right", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "batches", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "current_batch_idx", "type": null, "docstring": null, "docs...
d81a335ea7ea89c992abd8a27841b1b580695d88
gonzrubio/ML_Papers
Computational_Biolgy/Fout_2017/driver.py
[ "MIT" ]
Python
merge
<not_specific>
def merge(self, xnr, xnl): """Merge ligand and receptor (residue pairwise combinations).""" xmerge = torch.empty((xnr.shape[0] * xnl.shape[0], xnr.shape[1])) row = 0 for ii in range(xnr.shape[0]): for jj in range(xnl.shape[0]): # Note: This could be some other...
Merge ligand and receptor (residue pairwise combinations).
Merge ligand and receptor (residue pairwise combinations).
[ "Merge", "ligand", "and", "receptor", "(", "residue", "pairwise", "combinations", ")", "." ]
def merge(self, xnr, xnl): xmerge = torch.empty((xnr.shape[0] * xnl.shape[0], xnr.shape[1])) row = 0 for ii in range(xnr.shape[0]): for jj in range(xnl.shape[0]): xmerge[row, :] = 0.5 * (xnr[ii] + xnl[jj]) row += 1 return xmerge
[ "def", "merge", "(", "self", ",", "xnr", ",", "xnl", ")", ":", "xmerge", "=", "torch", ".", "empty", "(", "(", "xnr", ".", "shape", "[", "0", "]", "*", "xnl", ".", "shape", "[", "0", "]", ",", "xnr", ".", "shape", "[", "1", "]", ")", ")", ...
Merge ligand and receptor (residue pairwise combinations).
[ "Merge", "ligand", "and", "receptor", "(", "residue", "pairwise", "combinations", ")", "." ]
[ "\"\"\"Merge ligand and receptor (residue pairwise combinations).\"\"\"", "# Note: This could be some other operation" ]
[ { "param": "self", "type": null }, { "param": "xnr", "type": null }, { "param": "xnl", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xnr", "type": null, "docstring": null, "docstring_tokens": []...
d81a335ea7ea89c992abd8a27841b1b580695d88
gonzrubio/ML_Papers
Computational_Biolgy/Fout_2017/driver.py
[ "MIT" ]
Python
forward
<not_specific>
def forward(self, xnr, xer, ijr, xnl, xel, ijl): """Forward pass through the network.""" if not isinstance(xnr, torch.FloatTensor): xnr = xnr.float() if not isinstance(xer, torch.FloatTensor): xer = xer.float() if not isinstance(xnl, torch.FloatTensor): ...
Forward pass through the network.
Forward pass through the network.
[ "Forward", "pass", "through", "the", "network", "." ]
def forward(self, xnr, xer, ijr, xnl, xel, ijl): if not isinstance(xnr, torch.FloatTensor): xnr = xnr.float() if not isinstance(xer, torch.FloatTensor): xer = xer.float() if not isinstance(xnl, torch.FloatTensor): xnl = xnl.float() if not isinstance(xe...
[ "def", "forward", "(", "self", ",", "xnr", ",", "xer", ",", "ijr", ",", "xnl", ",", "xel", ",", "ijl", ")", ":", "if", "not", "isinstance", "(", "xnr", ",", "torch", ".", "FloatTensor", ")", ":", "xnr", "=", "xnr", ".", "float", "(", ")", "if",...
Forward pass through the network.
[ "Forward", "pass", "through", "the", "network", "." ]
[ "\"\"\"Forward pass through the network.\"\"\"", "# Ligand conv blocks (Note: could learn/update edge features too)", "# Receptor conv blocks (Note: could learn/update edge features too)", "# Merge rececptor and ligand conv block outputs" ]
[ { "param": "self", "type": null }, { "param": "xnr", "type": null }, { "param": "xer", "type": null }, { "param": "ijr", "type": null }, { "param": "xnl", "type": null }, { "param": "xel", "type": null }, { "param": "ijl", "type": null ...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xnr", "type": null, "docstring": null, "docstring_tokens": []...
9ffd260e80c638c8fbec6911f192cdd2c24529b9
gonzrubio/ML_Papers
Segmentation/UNet_Ronneberger_et_al_2015/dataset.py
[ "MIT" ]
Python
mean_std
<not_specific>
def mean_std(dataset): """Return the mean and std of the dataset.""" loader = DataLoader(dataset, batch_size=32, num_workers=0, shuffle=False) mean = 0. std = 0. for images, _ in loader: images = images.to(device) batch_samples = images.size(0) images = images.view(...
Return the mean and std of the dataset.
Return the mean and std of the dataset.
[ "Return", "the", "mean", "and", "std", "of", "the", "dataset", "." ]
def mean_std(dataset): loader = DataLoader(dataset, batch_size=32, num_workers=0, shuffle=False) mean = 0. std = 0. for images, _ in loader: images = images.to(device) batch_samples = images.size(0) images = images.view(batch_samples, images.size(1), -1) mean += images.me...
[ "def", "mean_std", "(", "dataset", ")", ":", "loader", "=", "DataLoader", "(", "dataset", ",", "batch_size", "=", "32", ",", "num_workers", "=", "0", ",", "shuffle", "=", "False", ")", "mean", "=", "0.", "std", "=", "0.", "for", "images", ",", "_", ...
Return the mean and std of the dataset.
[ "Return", "the", "mean", "and", "std", "of", "the", "dataset", "." ]
[ "\"\"\"Return the mean and std of the dataset.\"\"\"" ]
[ { "param": "dataset", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dataset", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d66ab339a087377c65dbed19ccbb1f9f262cdad6
gonzrubio/ML_Papers
GANs/CycleGAN_Zhu_et_al_2017/dataset.py
[ "MIT" ]
Python
mean_std
<not_specific>
def mean_std(dataset): """Return the mean and std of the dataset.""" loader = DataLoader(dataset, batch_size=128, num_workers=0, shuffle=False) mean_inputs = 0. std_inputs = 0. mean_targets = 0. std_targets = 0. for inputs, targets in tqdm(loader): inputs = inputs.to(DEVICE).view(...
Return the mean and std of the dataset.
Return the mean and std of the dataset.
[ "Return", "the", "mean", "and", "std", "of", "the", "dataset", "." ]
def mean_std(dataset): loader = DataLoader(dataset, batch_size=128, num_workers=0, shuffle=False) mean_inputs = 0. std_inputs = 0. mean_targets = 0. std_targets = 0. for inputs, targets in tqdm(loader): inputs = inputs.to(DEVICE).view(inputs.size(0), inputs.size(1), -1) mean_inpu...
[ "def", "mean_std", "(", "dataset", ")", ":", "loader", "=", "DataLoader", "(", "dataset", ",", "batch_size", "=", "128", ",", "num_workers", "=", "0", ",", "shuffle", "=", "False", ")", "mean_inputs", "=", "0.", "std_inputs", "=", "0.", "mean_targets", "...
Return the mean and std of the dataset.
[ "Return", "the", "mean", "and", "std", "of", "the", "dataset", "." ]
[ "\"\"\"Return the mean and std of the dataset.\"\"\"" ]
[ { "param": "dataset", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dataset", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
08a573701bfd9f47ef90d05321a8a31ed40c8781
gonzrubio/ML_Papers
Computational_Biolgy/Fout_2017/extra.py
[ "MIT" ]
Python
loader
<not_specific>
def loader(num_samples, b_size, shuffle=True): """Generate bacthes of random indices to behave as a dataloader. Parameters ---------- num_samples : int Number of samples. b_size : int Batch size. shuffle : bool, True by deffault Permute batches if True, keep order otherw...
Generate bacthes of random indices to behave as a dataloader. Parameters ---------- num_samples : int Number of samples. b_size : int Batch size. shuffle : bool, True by deffault Permute batches if True, keep order otherwise. Returns ------- batches : list ...
Generate bacthes of random indices to behave as a dataloader. Parameters num_samples : int Number of samples. b_size : int Batch size. shuffle : bool, True by deffault Permute batches if True, keep order otherwise. Returns batches : list A list of lists, each of size b_size. The last batch may contain exaclty b_size ...
[ "Generate", "bacthes", "of", "random", "indices", "to", "behave", "as", "a", "dataloader", ".", "Parameters", "num_samples", ":", "int", "Number", "of", "samples", ".", "b_size", ":", "int", "Batch", "size", ".", "shuffle", ":", "bool", "True", "by", "deff...
def loader(num_samples, b_size, shuffle=True): if shuffle: rng = np.random.default_rng() idx = rng.permutation(num_samples).tolist() else: idx = list(range(num_samples)) num_batches = num_samples // b_size remaining = num_samples % b_size batches = [idx[b * b_size: (b + 1)*b_...
[ "def", "loader", "(", "num_samples", ",", "b_size", ",", "shuffle", "=", "True", ")", ":", "if", "shuffle", ":", "rng", "=", "np", ".", "random", ".", "default_rng", "(", ")", "idx", "=", "rng", ".", "permutation", "(", "num_samples", ")", ".", "toli...
Generate bacthes of random indices to behave as a dataloader.
[ "Generate", "bacthes", "of", "random", "indices", "to", "behave", "as", "a", "dataloader", "." ]
[ "\"\"\"Generate bacthes of random indices to behave as a dataloader.\n\n Parameters\n ----------\n num_samples : int\n Number of samples.\n b_size : int\n Batch size.\n shuffle : bool, True by deffault\n Permute batches if True, keep order otherwise.\n Returns\n -------\n ...
[ { "param": "num_samples", "type": null }, { "param": "b_size", "type": null }, { "param": "shuffle", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "num_samples", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b_size", "type": null, "docstring": null, "docstring_t...
526452e62322163daaaa1f08580233772b42e78c
gonzrubio/ML_Papers
GANs/CycleGAN_Zhu_et_al_2017/model.py
[ "MIT" ]
Python
c7s1_k
<not_specific>
def c7s1_k(self, in_size, out_size): """7x7 Conv-InstanceNorm-ReLU layer with k filters and stride 1.""" layer = [nn.Conv2d(in_size, out_size, kernel_size=7, stride=1, padding=3, padding_mode='reflect', bias=False), nn.InstanceNorm2...
7x7 Conv-InstanceNorm-ReLU layer with k filters and stride 1.
7x7 Conv-InstanceNorm-ReLU layer with k filters and stride 1.
[ "7x7", "Conv", "-", "InstanceNorm", "-", "ReLU", "layer", "with", "k", "filters", "and", "stride", "1", "." ]
def c7s1_k(self, in_size, out_size): layer = [nn.Conv2d(in_size, out_size, kernel_size=7, stride=1, padding=3, padding_mode='reflect', bias=False), nn.InstanceNorm2d(num_features=out_size, affine=True), nn.ReLU(inplace=True...
[ "def", "c7s1_k", "(", "self", ",", "in_size", ",", "out_size", ")", ":", "layer", "=", "[", "nn", ".", "Conv2d", "(", "in_size", ",", "out_size", ",", "kernel_size", "=", "7", ",", "stride", "=", "1", ",", "padding", "=", "3", ",", "padding_mode", ...
7x7 Conv-InstanceNorm-ReLU layer with k filters and stride 1.
[ "7x7", "Conv", "-", "InstanceNorm", "-", "ReLU", "layer", "with", "k", "filters", "and", "stride", "1", "." ]
[ "\"\"\"7x7 Conv-InstanceNorm-ReLU layer with k filters and stride 1.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "in_size", "type": null }, { "param": "out_size", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "in_size", "type": null, "docstring": null, "docstring_tokens"...
526452e62322163daaaa1f08580233772b42e78c
gonzrubio/ML_Papers
GANs/CycleGAN_Zhu_et_al_2017/model.py
[ "MIT" ]
Python
dk
<not_specific>
def dk(self, in_size, out_size): """3x3 Conv-InstanceNorm-ReLU layer with k filters and stride 2.""" layer = [nn.Conv2d(in_size, out_size, kernel_size=3, stride=2, padding=1, padding_mode='reflect', bias=False), nn.InstanceNorm2d(nu...
3x3 Conv-InstanceNorm-ReLU layer with k filters and stride 2.
3x3 Conv-InstanceNorm-ReLU layer with k filters and stride 2.
[ "3x3", "Conv", "-", "InstanceNorm", "-", "ReLU", "layer", "with", "k", "filters", "and", "stride", "2", "." ]
def dk(self, in_size, out_size): layer = [nn.Conv2d(in_size, out_size, kernel_size=3, stride=2, padding=1, padding_mode='reflect', bias=False), nn.InstanceNorm2d(num_features=out_size, affine=True), nn.ReLU(inplace=True)] ...
[ "def", "dk", "(", "self", ",", "in_size", ",", "out_size", ")", ":", "layer", "=", "[", "nn", ".", "Conv2d", "(", "in_size", ",", "out_size", ",", "kernel_size", "=", "3", ",", "stride", "=", "2", ",", "padding", "=", "1", ",", "padding_mode", "=",...
3x3 Conv-InstanceNorm-ReLU layer with k filters and stride 2.
[ "3x3", "Conv", "-", "InstanceNorm", "-", "ReLU", "layer", "with", "k", "filters", "and", "stride", "2", "." ]
[ "\"\"\"3x3 Conv-InstanceNorm-ReLU layer with k filters and stride 2.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "in_size", "type": null }, { "param": "out_size", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "in_size", "type": null, "docstring": null, "docstring_tokens"...
526452e62322163daaaa1f08580233772b42e78c
gonzrubio/ML_Papers
GANs/CycleGAN_Zhu_et_al_2017/model.py
[ "MIT" ]
Python
Rk
<not_specific>
def Rk(self, in_size, out_size): """Res block with two 3x3 convs with same number of filters on both.""" layer = [nn.Conv2d(in_size, out_size, kernel_size=3, stride=1, padding=1, padding_mode='reflect', bias=False), nn.InstanceNorm2...
Res block with two 3x3 convs with same number of filters on both.
Res block with two 3x3 convs with same number of filters on both.
[ "Res", "block", "with", "two", "3x3", "convs", "with", "same", "number", "of", "filters", "on", "both", "." ]
def Rk(self, in_size, out_size): layer = [nn.Conv2d(in_size, out_size, kernel_size=3, stride=1, padding=1, padding_mode='reflect', bias=False), nn.InstanceNorm2d(num_features=out_size, affine=True), nn.ReLU(inplace=True), ...
[ "def", "Rk", "(", "self", ",", "in_size", ",", "out_size", ")", ":", "layer", "=", "[", "nn", ".", "Conv2d", "(", "in_size", ",", "out_size", ",", "kernel_size", "=", "3", ",", "stride", "=", "1", ",", "padding", "=", "1", ",", "padding_mode", "=",...
Res block with two 3x3 convs with same number of filters on both.
[ "Res", "block", "with", "two", "3x3", "convs", "with", "same", "number", "of", "filters", "on", "both", "." ]
[ "\"\"\"Res block with two 3x3 convs with same number of filters on both.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "in_size", "type": null }, { "param": "out_size", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "in_size", "type": null, "docstring": null, "docstring_tokens"...
526452e62322163daaaa1f08580233772b42e78c
gonzrubio/ML_Papers
GANs/CycleGAN_Zhu_et_al_2017/model.py
[ "MIT" ]
Python
make_conv
<not_specific>
def make_conv(self, in_size, out_size, encode, instance_norm, activation, drop_out): """Convolutional blocks of the Generator and the Discriminator. :param in_size: number of input filters :type in_size: int :param out_size: number of output filters :type out_size: int :...
Convolutional blocks of the Generator and the Discriminator. :param in_size: number of input filters :type in_size: int :param out_size: number of output filters :type out_size: int :param encode: apply convolution to downsaple :type encode: bool :param instance_...
Convolutional blocks of the Generator and the Discriminator.
[ "Convolutional", "blocks", "of", "the", "Generator", "and", "the", "Discriminator", "." ]
def make_conv(self, in_size, out_size, encode, instance_norm, activation, drop_out): block = [nn.Conv2d(in_size, out_size, kernel_size=4, stride=2, padding=1, padding_mode="reflect", bias=False if instance_norm else True) ...
[ "def", "make_conv", "(", "self", ",", "in_size", ",", "out_size", ",", "encode", ",", "instance_norm", ",", "activation", ",", "drop_out", ")", ":", "block", "=", "[", "nn", ".", "Conv2d", "(", "in_size", ",", "out_size", ",", "kernel_size", "=", "4", ...
Convolutional blocks of the Generator and the Discriminator.
[ "Convolutional", "blocks", "of", "the", "Generator", "and", "the", "Discriminator", "." ]
[ "\"\"\"Convolutional blocks of the Generator and the Discriminator.\n\n :param in_size: number of input filters\n :type in_size: int\n :param out_size: number of output filters\n :type out_size: int\n :param encode: apply convolution to downsaple\n :type encode: bool\n ...
[ { "param": "self", "type": null }, { "param": "in_size", "type": null }, { "param": "out_size", "type": null }, { "param": "encode", "type": null }, { "param": "instance_norm", "type": null }, { "param": "activation", "type": null }, { "par...
{ "returns": [ { "docstring": "the convolutional block", "docstring_tokens": [ "the", "convolutional", "block" ], "type": "nn.Sequential\nLet Ck denote a Convolution-InstanceNorm-ReLU block with k filters.\nCDk denotes a Convolution-BtachNorm-Dropout-ReLU block with...
4a285f8b4908082051e350357d1cb714958af43f
gonzrubio/ML_Papers
Image_Recognition/VGG_Simonyan_Zisserman_2015/driver.py
[ "MIT" ]
Python
make_conv_blocks
<not_specific>
def make_conv_blocks(self, specs): """Make the custom convolutional blocks.""" conv = [] krnl = (3, 3) strd = (1, 1) pdd = (1, 1) strd_pool = (2, 2) krnl_pool = (2, 2) in_channels = self.in_channels for spec in specs: if isinstance(sp...
Make the custom convolutional blocks.
Make the custom convolutional blocks.
[ "Make", "the", "custom", "convolutional", "blocks", "." ]
def make_conv_blocks(self, specs): conv = [] krnl = (3, 3) strd = (1, 1) pdd = (1, 1) strd_pool = (2, 2) krnl_pool = (2, 2) in_channels = self.in_channels for spec in specs: if isinstance(spec, int): conv += [nn.Conv2d(in_channe...
[ "def", "make_conv_blocks", "(", "self", ",", "specs", ")", ":", "conv", "=", "[", "]", "krnl", "=", "(", "3", ",", "3", ")", "strd", "=", "(", "1", ",", "1", ")", "pdd", "=", "(", "1", ",", "1", ")", "strd_pool", "=", "(", "2", ",", "2", ...
Make the custom convolutional blocks.
[ "Make", "the", "custom", "convolutional", "blocks", "." ]
[ "\"\"\"Make the custom convolutional blocks.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "specs", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "specs", "type": null, "docstring": null, "docstring_tokens": ...
4a285f8b4908082051e350357d1cb714958af43f
gonzrubio/ML_Papers
Image_Recognition/VGG_Simonyan_Zisserman_2015/driver.py
[ "MIT" ]
Python
make_fc_layers
<not_specific>
def make_fc_layers(self, specs): """Make the custom fully connected layers.""" fc = [] in_features = self.in_features*7*7 # 7x7 after 5 max pool on 224x224 for spec in specs: if spec != self.out_channels: fc += [nn.Linear(in_features=in_features, out_featu...
Make the custom fully connected layers.
Make the custom fully connected layers.
[ "Make", "the", "custom", "fully", "connected", "layers", "." ]
def make_fc_layers(self, specs): fc = [] in_features = self.in_features*7*7 for spec in specs: if spec != self.out_channels: fc += [nn.Linear(in_features=in_features, out_features=spec), nn.ReLU(), nn.Dropout(p=0.5)] ...
[ "def", "make_fc_layers", "(", "self", ",", "specs", ")", ":", "fc", "=", "[", "]", "in_features", "=", "self", ".", "in_features", "*", "7", "*", "7", "for", "spec", "in", "specs", ":", "if", "spec", "!=", "self", ".", "out_channels", ":", "fc", "+...
Make the custom fully connected layers.
[ "Make", "the", "custom", "fully", "connected", "layers", "." ]
[ "\"\"\"Make the custom fully connected layers.\"\"\"", "# 7x7 after 5 max pool on 224x224" ]
[ { "param": "self", "type": null }, { "param": "specs", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "specs", "type": null, "docstring": null, "docstring_tokens": ...
4a285f8b4908082051e350357d1cb714958af43f
gonzrubio/ML_Papers
Image_Recognition/VGG_Simonyan_Zisserman_2015/driver.py
[ "MIT" ]
Python
forward
<not_specific>
def forward(self, x): """Forward pass through conv and fc layers.""" x = self.conv_blocks(x) x = x.reshape(x.shape[0], -1) x = self.fc_layers(x) return x
Forward pass through conv and fc layers.
Forward pass through conv and fc layers.
[ "Forward", "pass", "through", "conv", "and", "fc", "layers", "." ]
def forward(self, x): x = self.conv_blocks(x) x = x.reshape(x.shape[0], -1) x = self.fc_layers(x) return x
[ "def", "forward", "(", "self", ",", "x", ")", ":", "x", "=", "self", ".", "conv_blocks", "(", "x", ")", "x", "=", "x", ".", "reshape", "(", "x", ".", "shape", "[", "0", "]", ",", "-", "1", ")", "x", "=", "self", ".", "fc_layers", "(", "x", ...
Forward pass through conv and fc layers.
[ "Forward", "pass", "through", "conv", "and", "fc", "layers", "." ]
[ "\"\"\"Forward pass through conv and fc layers.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "x", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], ...
4a0a05d031edfe25ea94ef33a837b65519fd4e18
gonzrubio/ML_Papers
GANs/Pix2Pix_Isola_et_al_2017/model.py
[ "MIT" ]
Python
make_conv
<not_specific>
def make_conv(in_size, out_size, encode, batch_norm, activation, drop_out): """Convolutional blocks of the Generator and the Discriminator. Let Ck denote a Convolution-BtachNorm-ReLU block with k filters. CDk denotes a Convolution-BtachNorm-Dropout-ReLU block with 50% dropout. All convolutions are 4 x ...
Convolutional blocks of the Generator and the Discriminator. Let Ck denote a Convolution-BtachNorm-ReLU block with k filters. CDk denotes a Convolution-BtachNorm-Dropout-ReLU block with 50% dropout. All convolutions are 4 x 4 spatial filters with stride 2. Convolutions in the encoder and discriminator ...
Convolutional blocks of the Generator and the Discriminator. Let Ck denote a Convolution-BtachNorm-ReLU block with k filters.
[ "Convolutional", "blocks", "of", "the", "Generator", "and", "the", "Discriminator", ".", "Let", "Ck", "denote", "a", "Convolution", "-", "BtachNorm", "-", "ReLU", "block", "with", "k", "filters", "." ]
def make_conv(in_size, out_size, encode, batch_norm, activation, drop_out): block = [nn.Conv2d(in_size, out_size, kernel_size=4, stride=2, padding=1, padding_mode="reflect", bias=False if batch_norm else True) if encode else ...
[ "def", "make_conv", "(", "in_size", ",", "out_size", ",", "encode", ",", "batch_norm", ",", "activation", ",", "drop_out", ")", ":", "block", "=", "[", "nn", ".", "Conv2d", "(", "in_size", ",", "out_size", ",", "kernel_size", "=", "4", ",", "stride", "...
Convolutional blocks of the Generator and the Discriminator.
[ "Convolutional", "blocks", "of", "the", "Generator", "and", "the", "Discriminator", "." ]
[ "\"\"\"Convolutional blocks of the Generator and the Discriminator.\n\n Let Ck denote a Convolution-BtachNorm-ReLU block with k filters.\n CDk denotes a Convolution-BtachNorm-Dropout-ReLU block with 50% dropout.\n All convolutions are 4 x 4 spatial filters with stride 2. Convolutions in\n the encoder an...
[ { "param": "in_size", "type": null }, { "param": "out_size", "type": null }, { "param": "encode", "type": null }, { "param": "batch_norm", "type": null }, { "param": "activation", "type": null }, { "param": "drop_out", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "in_size", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "out_size", "type": null, "docstring": null, "docstring_tok...
4a0a05d031edfe25ea94ef33a837b65519fd4e18
gonzrubio/ML_Papers
GANs/Pix2Pix_Isola_et_al_2017/model.py
[ "MIT" ]
Python
init_weights
null
def init_weights(model, mean=0.0, std=0.02): """Initialize weights from a Gaussian distribution.""" for module in model.modules(): if isinstance(module, (nn.Conv2d, nn.BatchNorm2d)): nn.init.normal_(module.weight.data, mean=mean, std=std)
Initialize weights from a Gaussian distribution.
Initialize weights from a Gaussian distribution.
[ "Initialize", "weights", "from", "a", "Gaussian", "distribution", "." ]
def init_weights(model, mean=0.0, std=0.02): for module in model.modules(): if isinstance(module, (nn.Conv2d, nn.BatchNorm2d)): nn.init.normal_(module.weight.data, mean=mean, std=std)
[ "def", "init_weights", "(", "model", ",", "mean", "=", "0.0", ",", "std", "=", "0.02", ")", ":", "for", "module", "in", "model", ".", "modules", "(", ")", ":", "if", "isinstance", "(", "module", ",", "(", "nn", ".", "Conv2d", ",", "nn", ".", "Bat...
Initialize weights from a Gaussian distribution.
[ "Initialize", "weights", "from", "a", "Gaussian", "distribution", "." ]
[ "\"\"\"Initialize weights from a Gaussian distribution.\"\"\"" ]
[ { "param": "model", "type": null }, { "param": "mean", "type": null }, { "param": "std", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mean", "type": null, "docstring": null, "docstring_tokens": ...
4a0a05d031edfe25ea94ef33a837b65519fd4e18
gonzrubio/ML_Papers
GANs/Pix2Pix_Isola_et_al_2017/model.py
[ "MIT" ]
Python
forward
<not_specific>
def forward(self, x, z): """Generate a translation of x conditioned on the noise z.""" x = torch.cat((x, z), dim=1) skip = [None]*len(self.encoder) for idx, block in zip(range(len(skip)-1, -1, -1), self.encoder): x = block(x) skip[idx] = x for idx, block...
Generate a translation of x conditioned on the noise z.
Generate a translation of x conditioned on the noise z.
[ "Generate", "a", "translation", "of", "x", "conditioned", "on", "the", "noise", "z", "." ]
def forward(self, x, z): x = torch.cat((x, z), dim=1) skip = [None]*len(self.encoder) for idx, block in zip(range(len(skip)-1, -1, -1), self.encoder): x = block(x) skip[idx] = x for idx, block in enumerate(self.decoder): if idx > 0: x =...
[ "def", "forward", "(", "self", ",", "x", ",", "z", ")", ":", "x", "=", "torch", ".", "cat", "(", "(", "x", ",", "z", ")", ",", "dim", "=", "1", ")", "skip", "=", "[", "None", "]", "*", "len", "(", "self", ".", "encoder", ")", "for", "idx"...
Generate a translation of x conditioned on the noise z.
[ "Generate", "a", "translation", "of", "x", "conditioned", "on", "the", "noise", "z", "." ]
[ "\"\"\"Generate a translation of x conditioned on the noise z.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "x", "type": null }, { "param": "z", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": null, "docstring": null, "docstring_tokens": [], ...
b5c5380f4180ec71ef722734dd0a36e5c6ec9c1f
gonzrubio/ML_Papers
GANs/Pix2Pix_Isola_et_al_2017/dataset.py
[ "MIT" ]
Python
mean_std
<not_specific>
def mean_std(dataset): """Return the mean and std of the dataset.""" loader = DataLoader(dataset, batch_size=128, num_workers=0, shuffle=False) mean_inputs = 0. std_inputs = 0. mean_targets = 0. std_targets = 0. for inputs, targets in tqdm(loader): inputs = inputs.to(DEVICE).view(...
Return the mean and std of the dataset.
Return the mean and std of the dataset.
[ "Return", "the", "mean", "and", "std", "of", "the", "dataset", "." ]
def mean_std(dataset): loader = DataLoader(dataset, batch_size=128, num_workers=0, shuffle=False) mean_inputs = 0. std_inputs = 0. mean_targets = 0. std_targets = 0. for inputs, targets in tqdm(loader): inputs = inputs.to(DEVICE).view(inputs.size(0), inputs.size(1), -1) mean_inpu...
[ "def", "mean_std", "(", "dataset", ")", ":", "loader", "=", "DataLoader", "(", "dataset", ",", "batch_size", "=", "128", ",", "num_workers", "=", "0", ",", "shuffle", "=", "False", ")", "mean_inputs", "=", "0.", "std_inputs", "=", "0.", "mean_targets", "...
Return the mean and std of the dataset.
[ "Return", "the", "mean", "and", "std", "of", "the", "dataset", "." ]
[ "\"\"\"Return the mean and std of the dataset.\"\"\"" ]
[ { "param": "dataset", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dataset", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b5c5380f4180ec71ef722734dd0a36e5c6ec9c1f
gonzrubio/ML_Papers
GANs/Pix2Pix_Isola_et_al_2017/dataset.py
[ "MIT" ]
Python
apply_transforms
<not_specific>
def apply_transforms(self, face, comic): """Apply the same transforms to the input and the target.""" common_transform = transforms.Compose([transforms.Resize((256, 256)), transforms.ToTensor()]) normalize_face = transforms.Normalize(mean=[0.5129, ...
Apply the same transforms to the input and the target.
Apply the same transforms to the input and the target.
[ "Apply", "the", "same", "transforms", "to", "the", "input", "and", "the", "target", "." ]
def apply_transforms(self, face, comic): common_transform = transforms.Compose([transforms.Resize((256, 256)), transforms.ToTensor()]) normalize_face = transforms.Normalize(mean=[0.5129, 0.4136, 0.3671], std=[0....
[ "def", "apply_transforms", "(", "self", ",", "face", ",", "comic", ")", ":", "common_transform", "=", "transforms", ".", "Compose", "(", "[", "transforms", ".", "Resize", "(", "(", "256", ",", "256", ")", ")", ",", "transforms", ".", "ToTensor", "(", "...
Apply the same transforms to the input and the target.
[ "Apply", "the", "same", "transforms", "to", "the", "input", "and", "the", "target", "." ]
[ "\"\"\"Apply the same transforms to the input and the target.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "face", "type": null }, { "param": "comic", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "face", "type": null, "docstring": null, "docstring_tokens": [...
901a8905aefb69b508e09887b6643a52394bb080
adsharma/raft
raft/states/voter.py
[ "MIT" ]
Python
on_leader_timeout
<not_specific>
def on_leader_timeout(self): """This is called when the leader timeout is reached.""" from .candidate import Candidate # TODO: Fix circular import logger.info( f"{self._server.group}: {self._server._name}: Lost Leader: {self.leader}" ) if ( self._server....
This is called when the leader timeout is reached.
This is called when the leader timeout is reached.
[ "This", "is", "called", "when", "the", "leader", "timeout", "is", "reached", "." ]
def on_leader_timeout(self): from .candidate import Candidate logger.info( f"{self._server.group}: {self._server._name}: Lost Leader: {self.leader}" ) if ( self._server._parent and self._server._parent._state.leader_name != self._server._human_name ...
[ "def", "on_leader_timeout", "(", "self", ")", ":", "from", ".", "candidate", "import", "Candidate", "logger", ".", "info", "(", "f\"{self._server.group}: {self._server._name}: Lost Leader: {self.leader}\"", ")", "if", "(", "self", ".", "_server", ".", "_parent", "and"...
This is called when the leader timeout is reached.
[ "This", "is", "called", "when", "the", "leader", "timeout", "is", "reached", "." ]
[ "\"\"\"This is called when the leader timeout is reached.\"\"\"", "# TODO: Fix circular import" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9c592445ecf6ac26de438136241679c850c68f3
adsharma/raft
raft/states/state.py
[ "MIT" ]
Python
on_message
<not_specific>
async def on_message(self, message): """This method is called when a message is received, and calls one of the other corrosponding methods that this state reacts to. """ _type = message.type if message.term > self._server._currentTerm: self._server._currentT...
This method is called when a message is received, and calls one of the other corrosponding methods that this state reacts to.
This method is called when a message is received, and calls one of the other corrosponding methods that this state reacts to.
[ "This", "method", "is", "called", "when", "a", "message", "is", "received", "and", "calls", "one", "of", "the", "other", "corrosponding", "methods", "that", "this", "state", "reacts", "to", "." ]
async def on_message(self, message): _type = message.type if message.term > self._server._currentTerm: self._server._currentTerm = message.term elif message.term < self._server._currentTerm: if _type != BaseMessage.MessageType.Response: await self._send_re...
[ "async", "def", "on_message", "(", "self", ",", "message", ")", ":", "_type", "=", "message", ".", "type", "if", "message", ".", "term", ">", "self", ".", "_server", ".", "_currentTerm", ":", "self", ".", "_server", ".", "_currentTerm", "=", "message", ...
This method is called when a message is received, and calls one of the other corrosponding methods that this state reacts to.
[ "This", "method", "is", "called", "when", "a", "message", "is", "received", "and", "calls", "one", "of", "the", "other", "corrosponding", "methods", "that", "this", "state", "reacts", "to", "." ]
[ "\"\"\"This method is called when a message is received,\n and calls one of the other corrosponding methods\n that this state reacts to.\n\n \"\"\"", "# Is the messages.term < ours? If so we need to tell", "# them this so they don't get left behind.", "# Do not send a response to a resp...
[ { "param": "self", "type": null }, { "param": "message", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "message", "type": null, "docstring": null, "docstring_tokens"...
c9c592445ecf6ac26de438136241679c850c68f3
adsharma/raft
raft/states/state.py
[ "MIT" ]
Python
on_append_entries
<not_specific>
async def on_append_entries(self, message: AppendEntriesMessage): """This is called when there is a request to append an entry to the log. """ return self, None
This is called when there is a request to append an entry to the log.
This is called when there is a request to append an entry to the log.
[ "This", "is", "called", "when", "there", "is", "a", "request", "to", "append", "an", "entry", "to", "the", "log", "." ]
async def on_append_entries(self, message: AppendEntriesMessage): return self, None
[ "async", "def", "on_append_entries", "(", "self", ",", "message", ":", "AppendEntriesMessage", ")", ":", "return", "self", ",", "None" ]
This is called when there is a request to append an entry to the log.
[ "This", "is", "called", "when", "there", "is", "a", "request", "to", "append", "an", "entry", "to", "the", "log", "." ]
[ "\"\"\"This is called when there is a request to\n append an entry to the log.\n\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "message", "type": "AppendEntriesMessage" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "message", "type": "AppendEntriesMessage", "docstring": null, ...
d7a3f3b24847177a1d40eeaa74b3cea4262f1ba3
jhermann/tablemate
src/tablemate/commands/help.py
[ "Apache-2.0" ]
Python
help_command
null
def help_command(ctx): """Print some information on the system environment.""" def banner(title): "Helper" click.echo('') click.secho('~~~ {} ~~~'.format(title), fg='green', bg='black', bold=True) app_name = ctx.find_root().info_name click.secho('*** "{}" Help & Information ***'...
Print some information on the system environment.
Print some information on the system environment.
[ "Print", "some", "information", "on", "the", "system", "environment", "." ]
def help_command(ctx): def banner(title): click.echo('') click.secho('~~~ {} ~~~'.format(title), fg='green', bg='black', bold=True) app_name = ctx.find_root().info_name click.secho('*** "{}" Help & Information ***'.format(app_name), fg='white', bg='blue', bold=True) banner('Version Infor...
[ "def", "help_command", "(", "ctx", ")", ":", "def", "banner", "(", "title", ")", ":", "\"Helper\"", "click", ".", "echo", "(", "''", ")", "click", ".", "secho", "(", "'~~~ {} ~~~'", ".", "format", "(", "title", ")", ",", "fg", "=", "'green'", ",", ...
Print some information on the system environment.
[ "Print", "some", "information", "on", "the", "system", "environment", "." ]
[ "\"\"\"Print some information on the system environment.\"\"\"", "\"Helper\"", "# click.echo('\\ncontext = {}'.format(repr(vars(ctx))))", "# click.echo('\\nparent = {}'.format(repr(vars(ctx.parent))))" ]
[ { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0cb221febf6e92410fa570d227b1cc2b9e3c9001
jhermann/tablemate
src/tablemate/util/dclick.py
[ "Apache-2.0" ]
Python
pretty_path
<not_specific>
def pretty_path(path, _home_re=re.compile('^' + re.escape(os.path.expanduser('~') + os.sep))): """Prettify path for humans, and make it Unicode.""" path = click.format_filename(path) path = _home_re.sub('~' + os.sep, path) return path
Prettify path for humans, and make it Unicode.
Prettify path for humans, and make it Unicode.
[ "Prettify", "path", "for", "humans", "and", "make", "it", "Unicode", "." ]
def pretty_path(path, _home_re=re.compile('^' + re.escape(os.path.expanduser('~') + os.sep))): path = click.format_filename(path) path = _home_re.sub('~' + os.sep, path) return path
[ "def", "pretty_path", "(", "path", ",", "_home_re", "=", "re", ".", "compile", "(", "'^'", "+", "re", ".", "escape", "(", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "+", "os", ".", "sep", ")", ")", ")", ":", "path", "=", "click", "....
Prettify path for humans, and make it Unicode.
[ "Prettify", "path", "for", "humans", "and", "make", "it", "Unicode", "." ]
[ "\"\"\"Prettify path for humans, and make it Unicode.\"\"\"" ]
[ { "param": "path", "type": null }, { "param": "_home_re", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "_home_re", "type": null, "docstring": null, "docstring_tokens...
0cb221febf6e92410fa570d227b1cc2b9e3c9001
jhermann/tablemate
src/tablemate/util/dclick.py
[ "Apache-2.0" ]
Python
serror
<not_specific>
def serror(message, *args, **kwargs): """Print a styled error message.""" if args or kwargs: message = message.format(*args, **kwargs) return click.secho(message, fg='white', bg='red', bold=True)
Print a styled error message.
Print a styled error message.
[ "Print", "a", "styled", "error", "message", "." ]
def serror(message, *args, **kwargs): if args or kwargs: message = message.format(*args, **kwargs) return click.secho(message, fg='white', bg='red', bold=True)
[ "def", "serror", "(", "message", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "args", "or", "kwargs", ":", "message", "=", "message", ".", "format", "(", "*", "args", ",", "**", "kwargs", ")", "return", "click", ".", "secho", "(", "messag...
Print a styled error message.
[ "Print", "a", "styled", "error", "message", "." ]
[ "\"\"\"Print a styled error message.\"\"\"" ]
[ { "param": "message", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "message", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fb193e0ff4cbd27ec959fb0bb766dae417c1fed0
jhermann/tablemate
src/tablemate/config.py
[ "Apache-2.0" ]
Python
version_info
<not_specific>
def version_info(ctx=None): """Return version information just like --version does.""" from . import __version__ prog = ctx.find_root().info_name if ctx else APP_NAME version = __version__ try: import pkg_resources except ImportError: pass else: for dist in pkg_resou...
Return version information just like --version does.
Return version information just like --version does.
[ "Return", "version", "information", "just", "like", "--", "version", "does", "." ]
def version_info(ctx=None): from . import __version__ prog = ctx.find_root().info_name if ctx else APP_NAME version = __version__ try: import pkg_resources except ImportError: pass else: for dist in pkg_resources.working_set: scripts = dist.get_entry_map().get...
[ "def", "version_info", "(", "ctx", "=", "None", ")", ":", "from", ".", "import", "__version__", "prog", "=", "ctx", ".", "find_root", "(", ")", ".", "info_name", "if", "ctx", "else", "APP_NAME", "version", "=", "__version__", "try", ":", "import", "pkg_r...
Return version information just like --version does.
[ "Return", "version", "information", "just", "like", "--", "version", "does", "." ]
[ "\"\"\"Return version information just like --version does.\"\"\"" ]
[ { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fb193e0ff4cbd27ec959fb0bb766dae417c1fed0
jhermann/tablemate
src/tablemate/config.py
[ "Apache-2.0" ]
Python
locations
<not_specific>
def locations(exists=True, extras=None): """Return the location of the config file(s).""" result = [] candidates = [ '/etc/{}.conf'.format(APP_NAME), os.path.join(click.get_app_dir(APP_NAME) + '.conf'), ] + (extras and list(extras) or []) for config_file in candidates: if c...
Return the location of the config file(s).
Return the location of the config file(s).
[ "Return", "the", "location", "of", "the", "config", "file", "(", "s", ")", "." ]
def locations(exists=True, extras=None): result = [] candidates = [ '/etc/{}.conf'.format(APP_NAME), os.path.join(click.get_app_dir(APP_NAME) + '.conf'), ] + (extras and list(extras) or []) for config_file in candidates: if config_file and (not exists or os.path.exists(config_fi...
[ "def", "locations", "(", "exists", "=", "True", ",", "extras", "=", "None", ")", ":", "result", "=", "[", "]", "candidates", "=", "[", "'/etc/{}.conf'", ".", "format", "(", "APP_NAME", ")", ",", "os", ".", "path", ".", "join", "(", "click", ".", "g...
Return the location of the config file(s).
[ "Return", "the", "location", "of", "the", "config", "file", "(", "s", ")", "." ]
[ "\"\"\"Return the location of the config file(s).\"\"\"" ]
[ { "param": "exists", "type": null }, { "param": "extras", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "exists", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "extras", "type": null, "docstring": null, "docstring_tokens...
3383a75b7b69fbbcee77b4edde593665a21f4987
pckhoi/deba
deba/test_utils.py
[ "MIT" ]
Python
assertFileContent
float
def assertFileContent(self, filename: str, lines: typing.List[str]) -> float: """Asserts file content and returns modified time as seconds since the epoch""" with open(self.file_path(filename), "r") as f: self.assertEqual( f.read(), "\n".join(lines), ...
Asserts file content and returns modified time as seconds since the epoch
Asserts file content and returns modified time as seconds since the epoch
[ "Asserts", "file", "content", "and", "returns", "modified", "time", "as", "seconds", "since", "the", "epoch" ]
def assertFileContent(self, filename: str, lines: typing.List[str]) -> float: with open(self.file_path(filename), "r") as f: self.assertEqual( f.read(), "\n".join(lines), ) return self.mod_time(filename)
[ "def", "assertFileContent", "(", "self", ",", "filename", ":", "str", ",", "lines", ":", "typing", ".", "List", "[", "str", "]", ")", "->", "float", ":", "with", "open", "(", "self", ".", "file_path", "(", "filename", ")", ",", "\"r\"", ")", "as", ...
Asserts file content and returns modified time as seconds since the epoch
[ "Asserts", "file", "content", "and", "returns", "modified", "time", "as", "seconds", "since", "the", "epoch" ]
[ "\"\"\"Asserts file content and returns modified time as seconds since the epoch\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "filename", "type": "str" }, { "param": "lines", "type": "typing.List[str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": "str", "docstring": null, "docstring_token...
2a5d2b2efb8460655cfb9e27e088dbdb57cfcbbd
pckhoi/deba
deba/__init__.py
[ "MIT" ]
Python
data
pathlib.Path
def data(filepath: str) -> pathlib.Path: """Joins Deba's dataDir with filepath This function will read deba.yaml to determine dataDir. By defaults, it read from current working directory. If that's not where deba.yaml is, set the location with set_root. :param str filepath: file path relative to d...
Joins Deba's dataDir with filepath This function will read deba.yaml to determine dataDir. By defaults, it read from current working directory. If that's not where deba.yaml is, set the location with set_root. :param str filepath: file path relative to data directory :rtype: str
Joins Deba's dataDir with filepath This function will read deba.yaml to determine dataDir. By defaults, it read from current working directory. If that's not where deba.yaml is, set the location with set_root.
[ "Joins", "Deba", "'", "s", "dataDir", "with", "filepath", "This", "function", "will", "read", "deba", ".", "yaml", "to", "determine", "dataDir", ".", "By", "defaults", "it", "read", "from", "current", "working", "directory", ".", "If", "that", "'", "s", ...
def data(filepath: str) -> pathlib.Path: conf = get_config(_root) return pathlib.Path(conf._root_dir) / conf.data_dir / filepath.lstrip("/")
[ "def", "data", "(", "filepath", ":", "str", ")", "->", "pathlib", ".", "Path", ":", "conf", "=", "get_config", "(", "_root", ")", "return", "pathlib", ".", "Path", "(", "conf", ".", "_root_dir", ")", "/", "conf", ".", "data_dir", "/", "filepath", "."...
Joins Deba's dataDir with filepath This function will read deba.yaml to determine dataDir.
[ "Joins", "Deba", "'", "s", "dataDir", "with", "filepath", "This", "function", "will", "read", "deba", ".", "yaml", "to", "determine", "dataDir", "." ]
[ "\"\"\"Joins Deba's dataDir with filepath\n\n This function will read deba.yaml to determine dataDir. By defaults,\n it read from current working directory. If that's not where deba.yaml\n is, set the location with set_root.\n\n :param str filepath: file path relative to data directory\n\n :rtype: st...
[ { "param": "filepath", "type": "str" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "str" } ], "raises": [], "params": [ { "identifier": "filepath", "type": "str", "docstring": "file path relative to data directory", "docstring_tokens": [ "file...
e5099589d66bcefb831862104fb6faf7852e6aa4
EasonChan236/self-driving-car-traffic-sign-identification
traffic_sign_identification/pipeline/network.py
[ "MIT" ]
Python
make_stocahstic
<not_specific>
def make_stocahstic(learning_rate): """ A helper to create adam optimizer """ return tf.train.AdamOptimizer(learning_rate=learning_rate)
A helper to create adam optimizer
A helper to create adam optimizer
[ "A", "helper", "to", "create", "adam", "optimizer" ]
def make_stocahstic(learning_rate): return tf.train.AdamOptimizer(learning_rate=learning_rate)
[ "def", "make_stocahstic", "(", "learning_rate", ")", ":", "return", "tf", ".", "train", ".", "AdamOptimizer", "(", "learning_rate", "=", "learning_rate", ")" ]
A helper to create adam optimizer
[ "A", "helper", "to", "create", "adam", "optimizer" ]
[ "\"\"\"\n A helper to create adam optimizer\n \"\"\"" ]
[ { "param": "learning_rate", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "learning_rate", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
40612ca885560fd2d2495b617e4accf197644a21
zeigo/jpeg-decoder-py
decoder.py
[ "MIT" ]
Python
init_stream
null
def init_stream(self): """read entroy-encoded data between SOS and the next marker to the stream, remove byte padding 0x00, which follows a 0xff""" stream = Stream() while True: x = self.read_1b() if x != 0xff: stream.write_byte(x) ...
read entroy-encoded data between SOS and the next marker to the stream, remove byte padding 0x00, which follows a 0xff
read entroy-encoded data between SOS and the next marker to the stream, remove byte padding 0x00, which follows a 0xff
[ "read", "entroy", "-", "encoded", "data", "between", "SOS", "and", "the", "next", "marker", "to", "the", "stream", "remove", "byte", "padding", "0x00", "which", "follows", "a", "0xff" ]
def init_stream(self): stream = Stream() while True: x = self.read_1b() if x != 0xff: stream.write_byte(x) else: y = self.read_1b() if y == 0x00: stream.write_byte(x) else: ...
[ "def", "init_stream", "(", "self", ")", ":", "stream", "=", "Stream", "(", ")", "while", "True", ":", "x", "=", "self", ".", "read_1b", "(", ")", "if", "x", "!=", "0xff", ":", "stream", ".", "write_byte", "(", "x", ")", "else", ":", "y", "=", "...
read entroy-encoded data between SOS and the next marker to the stream, remove byte padding 0x00, which follows a 0xff
[ "read", "entroy", "-", "encoded", "data", "between", "SOS", "and", "the", "next", "marker", "to", "the", "stream", "remove", "byte", "padding", "0x00", "which", "follows", "a", "0xff" ]
[ "\"\"\"read entroy-encoded data between SOS and the next marker to the stream,\r\n remove byte padding 0x00, which follows a 0xff\"\"\"", "# remove byte padding 0x00\r", "# x is the first byte of the next marker\r" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
40612ca885560fd2d2495b617e4accf197644a21
zeigo/jpeg-decoder-py
decoder.py
[ "MIT" ]
Python
read_huffman_symbol
<not_specific>
def read_huffman_symbol(self, ht): """read bits from the stream and decode them according to Huffman table, return a Huffman-encoded symbol""" while True: symbol = ht.get_bit(self.read_bit()) if symbol != None: return symbol
read bits from the stream and decode them according to Huffman table, return a Huffman-encoded symbol
read bits from the stream and decode them according to Huffman table, return a Huffman-encoded symbol
[ "read", "bits", "from", "the", "stream", "and", "decode", "them", "according", "to", "Huffman", "table", "return", "a", "Huffman", "-", "encoded", "symbol" ]
def read_huffman_symbol(self, ht): while True: symbol = ht.get_bit(self.read_bit()) if symbol != None: return symbol
[ "def", "read_huffman_symbol", "(", "self", ",", "ht", ")", ":", "while", "True", ":", "symbol", "=", "ht", ".", "get_bit", "(", "self", ".", "read_bit", "(", ")", ")", "if", "symbol", "!=", "None", ":", "return", "symbol" ]
read bits from the stream and decode them according to Huffman table, return a Huffman-encoded symbol
[ "read", "bits", "from", "the", "stream", "and", "decode", "them", "according", "to", "Huffman", "table", "return", "a", "Huffman", "-", "encoded", "symbol" ]
[ "\"\"\"read bits from the stream and decode them according to Huffman table,\r\n return a Huffman-encoded symbol\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ht", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ht", "type": null, "docstring": null, "docstring_tokens": [],...
40612ca885560fd2d2495b617e4accf197644a21
zeigo/jpeg-decoder-py
decoder.py
[ "MIT" ]
Python
decode_sequential
null
def decode_sequential(self, interleaved_components): """Most sequential encoding is interleaved, here it doesn't support non-interleaved""" for cp in interleaved_components: cp.prev_DC = 0 for i in range(self.nr_MCUs_ver): for j in range(self.nr_MCUs_hor): for cp...
Most sequential encoding is interleaved, here it doesn't support non-interleaved
Most sequential encoding is interleaved, here it doesn't support non-interleaved
[ "Most", "sequential", "encoding", "is", "interleaved", "here", "it", "doesn", "'", "t", "support", "non", "-", "interleaved" ]
def decode_sequential(self, interleaved_components): for cp in interleaved_components: cp.prev_DC = 0 for i in range(self.nr_MCUs_ver): for j in range(self.nr_MCUs_hor): for cp in interleaved_components: v_idx, h_idx = cp.vf * i, cp.hf * j ...
[ "def", "decode_sequential", "(", "self", ",", "interleaved_components", ")", ":", "for", "cp", "in", "interleaved_components", ":", "cp", ".", "prev_DC", "=", "0", "for", "i", "in", "range", "(", "self", ".", "nr_MCUs_ver", ")", ":", "for", "j", "in", "r...
Most sequential encoding is interleaved, here it doesn't support non-interleaved
[ "Most", "sequential", "encoding", "is", "interleaved", "here", "it", "doesn", "'", "t", "support", "non", "-", "interleaved" ]
[ "\"\"\"Most sequential encoding is interleaved, here it doesn't support non-interleaved\"\"\"", "# top-left block\r" ]
[ { "param": "self", "type": null }, { "param": "interleaved_components", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "interleaved_components", "type": null, "docstring": null, "do...
40612ca885560fd2d2495b617e4accf197644a21
zeigo/jpeg-decoder-py
decoder.py
[ "MIT" ]
Python
decode_ACs_progressive_first_per_block
<not_specific>
def decode_ACs_progressive_first_per_block(self, ACht, block, Ss, Se, Al, length_EOB_run): """the first scan of successive approximation or spectral selection only""" # this is a EOB if length_EOB_run > 0: return length_EOB_run - 1 idx = Ss while idx <= Se: ...
the first scan of successive approximation or spectral selection only
the first scan of successive approximation or spectral selection only
[ "the", "first", "scan", "of", "successive", "approximation", "or", "spectral", "selection", "only" ]
def decode_ACs_progressive_first_per_block(self, ACht, block, Ss, Se, Al, length_EOB_run): if length_EOB_run > 0: return length_EOB_run - 1 idx = Ss while idx <= Se: symbol = self.read_huffman_symbol(ACht) RUNLENGTH, SIZE = symbol >> 4, symbol % (2**4) ...
[ "def", "decode_ACs_progressive_first_per_block", "(", "self", ",", "ACht", ",", "block", ",", "Ss", ",", "Se", ",", "Al", ",", "length_EOB_run", ")", ":", "if", "length_EOB_run", ">", "0", ":", "return", "length_EOB_run", "-", "1", "idx", "=", "Ss", "while...
the first scan of successive approximation or spectral selection only
[ "the", "first", "scan", "of", "successive", "approximation", "or", "spectral", "selection", "only" ]
[ "\"\"\"the first scan of successive approximation or spectral selection only\"\"\"", "# this is a EOB\r", "# ZRL(15,0)\r", "# EOBn, n=0-14\r" ]
[ { "param": "self", "type": null }, { "param": "ACht", "type": null }, { "param": "block", "type": null }, { "param": "Ss", "type": null }, { "param": "Se", "type": null }, { "param": "Al", "type": null }, { "param": "length_EOB_run", "t...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ACht", "type": null, "docstring": null, "docstring_tokens": [...
eb48dc437c7eb1a274074885ae014a1a6287849d
zeigo/jpeg-decoder-py
utils.py
[ "MIT" ]
Python
create_nd_array
<not_specific>
def create_nd_array(shape): """create n-dimensional array filled with 0""" if len(shape) == 0: return 0 res = [] for _ in range(shape[0]): res.append(create_nd_array(shape[1:])) return res
create n-dimensional array filled with 0
create n-dimensional array filled with 0
[ "create", "n", "-", "dimensional", "array", "filled", "with", "0" ]
def create_nd_array(shape): if len(shape) == 0: return 0 res = [] for _ in range(shape[0]): res.append(create_nd_array(shape[1:])) return res
[ "def", "create_nd_array", "(", "shape", ")", ":", "if", "len", "(", "shape", ")", "==", "0", ":", "return", "0", "res", "=", "[", "]", "for", "_", "in", "range", "(", "shape", "[", "0", "]", ")", ":", "res", ".", "append", "(", "create_nd_array",...
create n-dimensional array filled with 0
[ "create", "n", "-", "dimensional", "array", "filled", "with", "0" ]
[ "\"\"\"create n-dimensional array filled with 0\"\"\"" ]
[ { "param": "shape", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "shape", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
eb48dc437c7eb1a274074885ae014a1a6287849d
zeigo/jpeg-decoder-py
utils.py
[ "MIT" ]
Python
bits_to_number
<not_specific>
def bits_to_number(bits): """convert the binary representation to the original positive number""" res = 0 for x in bits: res = res * 2 + x return res
convert the binary representation to the original positive number
convert the binary representation to the original positive number
[ "convert", "the", "binary", "representation", "to", "the", "original", "positive", "number" ]
def bits_to_number(bits): res = 0 for x in bits: res = res * 2 + x return res
[ "def", "bits_to_number", "(", "bits", ")", ":", "res", "=", "0", "for", "x", "in", "bits", ":", "res", "=", "res", "*", "2", "+", "x", "return", "res" ]
convert the binary representation to the original positive number
[ "convert", "the", "binary", "representation", "to", "the", "original", "positive", "number" ]
[ "\"\"\"convert the binary representation to the original positive number\"\"\"" ]
[ { "param": "bits", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bits", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
eb48dc437c7eb1a274074885ae014a1a6287849d
zeigo/jpeg-decoder-py
utils.py
[ "MIT" ]
Python
zigzag2matrix
<not_specific>
def zigzag2matrix(li): """convert a list of size 64 in zigzag order to a 8 by 8 matrix""" matrix = create_nd_array([8,8]) for i, val in enumerate(li): x, y = zigzag[i] matrix[x][y] = val return matrix
convert a list of size 64 in zigzag order to a 8 by 8 matrix
convert a list of size 64 in zigzag order to a 8 by 8 matrix
[ "convert", "a", "list", "of", "size", "64", "in", "zigzag", "order", "to", "a", "8", "by", "8", "matrix" ]
def zigzag2matrix(li): matrix = create_nd_array([8,8]) for i, val in enumerate(li): x, y = zigzag[i] matrix[x][y] = val return matrix
[ "def", "zigzag2matrix", "(", "li", ")", ":", "matrix", "=", "create_nd_array", "(", "[", "8", ",", "8", "]", ")", "for", "i", ",", "val", "in", "enumerate", "(", "li", ")", ":", "x", ",", "y", "=", "zigzag", "[", "i", "]", "matrix", "[", "x", ...
convert a list of size 64 in zigzag order to a 8 by 8 matrix
[ "convert", "a", "list", "of", "size", "64", "in", "zigzag", "order", "to", "a", "8", "by", "8", "matrix" ]
[ "\"\"\"convert a list of size 64 in zigzag order to a 8 by 8 matrix\"\"\"" ]
[ { "param": "li", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "li", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2a6d05acc14d47a9c1d6c90fe803de650ad5eba8
ryantam626/jupyterlab
jupyterlab/federated_labextensions.py
[ "BSD-3-Clause" ]
Python
develop_labextension
<not_specific>
def develop_labextension(path, symlink=True, overwrite=False, user=False, labextensions_dir=None, destination=None, logger=None, sys_prefix=False ): """Install a prebuilt extension for JupyterLab Stages files and/or...
Install a prebuilt extension for JupyterLab Stages files and/or directories into the labextensions directory. By default, this compares modification time, and only stages files that need updating. If `overwrite` is specified, matching files are purged before proceeding. Parameters ---------- ...
Install a prebuilt extension for JupyterLab Stages files and/or directories into the labextensions directory. By default, this compares modification time, and only stages files that need updating. If `overwrite` is specified, matching files are purged before proceeding. Parameters path : path to file, directory, zip ...
[ "Install", "a", "prebuilt", "extension", "for", "JupyterLab", "Stages", "files", "and", "/", "or", "directories", "into", "the", "labextensions", "directory", ".", "By", "default", "this", "compares", "modification", "time", "and", "only", "stages", "files", "th...
def develop_labextension(path, symlink=True, overwrite=False, user=False, labextensions_dir=None, destination=None, logger=None, sys_prefix=False ): full_dest = None labext = _get_labextension_dir(user=user, sys_pref...
[ "def", "develop_labextension", "(", "path", ",", "symlink", "=", "True", ",", "overwrite", "=", "False", ",", "user", "=", "False", ",", "labextensions_dir", "=", "None", ",", "destination", "=", "None", ",", "logger", "=", "None", ",", "sys_prefix", "=", ...
Install a prebuilt extension for JupyterLab Stages files and/or directories into the labextensions directory.
[ "Install", "a", "prebuilt", "extension", "for", "JupyterLab", "Stages", "files", "and", "/", "or", "directories", "into", "the", "labextensions", "directory", "." ]
[ "\"\"\"Install a prebuilt extension for JupyterLab\n\n Stages files and/or directories into the labextensions directory.\n By default, this compares modification time, and only stages files that need updating.\n If `overwrite` is specified, matching files are purged before proceeding.\n\n Parameters\n ...
[ { "param": "path", "type": null }, { "param": "symlink", "type": null }, { "param": "overwrite", "type": null }, { "param": "user", "type": null }, { "param": "labextensions_dir", "type": null }, { "param": "destination", "type": null }, { ...
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "symlink", "type": null, "docstring": null, "docstring_tokens"...
2a6d05acc14d47a9c1d6c90fe803de650ad5eba8
ryantam626/jupyterlab
jupyterlab/federated_labextensions.py
[ "BSD-3-Clause" ]
Python
develop_labextension_py
<not_specific>
def develop_labextension_py(module, user=False, sys_prefix=False, overwrite=True, symlink=True, labextensions_dir=None, logger=None): """Develop a labextension bundled in a Python package. Returns a list of installed/updated directories. See develop_labextension for parameter information.""" m, labext...
Develop a labextension bundled in a Python package. Returns a list of installed/updated directories. See develop_labextension for parameter information.
Develop a labextension bundled in a Python package. Returns a list of installed/updated directories. See develop_labextension for parameter information.
[ "Develop", "a", "labextension", "bundled", "in", "a", "Python", "package", ".", "Returns", "a", "list", "of", "installed", "/", "updated", "directories", ".", "See", "develop_labextension", "for", "parameter", "information", "." ]
def develop_labextension_py(module, user=False, sys_prefix=False, overwrite=True, symlink=True, labextensions_dir=None, logger=None): m, labexts = _get_labextension_metadata(module) base_path = os.path.split(m.__file__)[0] full_dests = [] for labext in labexts: src = os.path.join(base_path, labe...
[ "def", "develop_labextension_py", "(", "module", ",", "user", "=", "False", ",", "sys_prefix", "=", "False", ",", "overwrite", "=", "True", ",", "symlink", "=", "True", ",", "labextensions_dir", "=", "None", ",", "logger", "=", "None", ")", ":", "m", ","...
Develop a labextension bundled in a Python package.
[ "Develop", "a", "labextension", "bundled", "in", "a", "Python", "package", "." ]
[ "\"\"\"Develop a labextension bundled in a Python package.\n\n Returns a list of installed/updated directories.\n\n See develop_labextension for parameter information.\"\"\"" ]
[ { "param": "module", "type": null }, { "param": "user", "type": null }, { "param": "sys_prefix", "type": null }, { "param": "overwrite", "type": null }, { "param": "symlink", "type": null }, { "param": "labextensions_dir", "type": null }, { ...
{ "returns": [], "raises": [], "params": [ { "identifier": "module", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "user", "type": null, "docstring": null, "docstring_tokens":...
2a6d05acc14d47a9c1d6c90fe803de650ad5eba8
ryantam626/jupyterlab
jupyterlab/federated_labextensions.py
[ "BSD-3-Clause" ]
Python
build_labextension
null
def build_labextension(path, logger=None, development=False, static_url=None, source_map = False): """Build a labextension in the given path""" core_path = osp.join(HERE, 'staging') ext_path = osp.abspath(path) if logger: logger.info('Building extension in %s' % path) builder = _ensure_bui...
Build a labextension in the given path
Build a labextension in the given path
[ "Build", "a", "labextension", "in", "the", "given", "path" ]
def build_labextension(path, logger=None, development=False, static_url=None, source_map = False): core_path = osp.join(HERE, 'staging') ext_path = osp.abspath(path) if logger: logger.info('Building extension in %s' % path) builder = _ensure_builder(ext_path, core_path) arguments = ['node', ...
[ "def", "build_labextension", "(", "path", ",", "logger", "=", "None", ",", "development", "=", "False", ",", "static_url", "=", "None", ",", "source_map", "=", "False", ")", ":", "core_path", "=", "osp", ".", "join", "(", "HERE", ",", "'staging'", ")", ...
Build a labextension in the given path
[ "Build", "a", "labextension", "in", "the", "given", "path" ]
[ "\"\"\"Build a labextension in the given path\"\"\"" ]
[ { "param": "path", "type": null }, { "param": "logger", "type": null }, { "param": "development", "type": null }, { "param": "static_url", "type": null }, { "param": "source_map", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "logger", "type": null, "docstring": null, "docstring_tokens":...
2a6d05acc14d47a9c1d6c90fe803de650ad5eba8
ryantam626/jupyterlab
jupyterlab/federated_labextensions.py
[ "BSD-3-Clause" ]
Python
watch_labextension
null
def watch_labextension(path, labextensions_path, logger=None, development=False, source_map=False): """Watch a labextension in a given path""" core_path = osp.join(HERE, 'staging') ext_path = osp.abspath(path) if logger: logger.info('Building extension in %s' % path) # Check to see if we n...
Watch a labextension in a given path
Watch a labextension in a given path
[ "Watch", "a", "labextension", "in", "a", "given", "path" ]
def watch_labextension(path, labextensions_path, logger=None, development=False, source_map=False): core_path = osp.join(HERE, 'staging') ext_path = osp.abspath(path) if logger: logger.info('Building extension in %s' % path) federated_extensions = get_federated_extensions(labextensions_path) ...
[ "def", "watch_labextension", "(", "path", ",", "labextensions_path", ",", "logger", "=", "None", ",", "development", "=", "False", ",", "source_map", "=", "False", ")", ":", "core_path", "=", "osp", ".", "join", "(", "HERE", ",", "'staging'", ")", "ext_pat...
Watch a labextension in a given path
[ "Watch", "a", "labextension", "in", "a", "given", "path" ]
[ "\"\"\"Watch a labextension in a given path\"\"\"", "# Check to see if we need to create a symlink" ]
[ { "param": "path", "type": null }, { "param": "labextensions_path", "type": null }, { "param": "logger", "type": null }, { "param": "development", "type": null }, { "param": "source_map", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "labextensions_path", "type": null, "docstring": null, "docstr...
2a6d05acc14d47a9c1d6c90fe803de650ad5eba8
ryantam626/jupyterlab
jupyterlab/federated_labextensions.py
[ "BSD-3-Clause" ]
Python
_ensure_builder
<not_specific>
def _ensure_builder(ext_path, core_path): """Ensure that we can build the extension and return the builder script path """ # Test for compatible dependency on @jupyterlab/builder with open(osp.join(core_path, 'package.json')) as fid: core_data = json.load(fid) with open(osp.join(ext_path, 'p...
Ensure that we can build the extension and return the builder script path
Ensure that we can build the extension and return the builder script path
[ "Ensure", "that", "we", "can", "build", "the", "extension", "and", "return", "the", "builder", "script", "path" ]
def _ensure_builder(ext_path, core_path): with open(osp.join(core_path, 'package.json')) as fid: core_data = json.load(fid) with open(osp.join(ext_path, 'package.json')) as fid: ext_data = json.load(fid) depVersion1 = core_data['devDependencies']['@jupyterlab/builder'] depVersion2 = ext_...
[ "def", "_ensure_builder", "(", "ext_path", ",", "core_path", ")", ":", "with", "open", "(", "osp", ".", "join", "(", "core_path", ",", "'package.json'", ")", ")", "as", "fid", ":", "core_data", "=", "json", ".", "load", "(", "fid", ")", "with", "open",...
Ensure that we can build the extension and return the builder script path
[ "Ensure", "that", "we", "can", "build", "the", "extension", "and", "return", "the", "builder", "script", "path" ]
[ "\"\"\"Ensure that we can build the extension and return the builder script path\n \"\"\"", "# Test for compatible dependency on @jupyterlab/builder", "# if we have installed from disk (version is a path), assume we know what", "# we are doing and do not check versions.", "# Find @jupyterlab/builder usin...
[ { "param": "ext_path", "type": null }, { "param": "core_path", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ext_path", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "core_path", "type": null, "docstring": null, "docstring_t...
2a6d05acc14d47a9c1d6c90fe803de650ad5eba8
ryantam626/jupyterlab
jupyterlab/federated_labextensions.py
[ "BSD-3-Clause" ]
Python
_get_labextension_metadata
<not_specific>
def _get_labextension_metadata(module): """Get the list of labextension paths associated with a Python module. Returns a tuple of (the module path, [{ 'src': 'mockextension', 'dest': '_mockdestination' }]) Parameters ---------- module : str Importable Pytho...
Get the list of labextension paths associated with a Python module. Returns a tuple of (the module path, [{ 'src': 'mockextension', 'dest': '_mockdestination' }]) Parameters ---------- module : str Importable Python module exposing the magic-named `_jup...
Get the list of labextension paths associated with a Python module. Parameters module : str Importable Python module exposing the magic-named `_jupyter_labextension_paths` function
[ "Get", "the", "list", "of", "labextension", "paths", "associated", "with", "a", "Python", "module", ".", "Parameters", "module", ":", "str", "Importable", "Python", "module", "exposing", "the", "magic", "-", "named", "`", "_jupyter_labextension_paths", "`", "fun...
def _get_labextension_metadata(module): try: m = importlib.import_module(module) except Exception: m = None if not hasattr(m, '_jupyter_labextension_paths'): mod_path = osp.abspath(module) if osp.exists(mod_path): try: package = subprocess.check_ou...
[ "def", "_get_labextension_metadata", "(", "module", ")", ":", "try", ":", "m", "=", "importlib", ".", "import_module", "(", "module", ")", "except", "Exception", ":", "m", "=", "None", "if", "not", "hasattr", "(", "m", ",", "'_jupyter_labextension_paths'", "...
Get the list of labextension paths associated with a Python module.
[ "Get", "the", "list", "of", "labextension", "paths", "associated", "with", "a", "Python", "module", "." ]
[ "\"\"\"Get the list of labextension paths associated with a Python module.\n\n Returns a tuple of (the module path, [{\n 'src': 'mockextension',\n 'dest': '_mockdestination'\n }])\n\n Parameters\n ----------\n\n module : str\n Importable Python module exposing the\n ...
[ { "param": "module", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "module", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c90b8f3cd28ce5321b515312b26cb64b2eb3e9a4
vreshniak/exemplar-feature-inpainting
src/utils.py
[ "MIT" ]
Python
masked_indices
<not_specific>
def masked_indices(mask): """ Find linear indices of the masked pixels """ return np.nonzero(np.ravel(mask,order='C'))[0]
Find linear indices of the masked pixels
Find linear indices of the masked pixels
[ "Find", "linear", "indices", "of", "the", "masked", "pixels" ]
def masked_indices(mask): return np.nonzero(np.ravel(mask,order='C'))[0]
[ "def", "masked_indices", "(", "mask", ")", ":", "return", "np", ".", "nonzero", "(", "np", ".", "ravel", "(", "mask", ",", "order", "=", "'C'", ")", ")", "[", "0", "]" ]
Find linear indices of the masked pixels
[ "Find", "linear", "indices", "of", "the", "masked", "pixels" ]
[ "\"\"\"\n\tFind linear indices of the masked pixels\n\t\"\"\"" ]
[ { "param": "mask", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mask", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c90b8f3cd28ce5321b515312b26cb64b2eb3e9a4
vreshniak/exemplar-feature-inpainting
src/utils.py
[ "MIT" ]
Python
non_masked_indices
<not_specific>
def non_masked_indices(mask): """ Find linear indices of the non masked pixels """ return np.nonzero(np.ravel(mask-1,order='C'))[0]
Find linear indices of the non masked pixels
Find linear indices of the non masked pixels
[ "Find", "linear", "indices", "of", "the", "non", "masked", "pixels" ]
def non_masked_indices(mask): return np.nonzero(np.ravel(mask-1,order='C'))[0]
[ "def", "non_masked_indices", "(", "mask", ")", ":", "return", "np", ".", "nonzero", "(", "np", ".", "ravel", "(", "mask", "-", "1", ",", "order", "=", "'C'", ")", ")", "[", "0", "]" ]
Find linear indices of the non masked pixels
[ "Find", "linear", "indices", "of", "the", "non", "masked", "pixels" ]
[ "\"\"\"\n\tFind linear indices of the non masked pixels\n\t\"\"\"" ]
[ { "param": "mask", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mask", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c90b8f3cd28ce5321b515312b26cb64b2eb3e9a4
vreshniak/exemplar-feature-inpainting
src/utils.py
[ "MIT" ]
Python
masked_bounding_box
<not_specific>
def masked_bounding_box(mask): ''' Bounding box of the masked region ''' inp_ind_y, inp_ind_x = np.nonzero(mask) inp_top_left_x = np.amin(inp_ind_x); inp_bot_rght_x = np.amax(inp_ind_x) inp_top_left_y = np.amin(inp_ind_y); inp_bot_rght_y = np.amax(inp_ind_y) return [inp_top_left_y, inp_top_left_x, inp_bot_rght_y...
Bounding box of the masked region
Bounding box of the masked region
[ "Bounding", "box", "of", "the", "masked", "region" ]
def masked_bounding_box(mask): inp_ind_y, inp_ind_x = np.nonzero(mask) inp_top_left_x = np.amin(inp_ind_x); inp_bot_rght_x = np.amax(inp_ind_x) inp_top_left_y = np.amin(inp_ind_y); inp_bot_rght_y = np.amax(inp_ind_y) return [inp_top_left_y, inp_top_left_x, inp_bot_rght_y, inp_bot_rght_x]
[ "def", "masked_bounding_box", "(", "mask", ")", ":", "inp_ind_y", ",", "inp_ind_x", "=", "np", ".", "nonzero", "(", "mask", ")", "inp_top_left_x", "=", "np", ".", "amin", "(", "inp_ind_x", ")", ";", "inp_bot_rght_x", "=", "np", ".", "amax", "(", "inp_ind...
Bounding box of the masked region
[ "Bounding", "box", "of", "the", "masked", "region" ]
[ "'''\n\tBounding box of the masked region\n\t'''" ]
[ { "param": "mask", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mask", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c90b8f3cd28ce5321b515312b26cb64b2eb3e9a4
vreshniak/exemplar-feature-inpainting
src/utils.py
[ "MIT" ]
Python
extend_mask_nonlocal
<not_specific>
def extend_mask_nonlocal(mask,kernel=np.ones((3,3))): """ Extend inpainting mask to contain pixels in the support of the nonlocal kernel """ assert (mask.dtype is np.dtype(np.bool)), "input mask must be of bool type" ext_mask = mask.copy() inp_ind = masked_indices(mask) im_h, im_w = mask.shape ker_y, ker_x =...
Extend inpainting mask to contain pixels in the support of the nonlocal kernel
Extend inpainting mask to contain pixels in the support of the nonlocal kernel
[ "Extend", "inpainting", "mask", "to", "contain", "pixels", "in", "the", "support", "of", "the", "nonlocal", "kernel" ]
def extend_mask_nonlocal(mask,kernel=np.ones((3,3))): assert (mask.dtype is np.dtype(np.bool)), "input mask must be of bool type" ext_mask = mask.copy() inp_ind = masked_indices(mask) im_h, im_w = mask.shape ker_y, ker_x = kernel.shape assert(ker_x%2>0), "kernel must have odd dimensions" assert(ker_y%2>0), "ker...
[ "def", "extend_mask_nonlocal", "(", "mask", ",", "kernel", "=", "np", ".", "ones", "(", "(", "3", ",", "3", ")", ")", ")", ":", "assert", "(", "mask", ".", "dtype", "is", "np", ".", "dtype", "(", "np", ".", "bool", ")", ")", ",", "\"input mask mu...
Extend inpainting mask to contain pixels in the support of the nonlocal kernel
[ "Extend", "inpainting", "mask", "to", "contain", "pixels", "in", "the", "support", "of", "the", "nonlocal", "kernel" ]
[ "\"\"\"\n\tExtend inpainting mask to contain pixels in the support of the nonlocal kernel\n\t\"\"\"", "# indices of the nonzero kernel elements" ]
[ { "param": "mask", "type": null }, { "param": "kernel", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mask", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "kernel", "type": null, "docstring": null, "docstring_tokens":...
c90b8f3cd28ce5321b515312b26cb64b2eb3e9a4
vreshniak/exemplar-feature-inpainting
src/utils.py
[ "MIT" ]
Python
convmat
<not_specific>
def convmat(signal_size,kernel,dtype=_dtype): """ 1D convolution (correlation) matrix with zero boundary conditions """ assert (kernel.size%2==1), "kernel is assumed to have odd number of elements" mat = sp.dia_matrix( (signal_size,signal_size), dtype=dtype ) half_ker_size = kernel.size//2 # correlation for i...
1D convolution (correlation) matrix with zero boundary conditions
1D convolution (correlation) matrix with zero boundary conditions
[ "1D", "convolution", "(", "correlation", ")", "matrix", "with", "zero", "boundary", "conditions" ]
def convmat(signal_size,kernel,dtype=_dtype): assert (kernel.size%2==1), "kernel is assumed to have odd number of elements" mat = sp.dia_matrix( (signal_size,signal_size), dtype=dtype ) half_ker_size = kernel.size//2 for i in range(-half_ker_size,half_ker_size+1): if ( kernel[half_ker_size+i]!=0 ): mat.setdiag...
[ "def", "convmat", "(", "signal_size", ",", "kernel", ",", "dtype", "=", "_dtype", ")", ":", "assert", "(", "kernel", ".", "size", "%", "2", "==", "1", ")", ",", "\"kernel is assumed to have odd number of elements\"", "mat", "=", "sp", ".", "dia_matrix", "(",...
1D convolution (correlation) matrix with zero boundary conditions
[ "1D", "convolution", "(", "correlation", ")", "matrix", "with", "zero", "boundary", "conditions" ]
[ "\"\"\"\n\t1D convolution (correlation) matrix with zero boundary conditions\n\t\"\"\"", "# correlation", "# # convolution", "# for i in range(-half_ker_size,half_ker_size+1):", "# \tif ( kernel[half_ker_size-i]!=0 ):", "# \t\tmat.setdiag(kernel[half_ker_size-i],i)" ]
[ { "param": "signal_size", "type": null }, { "param": "kernel", "type": null }, { "param": "dtype", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "signal_size", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "kernel", "type": null, "docstring": null, "docstring_t...
c90b8f3cd28ce5321b515312b26cb64b2eb3e9a4
vreshniak/exemplar-feature-inpainting
src/utils.py
[ "MIT" ]
Python
conv2mat
<not_specific>
def conv2mat(im_shape,kernel,format="channels_first",dtype=_dtype): """ 2D convolution (correlation) matrix with zero boundary conditions """ if len(im_shape)==2: im_size_y, im_size_x = im_shape num_channels = 1 else: if format=="channels_last": im_size_y, im_size_x, num_channels = im_shape else: num...
2D convolution (correlation) matrix with zero boundary conditions
2D convolution (correlation) matrix with zero boundary conditions
[ "2D", "convolution", "(", "correlation", ")", "matrix", "with", "zero", "boundary", "conditions" ]
def conv2mat(im_shape,kernel,format="channels_first",dtype=_dtype): if len(im_shape)==2: im_size_y, im_size_x = im_shape num_channels = 1 else: if format=="channels_last": im_size_y, im_size_x, num_channels = im_shape else: num_channels, im_size_y, im_size_x = im_shape ker_size_y, ker_size_x = kernel.s...
[ "def", "conv2mat", "(", "im_shape", ",", "kernel", ",", "format", "=", "\"channels_first\"", ",", "dtype", "=", "_dtype", ")", ":", "if", "len", "(", "im_shape", ")", "==", "2", ":", "im_size_y", ",", "im_size_x", "=", "im_shape", "num_channels", "=", "1...
2D convolution (correlation) matrix with zero boundary conditions
[ "2D", "convolution", "(", "correlation", ")", "matrix", "with", "zero", "boundary", "conditions" ]
[ "\"\"\"\n\t2D convolution (correlation) matrix with zero boundary conditions\n\t\"\"\"", "# diagonal blocks corresponding to the rows of the kernel", "# diagonal of the block corresponding to the given row of the kernel", "# correlation", "# # convolution", "# diag = sp.eye(im_size_y,im_size_y,-j,dtype=dt...
[ { "param": "im_shape", "type": null }, { "param": "kernel", "type": null }, { "param": "format", "type": null }, { "param": "dtype", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "im_shape", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "kernel", "type": null, "docstring": null, "docstring_toke...
c90b8f3cd28ce5321b515312b26cb64b2eb3e9a4
vreshniak/exemplar-feature-inpainting
src/utils.py
[ "MIT" ]
Python
rgb2greymat
<not_specific>
def rgb2greymat(im_shape,format="channels_first",dtype=_dtype): """ Matrix converting rgb image to greyscale """ if len(im_shape)==2: im_size_y, im_size_x = im_shape num_channels = 1 else: if format=="channels_last": im_size_y, im_size_x, num_channels = im_shape else: num_channels, im_size_y, im_size...
Matrix converting rgb image to greyscale
Matrix converting rgb image to greyscale
[ "Matrix", "converting", "rgb", "image", "to", "greyscale" ]
def rgb2greymat(im_shape,format="channels_first",dtype=_dtype): if len(im_shape)==2: im_size_y, im_size_x = im_shape num_channels = 1 else: if format=="channels_last": im_size_y, im_size_x, num_channels = im_shape else: num_channels, im_size_y, im_size_x = im_shape im_size = im_size_x*im_size_y*num_cha...
[ "def", "rgb2greymat", "(", "im_shape", ",", "format", "=", "\"channels_first\"", ",", "dtype", "=", "_dtype", ")", ":", "if", "len", "(", "im_shape", ")", "==", "2", ":", "im_size_y", ",", "im_size_x", "=", "im_shape", "num_channels", "=", "1", "else", "...
Matrix converting rgb image to greyscale
[ "Matrix", "converting", "rgb", "image", "to", "greyscale" ]
[ "\"\"\"\n\tMatrix converting rgb image to greyscale\n\t\"\"\"" ]
[ { "param": "im_shape", "type": null }, { "param": "format", "type": null }, { "param": "dtype", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "im_shape", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "format", "type": null, "docstring": null, "docstring_toke...
c90b8f3cd28ce5321b515312b26cb64b2eb3e9a4
vreshniak/exemplar-feature-inpainting
src/utils.py
[ "MIT" ]
Python
fill_region
<not_specific>
def fill_region(image,mask,value=1): """ Fill masked region of the image with given value """ im = image.copy().ravel() if image.ndim > 2: im_h, im_w, im_ch = image.shape else: im_ch = 1 im_h, im_w = self.image.shape # linear indices of masked pixels ind = masked_indices(mask) for i in ind: for ch in r...
Fill masked region of the image with given value
Fill masked region of the image with given value
[ "Fill", "masked", "region", "of", "the", "image", "with", "given", "value" ]
def fill_region(image,mask,value=1): im = image.copy().ravel() if image.ndim > 2: im_h, im_w, im_ch = image.shape else: im_ch = 1 im_h, im_w = self.image.shape ind = masked_indices(mask) for i in ind: for ch in range(im_ch): im.data[i*im_ch+ch] = value return im.reshape(image.shape)
[ "def", "fill_region", "(", "image", ",", "mask", ",", "value", "=", "1", ")", ":", "im", "=", "image", ".", "copy", "(", ")", ".", "ravel", "(", ")", "if", "image", ".", "ndim", ">", "2", ":", "im_h", ",", "im_w", ",", "im_ch", "=", "image", ...
Fill masked region of the image with given value
[ "Fill", "masked", "region", "of", "the", "image", "with", "given", "value" ]
[ "\"\"\"\n\tFill masked region of the image with given value\n\t\"\"\"", "# linear indices of masked pixels" ]
[ { "param": "image", "type": null }, { "param": "mask", "type": null }, { "param": "value", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "image", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mask", "type": null, "docstring": null, "docstring_tokens": ...
c90b8f3cd28ce5321b515312b26cb64b2eb3e9a4
vreshniak/exemplar-feature-inpainting
src/utils.py
[ "MIT" ]
Python
gauss1d
<not_specific>
def gauss1d(sigma=1,order=0,nstd=3,x=np.empty((0,)),normalize=True): """ Derivative of the 1d Gaussian filter """ assert sigma>0, "sigma cannot be equal to zero" x_max = nstd * sigma if x.size==0: x = np.arange(-x_max,x_max+1) var = sigma**2 num = x * x den = 2 * var g = np.exp(-num/den) / (np.sqrt(2*np...
Derivative of the 1d Gaussian filter
Derivative of the 1d Gaussian filter
[ "Derivative", "of", "the", "1d", "Gaussian", "filter" ]
def gauss1d(sigma=1,order=0,nstd=3,x=np.empty((0,)),normalize=True): assert sigma>0, "sigma cannot be equal to zero" x_max = nstd * sigma if x.size==0: x = np.arange(-x_max,x_max+1) var = sigma**2 num = x * x den = 2 * var g = np.exp(-num/den) / (np.sqrt(2*np.pi)*sigma) if order==1: g *= -x/var elif orde...
[ "def", "gauss1d", "(", "sigma", "=", "1", ",", "order", "=", "0", ",", "nstd", "=", "3", ",", "x", "=", "np", ".", "empty", "(", "(", "0", ",", ")", ")", ",", "normalize", "=", "True", ")", ":", "assert", "sigma", ">", "0", ",", "\"sigma cann...
Derivative of the 1d Gaussian filter
[ "Derivative", "of", "the", "1d", "Gaussian", "filter" ]
[ "\"\"\"\n\tDerivative of the 1d Gaussian filter\n\n\t\"\"\"", "# return g / np.linalg.norm(g,1)" ]
[ { "param": "sigma", "type": null }, { "param": "order", "type": null }, { "param": "nstd", "type": null }, { "param": "x", "type": null }, { "param": "normalize", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sigma", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "order", "type": null, "docstring": null, "docstring_tokens":...
c90b8f3cd28ce5321b515312b26cb64b2eb3e9a4
vreshniak/exemplar-feature-inpainting
src/utils.py
[ "MIT" ]
Python
gauss2d
<not_specific>
def gauss2d(sigma=(1,1), order=(0,0), angle=0, nstd=3, normalize=True): """ Derivative of the rotated 2d Gaussian filter """ assert (sigma[0]>0)&(sigma[1]>0), "sigma cannot be equal to zero" # if angle==None: # g = np.outer( gauss1d(size[1],sigma[1],order[1]), gauss1d(size[0],sigma[0],order[0]) ) # else: x,y =...
Derivative of the rotated 2d Gaussian filter
Derivative of the rotated 2d Gaussian filter
[ "Derivative", "of", "the", "rotated", "2d", "Gaussian", "filter" ]
def gauss2d(sigma=(1,1), order=(0,0), angle=0, nstd=3, normalize=True): assert (sigma[0]>0)&(sigma[1]>0), "sigma cannot be equal to zero" x,y = generate_filter_support(sigma,angle,nstd) x_theta,y_theta = rotate(x,y,-angle) g = gauss1d(x=x_theta,sigma=sigma[0],order=order[0],normalize=False) * gauss1d(x=y_theta,sigm...
[ "def", "gauss2d", "(", "sigma", "=", "(", "1", ",", "1", ")", ",", "order", "=", "(", "0", ",", "0", ")", ",", "angle", "=", "0", ",", "nstd", "=", "3", ",", "normalize", "=", "True", ")", ":", "assert", "(", "sigma", "[", "0", "]", ">", ...
Derivative of the rotated 2d Gaussian filter
[ "Derivative", "of", "the", "rotated", "2d", "Gaussian", "filter" ]
[ "\"\"\"\n\tDerivative of the rotated 2d Gaussian filter\n\t\"\"\"", "# if angle==None:", "# \tg = np.outer( gauss1d(size[1],sigma[1],order[1]), gauss1d(size[0],sigma[0],order[0]) )", "# else:", "# return g / np.linalg.norm(g,1)" ]
[ { "param": "sigma", "type": null }, { "param": "order", "type": null }, { "param": "angle", "type": null }, { "param": "nstd", "type": null }, { "param": "normalize", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sigma", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "order", "type": null, "docstring": null, "docstring_tokens":...
2769e024a3bafaad7c8d67212205abaac3b1c6f4
pimoroni/breakout-garden
examples/rainbow-compass/rainbow-compass.py
[ "MIT" ]
Python
raw_heading
<not_specific>
def raw_heading(minimums, maximums, zero=0): """Return a raw compass heading calculated from the magnetometer data.""" X = 0 Y = 2 # Change to 1 if you have the breakout flat # The range over which values will be calculated, i.e. -1 to +1 mag_range = 2 # Get the magnetometer's values mag...
Return a raw compass heading calculated from the magnetometer data.
Return a raw compass heading calculated from the magnetometer data.
[ "Return", "a", "raw", "compass", "heading", "calculated", "from", "the", "magnetometer", "data", "." ]
def raw_heading(minimums, maximums, zero=0): X = 0 Y = 2 mag_range = 2 mag = list(lsm.magnetometer()) for i in range(len(mag)): mag[i] = ((mag_range / (maximums[i] - minimums[i])) * mag[i]) - \ (mag_range / 2.0) heading = math.atan2(mag[Y], mag[X]) if heading < 0: ...
[ "def", "raw_heading", "(", "minimums", ",", "maximums", ",", "zero", "=", "0", ")", ":", "X", "=", "0", "Y", "=", "2", "mag_range", "=", "2", "mag", "=", "list", "(", "lsm", ".", "magnetometer", "(", ")", ")", "for", "i", "in", "range", "(", "l...
Return a raw compass heading calculated from the magnetometer data.
[ "Return", "a", "raw", "compass", "heading", "calculated", "from", "the", "magnetometer", "data", "." ]
[ "\"\"\"Return a raw compass heading calculated from the magnetometer data.\"\"\"", "# Change to 1 if you have the breakout flat", "# The range over which values will be calculated, i.e. -1 to +1", "# Get the magnetometer's values", "# Scale and shift values", "# Calculate the heading from the vector", "...
[ { "param": "minimums", "type": null }, { "param": "maximums", "type": null }, { "param": "zero", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "minimums", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "maximums", "type": null, "docstring": null, "docstring_to...
0376f49303aa2f728a88dd67d773a06dd2d35e70
pimoroni/breakout-garden
examples/heartbeat/heartbeat.py
[ "MIT" ]
Python
sample
null
def sample(): """Function to thread heartbeat values separately to OLED drawing""" global bpm, bpm_avg, beat_detected, beat_status average_over = 5 bpm_vals = [0 for x in range(average_over)] last_beat = time.time() while running: t = time.time() samples = max30105.get_samples...
Function to thread heartbeat values separately to OLED drawing
Function to thread heartbeat values separately to OLED drawing
[ "Function", "to", "thread", "heartbeat", "values", "separately", "to", "OLED", "drawing" ]
def sample(): global bpm, bpm_avg, beat_detected, beat_status average_over = 5 bpm_vals = [0 for x in range(average_over)] last_beat = time.time() while running: t = time.time() samples = max30105.get_samples() if samples is not None: for i in range(0, len(samples...
[ "def", "sample", "(", ")", ":", "global", "bpm", ",", "bpm_avg", ",", "beat_detected", ",", "beat_status", "average_over", "=", "5", "bpm_vals", "=", "[", "0", "for", "x", "in", "range", "(", "average_over", ")", "]", "last_beat", "=", "time", ".", "ti...
Function to thread heartbeat values separately to OLED drawing
[ "Function", "to", "thread", "heartbeat", "values", "separately", "to", "OLED", "drawing" ]
[ "\"\"\"Function to thread heartbeat values separately to\n OLED drawing\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
538c18ccb562302a6fbada6fc4c96851de26f3c1
watchdogpolska/watchdog-kj-kultura
watchdog_kj_kultura/contrib/sites/migrations/0003_set_site_domain_and_name.py
[ "MIT" ]
Python
update_site_forward
null
def update_site_forward(apps, schema_editor): """Set site domain and name.""" Site = apps.get_model('sites', 'Site') Site.objects.update_or_create( id=settings.SITE_ID, defaults={ 'domain': 'kultura.kj.org.pl', 'name': 'watchdog-kj-kultura' } )
Set site domain and name.
Set site domain and name.
[ "Set", "site", "domain", "and", "name", "." ]
def update_site_forward(apps, schema_editor): Site = apps.get_model('sites', 'Site') Site.objects.update_or_create( id=settings.SITE_ID, defaults={ 'domain': 'kultura.kj.org.pl', 'name': 'watchdog-kj-kultura' } )
[ "def", "update_site_forward", "(", "apps", ",", "schema_editor", ")", ":", "Site", "=", "apps", ".", "get_model", "(", "'sites'", ",", "'Site'", ")", "Site", ".", "objects", ".", "update_or_create", "(", "id", "=", "settings", ".", "SITE_ID", ",", "default...
Set site domain and name.
[ "Set", "site", "domain", "and", "name", "." ]
[ "\"\"\"Set site domain and name.\"\"\"" ]
[ { "param": "apps", "type": null }, { "param": "schema_editor", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "apps", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "schema_editor", "type": null, "docstring": null, "docstring_t...
ec788c82c27e8ac641f3825fe27f191b3f6dc797
Nazze/ha_best_bottrop_garbage_collection
custom_components/best_bottrop_garbage_collection/config_flow.py
[ "MIT" ]
Python
validate_best_config
None
async def validate_best_config(self) -> None: """Validate that the data is correct and can be retrieved Raises a ValueError if there the data cannot be retrieved """ res_list: list[dict] = [""] if self._selected_street_id == "" or self._selected_number <= 0: raise Va...
Validate that the data is correct and can be retrieved Raises a ValueError if there the data cannot be retrieved
Validate that the data is correct and can be retrieved Raises a ValueError if there the data cannot be retrieved
[ "Validate", "that", "the", "data", "is", "correct", "and", "can", "be", "retrieved", "Raises", "a", "ValueError", "if", "there", "the", "data", "cannot", "be", "retrieved" ]
async def validate_best_config(self) -> None: res_list: list[dict] = [""] if self._selected_street_id == "" or self._selected_number <= 0: raise ValueError try: res_list = await self._bgc.get_dates_as_json( self._selected_street_id, self._selected_number ...
[ "async", "def", "validate_best_config", "(", "self", ")", "->", "None", ":", "res_list", ":", "list", "[", "dict", "]", "=", "[", "\"\"", "]", "if", "self", ".", "_selected_street_id", "==", "\"\"", "or", "self", ".", "_selected_number", "<=", "0", ":", ...
Validate that the data is correct and can be retrieved Raises a ValueError if there the data cannot be retrieved
[ "Validate", "that", "the", "data", "is", "correct", "and", "can", "be", "retrieved", "Raises", "a", "ValueError", "if", "there", "the", "data", "cannot", "be", "retrieved" ]
[ "\"\"\"Validate that the data is correct and can be retrieved\n Raises a ValueError if there the data cannot be retrieved\n \"\"\"", "# session = async_get_clientsession(hass)", "# There was some kind of problem to make the GET command (connectivity problems?)", "# If the result is empty,...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bd89e488bbce544b82358af524f5a80862fccd08
Nazze/ha_best_bottrop_garbage_collection
custom_components/best_bottrop_garbage_collection/sensor.py
[ "MIT" ]
Python
async_setup_entry
None
async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: """Defer sensor setup to the shared sensor module.""" coordinator = hass.data[DOMAIN]["coordinator"] entities: list[BESTBottropSensor] = [] bgc = BESTBottropGar...
Defer sensor setup to the shared sensor module.
Defer sensor setup to the shared sensor module.
[ "Defer", "sensor", "setup", "to", "the", "shared", "sensor", "module", "." ]
async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: coordinator = hass.data[DOMAIN]["coordinator"] entities: list[BESTBottropSensor] = [] bgc = BESTBottropGarbageCollectionDates() await bgc.get_trash_types() for...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "AddEntitiesCallback", ",", ")", "->", "None", ":", "coordinator", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[...
Defer sensor setup to the shared sensor module.
[ "Defer", "sensor", "setup", "to", "the", "shared", "sensor", "module", "." ]
[ "\"\"\"Defer sensor setup to the shared sensor module.\"\"\"" ]
[ { "param": "hass", "type": "HomeAssistant" }, { "param": "config_entry", "type": "ConfigEntry" }, { "param": "async_add_entities", "type": "AddEntitiesCallback" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hass", "type": "HomeAssistant", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "config_entry", "type": "ConfigEntry", "docstring": null,...
bd89e488bbce544b82358af524f5a80862fccd08
Nazze/ha_best_bottrop_garbage_collection
custom_components/best_bottrop_garbage_collection/sensor.py
[ "MIT" ]
Python
_handle_coordinator_update
None
def _handle_coordinator_update(self) -> None: """Handle updated data from the coordinator.""" _LOGGER.debug( "I am %s, callback function called", self._attr_unique_id, ) if self._trash_type_id == "A2954658" or self._trash_type_id == "43806A8A": _LOGGE...
Handle updated data from the coordinator.
Handle updated data from the coordinator.
[ "Handle", "updated", "data", "from", "the", "coordinator", "." ]
def _handle_coordinator_update(self) -> None: _LOGGER.debug( "I am %s, callback function called", self._attr_unique_id, ) if self._trash_type_id == "A2954658" or self._trash_type_id == "43806A8A": _LOGGER.debug("Container oder Weihnachten!") return...
[ "def", "_handle_coordinator_update", "(", "self", ")", "->", "None", ":", "_LOGGER", ".", "debug", "(", "\"I am %s, callback function called\"", ",", "self", ".", "_attr_unique_id", ",", ")", "if", "self", ".", "_trash_type_id", "==", "\"A2954658\"", "or", "self",...
Handle updated data from the coordinator.
[ "Handle", "updated", "data", "from", "the", "coordinator", "." ]
[ "\"\"\"Handle updated data from the coordinator.\"\"\"", "# Now find my JSON", "# sub_list_data: lists", "# the data is structured as a dict. The key is the street_id.", "# That data to that key is the JSON-dict.", "# iterate throught the JSON of our street_id!", "# now find the resulting trash type", ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bd89e488bbce544b82358af524f5a80862fccd08
Nazze/ha_best_bottrop_garbage_collection
custom_components/best_bottrop_garbage_collection/sensor.py
[ "MIT" ]
Python
extra_state_attributes
<not_specific>
def extra_state_attributes(self): """Generate dictionary with extra state attributes.""" attr = { "street_name": self._street_name, "street_number": self._number, "street_id": self._street_id, "trash_type_id": self._trash_type_id, "trash_type_n...
Generate dictionary with extra state attributes.
Generate dictionary with extra state attributes.
[ "Generate", "dictionary", "with", "extra", "state", "attributes", "." ]
def extra_state_attributes(self): attr = { "street_name": self._street_name, "street_number": self._number, "street_id": self._street_id, "trash_type_id": self._trash_type_id, "trash_type_name": self._trash_type_name, "special_message": sel...
[ "def", "extra_state_attributes", "(", "self", ")", ":", "attr", "=", "{", "\"street_name\"", ":", "self", ".", "_street_name", ",", "\"street_number\"", ":", "self", ".", "_number", ",", "\"street_id\"", ":", "self", ".", "_street_id", ",", "\"trash_type_id\"", ...
Generate dictionary with extra state attributes.
[ "Generate", "dictionary", "with", "extra", "state", "attributes", "." ]
[ "\"\"\"Generate dictionary with extra state attributes.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bd89e488bbce544b82358af524f5a80862fccd08
Nazze/ha_best_bottrop_garbage_collection
custom_components/best_bottrop_garbage_collection/sensor.py
[ "MIT" ]
Python
ignore
null
async def ignore(self, days: int): """Handle the ignore call. This will ignore this entity for the defined days""" _LOGGER.debug("Called handle_ignore for %s", self._attr_unique_id) ignore_until: date = None _LOGGER.debug("got days %s", str(days)) if days == 0: _LO...
Handle the ignore call. This will ignore this entity for the defined days
Handle the ignore call. This will ignore this entity for the defined days
[ "Handle", "the", "ignore", "call", ".", "This", "will", "ignore", "this", "entity", "for", "the", "defined", "days" ]
async def ignore(self, days: int): _LOGGER.debug("Called handle_ignore for %s", self._attr_unique_id) ignore_until: date = None _LOGGER.debug("got days %s", str(days)) if days == 0: _LOGGER.debug("Days is zero. Resetting") ignore_until = None else: ...
[ "async", "def", "ignore", "(", "self", ",", "days", ":", "int", ")", ":", "_LOGGER", ".", "debug", "(", "\"Called handle_ignore for %s\"", ",", "self", ".", "_attr_unique_id", ")", "ignore_until", ":", "date", "=", "None", "_LOGGER", ".", "debug", "(", "\"...
Handle the ignore call.
[ "Handle", "the", "ignore", "call", "." ]
[ "\"\"\"Handle the ignore call. This will ignore this entity for the defined days\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "days", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "days", "type": "int", "docstring": null, "docstring_tokens": ...
797258a0462cdb42ca24ed327bf9c7f27e19c606
Nazze/ha_best_bottrop_garbage_collection
custom_components/best_bottrop_garbage_collection/__init__.py
[ "MIT" ]
Python
async_setup_entry
bool
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up BEST Bottrop from a config entry.""" coordinator = BESTCoordinator(hass) hass.data[DOMAIN] = {COORDINATOR: coordinator} # hass.data[DOMAIN].coordinator = coordinator hass.config_entries.async_setup_platforms(en...
Set up BEST Bottrop from a config entry.
Set up BEST Bottrop from a config entry.
[ "Set", "up", "BEST", "Bottrop", "from", "a", "config", "entry", "." ]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: coordinator = BESTCoordinator(hass) hass.data[DOMAIN] = {COORDINATOR: coordinator} hass.config_entries.async_setup_platforms(entry, PLATFORMS) await coordinator.async_refresh() return True
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "coordinator", "=", "BESTCoordinator", "(", "hass", ")", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "COORDINATOR", ":"...
Set up BEST Bottrop from a config entry.
[ "Set", "up", "BEST", "Bottrop", "from", "a", "config", "entry", "." ]
[ "\"\"\"Set up BEST Bottrop from a config entry.\"\"\"", "# hass.data[DOMAIN].coordinator = coordinator", "# Update data for the first time. This has to be done after adding the entities,", "# otherwise the listeners won't be ready and won't be updated after reboot or", "# adding the component for the first ...
[ { "param": "hass", "type": "HomeAssistant" }, { "param": "entry", "type": "ConfigEntry" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hass", "type": "HomeAssistant", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "entry", "type": "ConfigEntry", "docstring": null, ...
797258a0462cdb42ca24ed327bf9c7f27e19c606
Nazze/ha_best_bottrop_garbage_collection
custom_components/best_bottrop_garbage_collection/__init__.py
[ "MIT" ]
Python
async_unload_entry
bool
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload BEST Bottrop config entry.""" unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if not hass.data[DOMAIN]: hass.data.pop(DOMAIN) return unload_ok
Unload BEST Bottrop config entry.
Unload BEST Bottrop config entry.
[ "Unload", "BEST", "Bottrop", "config", "entry", "." ]
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if not hass.data[DOMAIN]: hass.data.pop(DOMAIN) return unload_ok
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "unload_ok", "=", "await", "hass", ".", "config_entries", ".", "async_unload_platforms", "(", "entry", ",", "PLATFORMS", ")", "if...
Unload BEST Bottrop config entry.
[ "Unload", "BEST", "Bottrop", "config", "entry", "." ]
[ "\"\"\"Unload BEST Bottrop config entry.\"\"\"" ]
[ { "param": "hass", "type": "HomeAssistant" }, { "param": "entry", "type": "ConfigEntry" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hass", "type": "HomeAssistant", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "entry", "type": "ConfigEntry", "docstring": null, ...
797258a0462cdb42ca24ed327bf9c7f27e19c606
Nazze/ha_best_bottrop_garbage_collection
custom_components/best_bottrop_garbage_collection/__init__.py
[ "MIT" ]
Python
_async_update_data
dict
async def _async_update_data(self) -> dict: """Fetch data from API endpoint. This is the place to pre-process the data to lookup tables so entities can quickly look up their data. """ # create a list with responses # streetid : JSON-Object ret_dict: dict = {} ...
Fetch data from API endpoint. This is the place to pre-process the data to lookup tables so entities can quickly look up their data.
Fetch data from API endpoint. This is the place to pre-process the data to lookup tables so entities can quickly look up their data.
[ "Fetch", "data", "from", "API", "endpoint", ".", "This", "is", "the", "place", "to", "pre", "-", "process", "the", "data", "to", "lookup", "tables", "so", "entities", "can", "quickly", "look", "up", "their", "data", "." ]
async def _async_update_data(self) -> dict: ret_dict: dict = {} for entry in self.hass.config_entries.async_entries(DOMAIN): _LOGGER.debug( "Request for data fetch for street_id %s", entry.data["street_id"] ) async with async_timeout.timeout(10): ...
[ "async", "def", "_async_update_data", "(", "self", ")", "->", "dict", ":", "ret_dict", ":", "dict", "=", "{", "}", "for", "entry", "in", "self", ".", "hass", ".", "config_entries", ".", "async_entries", "(", "DOMAIN", ")", ":", "_LOGGER", ".", "debug", ...
Fetch data from API endpoint.
[ "Fetch", "data", "from", "API", "endpoint", "." ]
[ "\"\"\"Fetch data from API endpoint.\n\n This is the place to pre-process the data to lookup tables\n so entities can quickly look up their data.\n \"\"\"", "# create a list with responses", "# streetid : JSON-Object", "# ClientError Exceptions already caught by HA", "# the data is stru...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e4c546d864f8794b66783d7b2e5deeb39afe2091
matllubos/django-reversion
src/reversion/models.py
[ "BSD-3-Clause" ]
Python
safe_revert
null
def safe_revert(versions): """ Attempts to revert the given models contained in the give versions. This method will attempt to resolve dependencies between the versions to revert them in the correct order to avoid database integrity errors. """ unreverted_versions = [] for version in versio...
Attempts to revert the given models contained in the give versions. This method will attempt to resolve dependencies between the versions to revert them in the correct order to avoid database integrity errors.
Attempts to revert the given models contained in the give versions. This method will attempt to resolve dependencies between the versions to revert them in the correct order to avoid database integrity errors.
[ "Attempts", "to", "revert", "the", "given", "models", "contained", "in", "the", "give", "versions", ".", "This", "method", "will", "attempt", "to", "resolve", "dependencies", "between", "the", "versions", "to", "revert", "them", "in", "the", "correct", "order"...
def safe_revert(versions): unreverted_versions = [] for version in versions: try: with transaction.atomic(): version.revert() except (IntegrityError, ObjectDoesNotExist): unreverted_versions.append(version) if len(unreverted_versions) == len(versions...
[ "def", "safe_revert", "(", "versions", ")", ":", "unreverted_versions", "=", "[", "]", "for", "version", "in", "versions", ":", "try", ":", "with", "transaction", ".", "atomic", "(", ")", ":", "version", ".", "revert", "(", ")", "except", "(", "Integrity...
Attempts to revert the given models contained in the give versions.
[ "Attempts", "to", "revert", "the", "given", "models", "contained", "in", "the", "give", "versions", "." ]
[ "\"\"\"\n Attempts to revert the given models contained in the give versions.\n\n This method will attempt to resolve dependencies between the versions to revert\n them in the correct order to avoid database integrity errors.\n \"\"\"", "# pragma: no cover", "# pragma: no cover", "# pragma: no cov...
[ { "param": "versions", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "versions", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e4c546d864f8794b66783d7b2e5deeb39afe2091
matllubos/django-reversion
src/reversion/models.py
[ "BSD-3-Clause" ]
Python
revert
null
def revert(self, delete=False): """Reverts all objects in this revision.""" version_set = self.version_set.all() # Optionally delete objects no longer in the current revision. if delete: # Get a dict of all objects in this revision. old_revision = set() ...
Reverts all objects in this revision.
Reverts all objects in this revision.
[ "Reverts", "all", "objects", "in", "this", "revision", "." ]
def revert(self, delete=False): version_set = self.version_set.all() if delete: old_revision = set() for version in version_set: try: obj = version.object except ContentType.objects.get_for_id(version.content_type_id).model_clas...
[ "def", "revert", "(", "self", ",", "delete", "=", "False", ")", ":", "version_set", "=", "self", ".", "version_set", ".", "all", "(", ")", "if", "delete", ":", "old_revision", "=", "set", "(", ")", "for", "version", "in", "version_set", ":", "try", "...
Reverts all objects in this revision.
[ "Reverts", "all", "objects", "in", "this", "revision", "." ]
[ "\"\"\"Reverts all objects in this revision.\"\"\"", "# Optionally delete objects no longer in the current revision.", "# Get a dict of all objects in this revision.", "# Calculate the set of all objects that are in the revision now.", "# Delete objects that are no longer in the current revision.", "# Att...
[ { "param": "self", "type": null }, { "param": "delete", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "delete", "type": null, "docstring": null, "docstring_tokens":...
e4c546d864f8794b66783d7b2e5deeb39afe2091
matllubos/django-reversion
src/reversion/models.py
[ "BSD-3-Clause" ]
Python
has_int_pk
<not_specific>
def has_int_pk(model): """Tests whether the given model has an integer primary key.""" pk = model._meta.pk return ( ( isinstance(pk, (models.IntegerField, models.AutoField)) and not isinstance(pk, models.BigIntegerField) ) or ( isinstance(pk, models.Foreig...
Tests whether the given model has an integer primary key.
Tests whether the given model has an integer primary key.
[ "Tests", "whether", "the", "given", "model", "has", "an", "integer", "primary", "key", "." ]
def has_int_pk(model): pk = model._meta.pk return ( ( isinstance(pk, (models.IntegerField, models.AutoField)) and not isinstance(pk, models.BigIntegerField) ) or ( isinstance(pk, models.ForeignKey) and has_int_pk(pk.rel.to) ) )
[ "def", "has_int_pk", "(", "model", ")", ":", "pk", "=", "model", ".", "_meta", ".", "pk", "return", "(", "(", "isinstance", "(", "pk", ",", "(", "models", ".", "IntegerField", ",", "models", ".", "AutoField", ")", ")", "and", "not", "isinstance", "("...
Tests whether the given model has an integer primary key.
[ "Tests", "whether", "the", "given", "model", "has", "an", "integer", "primary", "key", "." ]
[ "\"\"\"Tests whether the given model has an integer primary key.\"\"\"" ]
[ { "param": "model", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e4c546d864f8794b66783d7b2e5deeb39afe2091
matllubos/django-reversion
src/reversion/models.py
[ "BSD-3-Clause" ]
Python
object_version
<not_specific>
def object_version(self): """The stored version of the model.""" data = self.serialized_data data = force_text(data.encode('utf8')) return list(serializers.deserialize(self.format, data, ignorenonexistent=True))[0]
The stored version of the model.
The stored version of the model.
[ "The", "stored", "version", "of", "the", "model", "." ]
def object_version(self): data = self.serialized_data data = force_text(data.encode('utf8')) return list(serializers.deserialize(self.format, data, ignorenonexistent=True))[0]
[ "def", "object_version", "(", "self", ")", ":", "data", "=", "self", ".", "serialized_data", "data", "=", "force_text", "(", "data", ".", "encode", "(", "'utf8'", ")", ")", "return", "list", "(", "serializers", ".", "deserialize", "(", "self", ".", "form...
The stored version of the model.
[ "The", "stored", "version", "of", "the", "model", "." ]
[ "\"\"\"The stored version of the model.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e4c546d864f8794b66783d7b2e5deeb39afe2091
matllubos/django-reversion
src/reversion/models.py
[ "BSD-3-Clause" ]
Python
field_dict
<not_specific>
def field_dict(self): """ A dictionary mapping field names to field values in this version of the model. This method will follow parent links, if present. """ if not hasattr(self, '_field_dict_cache'): object_version = self.object_version obj = ob...
A dictionary mapping field names to field values in this version of the model. This method will follow parent links, if present.
A dictionary mapping field names to field values in this version of the model. This method will follow parent links, if present.
[ "A", "dictionary", "mapping", "field", "names", "to", "field", "values", "in", "this", "version", "of", "the", "model", ".", "This", "method", "will", "follow", "parent", "links", "if", "present", "." ]
def field_dict(self): if not hasattr(self, '_field_dict_cache'): object_version = self.object_version obj = object_version.object result = {} for field in obj._meta.fields: result[field.name] = field.value_from_object(obj) result.update...
[ "def", "field_dict", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_field_dict_cache'", ")", ":", "object_version", "=", "self", ".", "object_version", "obj", "=", "object_version", ".", "object", "result", "=", "{", "}", "for", "field...
A dictionary mapping field names to field values in this version of the model.
[ "A", "dictionary", "mapping", "field", "names", "to", "field", "values", "in", "this", "version", "of", "the", "model", "." ]
[ "\"\"\"\n A dictionary mapping field names to field values in this version\n of the model.\n\n This method will follow parent links, if present.\n \"\"\"", "# Add parent data.", "# pragma: no cover" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e4c546d864f8794b66783d7b2e5deeb39afe2091
matllubos/django-reversion
src/reversion/models.py
[ "BSD-3-Clause" ]
Python
cached_instances
<not_specific>
def cached_instances(self): """ Return and cache instance with its parents """ obj = self.object_version.object result = [obj] for parent_class in obj._meta.get_parent_list(): content_type = ContentType.objects.get_for_model(parent_class) parent_i...
Return and cache instance with its parents
Return and cache instance with its parents
[ "Return", "and", "cache", "instance", "with", "its", "parents" ]
def cached_instances(self): obj = self.object_version.object result = [obj] for parent_class in obj._meta.get_parent_list(): content_type = ContentType.objects.get_for_model(parent_class) parent_id = obj.pk try: parent_version = Version.objects...
[ "def", "cached_instances", "(", "self", ")", ":", "obj", "=", "self", ".", "object_version", ".", "object", "result", "=", "[", "obj", "]", "for", "parent_class", "in", "obj", ".", "_meta", ".", "get_parent_list", "(", ")", ":", "content_type", "=", "Con...
Return and cache instance with its parents
[ "Return", "and", "cache", "instance", "with", "its", "parents" ]
[ "\"\"\"\n Return and cache instance with its parents\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c4adcaaf16cdd2b7ef259d3cebfa0d33bd0a217c
matllubos/django-reversion
src/reversion/revisions.py
[ "BSD-3-Clause" ]
Python
clear
null
def clear(self): """Puts the revision manager back into its default state.""" self._user = None self._comment = '' self._stack = [] self._callbacks = [] self._db = None
Puts the revision manager back into its default state.
Puts the revision manager back into its default state.
[ "Puts", "the", "revision", "manager", "back", "into", "its", "default", "state", "." ]
def clear(self): self._user = None self._comment = '' self._stack = [] self._callbacks = [] self._db = None
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_user", "=", "None", "self", ".", "_comment", "=", "''", "self", ".", "_stack", "=", "[", "]", "self", ".", "_callbacks", "=", "[", "]", "self", ".", "_db", "=", "None" ]
Puts the revision manager back into its default state.
[ "Puts", "the", "revision", "manager", "back", "into", "its", "default", "state", "." ]
[ "\"\"\"Puts the revision manager back into its default state.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c4adcaaf16cdd2b7ef259d3cebfa0d33bd0a217c
matllubos/django-reversion
src/reversion/revisions.py
[ "BSD-3-Clause" ]
Python
start
null
def start(self, manage_manually=False): """ Begins a revision for this thread. This MUST be balanced by a call to `end`. It is recommended that you leave these methods alone and instead use the revision context manager or the `create_revision` decorator. """ if ...
Begins a revision for this thread. This MUST be balanced by a call to `end`. It is recommended that you leave these methods alone and instead use the revision context manager or the `create_revision` decorator.
Begins a revision for this thread. This MUST be balanced by a call to `end`. It is recommended that you leave these methods alone and instead use the revision context manager or the `create_revision` decorator.
[ "Begins", "a", "revision", "for", "this", "thread", ".", "This", "MUST", "be", "balanced", "by", "a", "call", "to", "`", "end", "`", ".", "It", "is", "recommended", "that", "you", "leave", "these", "methods", "alone", "and", "instead", "use", "the", "r...
def start(self, manage_manually=False): if self.is_active(): self._stack.append(self._current_frame.fork(manage_manually)) else: self._stack.append(RevisionContextStackFrame(manage_manually))
[ "def", "start", "(", "self", ",", "manage_manually", "=", "False", ")", ":", "if", "self", ".", "is_active", "(", ")", ":", "self", ".", "_stack", ".", "append", "(", "self", ".", "_current_frame", ".", "fork", "(", "manage_manually", ")", ")", "else",...
Begins a revision for this thread.
[ "Begins", "a", "revision", "for", "this", "thread", "." ]
[ "\"\"\"\n Begins a revision for this thread.\n\n This MUST be balanced by a call to `end`. It is recommended that you\n leave these methods alone and instead use the revision context manager\n or the `create_revision` decorator.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "manage_manually", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "manage_manually", "type": null, "docstring": null, "docstring...
c4adcaaf16cdd2b7ef259d3cebfa0d33bd0a217c
matllubos/django-reversion
src/reversion/revisions.py
[ "BSD-3-Clause" ]
Python
end
null
def end(self): """Ends a revision for this thread.""" self._assert_active() stack_frame = self._stack.pop() if self._stack: self._current_frame.join(stack_frame) else: try: if not stack_frame.is_invalid: # Save the revis...
Ends a revision for this thread.
Ends a revision for this thread.
[ "Ends", "a", "revision", "for", "this", "thread", "." ]
def end(self): self._assert_active() stack_frame = self._stack.pop() if self._stack: self._current_frame.join(stack_frame) else: try: if not stack_frame.is_invalid: for manager, manager_context in stack_frame.objects.items(): ...
[ "def", "end", "(", "self", ")", ":", "self", ".", "_assert_active", "(", ")", "stack_frame", "=", "self", ".", "_stack", ".", "pop", "(", ")", "if", "self", ".", "_stack", ":", "self", ".", "_current_frame", ".", "join", "(", "stack_frame", ")", "els...
Ends a revision for this thread.
[ "Ends", "a", "revision", "for", "this", "thread", "." ]
[ "\"\"\"Ends a revision for this thread.\"\"\"", "# Save the revision data." ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c4adcaaf16cdd2b7ef259d3cebfa0d33bd0a217c
matllubos/django-reversion
src/reversion/revisions.py
[ "BSD-3-Clause" ]
Python
add_to_context
null
def add_to_context(self, manager, type, obj, version_data): """Adds an object to the current revision.""" manager_context = self._current_frame.objects[manager] if obj in manager_context: prev_type = manager_context[obj][0] type = version_type_operator(prev_type, type) ...
Adds an object to the current revision.
Adds an object to the current revision.
[ "Adds", "an", "object", "to", "the", "current", "revision", "." ]
def add_to_context(self, manager, type, obj, version_data): manager_context = self._current_frame.objects[manager] if obj in manager_context: prev_type = manager_context[obj][0] type = version_type_operator(prev_type, type) self._current_frame.objects[manager][obj] = (typ...
[ "def", "add_to_context", "(", "self", ",", "manager", ",", "type", ",", "obj", ",", "version_data", ")", ":", "manager_context", "=", "self", ".", "_current_frame", ".", "objects", "[", "manager", "]", "if", "obj", "in", "manager_context", ":", "prev_type", ...
Adds an object to the current revision.
[ "Adds", "an", "object", "to", "the", "current", "revision", "." ]
[ "\"\"\"Adds an object to the current revision.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "manager", "type": null }, { "param": "type", "type": null }, { "param": "obj", "type": null }, { "param": "version_data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "manager", "type": null, "docstring": null, "docstring_tokens"...
c4adcaaf16cdd2b7ef259d3cebfa0d33bd0a217c
matllubos/django-reversion
src/reversion/revisions.py
[ "BSD-3-Clause" ]
Python
_request_finished_receiver
null
def _request_finished_receiver(self, **kwargs): """ Called at the end of a request, ensuring that any open revisions are closed. Not closing all active revisions can cause memory leaks and weird behaviour. """ while self.is_active(): # pragma: no cover self.e...
Called at the end of a request, ensuring that any open revisions are closed. Not closing all active revisions can cause memory leaks and weird behaviour.
Called at the end of a request, ensuring that any open revisions are closed. Not closing all active revisions can cause memory leaks and weird behaviour.
[ "Called", "at", "the", "end", "of", "a", "request", "ensuring", "that", "any", "open", "revisions", "are", "closed", ".", "Not", "closing", "all", "active", "revisions", "can", "cause", "memory", "leaks", "and", "weird", "behaviour", "." ]
def _request_finished_receiver(self, **kwargs): while self.is_active(): self.end()
[ "def", "_request_finished_receiver", "(", "self", ",", "**", "kwargs", ")", ":", "while", "self", ".", "is_active", "(", ")", ":", "self", ".", "end", "(", ")" ]
Called at the end of a request, ensuring that any open revisions are closed.
[ "Called", "at", "the", "end", "of", "a", "request", "ensuring", "that", "any", "open", "revisions", "are", "closed", "." ]
[ "\"\"\"\n Called at the end of a request, ensuring that any open revisions\n are closed. Not closing all active revisions can cause memory leaks\n and weird behaviour.\n \"\"\"", "# pragma: no cover" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c4adcaaf16cdd2b7ef259d3cebfa0d33bd0a217c
matllubos/django-reversion
src/reversion/revisions.py
[ "BSD-3-Clause" ]
Python
is_registered
<not_specific>
def is_registered(self, model): """ Checks whether the given model has been registered with this revision manager. """ return self._registration_key_for_model(model) in self._registered_models
Checks whether the given model has been registered with this revision manager.
Checks whether the given model has been registered with this revision manager.
[ "Checks", "whether", "the", "given", "model", "has", "been", "registered", "with", "this", "revision", "manager", "." ]
def is_registered(self, model): return self._registration_key_for_model(model) in self._registered_models
[ "def", "is_registered", "(", "self", ",", "model", ")", ":", "return", "self", ".", "_registration_key_for_model", "(", "model", ")", "in", "self", ".", "_registered_models" ]
Checks whether the given model has been registered with this revision manager.
[ "Checks", "whether", "the", "given", "model", "has", "been", "registered", "with", "this", "revision", "manager", "." ]
[ "\"\"\"\n Checks whether the given model has been registered with this revision\n manager.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "model", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": ...
c4adcaaf16cdd2b7ef259d3cebfa0d33bd0a217c
matllubos/django-reversion
src/reversion/revisions.py
[ "BSD-3-Clause" ]
Python
register
<not_specific>
def register(self, model=None, adapter_cls=VersionAdapter, signals=None, eager_signals=None, follow_parents=True, **field_overrides): """Registers a model with this revision manager.""" # Default to post_save and post_delete if no signals are given if signals is None and eager_s...
Registers a model with this revision manager.
Registers a model with this revision manager.
[ "Registers", "a", "model", "with", "this", "revision", "manager", "." ]
def register(self, model=None, adapter_cls=VersionAdapter, signals=None, eager_signals=None, follow_parents=True, **field_overrides): if signals is None and eager_signals is None: signals = [post_save, pre_delete] eager_signals = [pre_delete] self._eager_signals[...
[ "def", "register", "(", "self", ",", "model", "=", "None", ",", "adapter_cls", "=", "VersionAdapter", ",", "signals", "=", "None", ",", "eager_signals", "=", "None", ",", "follow_parents", "=", "True", ",", "**", "field_overrides", ")", ":", "if", "signals...
Registers a model with this revision manager.
[ "Registers", "a", "model", "with", "this", "revision", "manager", "." ]
[ "\"\"\"Registers a model with this revision manager.\"\"\"", "# Default to post_save and post_delete if no signals are given", "# Store signals for usage in the signal receiver", "# Return a class decorator if model is not given", "# Prevent multiple registration.", "# Perform any customization.", "# Pe...
[ { "param": "self", "type": null }, { "param": "model", "type": null }, { "param": "adapter_cls", "type": null }, { "param": "signals", "type": null }, { "param": "eager_signals", "type": null }, { "param": "follow_parents", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": ...
c4adcaaf16cdd2b7ef259d3cebfa0d33bd0a217c
matllubos/django-reversion
src/reversion/revisions.py
[ "BSD-3-Clause" ]
Python
unregister
null
def unregister(self, model): """Removes a model from version control.""" if not self.is_registered(model): raise RegistrationError('{model} has not been registered with django-reversion'.format( model = model, )) del self._registered_models[self._registrat...
Removes a model from version control.
Removes a model from version control.
[ "Removes", "a", "model", "from", "version", "control", "." ]
def unregister(self, model): if not self.is_registered(model): raise RegistrationError('{model} has not been registered with django-reversion'.format( model = model, )) del self._registered_models[self._registration_key_for_model(model)] all_signals = self...
[ "def", "unregister", "(", "self", ",", "model", ")", ":", "if", "not", "self", ".", "is_registered", "(", "model", ")", ":", "raise", "RegistrationError", "(", "'{model} has not been registered with django-reversion'", ".", "format", "(", "model", "=", "model", ...
Removes a model from version control.
[ "Removes", "a", "model", "from", "version", "control", "." ]
[ "\"\"\"Removes a model from version control.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "model", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": ...
c4adcaaf16cdd2b7ef259d3cebfa0d33bd0a217c
matllubos/django-reversion
src/reversion/revisions.py
[ "BSD-3-Clause" ]
Python
_follow_relationships
<not_specific>
def _follow_relationships(self, objects): """Follows all relationships in the given set of objects.""" followed = set() def _follow(obj, version_type, exclude_concrete): # Check the pk first because objects without a pk are not hashable if obj.pk is None or obj in followe...
Follows all relationships in the given set of objects.
Follows all relationships in the given set of objects.
[ "Follows", "all", "relationships", "in", "the", "given", "set", "of", "objects", "." ]
def _follow_relationships(self, objects): followed = set() def _follow(obj, version_type, exclude_concrete): if obj.pk is None or obj in followed or (obj.__class__, obj.pk) == exclude_concrete: return model_parent_list = obj._meta.get_parent_list() fol...
[ "def", "_follow_relationships", "(", "self", ",", "objects", ")", ":", "followed", "=", "set", "(", ")", "def", "_follow", "(", "obj", ",", "version_type", ",", "exclude_concrete", ")", ":", "if", "obj", ".", "pk", "is", "None", "or", "obj", "in", "fol...
Follows all relationships in the given set of objects.
[ "Follows", "all", "relationships", "in", "the", "given", "set", "of", "objects", "." ]
[ "\"\"\"Follows all relationships in the given set of objects.\"\"\"", "# Check the pk first because objects without a pk are not hashable" ]
[ { "param": "self", "type": null }, { "param": "objects", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "objects", "type": null, "docstring": null, "docstring_tokens"...
c4adcaaf16cdd2b7ef259d3cebfa0d33bd0a217c
matllubos/django-reversion
src/reversion/revisions.py
[ "BSD-3-Clause" ]
Python
_get_versions
<not_specific>
def _get_versions(self, db=None): """Returns all versions that apply to this manager.""" return Version.objects.using(db).filter( revision__manager_slug = self._manager_slug, ).select_related('revision')
Returns all versions that apply to this manager.
Returns all versions that apply to this manager.
[ "Returns", "all", "versions", "that", "apply", "to", "this", "manager", "." ]
def _get_versions(self, db=None): return Version.objects.using(db).filter( revision__manager_slug = self._manager_slug, ).select_related('revision')
[ "def", "_get_versions", "(", "self", ",", "db", "=", "None", ")", ":", "return", "Version", ".", "objects", ".", "using", "(", "db", ")", ".", "filter", "(", "revision__manager_slug", "=", "self", ".", "_manager_slug", ",", ")", ".", "select_related", "(...
Returns all versions that apply to this manager.
[ "Returns", "all", "versions", "that", "apply", "to", "this", "manager", "." ]
[ "\"\"\"Returns all versions that apply to this manager.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "db", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "db", "type": null, "docstring": null, "docstring_tokens": [],...
c4adcaaf16cdd2b7ef259d3cebfa0d33bd0a217c
matllubos/django-reversion
src/reversion/revisions.py
[ "BSD-3-Clause" ]
Python
_signal_receiver
null
def _signal_receiver(self, instance, signal, **kwargs): """Adds registered models to the current revision, if any.""" if self._revision_context_manager.is_active() and not self._revision_context_manager.is_managing_manually(): eager = signal in self._eager_signals[instance.__class__] ...
Adds registered models to the current revision, if any.
Adds registered models to the current revision, if any.
[ "Adds", "registered", "models", "to", "the", "current", "revision", "if", "any", "." ]
def _signal_receiver(self, instance, signal, **kwargs): if self._revision_context_manager.is_active() and not self._revision_context_manager.is_managing_manually(): eager = signal in self._eager_signals[instance.__class__] adapter = self.get_adapter(instance.__class__) if sig...
[ "def", "_signal_receiver", "(", "self", ",", "instance", ",", "signal", ",", "**", "kwargs", ")", ":", "if", "self", ".", "_revision_context_manager", ".", "is_active", "(", ")", "and", "not", "self", ".", "_revision_context_manager", ".", "is_managing_manually"...
Adds registered models to the current revision, if any.
[ "Adds", "registered", "models", "to", "the", "current", "revision", "if", "any", "." ]
[ "\"\"\"Adds registered models to the current revision, if any.\"\"\"", "# pre_delete is a special case, because the instance will", "# be modified by django right after this.", "# don't use a lambda, but get the data out now." ]
[ { "param": "self", "type": null }, { "param": "instance", "type": null }, { "param": "signal", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "instance", "type": null, "docstring": null, "docstring_tokens...
b22f80bd0735edddaa8ff995302ae789d733a7f1
danijoo/biotite
src/biotite/structure/charges.py
[ "BSD-3-Clause" ]
Python
_get_parameters
<not_specific>
def _get_parameters(elements, amount_of_binding_partners): """ Gather the parameters required for electronegativity computation of all atoms comprised in the input array `elements`. By doing so, the function accesses the nested dictionary ``EN_PARAMETERS``. The values originate from a publication o...
Gather the parameters required for electronegativity computation of all atoms comprised in the input array `elements`. By doing so, the function accesses the nested dictionary ``EN_PARAMETERS``. The values originate from a publication of Johann Gasteiger and Mario Marsili. [1]_ Parameters ...
Gather the parameters required for electronegativity computation of all atoms comprised in the input array `elements`. By doing so, the function accesses the nested dictionary ``EN_PARAMETERS``. The values originate from a publication of Johann Gasteiger and Mario Marsili. [1]_ Parameters ndarray, dtype=str The arra...
[ "Gather", "the", "parameters", "required", "for", "electronegativity", "computation", "of", "all", "atoms", "comprised", "in", "the", "input", "array", "`", "elements", "`", ".", "By", "doing", "so", "the", "function", "accesses", "the", "nested", "dictionary", ...
def _get_parameters(elements, amount_of_binding_partners): parameters = np.zeros((elements.shape[0], 3)) has_atom_key_error = False has_valence_key_error = False list_of_unparametrized_elements = [] unparametrized_valences = [] unparam_valence_names = [] for i, element in enumerate(elements)...
[ "def", "_get_parameters", "(", "elements", ",", "amount_of_binding_partners", ")", ":", "parameters", "=", "np", ".", "zeros", "(", "(", "elements", ".", "shape", "[", "0", "]", ",", "3", ")", ")", "has_atom_key_error", "=", "False", "has_valence_key_error", ...
Gather the parameters required for electronegativity computation of all atoms comprised in the input array `elements`.
[ "Gather", "the", "parameters", "required", "for", "electronegativity", "computation", "of", "all", "atoms", "comprised", "in", "the", "input", "array", "`", "elements", "`", "." ]
[ "\"\"\"\n Gather the parameters required for electronegativity computation of\n all atoms comprised in the input array `elements`.\n\n By doing so, the function accesses the nested dictionary\n ``EN_PARAMETERS``. The values originate from a publication of Johann\n Gasteiger and Mario Marsili. [1]_\n\...
[ { "param": "elements", "type": null }, { "param": "amount_of_binding_partners", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "elements", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "amount_of_binding_partners", "type": null, "docstring": null, ...
abee1398ccc1b5931d48e71c8e201f6a30e3b042
gesellkammer/shapelib
shapelib/matplot.py
[ "BSD-3-Clause" ]
Python
geom_to_fig
<not_specific>
def geom_to_fig(geom, xrange=None, yrange=None, axis_visible=True, patchkws={}, aspect=1, linewidth=0.01, fig=None): """ convert a shapely geometry to a matplotlib figure If xrange and yrange are given, use them. If not, the bounds of the geometry are used xrange: a number (xmax) o...
convert a shapely geometry to a matplotlib figure If xrange and yrange are given, use them. If not, the bounds of the geometry are used xrange: a number (xmax) or a tuple (xmin, xmax) defining the range to plot in the x coord yrange: the same in the y coord. If these are not given, th...
convert a shapely geometry to a matplotlib figure If xrange and yrange are given, use them. If not, the bounds of the geometry are used a number (xmax) or a tuple (xmin, xmax) defining the range to plot in the x coord yrange: the same in the y coord. This function relies on functionality provided by `descartes`
[ "convert", "a", "shapely", "geometry", "to", "a", "matplotlib", "figure", "If", "xrange", "and", "yrange", "are", "given", "use", "them", ".", "If", "not", "the", "bounds", "of", "the", "geometry", "are", "used", "a", "number", "(", "xmax", ")", "or", ...
def geom_to_fig(geom, xrange=None, yrange=None, axis_visible=True, patchkws={}, aspect=1, linewidth=0.01, fig=None): try: import descartes except ImportError: raise ImportError("descartes is needed to plot geometries") x0, y0, x1, y1 = util.geom_getbounds(geom, xrange, yrange...
[ "def", "geom_to_fig", "(", "geom", ",", "xrange", "=", "None", ",", "yrange", "=", "None", ",", "axis_visible", "=", "True", ",", "patchkws", "=", "{", "}", ",", "aspect", "=", "1", ",", "linewidth", "=", "0.01", ",", "fig", "=", "None", ")", ":", ...
convert a shapely geometry to a matplotlib figure If xrange and yrange are given, use them.
[ "convert", "a", "shapely", "geometry", "to", "a", "matplotlib", "figure", "If", "xrange", "and", "yrange", "are", "given", "use", "them", "." ]
[ "\"\"\"\n convert a shapely geometry to a matplotlib figure\n\n If xrange and yrange are given, use them.\n If not, the bounds of the geometry are used\n\n xrange: a number (xmax) or a tuple (xmin, xmax) defining the range to plot\n in the x coord\n yrange: the same in the y coord. If thes...
[ { "param": "geom", "type": null }, { "param": "xrange", "type": null }, { "param": "yrange", "type": null }, { "param": "axis_visible", "type": null }, { "param": "patchkws", "type": null }, { "param": "aspect", "type": null }, { "param": "...
{ "returns": [], "raises": [], "params": [ { "identifier": "geom", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xrange", "type": null, "docstring": null, "docstring_tokens":...
abee1398ccc1b5931d48e71c8e201f6a30e3b042
gesellkammer/shapelib
shapelib/matplot.py
[ "BSD-3-Clause" ]
Python
geom_plot
null
def geom_plot(geom, xrange=None, yrange=None, axis_visible=True, patchkws={}, aspect=1): """ xrange: a number (xmax) or a tuple (xmin, xmax) defining the range to plot in the x coord yrange: the same in the y coord. If these are not given, they are deduced from the coordinates of the...
xrange: a number (xmax) or a tuple (xmin, xmax) defining the range to plot in the x coord yrange: the same in the y coord. If these are not given, they are deduced from the coordinates of the geometry width: used only when the geometry is not a polygon but a line or a ring. axis...
a number (xmax) or a tuple (xmin, xmax) defining the range to plot in the x coord yrange: the same in the y coord. If these are not given, they are deduced from the coordinates of the geometry width: used only when the geometry is not a polygon but a line or a ring. axis_visible: show the axis and labels patchkws: pass...
[ "a", "number", "(", "xmax", ")", "or", "a", "tuple", "(", "xmin", "xmax", ")", "defining", "the", "range", "to", "plot", "in", "the", "x", "coord", "yrange", ":", "the", "same", "in", "the", "y", "coord", ".", "If", "these", "are", "not", "given", ...
def geom_plot(geom, xrange=None, yrange=None, axis_visible=True, patchkws={}, aspect=1): fig = geom_to_fig(geom, xrange=xrange, yrange=yrange, axis_visible=axis_visible, patchkws=patchkws, aspect=aspect) fig.show()
[ "def", "geom_plot", "(", "geom", ",", "xrange", "=", "None", ",", "yrange", "=", "None", ",", "axis_visible", "=", "True", ",", "patchkws", "=", "{", "}", ",", "aspect", "=", "1", ")", ":", "fig", "=", "geom_to_fig", "(", "geom", ",", "xrange", "="...
xrange: a number (xmax) or a tuple (xmin, xmax) defining the range to plot in the x coord yrange: the same in the y coord.
[ "xrange", ":", "a", "number", "(", "xmax", ")", "or", "a", "tuple", "(", "xmin", "xmax", ")", "defining", "the", "range", "to", "plot", "in", "the", "x", "coord", "yrange", ":", "the", "same", "in", "the", "y", "coord", "." ]
[ "\"\"\"\n xrange: a number (xmax) or a tuple (xmin, xmax) defining the range to plot\n in the x coord\n yrange: the same in the y coord. If these are not given, they are deduced\n from the coordinates of the geometry\n width: used only when the geometry is not a polygon but a line or ...
[ { "param": "geom", "type": null }, { "param": "xrange", "type": null }, { "param": "yrange", "type": null }, { "param": "axis_visible", "type": null }, { "param": "patchkws", "type": null }, { "param": "aspect", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "geom", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xrange", "type": null, "docstring": null, "docstring_tokens":...
846848620207fdb54b087b72edff68156e8eb70d
gesellkammer/shapelib
shapelib/raster.py
[ "BSD-3-Clause" ]
Python
_rasterize_rasterio
<not_specific>
def _rasterize_rasterio(geom, pixratio, xrange=None, yrange=None, imageout=None): """ rasterize `geom` to a 2D array Uses rasterio """ try: import rasterio from rasterio import features except ImportError: return None geoms = [geom.__geo_interface__] x0, y0, x1, ...
rasterize `geom` to a 2D array Uses rasterio
rasterize `geom` to a 2D array Uses rasterio
[ "rasterize", "`", "geom", "`", "to", "a", "2D", "array", "Uses", "rasterio" ]
def _rasterize_rasterio(geom, pixratio, xrange=None, yrange=None, imageout=None): try: import rasterio from rasterio import features except ImportError: return None geoms = [geom.__geo_interface__] x0, y0, x1, y1 = _geomselectrange(geom, xrange, yrange) cols = int(abs(x1-x0) ...
[ "def", "_rasterize_rasterio", "(", "geom", ",", "pixratio", ",", "xrange", "=", "None", ",", "yrange", "=", "None", ",", "imageout", "=", "None", ")", ":", "try", ":", "import", "rasterio", "from", "rasterio", "import", "features", "except", "ImportError", ...
rasterize `geom` to a 2D array Uses rasterio
[ "rasterize", "`", "geom", "`", "to", "a", "2D", "array", "Uses", "rasterio" ]
[ "\"\"\"\n rasterize `geom` to a 2D array\n\n Uses rasterio\n \"\"\"" ]
[ { "param": "geom", "type": null }, { "param": "pixratio", "type": null }, { "param": "xrange", "type": null }, { "param": "yrange", "type": null }, { "param": "imageout", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "geom", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pixratio", "type": null, "docstring": null, "docstring_tokens...
846848620207fdb54b087b72edff68156e8eb70d
gesellkammer/shapelib
shapelib/raster.py
[ "BSD-3-Clause" ]
Python
rasterize
<not_specific>
def rasterize(geom, pixratio, xrange=None, yrange=None, imageout=None): """ rasterize the geometry geom: a shapely geometry pixratio: how many pixels pro unit x_pixels / x_size xrange, yrange: a selection of the geometry to be rendered, or None to select all. It ca...
rasterize the geometry geom: a shapely geometry pixratio: how many pixels pro unit x_pixels / x_size xrange, yrange: a selection of the geometry to be rendered, or None to select all. It can be bigger than the geometry itself. imageout: if give...
rasterize the geometry geom: a shapely geometry pixratio: how many pixels pro unit x_pixels / x_size xrange, yrange: a selection of the geometry to be rendered, or None to select all. It can be bigger than the geometry itself. imageout: if given, it should be the path to save the rasterized geometry as a monochrome ima...
[ "rasterize", "the", "geometry", "geom", ":", "a", "shapely", "geometry", "pixratio", ":", "how", "many", "pixels", "pro", "unit", "x_pixels", "/", "x_size", "xrange", "yrange", ":", "a", "selection", "of", "the", "geometry", "to", "be", "rendered", "or", "...
def rasterize(geom, pixratio, xrange=None, yrange=None, imageout=None): backends = [ ('rasterio', _rasterize_rasterio), ('mastplotlib', _rasterize_matplotlib) ] for backendname, func in backends: out = func(geom, pixratio, xrange, yrange, imageout=imageout) if out: ...
[ "def", "rasterize", "(", "geom", ",", "pixratio", ",", "xrange", "=", "None", ",", "yrange", "=", "None", ",", "imageout", "=", "None", ")", ":", "backends", "=", "[", "(", "'rasterio'", ",", "_rasterize_rasterio", ")", ",", "(", "'mastplotlib'", ",", ...
rasterize the geometry geom: a shapely geometry pixratio: how many pixels pro unit x_pixels / x_size xrange, yrange: a selection of the geometry to be rendered, or None to select all.
[ "rasterize", "the", "geometry", "geom", ":", "a", "shapely", "geometry", "pixratio", ":", "how", "many", "pixels", "pro", "unit", "x_pixels", "/", "x_size", "xrange", "yrange", ":", "a", "selection", "of", "the", "geometry", "to", "be", "rendered", "or", "...
[ "\"\"\"\n rasterize the geometry\n\n geom: a shapely geometry\n pixratio: how many pixels pro unit\n x_pixels / x_size\n xrange, yrange: a selection of the geometry to be rendered,\n or None to select all. It can be bigger than\n the geometry itself.\n ...
[ { "param": "geom", "type": null }, { "param": "pixratio", "type": null }, { "param": "xrange", "type": null }, { "param": "yrange", "type": null }, { "param": "imageout", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "geom", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pixratio", "type": null, "docstring": null, "docstring_tokens...
cc768bb897a92dbd8b56b8149f00f982b15fdc2d
gesellkammer/shapelib
shapelib/core.py
[ "BSD-3-Clause" ]
Python
linestr
<not_specific>
def linestr(*points): """ create a line-segment from the given points Example ======= >>> l = linestr((0, 0), (1, 1), (2, -1)) >>> l.bounds (0.0, -1.0, 2.0, 1.0) >>> [coord for coord in l.coords] [(0.0, 0.0), (1.0, 1.0), (2.0, -1.0)] """ coords = _normalize_points(points) ...
create a line-segment from the given points Example ======= >>> l = linestr((0, 0), (1, 1), (2, -1)) >>> l.bounds (0.0, -1.0, 2.0, 1.0) >>> [coord for coord in l.coords] [(0.0, 0.0), (1.0, 1.0), (2.0, -1.0)]
create a line-segment from the given points Example
[ "create", "a", "line", "-", "segment", "from", "the", "given", "points", "Example" ]
def linestr(*points): coords = _normalize_points(points) return LineString(coords)
[ "def", "linestr", "(", "*", "points", ")", ":", "coords", "=", "_normalize_points", "(", "points", ")", "return", "LineString", "(", "coords", ")" ]
create a line-segment from the given points Example
[ "create", "a", "line", "-", "segment", "from", "the", "given", "points", "Example" ]
[ "\"\"\"\n create a line-segment from the given points\n\n Example\n =======\n\n >>> l = linestr((0, 0), (1, 1), (2, -1))\n >>> l.bounds\n (0.0, -1.0, 2.0, 1.0)\n >>> [coord for coord in l.coords]\n [(0.0, 0.0), (1.0, 1.0), (2.0, -1.0)]\n\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
cc768bb897a92dbd8b56b8149f00f982b15fdc2d
gesellkammer/shapelib
shapelib/core.py
[ "BSD-3-Clause" ]
Python
rect_poly
<not_specific>
def rect_poly(x0, y0, x1, y1): """ a rectangular polygon (filled) """ return box(x0, y0, x1, y1)
a rectangular polygon (filled)
a rectangular polygon (filled)
[ "a", "rectangular", "polygon", "(", "filled", ")" ]
def rect_poly(x0, y0, x1, y1): return box(x0, y0, x1, y1)
[ "def", "rect_poly", "(", "x0", ",", "y0", ",", "x1", ",", "y1", ")", ":", "return", "box", "(", "x0", ",", "y0", ",", "x1", ",", "y1", ")" ]
a rectangular polygon (filled)
[ "a", "rectangular", "polygon", "(", "filled", ")" ]
[ "\"\"\"\n a rectangular polygon (filled)\n \"\"\"" ]
[ { "param": "x0", "type": null }, { "param": "y0", "type": null }, { "param": "x1", "type": null }, { "param": "y1", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x0", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y0", "type": null, "docstring": null, "docstring_tokens": [], ...
cc768bb897a92dbd8b56b8149f00f982b15fdc2d
gesellkammer/shapelib
shapelib/core.py
[ "BSD-3-Clause" ]
Python
rect_line
<not_specific>
def rect_line(x0, y0, x1, y1): """ the perimeter of a rectangle, without any dimensions. """ return LinearRing([(x0, y0), (x1, y0), (x1, y1), (x0, y1)])
the perimeter of a rectangle, without any dimensions.
the perimeter of a rectangle, without any dimensions.
[ "the", "perimeter", "of", "a", "rectangle", "without", "any", "dimensions", "." ]
def rect_line(x0, y0, x1, y1): return LinearRing([(x0, y0), (x1, y0), (x1, y1), (x0, y1)])
[ "def", "rect_line", "(", "x0", ",", "y0", ",", "x1", ",", "y1", ")", ":", "return", "LinearRing", "(", "[", "(", "x0", ",", "y0", ")", ",", "(", "x1", ",", "y0", ")", ",", "(", "x1", ",", "y1", ")", ",", "(", "x0", ",", "y1", ")", "]", ...
the perimeter of a rectangle, without any dimensions.
[ "the", "perimeter", "of", "a", "rectangle", "without", "any", "dimensions", "." ]
[ "\"\"\"\n the perimeter of a rectangle, without any dimensions.\n \"\"\"" ]
[ { "param": "x0", "type": null }, { "param": "y0", "type": null }, { "param": "x1", "type": null }, { "param": "y1", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x0", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y0", "type": null, "docstring": null, "docstring_tokens": [], ...
cc768bb897a92dbd8b56b8149f00f982b15fdc2d
gesellkammer/shapelib
shapelib/core.py
[ "BSD-3-Clause" ]
Python
line_extrapolate_point
<not_specific>
def line_extrapolate_point(l, p, length): """ Return a Point p2 which would extend the line `l` so that it would have a length of `length` l: a line p: a point within that line length: the length that a line from p to p2 would have """ p = Point(*_normalize_point(p)) a = line_angle...
Return a Point p2 which would extend the line `l` so that it would have a length of `length` l: a line p: a point within that line length: the length that a line from p to p2 would have
Return a Point p2 which would extend the line `l` so that it would have a length of `length` a line p: a point within that line length: the length that a line from p to p2 would have
[ "Return", "a", "Point", "p2", "which", "would", "extend", "the", "line", "`", "l", "`", "so", "that", "it", "would", "have", "a", "length", "of", "`", "length", "`", "a", "line", "p", ":", "a", "point", "within", "that", "line", "length", ":", "the...
def line_extrapolate_point(l, p, length): p = Point(*_normalize_point(p)) a = line_angle_at(l, p) if a > pi: a = a % pi p2 = Point(p.x, p.y + length) c = l.centroid if p.x < c.x: if p.y < c.y: angle = pi-a else: angle = a elif p.x > c.x: ...
[ "def", "line_extrapolate_point", "(", "l", ",", "p", ",", "length", ")", ":", "p", "=", "Point", "(", "*", "_normalize_point", "(", "p", ")", ")", "a", "=", "line_angle_at", "(", "l", ",", "p", ")", "if", "a", ">", "pi", ":", "a", "=", "a", "%"...
Return a Point p2 which would extend the line `l` so that it would have a length of `length`
[ "Return", "a", "Point", "p2", "which", "would", "extend", "the", "line", "`", "l", "`", "so", "that", "it", "would", "have", "a", "length", "of", "`", "length", "`" ]
[ "\"\"\"\n Return a Point p2 which would extend the line `l` so that it\n would have a length of `length`\n\n l: a line\n p: a point within that line\n length: the length that a line from p to p2 would have\n\n \"\"\"" ]
[ { "param": "l", "type": null }, { "param": "p", "type": null }, { "param": "length", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "l", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": null, "docstring": null, "docstring_tokens": [], ...
cc768bb897a92dbd8b56b8149f00f982b15fdc2d
gesellkammer/shapelib
shapelib/core.py
[ "BSD-3-Clause" ]
Python
tube
<not_specific>
def tube(points, diam, wallwidth=0.05, begin='closed', end='flat'): """ create a tube. A tube is a set of two parallel lines, where the edges are either closed (curved), open, or flat """ l = linestr(*points) return linestr_to_tube(l, diam=diam, wallwidth=wallwidth, begin=begin, end=end)
create a tube. A tube is a set of two parallel lines, where the edges are either closed (curved), open, or flat
create a tube. A tube is a set of two parallel lines, where the edges are either closed (curved), open, or flat
[ "create", "a", "tube", ".", "A", "tube", "is", "a", "set", "of", "two", "parallel", "lines", "where", "the", "edges", "are", "either", "closed", "(", "curved", ")", "open", "or", "flat" ]
def tube(points, diam, wallwidth=0.05, begin='closed', end='flat'): l = linestr(*points) return linestr_to_tube(l, diam=diam, wallwidth=wallwidth, begin=begin, end=end)
[ "def", "tube", "(", "points", ",", "diam", ",", "wallwidth", "=", "0.05", ",", "begin", "=", "'closed'", ",", "end", "=", "'flat'", ")", ":", "l", "=", "linestr", "(", "*", "points", ")", "return", "linestr_to_tube", "(", "l", ",", "diam", "=", "di...
create a tube.
[ "create", "a", "tube", "." ]
[ "\"\"\"\n create a tube.\n\n A tube is a set of two parallel lines, where the edges are either\n closed (curved), open, or flat\n \"\"\"" ]
[ { "param": "points", "type": null }, { "param": "diam", "type": null }, { "param": "wallwidth", "type": null }, { "param": "begin", "type": null }, { "param": "end", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "points", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "diam", "type": null, "docstring": null, "docstring_tokens":...
cc768bb897a92dbd8b56b8149f00f982b15fdc2d
gesellkammer/shapelib
shapelib/core.py
[ "BSD-3-Clause" ]
Python
perpendicular_at
<not_specific>
def perpendicular_at(line, point, length): """ line: a linestring point: a point within the line at which to search for a perpendicular line length: length of the line """ point = asPoint(point) E = 1e-8 if line.intersects(point): refpoint = point else: r = 16 ...
line: a linestring point: a point within the line at which to search for a perpendicular line length: length of the line
a linestring point: a point within the line at which to search for a perpendicular line length: length of the line
[ "a", "linestring", "point", ":", "a", "point", "within", "the", "line", "at", "which", "to", "search", "for", "a", "perpendicular", "line", "length", ":", "length", "of", "the", "line" ]
def perpendicular_at(line, point, length): point = asPoint(point) E = 1e-8 if line.intersects(point): refpoint = point else: r = 16 while True: refpoint = point.buffer(line.distance(point)+E, resolution=r).exterior.intersection(line) if not refpoint.is_emp...
[ "def", "perpendicular_at", "(", "line", ",", "point", ",", "length", ")", ":", "point", "=", "asPoint", "(", "point", ")", "E", "=", "1e-8", "if", "line", ".", "intersects", "(", "point", ")", ":", "refpoint", "=", "point", "else", ":", "r", "=", "...
line: a linestring point: a point within the line at which to search for a perpendicular line length: length of the line
[ "line", ":", "a", "linestring", "point", ":", "a", "point", "within", "the", "line", "at", "which", "to", "search", "for", "a", "perpendicular", "line", "length", ":", "length", "of", "the", "line" ]
[ "\"\"\"\n line: a linestring\n point: a point within the line at which to search for a perpendicular line\n length: length of the line\n \"\"\"" ]
[ { "param": "line", "type": null }, { "param": "point", "type": null }, { "param": "length", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "line", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "point", "type": null, "docstring": null, "docstring_tokens": ...
cc768bb897a92dbd8b56b8149f00f982b15fdc2d
gesellkammer/shapelib
shapelib/core.py
[ "BSD-3-Clause" ]
Python
line_angle_at
<not_specific>
def line_angle_at(line, point, h=0.001): """ return the angle of `line` at the `point` given. I If point is not in the line, return the angle at the nearest point within the line. """ point = Point(*_normalize_point(point)) if not line.intersects(point): point = nearest_point(line, ...
return the angle of `line` at the `point` given. I If point is not in the line, return the angle at the nearest point within the line.
return the angle of `line` at the `point` given. I If point is not in the line, return the angle at the nearest point within the line.
[ "return", "the", "angle", "of", "`", "line", "`", "at", "the", "`", "point", "`", "given", ".", "I", "If", "point", "is", "not", "in", "the", "line", "return", "the", "angle", "at", "the", "nearest", "point", "within", "the", "line", "." ]
def line_angle_at(line, point, h=0.001): point = Point(*_normalize_point(point)) if not line.intersects(point): point = nearest_point(line, point) bufdist = min(line.length, h) c = point.buffer(bufdist).exterior points = c.intersection(line) if isinstance(points, Point): a = poin...
[ "def", "line_angle_at", "(", "line", ",", "point", ",", "h", "=", "0.001", ")", ":", "point", "=", "Point", "(", "*", "_normalize_point", "(", "point", ")", ")", "if", "not", "line", ".", "intersects", "(", "point", ")", ":", "point", "=", "nearest_p...
return the angle of `line` at the `point` given.
[ "return", "the", "angle", "of", "`", "line", "`", "at", "the", "`", "point", "`", "given", "." ]
[ "\"\"\"\n return the angle of `line` at the `point` given. I\n\n If point is not in the line, return the angle at the\n nearest point within the line.\n \"\"\"", "# only one intersection, point is one of the extremes" ]
[ { "param": "line", "type": null }, { "param": "point", "type": null }, { "param": "h", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "line", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "point", "type": null, "docstring": null, "docstring_tokens": ...
cc768bb897a92dbd8b56b8149f00f982b15fdc2d
gesellkammer/shapelib
shapelib/core.py
[ "BSD-3-Clause" ]
Python
edge
<not_specific>
def edge(geom): """ return a polygon representing the edge of `geom` """ h = 1e-8 try: geomext = geom.exterior except: try: geomext = geom.buffer(h).exterior except: geomext = geom return geomext
return a polygon representing the edge of `geom`
return a polygon representing the edge of `geom`
[ "return", "a", "polygon", "representing", "the", "edge", "of", "`", "geom", "`" ]
def edge(geom): h = 1e-8 try: geomext = geom.exterior except: try: geomext = geom.buffer(h).exterior except: geomext = geom return geomext
[ "def", "edge", "(", "geom", ")", ":", "h", "=", "1e-8", "try", ":", "geomext", "=", "geom", ".", "exterior", "except", ":", "try", ":", "geomext", "=", "geom", ".", "buffer", "(", "h", ")", ".", "exterior", "except", ":", "geomext", "=", "geom", ...
return a polygon representing the edge of `geom`
[ "return", "a", "polygon", "representing", "the", "edge", "of", "`", "geom", "`" ]
[ "\"\"\"\n return a polygon representing the edge of `geom`\n \"\"\"" ]
[ { "param": "geom", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "geom", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cc768bb897a92dbd8b56b8149f00f982b15fdc2d
gesellkammer/shapelib
shapelib/core.py
[ "BSD-3-Clause" ]
Python
holes
<not_specific>
def holes(geom): """ return the geometry which would fill the holes in geom """ return tight_envelope(geom).difference(geom)
return the geometry which would fill the holes in geom
return the geometry which would fill the holes in geom
[ "return", "the", "geometry", "which", "would", "fill", "the", "holes", "in", "geom" ]
def holes(geom): return tight_envelope(geom).difference(geom)
[ "def", "holes", "(", "geom", ")", ":", "return", "tight_envelope", "(", "geom", ")", ".", "difference", "(", "geom", ")" ]
return the geometry which would fill the holes in geom
[ "return", "the", "geometry", "which", "would", "fill", "the", "holes", "in", "geom" ]
[ "\"\"\"\n return the geometry which would fill the holes in geom\n \"\"\"" ]
[ { "param": "geom", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "geom", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cc768bb897a92dbd8b56b8149f00f982b15fdc2d
gesellkammer/shapelib
shapelib/core.py
[ "BSD-3-Clause" ]
Python
tight_envelope
<not_specific>
def tight_envelope(geom): """ return the geometry which builds an envelope around `geom` """ if hasattr(geom, 'geoms'): g0 = max((sub.envelope.area, sub) for sub in geom.geoms)[1] g00 = asPolygon(g0.exterior) elif isinstance(geom, Polygon): g00 = asPolygon(geom.exterior) ...
return the geometry which builds an envelope around `geom`
return the geometry which builds an envelope around `geom`
[ "return", "the", "geometry", "which", "builds", "an", "envelope", "around", "`", "geom", "`" ]
def tight_envelope(geom): if hasattr(geom, 'geoms'): g0 = max((sub.envelope.area, sub) for sub in geom.geoms)[1] g00 = asPolygon(g0.exterior) elif isinstance(geom, Polygon): g00 = asPolygon(geom.exterior) return g00
[ "def", "tight_envelope", "(", "geom", ")", ":", "if", "hasattr", "(", "geom", ",", "'geoms'", ")", ":", "g0", "=", "max", "(", "(", "sub", ".", "envelope", ".", "area", ",", "sub", ")", "for", "sub", "in", "geom", ".", "geoms", ")", "[", "1", "...
return the geometry which builds an envelope around `geom`
[ "return", "the", "geometry", "which", "builds", "an", "envelope", "around", "`", "geom", "`" ]
[ "\"\"\"\n return the geometry which builds an envelope around `geom`\n \"\"\"" ]
[ { "param": "geom", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "geom", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }