repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
mesbahamin/chronophore | chronophore/controller.py | flag_forgotten_entries | def flag_forgotten_entries(session, today=None):
"""Flag any entries from previous days where users forgot to sign
out.
:param session: SQLAlchemy session through which to access the database.
:param today: (optional) The current date as a `datetime.date` object. Used for testing.
""" # noqa
to... | python | def flag_forgotten_entries(session, today=None):
"""Flag any entries from previous days where users forgot to sign
out.
:param session: SQLAlchemy session through which to access the database.
:param today: (optional) The current date as a `datetime.date` object. Used for testing.
""" # noqa
to... | [
"def",
"flag_forgotten_entries",
"(",
"session",
",",
"today",
"=",
"None",
")",
":",
"# noqa",
"today",
"=",
"date",
".",
"today",
"(",
")",
"if",
"today",
"is",
"None",
"else",
"today",
"forgotten",
"=",
"(",
"session",
".",
"query",
"(",
"Entry",
")... | Flag any entries from previous days where users forgot to sign
out.
:param session: SQLAlchemy session through which to access the database.
:param today: (optional) The current date as a `datetime.date` object. Used for testing. | [
"Flag",
"any",
"entries",
"from",
"previous",
"days",
"where",
"users",
"forgot",
"to",
"sign",
"out",
"."
] | ee140c61b4dfada966f078de8304bac737cec6f7 | https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L65-L87 | train | Flag any entries from previous days where users forgot to sign_out out. |
mesbahamin/chronophore | chronophore/controller.py | signed_in_users | def signed_in_users(session=None, today=None, full_name=True):
"""Return list of names of currently signed in users.
:param session: SQLAlchemy session through which to access the database.
:param today: (optional) The current date as a `datetime.date` object. Used for testing.
:param full_name: (optio... | python | def signed_in_users(session=None, today=None, full_name=True):
"""Return list of names of currently signed in users.
:param session: SQLAlchemy session through which to access the database.
:param today: (optional) The current date as a `datetime.date` object. Used for testing.
:param full_name: (optio... | [
"def",
"signed_in_users",
"(",
"session",
"=",
"None",
",",
"today",
"=",
"None",
",",
"full_name",
"=",
"True",
")",
":",
"# noqa",
"if",
"session",
"is",
"None",
":",
"session",
"=",
"Session",
"(",
")",
"else",
":",
"session",
"=",
"session",
"if",
... | Return list of names of currently signed in users.
:param session: SQLAlchemy session through which to access the database.
:param today: (optional) The current date as a `datetime.date` object. Used for testing.
:param full_name: (optional) Whether to display full user names, or just first names.
:ret... | [
"Return",
"list",
"of",
"names",
"of",
"currently",
"signed",
"in",
"users",
"."
] | ee140c61b4dfada966f078de8304bac737cec6f7 | https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L90-L118 | train | Return list of currently signed in users. |
mesbahamin/chronophore | chronophore/controller.py | get_user_name | def get_user_name(user, full_name=True):
"""Return the user's name as a string.
:param user: `models.User` object. The user to get the name of.
:param full_name: (optional) Whether to return full user name, or just first name.
:return: The user's name.
""" # noqa
try:
if full_name:
... | python | def get_user_name(user, full_name=True):
"""Return the user's name as a string.
:param user: `models.User` object. The user to get the name of.
:param full_name: (optional) Whether to return full user name, or just first name.
:return: The user's name.
""" # noqa
try:
if full_name:
... | [
"def",
"get_user_name",
"(",
"user",
",",
"full_name",
"=",
"True",
")",
":",
"# noqa",
"try",
":",
"if",
"full_name",
":",
"name",
"=",
"' '",
".",
"join",
"(",
"[",
"user",
".",
"first_name",
",",
"user",
".",
"last_name",
"]",
")",
"else",
":",
... | Return the user's name as a string.
:param user: `models.User` object. The user to get the name of.
:param full_name: (optional) Whether to return full user name, or just first name.
:return: The user's name. | [
"Return",
"the",
"user",
"s",
"name",
"as",
"a",
"string",
"."
] | ee140c61b4dfada966f078de8304bac737cec6f7 | https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L121-L136 | train | Return the user s name as a string. |
mesbahamin/chronophore | chronophore/controller.py | sign_in | def sign_in(user, user_type=None, date=None, time_in=None):
"""Add a new entry to the timesheet.
:param user: `models.User` object. The user to sign in.
:param user_type: (optional) Specify whether user is signing in as a `'student'` or `'tutor'`.
:param date: (optional) `datetime.date` object. Specify... | python | def sign_in(user, user_type=None, date=None, time_in=None):
"""Add a new entry to the timesheet.
:param user: `models.User` object. The user to sign in.
:param user_type: (optional) Specify whether user is signing in as a `'student'` or `'tutor'`.
:param date: (optional) `datetime.date` object. Specify... | [
"def",
"sign_in",
"(",
"user",
",",
"user_type",
"=",
"None",
",",
"date",
"=",
"None",
",",
"time_in",
"=",
"None",
")",
":",
"# noqa",
"now",
"=",
"datetime",
".",
"today",
"(",
")",
"if",
"date",
"is",
"None",
":",
"date",
"=",
"now",
".",
"da... | Add a new entry to the timesheet.
:param user: `models.User` object. The user to sign in.
:param user_type: (optional) Specify whether user is signing in as a `'student'` or `'tutor'`.
:param date: (optional) `datetime.date` object. Specify the entry date.
:param time_in: (optional) `datetime.time` obj... | [
"Add",
"a",
"new",
"entry",
"to",
"the",
"timesheet",
"."
] | ee140c61b4dfada966f078de8304bac737cec6f7 | https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L139-L174 | train | Add a new entry to the timesheet. |
mesbahamin/chronophore | chronophore/controller.py | sign_out | def sign_out(entry, time_out=None, forgot=False):
"""Sign out of an existing entry in the timesheet. If the user
forgot to sign out, flag the entry.
:param entry: `models.Entry` object. The entry to sign out.
:param time_out: (optional) `datetime.time` object. Specify the sign out time.
:param forg... | python | def sign_out(entry, time_out=None, forgot=False):
"""Sign out of an existing entry in the timesheet. If the user
forgot to sign out, flag the entry.
:param entry: `models.Entry` object. The entry to sign out.
:param time_out: (optional) `datetime.time` object. Specify the sign out time.
:param forg... | [
"def",
"sign_out",
"(",
"entry",
",",
"time_out",
"=",
"None",
",",
"forgot",
"=",
"False",
")",
":",
"# noqa",
"if",
"time_out",
"is",
"None",
":",
"time_out",
"=",
"datetime",
".",
"today",
"(",
")",
".",
"time",
"(",
")",
"if",
"forgot",
":",
"e... | Sign out of an existing entry in the timesheet. If the user
forgot to sign out, flag the entry.
:param entry: `models.Entry` object. The entry to sign out.
:param time_out: (optional) `datetime.time` object. Specify the sign out time.
:param forgot: (optional) If true, user forgot to sign out. Entry wi... | [
"Sign",
"out",
"of",
"an",
"existing",
"entry",
"in",
"the",
"timesheet",
".",
"If",
"the",
"user",
"forgot",
"to",
"sign",
"out",
"flag",
"the",
"entry",
"."
] | ee140c61b4dfada966f078de8304bac737cec6f7 | https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L177-L199 | train | Sign out of an existing entry in the timesheet. |
mesbahamin/chronophore | chronophore/controller.py | undo_sign_in | def undo_sign_in(entry, session=None):
"""Delete a signed in entry.
:param entry: `models.Entry` object. The entry to delete.
:param session: (optional) SQLAlchemy session through which to access the database.
""" # noqa
if session is None:
session = Session()
else:
session = se... | python | def undo_sign_in(entry, session=None):
"""Delete a signed in entry.
:param entry: `models.Entry` object. The entry to delete.
:param session: (optional) SQLAlchemy session through which to access the database.
""" # noqa
if session is None:
session = Session()
else:
session = se... | [
"def",
"undo_sign_in",
"(",
"entry",
",",
"session",
"=",
"None",
")",
":",
"# noqa",
"if",
"session",
"is",
"None",
":",
"session",
"=",
"Session",
"(",
")",
"else",
":",
"session",
"=",
"session",
"entry_to_delete",
"=",
"(",
"session",
".",
"query",
... | Delete a signed in entry.
:param entry: `models.Entry` object. The entry to delete.
:param session: (optional) SQLAlchemy session through which to access the database. | [
"Delete",
"a",
"signed",
"in",
"entry",
"."
] | ee140c61b4dfada966f078de8304bac737cec6f7 | https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L202-L228 | train | Delete a signed in entry. |
mesbahamin/chronophore | chronophore/controller.py | undo_sign_out | def undo_sign_out(entry, session=None):
"""Sign in a signed out entry.
:param entry: `models.Entry` object. The entry to sign back in.
:param session: (optional) SQLAlchemy session through which to access the database.
""" # noqa
if session is None:
session = Session()
else:
ses... | python | def undo_sign_out(entry, session=None):
"""Sign in a signed out entry.
:param entry: `models.Entry` object. The entry to sign back in.
:param session: (optional) SQLAlchemy session through which to access the database.
""" # noqa
if session is None:
session = Session()
else:
ses... | [
"def",
"undo_sign_out",
"(",
"entry",
",",
"session",
"=",
"None",
")",
":",
"# noqa",
"if",
"session",
"is",
"None",
":",
"session",
"=",
"Session",
"(",
")",
"else",
":",
"session",
"=",
"session",
"entry_to_sign_in",
"=",
"(",
"session",
".",
"query",... | Sign in a signed out entry.
:param entry: `models.Entry` object. The entry to sign back in.
:param session: (optional) SQLAlchemy session through which to access the database. | [
"Sign",
"in",
"a",
"signed",
"out",
"entry",
"."
] | ee140c61b4dfada966f078de8304bac737cec6f7 | https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L231-L258 | train | Sign in a signed out entry. |
mesbahamin/chronophore | chronophore/controller.py | sign | def sign(user_id, user_type=None, today=None, session=None):
"""Check user id for validity, then sign user in if they are signed
out, or out if they are signed in.
:param user_id: The ID of the user to sign in or out.
:param user_type: (optional) Specify whether user is signing in as a `'student'` or `... | python | def sign(user_id, user_type=None, today=None, session=None):
"""Check user id for validity, then sign user in if they are signed
out, or out if they are signed in.
:param user_id: The ID of the user to sign in or out.
:param user_type: (optional) Specify whether user is signing in as a `'student'` or `... | [
"def",
"sign",
"(",
"user_id",
",",
"user_type",
"=",
"None",
",",
"today",
"=",
"None",
",",
"session",
"=",
"None",
")",
":",
"# noqa",
"if",
"session",
"is",
"None",
":",
"session",
"=",
"Session",
"(",
")",
"else",
":",
"session",
"=",
"session",... | Check user id for validity, then sign user in if they are signed
out, or out if they are signed in.
:param user_id: The ID of the user to sign in or out.
:param user_type: (optional) Specify whether user is signing in as a `'student'` or `'tutor'`.
:param today: (optional) The current date as a `dateti... | [
"Check",
"user",
"id",
"for",
"validity",
"then",
"sign",
"user",
"in",
"if",
"they",
"are",
"signed",
"out",
"or",
"out",
"if",
"they",
"are",
"signed",
"in",
"."
] | ee140c61b4dfada966f078de8304bac737cec6f7 | https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L261-L330 | train | Signs a user in or out if they are signed in or out. |
pgxcentre/geneparse | geneparse/readers/bgen.py | BGENReader.get_variant_genotypes | def get_variant_genotypes(self, variant):
"""Get the genotypes from a well formed variant instance.
Args:
marker (Variant): A Variant instance.
Returns:
A list of Genotypes instance containing a pointer to the variant as
well as a vector of encoded genotypes... | python | def get_variant_genotypes(self, variant):
"""Get the genotypes from a well formed variant instance.
Args:
marker (Variant): A Variant instance.
Returns:
A list of Genotypes instance containing a pointer to the variant as
well as a vector of encoded genotypes... | [
"def",
"get_variant_genotypes",
"(",
"self",
",",
"variant",
")",
":",
"# The chromosome to search for (if a general one is set, that's the one",
"# we need to search for)",
"chrom",
"=",
"variant",
".",
"chrom",
".",
"name",
"if",
"self",
".",
"chrom",
"is",
"not",
"No... | Get the genotypes from a well formed variant instance.
Args:
marker (Variant): A Variant instance.
Returns:
A list of Genotypes instance containing a pointer to the variant as
well as a vector of encoded genotypes. | [
"Get",
"the",
"genotypes",
"from",
"a",
"well",
"formed",
"variant",
"instance",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/bgen.py#L76-L117 | train | Get the genotypes from a well formed variant. |
pgxcentre/geneparse | geneparse/readers/bgen.py | BGENReader.iter_genotypes | def iter_genotypes(self):
"""Iterates on available markers.
Returns:
Genotypes instances.
"""
for info, dosage in self._bgen.iter_variants():
yield Genotypes(
Variant(
info.name, CHROM_STR_ENCODE.get(info.chrom, info.chrom),
... | python | def iter_genotypes(self):
"""Iterates on available markers.
Returns:
Genotypes instances.
"""
for info, dosage in self._bgen.iter_variants():
yield Genotypes(
Variant(
info.name, CHROM_STR_ENCODE.get(info.chrom, info.chrom),
... | [
"def",
"iter_genotypes",
"(",
"self",
")",
":",
"for",
"info",
",",
"dosage",
"in",
"self",
".",
"_bgen",
".",
"iter_variants",
"(",
")",
":",
"yield",
"Genotypes",
"(",
"Variant",
"(",
"info",
".",
"name",
",",
"CHROM_STR_ENCODE",
".",
"get",
"(",
"in... | Iterates on available markers.
Returns:
Genotypes instances. | [
"Iterates",
"on",
"available",
"markers",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/bgen.py#L119-L136 | train | Iterates on available markers and yields Genotypes instances. |
pgxcentre/geneparse | geneparse/readers/bgen.py | BGENReader.iter_variants | def iter_variants(self):
"""Iterate over marker information."""
for variant in self._bgen.iter_variant_info():
yield Variant(
variant.name,
CHROM_STR_ENCODE.get(variant.chrom, variant.chrom),
variant.pos, [variant.a1, variant.a2],
) | python | def iter_variants(self):
"""Iterate over marker information."""
for variant in self._bgen.iter_variant_info():
yield Variant(
variant.name,
CHROM_STR_ENCODE.get(variant.chrom, variant.chrom),
variant.pos, [variant.a1, variant.a2],
) | [
"def",
"iter_variants",
"(",
"self",
")",
":",
"for",
"variant",
"in",
"self",
".",
"_bgen",
".",
"iter_variant_info",
"(",
")",
":",
"yield",
"Variant",
"(",
"variant",
".",
"name",
",",
"CHROM_STR_ENCODE",
".",
"get",
"(",
"variant",
".",
"chrom",
",",... | Iterate over marker information. | [
"Iterate",
"over",
"marker",
"information",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/bgen.py#L138-L145 | train | Iterate over the variants in the marker information. |
pgxcentre/geneparse | geneparse/readers/bgen.py | BGENReader.get_variants_in_region | def get_variants_in_region(self, chrom, start, end):
"""Iterate over variants in a region."""
if self.chrom is not None and chrom == self.chrom:
# We are going to search for 'NA' since the chromosome was set
chrom = "NA"
iterator = self._bgen.iter_variants_in_region(
... | python | def get_variants_in_region(self, chrom, start, end):
"""Iterate over variants in a region."""
if self.chrom is not None and chrom == self.chrom:
# We are going to search for 'NA' since the chromosome was set
chrom = "NA"
iterator = self._bgen.iter_variants_in_region(
... | [
"def",
"get_variants_in_region",
"(",
"self",
",",
"chrom",
",",
"start",
",",
"end",
")",
":",
"if",
"self",
".",
"chrom",
"is",
"not",
"None",
"and",
"chrom",
"==",
"self",
".",
"chrom",
":",
"# We are going to search for 'NA' since the chromosome was set",
"c... | Iterate over variants in a region. | [
"Iterate",
"over",
"variants",
"in",
"a",
"region",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/bgen.py#L147-L166 | train | Iterate over variants in a region. |
pgxcentre/geneparse | geneparse/readers/bgen.py | BGENReader.iter_variants_by_names | def iter_variants_by_names(self, names):
"""Iterates over the genotypes for variants using a list of names.
Args:
names (list): The list of names for variant extraction.
"""
if not self.is_parallel:
yield from super().iter_variants_by_names(names)
else:... | python | def iter_variants_by_names(self, names):
"""Iterates over the genotypes for variants using a list of names.
Args:
names (list): The list of names for variant extraction.
"""
if not self.is_parallel:
yield from super().iter_variants_by_names(names)
else:... | [
"def",
"iter_variants_by_names",
"(",
"self",
",",
"names",
")",
":",
"if",
"not",
"self",
".",
"is_parallel",
":",
"yield",
"from",
"super",
"(",
")",
".",
"iter_variants_by_names",
"(",
"names",
")",
"else",
":",
"for",
"info",
",",
"dosage",
"in",
"se... | Iterates over the genotypes for variants using a list of names.
Args:
names (list): The list of names for variant extraction. | [
"Iterates",
"over",
"the",
"genotypes",
"for",
"variants",
"using",
"a",
"list",
"of",
"names",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/bgen.py#L168-L188 | train | Iterates over the genotypes for variants using a list of names. |
pgxcentre/geneparse | geneparse/readers/bgen.py | BGENReader.get_variant_by_name | def get_variant_by_name(self, name):
"""Get the genotype of a marker using it's name.
Args:
name (str): The name of the marker.
Returns:
list: A list of Genotypes.
"""
results = []
try:
for info, dosage in self._bgen.get_variant(nam... | python | def get_variant_by_name(self, name):
"""Get the genotype of a marker using it's name.
Args:
name (str): The name of the marker.
Returns:
list: A list of Genotypes.
"""
results = []
try:
for info, dosage in self._bgen.get_variant(nam... | [
"def",
"get_variant_by_name",
"(",
"self",
",",
"name",
")",
":",
"results",
"=",
"[",
"]",
"try",
":",
"for",
"info",
",",
"dosage",
"in",
"self",
".",
"_bgen",
".",
"get_variant",
"(",
"name",
")",
":",
"results",
".",
"append",
"(",
"Genotypes",
"... | Get the genotype of a marker using it's name.
Args:
name (str): The name of the marker.
Returns:
list: A list of Genotypes. | [
"Get",
"the",
"genotype",
"of",
"a",
"marker",
"using",
"it",
"s",
"name",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/bgen.py#L190-L220 | train | Get the genotype of a specific variant using it s name. |
reorx/torext | torext/gevent_wsgi.py | FormattedWSGIHandler.format_request | def format_request(self):
"""Override for better log format
Tornado format:
[INFO 2015-03-24 11:29:57 app:521] 200 GET /static/css/lib/pure-min.css (127.0.0.1) 6.76ms
Current format:
[gevent.wsgi] INFO 127.0.0.1 - - [2015-03-24 11:18:45] "GET /test HTTP/1.1" 200 304 0.000793
... | python | def format_request(self):
"""Override for better log format
Tornado format:
[INFO 2015-03-24 11:29:57 app:521] 200 GET /static/css/lib/pure-min.css (127.0.0.1) 6.76ms
Current format:
[gevent.wsgi] INFO 127.0.0.1 - - [2015-03-24 11:18:45] "GET /test HTTP/1.1" 200 304 0.000793
... | [
"def",
"format_request",
"(",
"self",
")",
":",
"fmt",
"=",
"'{now} {status} {requestline} ({client_address}) {response_length} {delta}ms'",
"requestline",
"=",
"getattr",
"(",
"self",
",",
"'requestline'",
")",
"if",
"requestline",
":",
"# Original \"GET / HTTP/1.1\", remove... | Override for better log format
Tornado format:
[INFO 2015-03-24 11:29:57 app:521] 200 GET /static/css/lib/pure-min.css (127.0.0.1) 6.76ms
Current format:
[gevent.wsgi] INFO 127.0.0.1 - - [2015-03-24 11:18:45] "GET /test HTTP/1.1" 200 304 0.000793 | [
"Override",
"for",
"better",
"log",
"format"
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/gevent_wsgi.py#L21-L52 | train | Override for better log format
|
reorx/torext | torext/gevent_wsgi.py | FormattedWSGIHandler.handle_error | def handle_error(self, type_, value, tb):
"""This method copies the code from pywsgi.WSGIHandler.handle_error,
change the write part to be a reflection of traceback and environ
"""
if not issubclass(type_, pywsgi.GreenletExit):
self.server.loop.handle_error(self.environ, type... | python | def handle_error(self, type_, value, tb):
"""This method copies the code from pywsgi.WSGIHandler.handle_error,
change the write part to be a reflection of traceback and environ
"""
if not issubclass(type_, pywsgi.GreenletExit):
self.server.loop.handle_error(self.environ, type... | [
"def",
"handle_error",
"(",
"self",
",",
"type_",
",",
"value",
",",
"tb",
")",
":",
"if",
"not",
"issubclass",
"(",
"type_",
",",
"pywsgi",
".",
"GreenletExit",
")",
":",
"self",
".",
"server",
".",
"loop",
".",
"handle_error",
"(",
"self",
".",
"en... | This method copies the code from pywsgi.WSGIHandler.handle_error,
change the write part to be a reflection of traceback and environ | [
"This",
"method",
"copies",
"the",
"code",
"from",
"pywsgi",
".",
"WSGIHandler",
".",
"handle_error",
"change",
"the",
"write",
"part",
"to",
"be",
"a",
"reflection",
"of",
"traceback",
"and",
"environ"
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/gevent_wsgi.py#L82-L100 | train | This method copies the code from pywsgi. WSGIHandler. handle_error and writes the error to the response. |
geophysics-ubonn/crtomo_tools | lib/crtomo/configManager.py | ConfigManager.clear_measurements | def clear_measurements(self):
"""Remove all measurements from self.measurements. Reset the
measurement counter. All ID are invalidated.
"""
keys = list(self.measurements.keys())
for key in keys:
del(self.measurements[key])
self.meas_counter = -1 | python | def clear_measurements(self):
"""Remove all measurements from self.measurements. Reset the
measurement counter. All ID are invalidated.
"""
keys = list(self.measurements.keys())
for key in keys:
del(self.measurements[key])
self.meas_counter = -1 | [
"def",
"clear_measurements",
"(",
"self",
")",
":",
"keys",
"=",
"list",
"(",
"self",
".",
"measurements",
".",
"keys",
"(",
")",
")",
"for",
"key",
"in",
"keys",
":",
"del",
"(",
"self",
".",
"measurements",
"[",
"key",
"]",
")",
"self",
".",
"mea... | Remove all measurements from self.measurements. Reset the
measurement counter. All ID are invalidated. | [
"Remove",
"all",
"measurements",
"from",
"self",
".",
"measurements",
".",
"Reset",
"the",
"measurement",
"counter",
".",
"All",
"ID",
"are",
"invalidated",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L56-L63 | train | Remove all measurements from self. measurements. Reset the
measurement counter. All ID is invalidated. |
geophysics-ubonn/crtomo_tools | lib/crtomo/configManager.py | ConfigManager.add_measurements | def add_measurements(self, measurements):
"""Add new measurements to this instance
Parameters
----------
measurements: numpy.ndarray
one or more measurement sets. It must either be 1D or 2D, with the
first dimension the number of measurement sets (K), and the sec... | python | def add_measurements(self, measurements):
"""Add new measurements to this instance
Parameters
----------
measurements: numpy.ndarray
one or more measurement sets. It must either be 1D or 2D, with the
first dimension the number of measurement sets (K), and the sec... | [
"def",
"add_measurements",
"(",
"self",
",",
"measurements",
")",
":",
"subdata",
"=",
"np",
".",
"atleast_2d",
"(",
"measurements",
")",
"if",
"self",
".",
"configs",
"is",
"None",
":",
"raise",
"Exception",
"(",
"'must read in configuration before measurements c... | Add new measurements to this instance
Parameters
----------
measurements: numpy.ndarray
one or more measurement sets. It must either be 1D or 2D, with the
first dimension the number of measurement sets (K), and the second
the number of measurements (N): K x N... | [
"Add",
"new",
"measurements",
"to",
"this",
"instance"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L120-L173 | train | Add new measurements to this instance. |
geophysics-ubonn/crtomo_tools | lib/crtomo/configManager.py | ConfigManager.gen_all_voltages_for_injections | def gen_all_voltages_for_injections(self, injections_raw):
"""For a given set of current injections AB, generate all possible
unique potential measurements.
After Noel and Xu, 1991, for N electrodes, the number of possible
voltage dipoles for a given current dipole is :math:`(N - 2)(N -... | python | def gen_all_voltages_for_injections(self, injections_raw):
"""For a given set of current injections AB, generate all possible
unique potential measurements.
After Noel and Xu, 1991, for N electrodes, the number of possible
voltage dipoles for a given current dipole is :math:`(N - 2)(N -... | [
"def",
"gen_all_voltages_for_injections",
"(",
"self",
",",
"injections_raw",
")",
":",
"injections",
"=",
"injections_raw",
".",
"astype",
"(",
"int",
")",
"N",
"=",
"self",
".",
"nr_electrodes",
"all_quadpoles",
"=",
"[",
"]",
"for",
"idipole",
"in",
"inject... | For a given set of current injections AB, generate all possible
unique potential measurements.
After Noel and Xu, 1991, for N electrodes, the number of possible
voltage dipoles for a given current dipole is :math:`(N - 2)(N - 3) /
2`. This includes normal and reciprocal measurements.
... | [
"For",
"a",
"given",
"set",
"of",
"current",
"injections",
"AB",
"generate",
"all",
"possible",
"unique",
"potential",
"measurements",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L893-L954 | train | This function generates all possible measurements for a given set of current injections. This function generates all possible measurements for the given set of current injections. |
geophysics-ubonn/crtomo_tools | lib/crtomo/configManager.py | ConfigManager.gen_wenner | def gen_wenner(self, a):
"""Generate Wenner measurement configurations.
Parameters
----------
a: int
distance (in electrodes) between subsequent electrodes of each
four-point configuration.
Returns
-------
configs: Kx4 numpy.ndarray
... | python | def gen_wenner(self, a):
"""Generate Wenner measurement configurations.
Parameters
----------
a: int
distance (in electrodes) between subsequent electrodes of each
four-point configuration.
Returns
-------
configs: Kx4 numpy.ndarray
... | [
"def",
"gen_wenner",
"(",
"self",
",",
"a",
")",
":",
"configs",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"self",
".",
"nr_electrodes",
"-",
"3",
"*",
"a",
"+",
"1",
")",
":",
"configs",
".",
"append",
"(",
"(",
"i",
",",
"i",... | Generate Wenner measurement configurations.
Parameters
----------
a: int
distance (in electrodes) between subsequent electrodes of each
four-point configuration.
Returns
-------
configs: Kx4 numpy.ndarray
array holding the configurati... | [
"Generate",
"Wenner",
"measurement",
"configurations",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L1108-L1129 | train | Generate the Wenner measurement configurations. |
geophysics-ubonn/crtomo_tools | lib/crtomo/configManager.py | ConfigManager.gen_reciprocals | def gen_reciprocals(self, quadrupoles):
"""For a given set of quadrupoles, generate and return reciprocals
"""
reciprocals = quadrupoles[:, ::-1].copy()
reciprocals[:, 0:2] = np.sort(reciprocals[:, 0:2], axis=1)
reciprocals[:, 2:4] = np.sort(reciprocals[:, 2:4], axis=1)
r... | python | def gen_reciprocals(self, quadrupoles):
"""For a given set of quadrupoles, generate and return reciprocals
"""
reciprocals = quadrupoles[:, ::-1].copy()
reciprocals[:, 0:2] = np.sort(reciprocals[:, 0:2], axis=1)
reciprocals[:, 2:4] = np.sort(reciprocals[:, 2:4], axis=1)
r... | [
"def",
"gen_reciprocals",
"(",
"self",
",",
"quadrupoles",
")",
":",
"reciprocals",
"=",
"quadrupoles",
"[",
":",
",",
":",
":",
"-",
"1",
"]",
".",
"copy",
"(",
")",
"reciprocals",
"[",
":",
",",
"0",
":",
"2",
"]",
"=",
"np",
".",
"sort",
"(",
... | For a given set of quadrupoles, generate and return reciprocals | [
"For",
"a",
"given",
"set",
"of",
"quadrupoles",
"generate",
"and",
"return",
"reciprocals"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L1253-L1259 | train | Generate and return the reciprocals for a given set of quadrupoles |
geophysics-ubonn/crtomo_tools | lib/crtomo/configManager.py | ConfigManager.plot_error_pars | def plot_error_pars(self, mid):
""" ???
"""
fig, axes = plt.subplots(1, 2, figsize=(10, 6))
def plot_error_pars(axes, a, b, R, label=''):
dR = a * R + b
dlogR = np.abs(a + b / R)
ax = axes[0]
ax.scatter(R, dR / R * 100, label=label)
... | python | def plot_error_pars(self, mid):
""" ???
"""
fig, axes = plt.subplots(1, 2, figsize=(10, 6))
def plot_error_pars(axes, a, b, R, label=''):
dR = a * R + b
dlogR = np.abs(a + b / R)
ax = axes[0]
ax.scatter(R, dR / R * 100, label=label)
... | [
"def",
"plot_error_pars",
"(",
"self",
",",
"mid",
")",
":",
"fig",
",",
"axes",
"=",
"plt",
".",
"subplots",
"(",
"1",
",",
"2",
",",
"figsize",
"=",
"(",
"10",
",",
"6",
")",
")",
"def",
"plot_error_pars",
"(",
"axes",
",",
"a",
",",
"b",
","... | ??? | [
"???"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L1261-L1297 | train | Plot error parameters for a single object. |
geophysics-ubonn/crtomo_tools | lib/crtomo/configManager.py | ConfigManager.compute_K_factors | def compute_K_factors(self, spacing=None, configs=None, numerical=False,
elem_file=None, elec_file=None):
"""Compute analytical geometrical factors.
TODO: use real electrode positions from self.grid
"""
if configs is None:
use_configs = self.configs... | python | def compute_K_factors(self, spacing=None, configs=None, numerical=False,
elem_file=None, elec_file=None):
"""Compute analytical geometrical factors.
TODO: use real electrode positions from self.grid
"""
if configs is None:
use_configs = self.configs... | [
"def",
"compute_K_factors",
"(",
"self",
",",
"spacing",
"=",
"None",
",",
"configs",
"=",
"None",
",",
"numerical",
"=",
"False",
",",
"elem_file",
"=",
"None",
",",
"elec_file",
"=",
"None",
")",
":",
"if",
"configs",
"is",
"None",
":",
"use_configs",
... | Compute analytical geometrical factors.
TODO: use real electrode positions from self.grid | [
"Compute",
"analytical",
"geometrical",
"factors",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L1299-L1319 | train | Compute analytical geometrical factors. |
geophysics-ubonn/crtomo_tools | lib/crtomo/configManager.py | ConfigManager.plot_pseudosection_type2 | def plot_pseudosection_type2(self, mid, **kwargs):
"""Create a pseudosection plot of type 2.
For a given measurement data set, create plots that graphically show
the data in a 2D color plot. Hereby, x and y coordinates in the plot
are determined by the current dipole (x-axis) and voltag... | python | def plot_pseudosection_type2(self, mid, **kwargs):
"""Create a pseudosection plot of type 2.
For a given measurement data set, create plots that graphically show
the data in a 2D color plot. Hereby, x and y coordinates in the plot
are determined by the current dipole (x-axis) and voltag... | [
"def",
"plot_pseudosection_type2",
"(",
"self",
",",
"mid",
",",
"*",
"*",
"kwargs",
")",
":",
"c",
"=",
"self",
".",
"configs",
"AB_ids",
"=",
"self",
".",
"_get_unique_identifiers",
"(",
"c",
"[",
":",
",",
"0",
":",
"2",
"]",
")",
"MN_ids",
"=",
... | Create a pseudosection plot of type 2.
For a given measurement data set, create plots that graphically show
the data in a 2D color plot. Hereby, x and y coordinates in the plot
are determined by the current dipole (x-axis) and voltage dipole
(y-axis) of the corresponding measurement con... | [
"Create",
"a",
"pseudosection",
"plot",
"of",
"type",
"2",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L1456-L1694 | train | Create a pseudosection plot of type 2 for a given measurement data set. |
geophysics-ubonn/crtomo_tools | lib/crtomo/configManager.py | ConfigManager.gen_voltage_dipoles_skip | def gen_voltage_dipoles_skip(self, cinj, skip=0):
"""For given current injections, generate all possible voltage dipoles
with skip **skip**.
Parameters
----------
cinj : :py:class:`numpy.ndarray`
Nx2 array containing the current injection electrodes a,b
skip ... | python | def gen_voltage_dipoles_skip(self, cinj, skip=0):
"""For given current injections, generate all possible voltage dipoles
with skip **skip**.
Parameters
----------
cinj : :py:class:`numpy.ndarray`
Nx2 array containing the current injection electrodes a,b
skip ... | [
"def",
"gen_voltage_dipoles_skip",
"(",
"self",
",",
"cinj",
",",
"skip",
"=",
"0",
")",
":",
"new_configs",
"=",
"[",
"]",
"for",
"ab",
"in",
"cinj",
":",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"self",
".",
"nr_electrodes",
"+",
"1",
")",
":",
... | For given current injections, generate all possible voltage dipoles
with skip **skip**.
Parameters
----------
cinj : :py:class:`numpy.ndarray`
Nx2 array containing the current injection electrodes a,b
skip : int, optional
Skip used for voltage electrodes.... | [
"For",
"given",
"current",
"injections",
"generate",
"all",
"possible",
"voltage",
"dipoles",
"with",
"skip",
"**",
"skip",
"**",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L1705-L1729 | train | Generate all possible voltage dipoles for given current injections. |
albert12132/templar | templar/api/rules/core.py | Rule.applies | def applies(self, src, dst):
"""Checks if this rule applies to the given src and dst paths, based on the src pattern and
dst pattern given in the constructor.
If src pattern was None, this rule will apply to any given src path (same for dst).
"""
if self._src_pattern and (src is... | python | def applies(self, src, dst):
"""Checks if this rule applies to the given src and dst paths, based on the src pattern and
dst pattern given in the constructor.
If src pattern was None, this rule will apply to any given src path (same for dst).
"""
if self._src_pattern and (src is... | [
"def",
"applies",
"(",
"self",
",",
"src",
",",
"dst",
")",
":",
"if",
"self",
".",
"_src_pattern",
"and",
"(",
"src",
"is",
"None",
"or",
"re",
".",
"search",
"(",
"self",
".",
"_src_pattern",
",",
"src",
")",
"is",
"None",
")",
":",
"return",
"... | Checks if this rule applies to the given src and dst paths, based on the src pattern and
dst pattern given in the constructor.
If src pattern was None, this rule will apply to any given src path (same for dst). | [
"Checks",
"if",
"this",
"rule",
"applies",
"to",
"the",
"given",
"src",
"and",
"dst",
"paths",
"based",
"on",
"the",
"src",
"pattern",
"and",
"dst",
"pattern",
"given",
"in",
"the",
"constructor",
"."
] | 39851c89730ab69e5c73d0a46adca2a44ecc4165 | https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/api/rules/core.py#L33-L43 | train | Checks if this rule applies to the given src and dst paths based on the src pattern and dst pattern given in the constructor. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/proxy.py | ProxyCommand.recv | def recv(self, size):
"""
Read from the standard output of the forked program.
:param int size: how many chars should be read
:return: the length of the read content, as an `int`
"""
try:
start = datetime.now()
while len(self.buffer) < size:
... | python | def recv(self, size):
"""
Read from the standard output of the forked program.
:param int size: how many chars should be read
:return: the length of the read content, as an `int`
"""
try:
start = datetime.now()
while len(self.buffer) < size:
... | [
"def",
"recv",
"(",
"self",
",",
"size",
")",
":",
"try",
":",
"start",
"=",
"datetime",
".",
"now",
"(",
")",
"while",
"len",
"(",
"self",
".",
"buffer",
")",
"<",
"size",
":",
"if",
"self",
".",
"timeout",
"is",
"not",
"None",
":",
"elapsed",
... | Read from the standard output of the forked program.
:param int size: how many chars should be read
:return: the length of the read content, as an `int` | [
"Read",
"from",
"the",
"standard",
"output",
"of",
"the",
"forked",
"program",
"."
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/proxy.py#L70-L99 | train | Read from the forked program and return the length of the read content. |
NJDFan/ctypes-bitfield | bitfield/walk.py | _createunbound | def _createunbound(kls, **info):
"""Create a new UnboundNode representing a given class."""
if issubclass(kls, Bitfield):
nodetype = UnboundBitfieldNode
elif hasattr(kls, '_fields_'):
nodetype = UnboundStructureNode
elif issubclass(kls, ctypes.Array):
nodetype = UnboundArray... | python | def _createunbound(kls, **info):
"""Create a new UnboundNode representing a given class."""
if issubclass(kls, Bitfield):
nodetype = UnboundBitfieldNode
elif hasattr(kls, '_fields_'):
nodetype = UnboundStructureNode
elif issubclass(kls, ctypes.Array):
nodetype = UnboundArray... | [
"def",
"_createunbound",
"(",
"kls",
",",
"*",
"*",
"info",
")",
":",
"if",
"issubclass",
"(",
"kls",
",",
"Bitfield",
")",
":",
"nodetype",
"=",
"UnboundBitfieldNode",
"elif",
"hasattr",
"(",
"kls",
",",
"'_fields_'",
")",
":",
"nodetype",
"=",
"Unbound... | Create a new UnboundNode representing a given class. | [
"Create",
"a",
"new",
"UnboundNode",
"representing",
"a",
"given",
"class",
"."
] | ae76b1dcfef7ecc90bd1900735b94ddee41a6376 | https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L240-L251 | train | Create a new UnboundNode representing a given class. |
NJDFan/ctypes-bitfield | bitfield/walk.py | _createbound | def _createbound(obj):
"""Create a new BoundNode representing a given object."""
# Start by allowing objects to define custom unbound reference hooks
try:
kls = obj._unboundreference_()
except AttributeError:
kls = type(obj)
unbound = _createunbound(kls)
def valueget():
... | python | def _createbound(obj):
"""Create a new BoundNode representing a given object."""
# Start by allowing objects to define custom unbound reference hooks
try:
kls = obj._unboundreference_()
except AttributeError:
kls = type(obj)
unbound = _createunbound(kls)
def valueget():
... | [
"def",
"_createbound",
"(",
"obj",
")",
":",
"# Start by allowing objects to define custom unbound reference hooks",
"try",
":",
"kls",
"=",
"obj",
".",
"_unboundreference_",
"(",
")",
"except",
"AttributeError",
":",
"kls",
"=",
"type",
"(",
"obj",
")",
"unbound",
... | Create a new BoundNode representing a given object. | [
"Create",
"a",
"new",
"BoundNode",
"representing",
"a",
"given",
"object",
"."
] | ae76b1dcfef7ecc90bd1900735b94ddee41a6376 | https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L361-L380 | train | Create a new BoundNode representing a given object. |
NJDFan/ctypes-bitfield | bitfield/walk.py | findnode | def findnode(obj, path=''):
"""Returns a Node pointing to obj.
If obj is a ctypes-derived class, an UnboundNode is returned. If obj is
an instance of such a class, then a BoundNode will be returned.
If the optional path is provided, it is a string to look up searching
down the original so... | python | def findnode(obj, path=''):
"""Returns a Node pointing to obj.
If obj is a ctypes-derived class, an UnboundNode is returned. If obj is
an instance of such a class, then a BoundNode will be returned.
If the optional path is provided, it is a string to look up searching
down the original so... | [
"def",
"findnode",
"(",
"obj",
",",
"path",
"=",
"''",
")",
":",
"if",
"isclass",
"(",
"obj",
")",
":",
"node",
"=",
"_createunbound",
"(",
"obj",
")",
"else",
":",
"node",
"=",
"_createbound",
"(",
"obj",
")",
"# And walk it down.",
"pathparts",
"=",
... | Returns a Node pointing to obj.
If obj is a ctypes-derived class, an UnboundNode is returned. If obj is
an instance of such a class, then a BoundNode will be returned.
If the optional path is provided, it is a string to look up searching
down the original source node, such as '.overhead.windo... | [
"Returns",
"a",
"Node",
"pointing",
"to",
"obj",
".",
"If",
"obj",
"is",
"a",
"ctypes",
"-",
"derived",
"class",
"an",
"UnboundNode",
"is",
"returned",
".",
"If",
"obj",
"is",
"an",
"instance",
"of",
"such",
"a",
"class",
"then",
"a",
"BoundNode",
"wil... | ae76b1dcfef7ecc90bd1900735b94ddee41a6376 | https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L474-L497 | train | Returns a Node pointing to obj. |
NJDFan/ctypes-bitfield | bitfield/walk.py | display | def display(obj, skiphidden=True, **printargs):
"""Print a view of obj, where obj is either a ctypes-derived class or an
instance of such a class. Any additional keyword arguments are passed
directly to the print function.
This is mostly useful to introspect structures from an interactive session.... | python | def display(obj, skiphidden=True, **printargs):
"""Print a view of obj, where obj is either a ctypes-derived class or an
instance of such a class. Any additional keyword arguments are passed
directly to the print function.
This is mostly useful to introspect structures from an interactive session.... | [
"def",
"display",
"(",
"obj",
",",
"skiphidden",
"=",
"True",
",",
"*",
"*",
"printargs",
")",
":",
"top",
"=",
"findnode",
"(",
"obj",
")",
"#-------------------------------------------------------------------",
"# Iterate through the entire structure turning all the nodes... | Print a view of obj, where obj is either a ctypes-derived class or an
instance of such a class. Any additional keyword arguments are passed
directly to the print function.
This is mostly useful to introspect structures from an interactive session. | [
"Print",
"a",
"view",
"of",
"obj",
"where",
"obj",
"is",
"either",
"a",
"ctypes",
"-",
"derived",
"class",
"or",
"an",
"instance",
"of",
"such",
"a",
"class",
".",
"Any",
"additional",
"keyword",
"arguments",
"are",
"passed",
"directly",
"to",
"the",
"pr... | ae76b1dcfef7ecc90bd1900735b94ddee41a6376 | https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L507-L567 | train | Print a view of obj. |
NJDFan/ctypes-bitfield | bitfield/walk.py | walknode | def walknode(top, skiphidden=True):
"""Returns a recursive iterator over all Nodes under top.
If skiphidden is True (the default) then structure branches starting with
an underscore will be ignored.
"""
if skiphidden and top.name.startswith('._'):
return
yield top
for c... | python | def walknode(top, skiphidden=True):
"""Returns a recursive iterator over all Nodes under top.
If skiphidden is True (the default) then structure branches starting with
an underscore will be ignored.
"""
if skiphidden and top.name.startswith('._'):
return
yield top
for c... | [
"def",
"walknode",
"(",
"top",
",",
"skiphidden",
"=",
"True",
")",
":",
"if",
"skiphidden",
"and",
"top",
".",
"name",
".",
"startswith",
"(",
"'._'",
")",
":",
"return",
"yield",
"top",
"for",
"child",
"in",
"top",
":",
"for",
"c",
"in",
"walknode"... | Returns a recursive iterator over all Nodes under top.
If skiphidden is True (the default) then structure branches starting with
an underscore will be ignored. | [
"Returns",
"a",
"recursive",
"iterator",
"over",
"all",
"Nodes",
"under",
"top",
".",
"If",
"skiphidden",
"is",
"True",
"(",
"the",
"default",
")",
"then",
"structure",
"branches",
"starting",
"with",
"an",
"underscore",
"will",
"be",
"ignored",
"."
] | ae76b1dcfef7ecc90bd1900735b94ddee41a6376 | https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L569-L581 | train | Returns an iterator over all Nodes under top. |
NJDFan/ctypes-bitfield | bitfield/walk.py | walk | def walk(obj, path='', skiphidden=True):
"""Returns a recursive iterator over all Nodes starting from
findnode(obj, path).
If skiphidden is True (the default) then structure branches starting with
an underscore will be ignored.
"""
node = findnode(obj, path)
return walknode(node, s... | python | def walk(obj, path='', skiphidden=True):
"""Returns a recursive iterator over all Nodes starting from
findnode(obj, path).
If skiphidden is True (the default) then structure branches starting with
an underscore will be ignored.
"""
node = findnode(obj, path)
return walknode(node, s... | [
"def",
"walk",
"(",
"obj",
",",
"path",
"=",
"''",
",",
"skiphidden",
"=",
"True",
")",
":",
"node",
"=",
"findnode",
"(",
"obj",
",",
"path",
")",
"return",
"walknode",
"(",
"node",
",",
"skiphidden",
")"
] | Returns a recursive iterator over all Nodes starting from
findnode(obj, path).
If skiphidden is True (the default) then structure branches starting with
an underscore will be ignored. | [
"Returns",
"a",
"recursive",
"iterator",
"over",
"all",
"Nodes",
"starting",
"from",
"findnode",
"(",
"obj",
"path",
")",
".",
"If",
"skiphidden",
"is",
"True",
"(",
"the",
"default",
")",
"then",
"structure",
"branches",
"starting",
"with",
"an",
"underscor... | ae76b1dcfef7ecc90bd1900735b94ddee41a6376 | https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L583-L592 | train | Returns a recursive iterator over all Nodes starting from the given path. |
NJDFan/ctypes-bitfield | bitfield/walk.py | Node.parents | def parents(self):
"""A list of all the parent nodes of this node, back to the root.
parents[0] is the root, and parents[-1] is the immediate parent.
"""
try:
parents = self.parent.parents
parents.append(self.parent)
except AttributeError:
pare... | python | def parents(self):
"""A list of all the parent nodes of this node, back to the root.
parents[0] is the root, and parents[-1] is the immediate parent.
"""
try:
parents = self.parent.parents
parents.append(self.parent)
except AttributeError:
pare... | [
"def",
"parents",
"(",
"self",
")",
":",
"try",
":",
"parents",
"=",
"self",
".",
"parent",
".",
"parents",
"parents",
".",
"append",
"(",
"self",
".",
"parent",
")",
"except",
"AttributeError",
":",
"parents",
"=",
"[",
"]",
"return",
"parents"
] | A list of all the parent nodes of this node, back to the root.
parents[0] is the root, and parents[-1] is the immediate parent. | [
"A",
"list",
"of",
"all",
"the",
"parent",
"nodes",
"of",
"this",
"node",
"back",
"to",
"the",
"root",
".",
"parents",
"[",
"0",
"]",
"is",
"the",
"root",
"and",
"parents",
"[",
"-",
"1",
"]",
"is",
"the",
"immediate",
"parent",
"."
] | ae76b1dcfef7ecc90bd1900735b94ddee41a6376 | https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L152-L161 | train | A list of all the parent nodes of this node back to the root. |
NJDFan/ctypes-bitfield | bitfield/walk.py | Node.pathparts | def pathparts(self):
"""A list of the parts of the path, with the root node returning
an empty list.
"""
try:
parts = self.parent.pathparts()
parts.append(self.name)
return parts
except AttributeError:
return [] | python | def pathparts(self):
"""A list of the parts of the path, with the root node returning
an empty list.
"""
try:
parts = self.parent.pathparts()
parts.append(self.name)
return parts
except AttributeError:
return [] | [
"def",
"pathparts",
"(",
"self",
")",
":",
"try",
":",
"parts",
"=",
"self",
".",
"parent",
".",
"pathparts",
"(",
")",
"parts",
".",
"append",
"(",
"self",
".",
"name",
")",
"return",
"parts",
"except",
"AttributeError",
":",
"return",
"[",
"]"
] | A list of the parts of the path, with the root node returning
an empty list. | [
"A",
"list",
"of",
"the",
"parts",
"of",
"the",
"path",
"with",
"the",
"root",
"node",
"returning",
"an",
"empty",
"list",
"."
] | ae76b1dcfef7ecc90bd1900735b94ddee41a6376 | https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L166-L175 | train | A list of the parts of the path returning the root node returning
an empty list. |
NJDFan/ctypes-bitfield | bitfield/walk.py | Node.baseoffset | def baseoffset(self):
"""The offset of this node from the root node."""
try:
return self.parent.baseoffset + self.offset
except AttributeError:
return self.offset | python | def baseoffset(self):
"""The offset of this node from the root node."""
try:
return self.parent.baseoffset + self.offset
except AttributeError:
return self.offset | [
"def",
"baseoffset",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"parent",
".",
"baseoffset",
"+",
"self",
".",
"offset",
"except",
"AttributeError",
":",
"return",
"self",
".",
"offset"
] | The offset of this node from the root node. | [
"The",
"offset",
"of",
"this",
"node",
"from",
"the",
"root",
"node",
"."
] | ae76b1dcfef7ecc90bd1900735b94ddee41a6376 | https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L192-L197 | train | The offset of this node from the root node. |
geophysics-ubonn/crtomo_tools | src/grid_translate_model.py | _almost_equal | def _almost_equal(a, b):
"""Check if the two numbers are almost equal
"""
# arbitrary small number!!!
threshold = 1e-9
diff = np.abs(a - b)
return (diff < threshold) | python | def _almost_equal(a, b):
"""Check if the two numbers are almost equal
"""
# arbitrary small number!!!
threshold = 1e-9
diff = np.abs(a - b)
return (diff < threshold) | [
"def",
"_almost_equal",
"(",
"a",
",",
"b",
")",
":",
"# arbitrary small number!!!",
"threshold",
"=",
"1e-9",
"diff",
"=",
"np",
".",
"abs",
"(",
"a",
"-",
"b",
")",
"return",
"(",
"diff",
"<",
"threshold",
")"
] | Check if the two numbers are almost equal | [
"Check",
"if",
"the",
"two",
"numbers",
"are",
"almost",
"equal"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/grid_translate_model.py#L62-L68 | train | Check if two numbers are almost equal. |
pgxcentre/geneparse | geneparse/core.py | Variant.complement_alleles | def complement_alleles(self):
"""Complement the alleles of this variant.
This will call this module's `complement_alleles` function.
Note that this will not create a new object, but modify the state of
the current instance.
"""
self.alleles = self._encode_alleles(
... | python | def complement_alleles(self):
"""Complement the alleles of this variant.
This will call this module's `complement_alleles` function.
Note that this will not create a new object, but modify the state of
the current instance.
"""
self.alleles = self._encode_alleles(
... | [
"def",
"complement_alleles",
"(",
"self",
")",
":",
"self",
".",
"alleles",
"=",
"self",
".",
"_encode_alleles",
"(",
"[",
"complement_alleles",
"(",
"i",
")",
"for",
"i",
"in",
"self",
".",
"alleles",
"]",
")"
] | Complement the alleles of this variant.
This will call this module's `complement_alleles` function.
Note that this will not create a new object, but modify the state of
the current instance. | [
"Complement",
"the",
"alleles",
"of",
"this",
"variant",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/core.py#L139-L150 | train | Complement the alleles of this variant. |
pgxcentre/geneparse | geneparse/core.py | Genotypes.flip_coded | def flip_coded(self):
"""Flips the coding of the alleles."""
self.genotypes = 2 - self.genotypes
self.reference, self.coded = self.coded, self.reference | python | def flip_coded(self):
"""Flips the coding of the alleles."""
self.genotypes = 2 - self.genotypes
self.reference, self.coded = self.coded, self.reference | [
"def",
"flip_coded",
"(",
"self",
")",
":",
"self",
".",
"genotypes",
"=",
"2",
"-",
"self",
".",
"genotypes",
"self",
".",
"reference",
",",
"self",
".",
"coded",
"=",
"self",
".",
"coded",
",",
"self",
".",
"reference"
] | Flips the coding of the alleles. | [
"Flips",
"the",
"coding",
"of",
"the",
"alleles",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/core.py#L229-L232 | train | Flips the coding of the alleles. |
pgxcentre/geneparse | geneparse/core.py | Genotypes.flip_strand | def flip_strand(self):
"""Flips the strand of the alleles."""
self.reference = complement_alleles(self.reference)
self.coded = complement_alleles(self.coded)
self.variant.complement_alleles() | python | def flip_strand(self):
"""Flips the strand of the alleles."""
self.reference = complement_alleles(self.reference)
self.coded = complement_alleles(self.coded)
self.variant.complement_alleles() | [
"def",
"flip_strand",
"(",
"self",
")",
":",
"self",
".",
"reference",
"=",
"complement_alleles",
"(",
"self",
".",
"reference",
")",
"self",
".",
"coded",
"=",
"complement_alleles",
"(",
"self",
".",
"coded",
")",
"self",
".",
"variant",
".",
"complement_... | Flips the strand of the alleles. | [
"Flips",
"the",
"strand",
"of",
"the",
"alleles",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/core.py#L234-L238 | train | Flips the strand of the alleles. |
pgxcentre/geneparse | geneparse/core.py | GenotypesReader.iter_variants_by_names | def iter_variants_by_names(self, names):
"""Iterates over the genotypes for variants using a list of names.
Args:
names (list): The list of names for variant extraction.
"""
for name in names:
for result in self.get_variant_by_name(name):
yield r... | python | def iter_variants_by_names(self, names):
"""Iterates over the genotypes for variants using a list of names.
Args:
names (list): The list of names for variant extraction.
"""
for name in names:
for result in self.get_variant_by_name(name):
yield r... | [
"def",
"iter_variants_by_names",
"(",
"self",
",",
"names",
")",
":",
"for",
"name",
"in",
"names",
":",
"for",
"result",
"in",
"self",
".",
"get_variant_by_name",
"(",
"name",
")",
":",
"yield",
"result"
] | Iterates over the genotypes for variants using a list of names.
Args:
names (list): The list of names for variant extraction. | [
"Iterates",
"over",
"the",
"genotypes",
"for",
"variants",
"using",
"a",
"list",
"of",
"names",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/core.py#L456-L465 | train | Iterates over the genotypes for variants using a list of names. |
aglie/meerkat | meerkat/det2lab_xds.py | rotvec2mat | def rotvec2mat(u, phi):
"""Convert rotation from axis and angle to matrix representation"""
phi = np.squeeze(phi)
norm_u = np.linalg.norm(u)
if norm_u < 1e-12:
raise Exception("the rotation vector is equal to zero")
u = u / norm_u
# http://en.wikipedia.org/wiki/Rotation_matrix
s =... | python | def rotvec2mat(u, phi):
"""Convert rotation from axis and angle to matrix representation"""
phi = np.squeeze(phi)
norm_u = np.linalg.norm(u)
if norm_u < 1e-12:
raise Exception("the rotation vector is equal to zero")
u = u / norm_u
# http://en.wikipedia.org/wiki/Rotation_matrix
s =... | [
"def",
"rotvec2mat",
"(",
"u",
",",
"phi",
")",
":",
"phi",
"=",
"np",
".",
"squeeze",
"(",
"phi",
")",
"norm_u",
"=",
"np",
".",
"linalg",
".",
"norm",
"(",
"u",
")",
"if",
"norm_u",
"<",
"1e-12",
":",
"raise",
"Exception",
"(",
"\"the rotation ve... | Convert rotation from axis and angle to matrix representation | [
"Convert",
"rotation",
"from",
"axis",
"and",
"angle",
"to",
"matrix",
"representation"
] | f056a3da7ed3d7cd43edb56a38903cfa146e4b24 | https://github.com/aglie/meerkat/blob/f056a3da7ed3d7cd43edb56a38903cfa146e4b24/meerkat/det2lab_xds.py#L4-L26 | train | Convert rotation from axis and angle to matrix representation |
aglie/meerkat | meerkat/det2lab_xds.py | det2lab_xds | def det2lab_xds(
pixels_coord, frame_number,
starting_frame, starting_angle, oscillation_angle,
rotation_axis,
wavelength, wavevector,
NX, NY, pixelsize_x, pixelsize_y,
distance_to_detector, x_center, y_center,
detector_x, detector_y, detector_normal, **kwargs):
... | python | def det2lab_xds(
pixels_coord, frame_number,
starting_frame, starting_angle, oscillation_angle,
rotation_axis,
wavelength, wavevector,
NX, NY, pixelsize_x, pixelsize_y,
distance_to_detector, x_center, y_center,
detector_x, detector_y, detector_normal, **kwargs):
... | [
"def",
"det2lab_xds",
"(",
"pixels_coord",
",",
"frame_number",
",",
"starting_frame",
",",
"starting_angle",
",",
"oscillation_angle",
",",
"rotation_axis",
",",
"wavelength",
",",
"wavevector",
",",
"NX",
",",
"NY",
",",
"pixelsize_x",
",",
"pixelsize_y",
",",
... | Converts pixels coordinates from the frame into q-vector | [
"Converts",
"pixels",
"coordinates",
"from",
"the",
"frame",
"into",
"q",
"-",
"vector"
] | f056a3da7ed3d7cd43edb56a38903cfa146e4b24 | https://github.com/aglie/meerkat/blob/f056a3da7ed3d7cd43edb56a38903cfa146e4b24/meerkat/det2lab_xds.py#L29-L75 | train | Converts the pixel coordinates from the frame into lab - vector. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/dsskey.py | DSSKey.generate | def generate(bits=1024, progress_func=None):
"""
Generate a new private DSS key. This factory function can be used to
generate a new host key or authentication key.
:param int bits: number of bits the generated key should be.
:param function progress_func:
an option... | python | def generate(bits=1024, progress_func=None):
"""
Generate a new private DSS key. This factory function can be used to
generate a new host key or authentication key.
:param int bits: number of bits the generated key should be.
:param function progress_func:
an option... | [
"def",
"generate",
"(",
"bits",
"=",
"1024",
",",
"progress_func",
"=",
"None",
")",
":",
"dsa",
"=",
"DSA",
".",
"generate",
"(",
"bits",
",",
"os",
".",
"urandom",
",",
"progress_func",
")",
"key",
"=",
"DSSKey",
"(",
"vals",
"=",
"(",
"dsa",
"."... | Generate a new private DSS key. This factory function can be used to
generate a new host key or authentication key.
:param int bits: number of bits the generated key should be.
:param function progress_func:
an optional function to call at key points in key generation (used
... | [
"Generate",
"a",
"new",
"private",
"DSS",
"key",
".",
"This",
"factory",
"function",
"can",
"be",
"used",
"to",
"generate",
"a",
"new",
"host",
"key",
"or",
"authentication",
"key",
"."
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/dsskey.py#L157-L171 | train | This factory function can be used to generate a new private DSS key. |
KnightConan/sspdatatables | src/sspdatatables/datatables.py | DataTables.get_table_frame | def get_table_frame(self, prefix="", table_id="sspdtable", *args, **kwargs):
"""
render the structure (or structure_for_superuser) and an instance of the
footer form
:param prefix: str: used for unifying the rendered parameter's name,
such
that the template of se... | python | def get_table_frame(self, prefix="", table_id="sspdtable", *args, **kwargs):
"""
render the structure (or structure_for_superuser) and an instance of the
footer form
:param prefix: str: used for unifying the rendered parameter's name,
such
that the template of se... | [
"def",
"get_table_frame",
"(",
"self",
",",
"prefix",
"=",
"\"\"",
",",
"table_id",
"=",
"\"sspdtable\"",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"table_id",
":",
"raise",
"ValueError",
"(",
"\"table_id parameter can not be an empty s... | render the structure (or structure_for_superuser) and an instance of the
footer form
:param prefix: str: used for unifying the rendered parameter's name,
such
that the template of serverside datatables can be used in one page
multiple times
:param table_id: s... | [
"render",
"the",
"structure",
"(",
"or",
"structure_for_superuser",
")",
"and",
"an",
"instance",
"of",
"the",
"footer",
"form"
] | 1179a11358734e5e472e5eee703e8d34fa49e9bf | https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L172-L197 | train | Render the structure and an instance of the footer form |
KnightConan/sspdatatables | src/sspdatatables/datatables.py | DataTables.get_query_dict | def get_query_dict(self, **kwargs):
"""
function to generate a filter dictionary, in which the key is the
keyword used in django filter function in string form, and the value is
the searched value.
:param kwargs:dict: query dict sent by data tables package
:return: dict:... | python | def get_query_dict(self, **kwargs):
"""
function to generate a filter dictionary, in which the key is the
keyword used in django filter function in string form, and the value is
the searched value.
:param kwargs:dict: query dict sent by data tables package
:return: dict:... | [
"def",
"get_query_dict",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"total_cols",
"=",
"ensure",
"(",
"int",
",",
"kwargs",
".",
"get",
"(",
"'total_cols'",
",",
"[",
"0",
"]",
")",
"[",
"0",
"]",
",",
"0",
")",
"mapping",
"=",
"self",
".",
... | function to generate a filter dictionary, in which the key is the
keyword used in django filter function in string form, and the value is
the searched value.
:param kwargs:dict: query dict sent by data tables package
:return: dict: filtering dictionary | [
"function",
"to",
"generate",
"a",
"filter",
"dictionary",
"in",
"which",
"the",
"key",
"is",
"the",
"keyword",
"used",
"in",
"django",
"filter",
"function",
"in",
"string",
"form",
"and",
"the",
"value",
"is",
"the",
"searched",
"value",
"."
] | 1179a11358734e5e472e5eee703e8d34fa49e9bf | https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L199-L230 | train | function to generate a filter dictionary from the keyword arguments passed to the filter function. |
KnightConan/sspdatatables | src/sspdatatables/datatables.py | DataTables.filtering | def filtering(queryset, query_dict):
"""
function to apply the pre search condition to the queryset to narrow
down the queryset's size
:param queryset: Django Queryset: queryset of all objects
:param query_dict: dict: contains selected_related, filter and other
customi... | python | def filtering(queryset, query_dict):
"""
function to apply the pre search condition to the queryset to narrow
down the queryset's size
:param queryset: Django Queryset: queryset of all objects
:param query_dict: dict: contains selected_related, filter and other
customi... | [
"def",
"filtering",
"(",
"queryset",
",",
"query_dict",
")",
":",
"# apply pre_search_condition",
"for",
"key",
",",
"value",
"in",
"query_dict",
".",
"items",
"(",
")",
":",
"assert",
"hasattr",
"(",
"queryset",
",",
"key",
")",
",",
"\"Parameter 'query_dict'... | function to apply the pre search condition to the queryset to narrow
down the queryset's size
:param queryset: Django Queryset: queryset of all objects
:param query_dict: dict: contains selected_related, filter and other
customized filter functions
:return: queryset: result af... | [
"function",
"to",
"apply",
"the",
"pre",
"search",
"condition",
"to",
"the",
"queryset",
"to",
"narrow",
"down",
"the",
"queryset",
"s",
"size"
] | 1179a11358734e5e472e5eee703e8d34fa49e9bf | https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L255-L275 | train | function to narrow the queryset down the queryset s size by applying the pre search condition to the queryset s size by applying the pre search condition to the queryset s size by narrowing the queryset s size by the query_dict s size. |
KnightConan/sspdatatables | src/sspdatatables/datatables.py | DataTables.slicing | def slicing(queryset, **kwargs):
"""
function to slice the queryset according to the display length
:param queryset: Django Queryset: filtered and ordered queryset result
:param kwargs: dict: query dict sent by data tables package
:return: queryset: result after slicing
... | python | def slicing(queryset, **kwargs):
"""
function to slice the queryset according to the display length
:param queryset: Django Queryset: filtered and ordered queryset result
:param kwargs: dict: query dict sent by data tables package
:return: queryset: result after slicing
... | [
"def",
"slicing",
"(",
"queryset",
",",
"*",
"*",
"kwargs",
")",
":",
"# if the length is -1, we need to display all the records",
"# otherwise, just slicing the queryset",
"length",
"=",
"ensure",
"(",
"int",
",",
"kwargs",
".",
"get",
"(",
"'length'",
",",
"[",
"0... | function to slice the queryset according to the display length
:param queryset: Django Queryset: filtered and ordered queryset result
:param kwargs: dict: query dict sent by data tables package
:return: queryset: result after slicing | [
"function",
"to",
"slice",
"the",
"queryset",
"according",
"to",
"the",
"display",
"length"
] | 1179a11358734e5e472e5eee703e8d34fa49e9bf | https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L278-L292 | train | function to slice the queryset according to the display length
|
KnightConan/sspdatatables | src/sspdatatables/datatables.py | DataTables.query_by_args | def query_by_args(self, pre_search_condition=None, **kwargs):
"""
intends to process the queries sent by data tables package in frontend.
The model_cls indicates the model class, get_query_dict is a function
implemented by you, such that it can
return a query dictionary, in which... | python | def query_by_args(self, pre_search_condition=None, **kwargs):
"""
intends to process the queries sent by data tables package in frontend.
The model_cls indicates the model class, get_query_dict is a function
implemented by you, such that it can
return a query dictionary, in which... | [
"def",
"query_by_args",
"(",
"self",
",",
"pre_search_condition",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"pre_search_condition",
"and",
"not",
"isinstance",
"(",
"pre_search_condition",
",",
"OrderedDict",
")",
":",
"raise",
"TypeError",
"(",
"\... | intends to process the queries sent by data tables package in frontend.
The model_cls indicates the model class, get_query_dict is a function
implemented by you, such that it can
return a query dictionary, in which the key is the query keyword in str
form and the value is the queried val... | [
"intends",
"to",
"process",
"the",
"queries",
"sent",
"by",
"data",
"tables",
"package",
"in",
"frontend",
".",
"The",
"model_cls",
"indicates",
"the",
"model",
"class",
"get_query_dict",
"is",
"a",
"function",
"implemented",
"by",
"you",
"such",
"that",
"it",... | 1179a11358734e5e472e5eee703e8d34fa49e9bf | https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L294-L345 | train | This function is used to process the query_by_args method of the data tables package in frontend. |
KnightConan/sspdatatables | src/sspdatatables/datatables.py | DataTables.process | def process(self, pre_search_condition=None, **kwargs):
"""
function to be called outside to get the footer search condition,
apply the search in DB and render the serialized result.
:param pre_search_condition: None/OrderedDict: pre search condition to
be applied before apply... | python | def process(self, pre_search_condition=None, **kwargs):
"""
function to be called outside to get the footer search condition,
apply the search in DB and render the serialized result.
:param pre_search_condition: None/OrderedDict: pre search condition to
be applied before apply... | [
"def",
"process",
"(",
"self",
",",
"pre_search_condition",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"records",
"=",
"self",
".",
"query_by_args",
"(",
"pre_search_condition",
"=",
"pre_search_condition",
",",
"*",
"*",
"kwargs",
")",
"serializer",
"=... | function to be called outside to get the footer search condition,
apply the search in DB and render the serialized result.
:param pre_search_condition: None/OrderedDict: pre search condition to
be applied before applying the one getting from footer
:param kwargs: dict: search paramete... | [
"function",
"to",
"be",
"called",
"outside",
"to",
"get",
"the",
"footer",
"search",
"condition",
"apply",
"the",
"search",
"in",
"DB",
"and",
"render",
"the",
"serialized",
"result",
"."
] | 1179a11358734e5e472e5eee703e8d34fa49e9bf | https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L347-L367 | train | This function is called outside to get the footer search condition apply the search in DB and render the serialized result. |
reorx/torext | torext/sql.py | MutationDict.coerce | def coerce(cls, key, value):
"""Convert plain dictionary to MutationDict"""
self = MutationDict((k,MutationObj.coerce(key, v)) for (k, v) in value.items())
self._key = key
return self | python | def coerce(cls, key, value):
"""Convert plain dictionary to MutationDict"""
self = MutationDict((k,MutationObj.coerce(key, v)) for (k, v) in value.items())
self._key = key
return self | [
"def",
"coerce",
"(",
"cls",
",",
"key",
",",
"value",
")",
":",
"self",
"=",
"MutationDict",
"(",
"(",
"k",
",",
"MutationObj",
".",
"coerce",
"(",
"key",
",",
"v",
")",
")",
"for",
"(",
"k",
",",
"v",
")",
"in",
"value",
".",
"items",
"(",
... | Convert plain dictionary to MutationDict | [
"Convert",
"plain",
"dictionary",
"to",
"MutationDict"
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/sql.py#L361-L365 | train | Convert plain dictionary to MutationDict |
reorx/torext | torext/sql.py | MutationList.coerce | def coerce(cls, key, value):
"""Convert plain list to MutationList"""
self = MutationList((MutationObj.coerce(key, v) for v in value))
self._key = key
return self | python | def coerce(cls, key, value):
"""Convert plain list to MutationList"""
self = MutationList((MutationObj.coerce(key, v) for v in value))
self._key = key
return self | [
"def",
"coerce",
"(",
"cls",
",",
"key",
",",
"value",
")",
":",
"self",
"=",
"MutationList",
"(",
"(",
"MutationObj",
".",
"coerce",
"(",
"key",
",",
"v",
")",
"for",
"v",
"in",
"value",
")",
")",
"self",
".",
"_key",
"=",
"key",
"return",
"self... | Convert plain list to MutationList | [
"Convert",
"plain",
"list",
"to",
"MutationList"
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/sql.py#L378-L382 | train | Convert plain list to MutationList |
observermedia/django-wordpress-rest | wordpress/views.py | load_post_webhook | def load_post_webhook(request):
"""
Webhook to insert/update a WordPress.com post on the local Django site.
Call this after making changes to the post in WP Admin.
The post is processed asynchronously so that a response can be returned to WordPress.com immediately.
:param request: Should contain th... | python | def load_post_webhook(request):
"""
Webhook to insert/update a WordPress.com post on the local Django site.
Call this after making changes to the post in WP Admin.
The post is processed asynchronously so that a response can be returned to WordPress.com immediately.
:param request: Should contain th... | [
"def",
"load_post_webhook",
"(",
"request",
")",
":",
"try",
":",
"wp_post_id",
"=",
"int",
"(",
"request",
".",
"POST",
"[",
"\"ID\"",
"]",
")",
"except",
":",
"raise",
"Http404",
"(",
"\"Post does not exist\"",
")",
"# load this asynchronously so that the webhoo... | Webhook to insert/update a WordPress.com post on the local Django site.
Call this after making changes to the post in WP Admin.
The post is processed asynchronously so that a response can be returned to WordPress.com immediately.
:param request: Should contain the WordPress post ID, named "ID", in POST for... | [
"Webhook",
"to",
"insert",
"/",
"update",
"a",
"WordPress",
".",
"com",
"post",
"on",
"the",
"local",
"Django",
"site",
".",
"Call",
"this",
"after",
"making",
"changes",
"to",
"the",
"post",
"in",
"WP",
"Admin",
".",
"The",
"post",
"is",
"processed",
... | f0d96891d8ac5a69c8ba90e044876e756fad1bfe | https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/views.py#L19-L35 | train | Load a WordPress post from the local Django site. |
observermedia/django-wordpress-rest | wordpress/views.py | load_post | def load_post(wp_post_id):
"""
Called from load_post_webhook.
This builds a generic WPAPILoader and uses its load_post() to insert/update content for the post.
:param wp_post_id: the WordPress post ID to load
:return: None
"""
# wait a bit to give WordPress REST API a chance to catch up
... | python | def load_post(wp_post_id):
"""
Called from load_post_webhook.
This builds a generic WPAPILoader and uses its load_post() to insert/update content for the post.
:param wp_post_id: the WordPress post ID to load
:return: None
"""
# wait a bit to give WordPress REST API a chance to catch up
... | [
"def",
"load_post",
"(",
"wp_post_id",
")",
":",
"# wait a bit to give WordPress REST API a chance to catch up",
"time",
".",
"sleep",
"(",
"1",
")",
"loader",
"=",
"WPAPILoader",
"(",
")",
"post",
"=",
"loader",
".",
"load_post",
"(",
"wp_post_id",
")",
"if",
"... | Called from load_post_webhook.
This builds a generic WPAPILoader and uses its load_post() to insert/update content for the post.
:param wp_post_id: the WordPress post ID to load
:return: None | [
"Called",
"from",
"load_post_webhook",
".",
"This",
"builds",
"a",
"generic",
"WPAPILoader",
"and",
"uses",
"its",
"load_post",
"()",
"to",
"insert",
"/",
"update",
"content",
"for",
"the",
"post",
"."
] | f0d96891d8ac5a69c8ba90e044876e756fad1bfe | https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/views.py#L39-L57 | train | Loads a WordPress post from WordPress REST API. |
reorx/torext | torext/handlers/oauth.py | RenrenOAuth2Mixin.get_authenticated_user | def get_authenticated_user(self, redirect_uri, callback, scope=None, **args):
"""
class RenrenHandler(tornado.web.RequestHandler, RenrenGraphMixin):
@tornado.web.asynchronous
@gen.engine
def get(self):
self.get_authenticated_user(
c... | python | def get_authenticated_user(self, redirect_uri, callback, scope=None, **args):
"""
class RenrenHandler(tornado.web.RequestHandler, RenrenGraphMixin):
@tornado.web.asynchronous
@gen.engine
def get(self):
self.get_authenticated_user(
c... | [
"def",
"get_authenticated_user",
"(",
"self",
",",
"redirect_uri",
",",
"callback",
",",
"scope",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"code",
"=",
"self",
".",
"get_argument",
"(",
"'code'",
",",
"None",
")",
"if",
"not",
"code",
":",
"self",... | class RenrenHandler(tornado.web.RequestHandler, RenrenGraphMixin):
@tornado.web.asynchronous
@gen.engine
def get(self):
self.get_authenticated_user(
callback=(yield gen.Callback('key')),
redirect_uri=url)
user = ... | [
"class",
"RenrenHandler",
"(",
"tornado",
".",
"web",
".",
"RequestHandler",
"RenrenGraphMixin",
")",
":"
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/oauth.py#L511-L569 | train | Get authenticated user. |
reorx/torext | torext/handlers/oauth.py | FacebookAuthMixin.authenticate_redirect | def authenticate_redirect(self, callback_uri=None, cancel_uri=None,
extended_permissions=None):
"""Authenticates/installs this app for the current user."""
self.require_setting("facebook_api_key", "Facebook Connect")
callback_uri = callback_uri or self.request.uri
... | python | def authenticate_redirect(self, callback_uri=None, cancel_uri=None,
extended_permissions=None):
"""Authenticates/installs this app for the current user."""
self.require_setting("facebook_api_key", "Facebook Connect")
callback_uri = callback_uri or self.request.uri
... | [
"def",
"authenticate_redirect",
"(",
"self",
",",
"callback_uri",
"=",
"None",
",",
"cancel_uri",
"=",
"None",
",",
"extended_permissions",
"=",
"None",
")",
":",
"self",
".",
"require_setting",
"(",
"\"facebook_api_key\"",
",",
"\"Facebook Connect\"",
")",
"callb... | Authenticates/installs this app for the current user. | [
"Authenticates",
"/",
"installs",
"this",
"app",
"for",
"the",
"current",
"user",
"."
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/oauth.py#L630-L651 | train | Redirect to Facebook login. php. |
althonos/moclo | moclo/moclo/core/vectors.py | AbstractVector.structure | def structure(cls):
# type: () -> Text
"""Get the vector structure, as a DNA regex pattern.
Warning:
If overloading this method, the returned pattern must include 3
capture groups to capture the following features:
1. The downstream (3') overhang sequence
... | python | def structure(cls):
# type: () -> Text
"""Get the vector structure, as a DNA regex pattern.
Warning:
If overloading this method, the returned pattern must include 3
capture groups to capture the following features:
1. The downstream (3') overhang sequence
... | [
"def",
"structure",
"(",
"cls",
")",
":",
"# type: () -> Text",
"downstream",
"=",
"cls",
".",
"cutter",
".",
"elucidate",
"(",
")",
"upstream",
"=",
"str",
"(",
"Seq",
"(",
"downstream",
")",
".",
"reverse_complement",
"(",
")",
")",
"return",
"\"\"",
"... | Get the vector structure, as a DNA regex pattern.
Warning:
If overloading this method, the returned pattern must include 3
capture groups to capture the following features:
1. The downstream (3') overhang sequence
2. The vector placeholder sequence
3... | [
"Get",
"the",
"vector",
"structure",
"as",
"a",
"DNA",
"regex",
"pattern",
"."
] | 28a03748df8a2fa43f0c0c8098ca64d11559434e | https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/core/vectors.py#L39-L60 | train | Return the vector structure as a DNA regex pattern. |
althonos/moclo | moclo/moclo/core/vectors.py | AbstractVector.placeholder_sequence | def placeholder_sequence(self):
# type: () -> SeqRecord
"""Get the placeholder sequence in the vector.
The placeholder sequence is replaced by the concatenation of modules
during the assembly. It often contains a dropout sequence, such as a
GFP expression cassette that can be us... | python | def placeholder_sequence(self):
# type: () -> SeqRecord
"""Get the placeholder sequence in the vector.
The placeholder sequence is replaced by the concatenation of modules
during the assembly. It often contains a dropout sequence, such as a
GFP expression cassette that can be us... | [
"def",
"placeholder_sequence",
"(",
"self",
")",
":",
"# type: () -> SeqRecord",
"if",
"self",
".",
"cutter",
".",
"is_3overhang",
"(",
")",
":",
"return",
"self",
".",
"_match",
".",
"group",
"(",
"2",
")",
"+",
"self",
".",
"overhang_end",
"(",
")",
"e... | Get the placeholder sequence in the vector.
The placeholder sequence is replaced by the concatenation of modules
during the assembly. It often contains a dropout sequence, such as a
GFP expression cassette that can be used to measure the progress of
the assembly. | [
"Get",
"the",
"placeholder",
"sequence",
"in",
"the",
"vector",
"."
] | 28a03748df8a2fa43f0c0c8098ca64d11559434e | https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/core/vectors.py#L74-L86 | train | Get the placeholder sequence in the vector. |
althonos/moclo | moclo/moclo/core/vectors.py | AbstractVector.target_sequence | def target_sequence(self):
# type: () -> SeqRecord
"""Get the target sequence in the vector.
The target sequence if the part of the plasmid that is not discarded
during the assembly (everything except the placeholder sequence).
"""
if self.cutter.is_3overhang():
... | python | def target_sequence(self):
# type: () -> SeqRecord
"""Get the target sequence in the vector.
The target sequence if the part of the plasmid that is not discarded
during the assembly (everything except the placeholder sequence).
"""
if self.cutter.is_3overhang():
... | [
"def",
"target_sequence",
"(",
"self",
")",
":",
"# type: () -> SeqRecord",
"if",
"self",
".",
"cutter",
".",
"is_3overhang",
"(",
")",
":",
"start",
",",
"end",
"=",
"self",
".",
"_match",
".",
"span",
"(",
"2",
")",
"[",
"0",
"]",
",",
"self",
".",... | Get the target sequence in the vector.
The target sequence if the part of the plasmid that is not discarded
during the assembly (everything except the placeholder sequence). | [
"Get",
"the",
"target",
"sequence",
"in",
"the",
"vector",
"."
] | 28a03748df8a2fa43f0c0c8098ca64d11559434e | https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/core/vectors.py#L88-L99 | train | Get the target sequence in the vector. |
althonos/moclo | moclo/moclo/core/vectors.py | AbstractVector.assemble | def assemble(self, module, *modules, **kwargs):
# type: (AbstractModule, *AbstractModule, **Any) -> SeqRecord
"""Assemble the provided modules into the vector.
Arguments:
module (`~moclo.base.modules.AbstractModule`): a module to insert
in the vector.
mod... | python | def assemble(self, module, *modules, **kwargs):
# type: (AbstractModule, *AbstractModule, **Any) -> SeqRecord
"""Assemble the provided modules into the vector.
Arguments:
module (`~moclo.base.modules.AbstractModule`): a module to insert
in the vector.
mod... | [
"def",
"assemble",
"(",
"self",
",",
"module",
",",
"*",
"modules",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (AbstractModule, *AbstractModule, **Any) -> SeqRecord",
"mgr",
"=",
"AssemblyManager",
"(",
"vector",
"=",
"self",
",",
"modules",
"=",
"[",
"module",... | Assemble the provided modules into the vector.
Arguments:
module (`~moclo.base.modules.AbstractModule`): a module to insert
in the vector.
modules (`~moclo.base.modules.AbstractModule`, optional): additional
modules to insert in the vector. The order of t... | [
"Assemble",
"the",
"provided",
"modules",
"into",
"the",
"vector",
"."
] | 28a03748df8a2fa43f0c0c8098ca64d11559434e | https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/core/vectors.py#L108-L145 | train | Assemble the provided modules into the vector. |
eventifyio/eventify | eventify/drivers/base.py | BaseComponent.onConnect | async def onConnect(self):
"""
Configure the component
"""
# Add extra attribute
# This allows for following crossbar/autobahn spec
# without changing legacy configuration
if not hasattr(self.config, 'extra'):
original_config = {'config': self.config}
... | python | async def onConnect(self):
"""
Configure the component
"""
# Add extra attribute
# This allows for following crossbar/autobahn spec
# without changing legacy configuration
if not hasattr(self.config, 'extra'):
original_config = {'config': self.config}
... | [
"async",
"def",
"onConnect",
"(",
"self",
")",
":",
"# Add extra attribute",
"# This allows for following crossbar/autobahn spec",
"# without changing legacy configuration",
"if",
"not",
"hasattr",
"(",
"self",
".",
"config",
",",
"'extra'",
")",
":",
"original_config",
"... | Configure the component | [
"Configure",
"the",
"component"
] | 0e519964a56bd07a879b266f21f177749c63aaed | https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/base.py#L20-L66 | train | Called when the connection is established. |
gofed/gofedlib | gofedlib/distribution/distributionsnapshot.py | DistributionSnapshot.setRpms | def setRpms(self, package, build, build_ts, rpms):
"""Add/Update package rpm
"""
self._builds[package] = {"build": build, "build_ts": build_ts, "rpms": rpms} | python | def setRpms(self, package, build, build_ts, rpms):
"""Add/Update package rpm
"""
self._builds[package] = {"build": build, "build_ts": build_ts, "rpms": rpms} | [
"def",
"setRpms",
"(",
"self",
",",
"package",
",",
"build",
",",
"build_ts",
",",
"rpms",
")",
":",
"self",
".",
"_builds",
"[",
"package",
"]",
"=",
"{",
"\"build\"",
":",
"build",
",",
"\"build_ts\"",
":",
"build_ts",
",",
"\"rpms\"",
":",
"rpms",
... | Add/Update package rpm | [
"Add",
"/",
"Update",
"package",
"rpm"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/distribution/distributionsnapshot.py#L42-L45 | train | Add or update build to rpm
|
gofed/gofedlib | gofedlib/distribution/distributionsnapshot.py | DistributionSnapshot.clone | def clone(self):
"""Clone (deepcopy) snapshot
"""
snapshot = DistributionSnapshot(self.distribution(), self.go_version)
for package in self.builds:
snapshot.setRpms(package, self.builds[package]["build"], self.builds[package]["build_ts"], self.builds[package]["rpms"])
return snapshot | python | def clone(self):
"""Clone (deepcopy) snapshot
"""
snapshot = DistributionSnapshot(self.distribution(), self.go_version)
for package in self.builds:
snapshot.setRpms(package, self.builds[package]["build"], self.builds[package]["build_ts"], self.builds[package]["rpms"])
return snapshot | [
"def",
"clone",
"(",
"self",
")",
":",
"snapshot",
"=",
"DistributionSnapshot",
"(",
"self",
".",
"distribution",
"(",
")",
",",
"self",
".",
"go_version",
")",
"for",
"package",
"in",
"self",
".",
"builds",
":",
"snapshot",
".",
"setRpms",
"(",
"package... | Clone (deepcopy) snapshot | [
"Clone",
"(",
"deepcopy",
")",
"snapshot"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/distribution/distributionsnapshot.py#L47-L54 | train | Clone this distribution snapshot |
gofed/gofedlib | gofedlib/distribution/distributionsnapshot.py | DistributionSnapshot.compare | def compare(self, snapshot):
"""Compare two snapshots:
- return a list of new packages in this snapshot
- return a list of new builds in this snapshot
:param snapshot: distribution snapshot
:type snapshot: DistributionSnapshot
"""
builds = snapshot.builds()
diff_snapshot = DistributionSnapshot(self.d... | python | def compare(self, snapshot):
"""Compare two snapshots:
- return a list of new packages in this snapshot
- return a list of new builds in this snapshot
:param snapshot: distribution snapshot
:type snapshot: DistributionSnapshot
"""
builds = snapshot.builds()
diff_snapshot = DistributionSnapshot(self.d... | [
"def",
"compare",
"(",
"self",
",",
"snapshot",
")",
":",
"builds",
"=",
"snapshot",
".",
"builds",
"(",
")",
"diff_snapshot",
"=",
"DistributionSnapshot",
"(",
"self",
".",
"distribution",
"(",
")",
",",
"self",
".",
"go_version",
")",
"for",
"package",
... | Compare two snapshots:
- return a list of new packages in this snapshot
- return a list of new builds in this snapshot
:param snapshot: distribution snapshot
:type snapshot: DistributionSnapshot | [
"Compare",
"two",
"snapshots",
":",
"-",
"return",
"a",
"list",
"of",
"new",
"packages",
"in",
"this",
"snapshot",
"-",
"return",
"a",
"list",
"of",
"new",
"builds",
"in",
"this",
"snapshot"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/distribution/distributionsnapshot.py#L97-L117 | train | Compare two snapshots |
peterbe/gg | gg/builtins/getback/gg_getback.py | getback | def getback(config, force=False):
"""Goes back to the master branch, deletes the current branch locally
and remotely."""
repo = config.repo
active_branch = repo.active_branch
if active_branch.name == "master":
error_out("You're already on the master branch.")
if repo.is_dirty():
... | python | def getback(config, force=False):
"""Goes back to the master branch, deletes the current branch locally
and remotely."""
repo = config.repo
active_branch = repo.active_branch
if active_branch.name == "master":
error_out("You're already on the master branch.")
if repo.is_dirty():
... | [
"def",
"getback",
"(",
"config",
",",
"force",
"=",
"False",
")",
":",
"repo",
"=",
"config",
".",
"repo",
"active_branch",
"=",
"repo",
".",
"active_branch",
"if",
"active_branch",
".",
"name",
"==",
"\"master\"",
":",
"error_out",
"(",
"\"You're already on... | Goes back to the master branch, deletes the current branch locally
and remotely. | [
"Goes",
"back",
"to",
"the",
"master",
"branch",
"deletes",
"the",
"current",
"branch",
"locally",
"and",
"remotely",
"."
] | 2aace5bdb4a9b1cb65bea717784edf54c63b7bad | https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/getback/gg_getback.py#L11-L79 | train | Goes back to the master branch deletes the current branch locally and remotely. |
nhfruchter/pgh-bustime | pghbustime/datatypes.py | Bus.get | def get(_class, api, vid):
"""
Return a Bus object for a certain vehicle ID `vid` using API
instance `api`.
"""
busses = api.vehicles(vid=vid)['vehicle']
return _class.fromapi(api, api.vehicles(vid=vid)['vehicle']) | python | def get(_class, api, vid):
"""
Return a Bus object for a certain vehicle ID `vid` using API
instance `api`.
"""
busses = api.vehicles(vid=vid)['vehicle']
return _class.fromapi(api, api.vehicles(vid=vid)['vehicle']) | [
"def",
"get",
"(",
"_class",
",",
"api",
",",
"vid",
")",
":",
"busses",
"=",
"api",
".",
"vehicles",
"(",
"vid",
"=",
"vid",
")",
"[",
"'vehicle'",
"]",
"return",
"_class",
".",
"fromapi",
"(",
"api",
",",
"api",
".",
"vehicles",
"(",
"vid",
"="... | Return a Bus object for a certain vehicle ID `vid` using API
instance `api`. | [
"Return",
"a",
"Bus",
"object",
"for",
"a",
"certain",
"vehicle",
"ID",
"vid",
"using",
"API",
"instance",
"api",
"."
] | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L13-L19 | train | Get a Bus object for a certain vehicle ID. |
nhfruchter/pgh-bustime | pghbustime/datatypes.py | Bus.fromapi | def fromapi(_class, api, apiresponse):
"""
Return a Bus object from an API response dict.
"""
bus = apiresponse
return _class(
api = api,
vid = bus['vid'],
timeupdated = datetime.strptime(bus['tmstmp'], api.STRPTIME),
lat = float(bu... | python | def fromapi(_class, api, apiresponse):
"""
Return a Bus object from an API response dict.
"""
bus = apiresponse
return _class(
api = api,
vid = bus['vid'],
timeupdated = datetime.strptime(bus['tmstmp'], api.STRPTIME),
lat = float(bu... | [
"def",
"fromapi",
"(",
"_class",
",",
"api",
",",
"apiresponse",
")",
":",
"bus",
"=",
"apiresponse",
"return",
"_class",
"(",
"api",
"=",
"api",
",",
"vid",
"=",
"bus",
"[",
"'vid'",
"]",
",",
"timeupdated",
"=",
"datetime",
".",
"strptime",
"(",
"b... | Return a Bus object from an API response dict. | [
"Return",
"a",
"Bus",
"object",
"from",
"an",
"API",
"response",
"dict",
"."
] | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L22-L40 | train | Return a Bus object from an API response dict. |
nhfruchter/pgh-bustime | pghbustime/datatypes.py | Bus.update | def update(self):
"""Update this bus by creating a new one and transplanting dictionaries."""
vehicle = self.api.vehicles(vid=self.vid)['vehicle']
newbus = self.fromapi(self.api, vehicle)
self.__dict__ = newbus.__dict__
del newbus | python | def update(self):
"""Update this bus by creating a new one and transplanting dictionaries."""
vehicle = self.api.vehicles(vid=self.vid)['vehicle']
newbus = self.fromapi(self.api, vehicle)
self.__dict__ = newbus.__dict__
del newbus | [
"def",
"update",
"(",
"self",
")",
":",
"vehicle",
"=",
"self",
".",
"api",
".",
"vehicles",
"(",
"vid",
"=",
"self",
".",
"vid",
")",
"[",
"'vehicle'",
"]",
"newbus",
"=",
"self",
".",
"fromapi",
"(",
"self",
".",
"api",
",",
"vehicle",
")",
"se... | Update this bus by creating a new one and transplanting dictionaries. | [
"Update",
"this",
"bus",
"by",
"creating",
"a",
"new",
"one",
"and",
"transplanting",
"dictionaries",
"."
] | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L61-L66 | train | Update this bus by creating a new one and transplanting dictionaries. |
nhfruchter/pgh-bustime | pghbustime/datatypes.py | Bus.predictions | def predictions(self):
"""Generator that yields prediction objects from an API response."""
for prediction in self.api.predictions(vid=self.vid)['prd']:
pobj = Prediction.fromapi(self.api, prediction)
pobj._busobj = self
yield pobj | python | def predictions(self):
"""Generator that yields prediction objects from an API response."""
for prediction in self.api.predictions(vid=self.vid)['prd']:
pobj = Prediction.fromapi(self.api, prediction)
pobj._busobj = self
yield pobj | [
"def",
"predictions",
"(",
"self",
")",
":",
"for",
"prediction",
"in",
"self",
".",
"api",
".",
"predictions",
"(",
"vid",
"=",
"self",
".",
"vid",
")",
"[",
"'prd'",
"]",
":",
"pobj",
"=",
"Prediction",
".",
"fromapi",
"(",
"self",
".",
"api",
",... | Generator that yields prediction objects from an API response. | [
"Generator",
"that",
"yields",
"prediction",
"objects",
"from",
"an",
"API",
"response",
"."
] | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L73-L78 | train | Generator that yields prediction objects from an API response. |
nhfruchter/pgh-bustime | pghbustime/datatypes.py | Bus.next_stop | def next_stop(self):
"""Return the next stop for this bus."""
p = self.api.predictions(vid=self.vid)['prd']
pobj = Prediction.fromapi(self.api, p[0])
pobj._busobj = self
return pobj | python | def next_stop(self):
"""Return the next stop for this bus."""
p = self.api.predictions(vid=self.vid)['prd']
pobj = Prediction.fromapi(self.api, p[0])
pobj._busobj = self
return pobj | [
"def",
"next_stop",
"(",
"self",
")",
":",
"p",
"=",
"self",
".",
"api",
".",
"predictions",
"(",
"vid",
"=",
"self",
".",
"vid",
")",
"[",
"'prd'",
"]",
"pobj",
"=",
"Prediction",
".",
"fromapi",
"(",
"self",
".",
"api",
",",
"p",
"[",
"0",
"]... | Return the next stop for this bus. | [
"Return",
"the",
"next",
"stop",
"for",
"this",
"bus",
"."
] | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L81-L86 | train | Return the next stop for this bus. |
nhfruchter/pgh-bustime | pghbustime/datatypes.py | Route.get | def get(_class, api, rt):
"""
Return a Route object for route `rt` using API instance `api`.
"""
if not _class.all_routes:
_class.all_routes = _class.update_list(api, api.routes()['route'])
return _class.all_routes[str(rt)] | python | def get(_class, api, rt):
"""
Return a Route object for route `rt` using API instance `api`.
"""
if not _class.all_routes:
_class.all_routes = _class.update_list(api, api.routes()['route'])
return _class.all_routes[str(rt)] | [
"def",
"get",
"(",
"_class",
",",
"api",
",",
"rt",
")",
":",
"if",
"not",
"_class",
".",
"all_routes",
":",
"_class",
".",
"all_routes",
"=",
"_class",
".",
"update_list",
"(",
"api",
",",
"api",
".",
"routes",
"(",
")",
"[",
"'route'",
"]",
")",
... | Return a Route object for route `rt` using API instance `api`. | [
"Return",
"a",
"Route",
"object",
"for",
"route",
"rt",
"using",
"API",
"instance",
"api",
"."
] | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L114-L122 | train | Get a Route object for a given route rt using API instance api. |
nhfruchter/pgh-bustime | pghbustime/datatypes.py | Route.find_stop | def find_stop(self, query, direction=""):
"""
Search the list of stops, optionally in a direction (inbound or outbound),
for the term passed to the function. Case insensitive, searches both the
stop name and ID. Yields a generator.
Defaults to both directions.
""... | python | def find_stop(self, query, direction=""):
"""
Search the list of stops, optionally in a direction (inbound or outbound),
for the term passed to the function. Case insensitive, searches both the
stop name and ID. Yields a generator.
Defaults to both directions.
""... | [
"def",
"find_stop",
"(",
"self",
",",
"query",
",",
"direction",
"=",
"\"\"",
")",
":",
"_directions",
"=",
"[",
"\"inbound\"",
",",
"\"outbound\"",
",",
"\"\"",
"]",
"direction",
"=",
"direction",
".",
"lower",
"(",
")",
"if",
"direction",
"==",
"\"inbo... | Search the list of stops, optionally in a direction (inbound or outbound),
for the term passed to the function. Case insensitive, searches both the
stop name and ID. Yields a generator.
Defaults to both directions. | [
"Search",
"the",
"list",
"of",
"stops",
"optionally",
"in",
"a",
"direction",
"(",
"inbound",
"or",
"outbound",
")",
"for",
"the",
"term",
"passed",
"to",
"the",
"function",
".",
"Case",
"insensitive",
"searches",
"both",
"the",
"stop",
"name",
"and",
"ID"... | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L198-L220 | train | Search the list of stops optionally in a direction |
nhfruchter/pgh-bustime | pghbustime/datatypes.py | Stop.predictions | def predictions(self, route=''):
"""
Yields predicted bus ETAs for this stop. You can specify a
route identifier for ETAs specific to one route, or leave `route`
blank (done by default) to get information on all arriving busses.
"""
apiresponse = self.api.predictions... | python | def predictions(self, route=''):
"""
Yields predicted bus ETAs for this stop. You can specify a
route identifier for ETAs specific to one route, or leave `route`
blank (done by default) to get information on all arriving busses.
"""
apiresponse = self.api.predictions... | [
"def",
"predictions",
"(",
"self",
",",
"route",
"=",
"''",
")",
":",
"apiresponse",
"=",
"self",
".",
"api",
".",
"predictions",
"(",
"stpid",
"=",
"self",
".",
"id",
",",
"rt",
"=",
"route",
")",
"[",
"'prd'",
"]",
"if",
"type",
"(",
"apiresponse... | Yields predicted bus ETAs for this stop. You can specify a
route identifier for ETAs specific to one route, or leave `route`
blank (done by default) to get information on all arriving busses. | [
"Yields",
"predicted",
"bus",
"ETAs",
"for",
"this",
"stop",
".",
"You",
"can",
"specify",
"a",
"route",
"identifier",
"for",
"ETAs",
"specific",
"to",
"one",
"route",
"or",
"leave",
"route",
"blank",
"(",
"done",
"by",
"default",
")",
"to",
"get",
"info... | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L252-L270 | train | Yields predicted bus ETAs for this stop. |
nhfruchter/pgh-bustime | pghbustime/datatypes.py | Bulletin.fromapi | def fromapi(_class, apiresponse):
"""Create a bulletin object from an API response (dict), containing `sbj`, etc."""
for resp in apiresponse['sb']:
# Extract details from dict
_id = "n/a" or resp.get("nm")
subject = resp.get("sbj")
text = resp.get('dtl') +... | python | def fromapi(_class, apiresponse):
"""Create a bulletin object from an API response (dict), containing `sbj`, etc."""
for resp in apiresponse['sb']:
# Extract details from dict
_id = "n/a" or resp.get("nm")
subject = resp.get("sbj")
text = resp.get('dtl') +... | [
"def",
"fromapi",
"(",
"_class",
",",
"apiresponse",
")",
":",
"for",
"resp",
"in",
"apiresponse",
"[",
"'sb'",
"]",
":",
"# Extract details from dict",
"_id",
"=",
"\"n/a\"",
"or",
"resp",
".",
"get",
"(",
"\"nm\"",
")",
"subject",
"=",
"resp",
".",
"ge... | Create a bulletin object from an API response (dict), containing `sbj`, etc. | [
"Create",
"a",
"bulletin",
"object",
"from",
"an",
"API",
"response",
"(",
"dict",
")",
"containing",
"sbj",
"etc",
"."
] | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L391-L414 | train | Create a bulletin object from an API response. |
gebn/wood | wood/__init__.py | _normalise_path | def _normalise_path(path: Union[str, pathlib.Path]) -> pathlib.Path:
"""
Ensures a path is parsed.
:param path: A path string or Path object.
:return: The path as a Path object.
"""
if isinstance(path, str):
return pathlib.Path(path)
return path | python | def _normalise_path(path: Union[str, pathlib.Path]) -> pathlib.Path:
"""
Ensures a path is parsed.
:param path: A path string or Path object.
:return: The path as a Path object.
"""
if isinstance(path, str):
return pathlib.Path(path)
return path | [
"def",
"_normalise_path",
"(",
"path",
":",
"Union",
"[",
"str",
",",
"pathlib",
".",
"Path",
"]",
")",
"->",
"pathlib",
".",
"Path",
":",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"return",
"pathlib",
".",
"Path",
"(",
"path",
")",
"r... | Ensures a path is parsed.
:param path: A path string or Path object.
:return: The path as a Path object. | [
"Ensures",
"a",
"path",
"is",
"parsed",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/__init__.py#L30-L39 | train | Converts a path string or Path object to a pathlib. Path object. |
gebn/wood | wood/__init__.py | root | def root(path: Union[str, pathlib.Path]) -> _Root:
"""
Retrieve a root directory object from a path.
:param path: The path string or Path object.
:return: The created root object.
"""
return _Root.from_path(_normalise_path(path)) | python | def root(path: Union[str, pathlib.Path]) -> _Root:
"""
Retrieve a root directory object from a path.
:param path: The path string or Path object.
:return: The created root object.
"""
return _Root.from_path(_normalise_path(path)) | [
"def",
"root",
"(",
"path",
":",
"Union",
"[",
"str",
",",
"pathlib",
".",
"Path",
"]",
")",
"->",
"_Root",
":",
"return",
"_Root",
".",
"from_path",
"(",
"_normalise_path",
"(",
"path",
")",
")"
] | Retrieve a root directory object from a path.
:param path: The path string or Path object.
:return: The created root object. | [
"Retrieve",
"a",
"root",
"directory",
"object",
"from",
"a",
"path",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/__init__.py#L42-L49 | train | Retrieve a root directory object from a path. |
gebn/wood | wood/__init__.py | entity | def entity(path: Union[str, pathlib.Path]) -> _Entity:
"""
Retrieve an appropriate entity object from a path.
:param path: The path of the entity to represent, either a string or Path
object.
:return: An entity representing the input path.
"""
return _Entity.from_path(_normalis... | python | def entity(path: Union[str, pathlib.Path]) -> _Entity:
"""
Retrieve an appropriate entity object from a path.
:param path: The path of the entity to represent, either a string or Path
object.
:return: An entity representing the input path.
"""
return _Entity.from_path(_normalis... | [
"def",
"entity",
"(",
"path",
":",
"Union",
"[",
"str",
",",
"pathlib",
".",
"Path",
"]",
")",
"->",
"_Entity",
":",
"return",
"_Entity",
".",
"from_path",
"(",
"_normalise_path",
"(",
"path",
")",
")"
] | Retrieve an appropriate entity object from a path.
:param path: The path of the entity to represent, either a string or Path
object.
:return: An entity representing the input path. | [
"Retrieve",
"an",
"appropriate",
"entity",
"object",
"from",
"a",
"path",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/__init__.py#L52-L60 | train | Retrieve an appropriate entity object from a path. |
gebn/wood | wood/__init__.py | compare | def compare(left: Union[str, pathlib.Path, _Entity],
right: Union[str, pathlib.Path, _Entity]) -> Comparison:
"""
Compare two paths.
:param left: The left side or "before" entity.
:param right: The right side or "after" entity.
:return: A comparison details what has changed from the lef... | python | def compare(left: Union[str, pathlib.Path, _Entity],
right: Union[str, pathlib.Path, _Entity]) -> Comparison:
"""
Compare two paths.
:param left: The left side or "before" entity.
:param right: The right side or "after" entity.
:return: A comparison details what has changed from the lef... | [
"def",
"compare",
"(",
"left",
":",
"Union",
"[",
"str",
",",
"pathlib",
".",
"Path",
",",
"_Entity",
"]",
",",
"right",
":",
"Union",
"[",
"str",
",",
"pathlib",
".",
"Path",
",",
"_Entity",
"]",
")",
"->",
"Comparison",
":",
"def",
"normalise",
"... | Compare two paths.
:param left: The left side or "before" entity.
:param right: The right side or "after" entity.
:return: A comparison details what has changed from the left side to the
right side. | [
"Compare",
"two",
"paths",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/__init__.py#L63-L88 | train | Compare two paths. |
aglie/meerkat | meerkat/meerkat.py | r_get_numbers | def r_get_numbers(matchgroup, num):
"""A helper function which can be used similarly to fscanf(fid,'%f',num) to extract num arguments from the regex iterator"""
res = []
for i in range(num):
res.append(float(matchgroup.next().group()))
return np.array(res) | python | def r_get_numbers(matchgroup, num):
"""A helper function which can be used similarly to fscanf(fid,'%f',num) to extract num arguments from the regex iterator"""
res = []
for i in range(num):
res.append(float(matchgroup.next().group()))
return np.array(res) | [
"def",
"r_get_numbers",
"(",
"matchgroup",
",",
"num",
")",
":",
"res",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"num",
")",
":",
"res",
".",
"append",
"(",
"float",
"(",
"matchgroup",
".",
"next",
"(",
")",
".",
"group",
"(",
")",
")",
"... | A helper function which can be used similarly to fscanf(fid,'%f',num) to extract num arguments from the regex iterator | [
"A",
"helper",
"function",
"which",
"can",
"be",
"used",
"similarly",
"to",
"fscanf",
"(",
"fid",
"%f",
"num",
")",
"to",
"extract",
"num",
"arguments",
"from",
"the",
"regex",
"iterator"
] | f056a3da7ed3d7cd43edb56a38903cfa146e4b24 | https://github.com/aglie/meerkat/blob/f056a3da7ed3d7cd43edb56a38903cfa146e4b24/meerkat/meerkat.py#L10-L15 | train | A helper function which can be used similarly to fscanf ( fid num ) to extract num arguments from the regex iterator |
aglie/meerkat | meerkat/meerkat.py | read_XPARM | def read_XPARM(path_to_XPARM='.'):
"""Loads the instrumental geometry information from the XPARM.XDS or GXPARM.XDS files at the proposed location"""
if not os.path.exists(path_to_XPARM):
raise Exception("path " + path_to_XPARM + "does not exist")
if os.path.isdir(path_to_XPARM):
candidate ... | python | def read_XPARM(path_to_XPARM='.'):
"""Loads the instrumental geometry information from the XPARM.XDS or GXPARM.XDS files at the proposed location"""
if not os.path.exists(path_to_XPARM):
raise Exception("path " + path_to_XPARM + "does not exist")
if os.path.isdir(path_to_XPARM):
candidate ... | [
"def",
"read_XPARM",
"(",
"path_to_XPARM",
"=",
"'.'",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path_to_XPARM",
")",
":",
"raise",
"Exception",
"(",
"\"path \"",
"+",
"path_to_XPARM",
"+",
"\"does not exist\"",
")",
"if",
"os",
".",
... | Loads the instrumental geometry information from the XPARM.XDS or GXPARM.XDS files at the proposed location | [
"Loads",
"the",
"instrumental",
"geometry",
"information",
"from",
"the",
"XPARM",
".",
"XDS",
"or",
"GXPARM",
".",
"XDS",
"files",
"at",
"the",
"proposed",
"location"
] | f056a3da7ed3d7cd43edb56a38903cfa146e4b24 | https://github.com/aglie/meerkat/blob/f056a3da7ed3d7cd43edb56a38903cfa146e4b24/meerkat/meerkat.py#L18-L82 | train | Loads the instrumental geometry information from the XPARM. XDS or GXPARM. XDS files at the proposed location. |
aglie/meerkat | meerkat/meerkat.py | air_absorption_coefficient | def air_absorption_coefficient(medium, wavelength):
"""
The function returns linear absorbtion coefficient of selected medium at
given x-ray wavelength [mm^-1]
Mass attenuation coefficients are taken from NIST "Tables of X-Ray Mass
Attenuation Coefficients and Mass Energy-Absorption Coefficien... | python | def air_absorption_coefficient(medium, wavelength):
"""
The function returns linear absorbtion coefficient of selected medium at
given x-ray wavelength [mm^-1]
Mass attenuation coefficients are taken from NIST "Tables of X-Ray Mass
Attenuation Coefficients and Mass Energy-Absorption Coefficien... | [
"def",
"air_absorption_coefficient",
"(",
"medium",
",",
"wavelength",
")",
":",
"if",
"medium",
"==",
"'Helium'",
":",
"density",
"=",
"1.663e-04",
"# the table contains photon energy [Mev] and mass attenuation coefficient",
"# mu/sigma [cm^2/g]",
"mass_attenuation_coefficient",... | The function returns linear absorbtion coefficient of selected medium at
given x-ray wavelength [mm^-1]
Mass attenuation coefficients are taken from NIST "Tables of X-Ray Mass
Attenuation Coefficients and Mass Energy-Absorption Coefficients from 1
keV to 20 MeV for Elements Z = 1 to 92 and 48 Addit... | [
"The",
"function",
"returns",
"linear",
"absorbtion",
"coefficient",
"of",
"selected",
"medium",
"at",
"given",
"x",
"-",
"ray",
"wavelength",
"[",
"mm^",
"-",
"1",
"]"
] | f056a3da7ed3d7cd43edb56a38903cfa146e4b24 | https://github.com/aglie/meerkat/blob/f056a3da7ed3d7cd43edb56a38903cfa146e4b24/meerkat/meerkat.py#L90-L200 | train | This function returns the linear absorbtion coefficient of the selected medium at a specific x - ray wavelength. |
aglie/meerkat | meerkat/meerkat.py | create_h5py_with_large_cache | def create_h5py_with_large_cache(filename, cache_size_mb):
"""
Allows to open the hdf5 file with specified cache size
"""
# h5py does not allow to control the cache size from the high level
# we employ the workaround
# sources:
#http://stackoverflow.com/questions/14653259/how-to-set-cache-settin... | python | def create_h5py_with_large_cache(filename, cache_size_mb):
"""
Allows to open the hdf5 file with specified cache size
"""
# h5py does not allow to control the cache size from the high level
# we employ the workaround
# sources:
#http://stackoverflow.com/questions/14653259/how-to-set-cache-settin... | [
"def",
"create_h5py_with_large_cache",
"(",
"filename",
",",
"cache_size_mb",
")",
":",
"# h5py does not allow to control the cache size from the high level",
"# we employ the workaround",
"# sources:",
"#http://stackoverflow.com/questions/14653259/how-to-set-cache-settings-while-using-h5py-hi... | Allows to open the hdf5 file with specified cache size | [
"Allows",
"to",
"open",
"the",
"hdf5",
"file",
"with",
"specified",
"cache",
"size"
] | f056a3da7ed3d7cd43edb56a38903cfa146e4b24 | https://github.com/aglie/meerkat/blob/f056a3da7ed3d7cd43edb56a38903cfa146e4b24/meerkat/meerkat.py#L203-L218 | train | Create an hdf5 file with large cache size |
kblin/bioinf-helperlibs | helperlibs/bio/featurematch.py | find_features | def find_features(seqs, locus_tag="all", utr_len=200):
"""Find features in sequences by locus tag"""
found_features = []
for seq_i in seqs:
for feature in seq_i.features:
if feature.type == "CDS" and (locus_tag == "all" or \
('locus_tag' in feature.qualifiers and \
... | python | def find_features(seqs, locus_tag="all", utr_len=200):
"""Find features in sequences by locus tag"""
found_features = []
for seq_i in seqs:
for feature in seq_i.features:
if feature.type == "CDS" and (locus_tag == "all" or \
('locus_tag' in feature.qualifiers and \
... | [
"def",
"find_features",
"(",
"seqs",
",",
"locus_tag",
"=",
"\"all\"",
",",
"utr_len",
"=",
"200",
")",
":",
"found_features",
"=",
"[",
"]",
"for",
"seq_i",
"in",
"seqs",
":",
"for",
"feature",
"in",
"seq_i",
".",
"features",
":",
"if",
"feature",
"."... | Find features in sequences by locus tag | [
"Find",
"features",
"in",
"sequences",
"by",
"locus",
"tag"
] | 3a732d62b4b3cc42675631db886ba534672cb134 | https://github.com/kblin/bioinf-helperlibs/blob/3a732d62b4b3cc42675631db886ba534672cb134/helperlibs/bio/featurematch.py#L111-L127 | train | Find features in sequences by locus tag |
Nic30/hwtGraph | hwtGraph/elk/containers/lPort.py | LPort.getLevel | def getLevel(self):
"""
Get nest-level of this port
"""
lvl = 0
p = self
while True:
p = p.parent
if not isinstance(p, LPort):
break
lvl += 1
return lvl | python | def getLevel(self):
"""
Get nest-level of this port
"""
lvl = 0
p = self
while True:
p = p.parent
if not isinstance(p, LPort):
break
lvl += 1
return lvl | [
"def",
"getLevel",
"(",
"self",
")",
":",
"lvl",
"=",
"0",
"p",
"=",
"self",
"while",
"True",
":",
"p",
"=",
"p",
".",
"parent",
"if",
"not",
"isinstance",
"(",
"p",
",",
"LPort",
")",
":",
"break",
"lvl",
"+=",
"1",
"return",
"lvl"
] | Get nest-level of this port | [
"Get",
"nest",
"-",
"level",
"of",
"this",
"port"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/containers/lPort.py#L44-L55 | train | Get nest - level of this port. |
unt-libraries/pyuntl | pyuntl/util.py | normalize_LCSH | def normalize_LCSH(subject):
"""Normalize a LCSH subject heading prior to indexing."""
# Strip then divide on -- which is a delimiter for LCSH;
# rejoin after stripping parts.
subject_parts = subject.strip().split('--')
joined_subject = ' -- '.join([part.strip() for part in subject_parts])
# Ch... | python | def normalize_LCSH(subject):
"""Normalize a LCSH subject heading prior to indexing."""
# Strip then divide on -- which is a delimiter for LCSH;
# rejoin after stripping parts.
subject_parts = subject.strip().split('--')
joined_subject = ' -- '.join([part.strip() for part in subject_parts])
# Ch... | [
"def",
"normalize_LCSH",
"(",
"subject",
")",
":",
"# Strip then divide on -- which is a delimiter for LCSH;",
"# rejoin after stripping parts.",
"subject_parts",
"=",
"subject",
".",
"strip",
"(",
")",
".",
"split",
"(",
"'--'",
")",
"joined_subject",
"=",
"' -- '",
".... | Normalize a LCSH subject heading prior to indexing. | [
"Normalize",
"a",
"LCSH",
"subject",
"heading",
"prior",
"to",
"indexing",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/util.py#L4-L16 | train | Normalize a LCSH subject heading prior to indexing. |
unt-libraries/pyuntl | pyuntl/util.py | normalize_UNTL | def normalize_UNTL(subject):
"""Normalize a UNTL subject heading for consistency."""
subject = subject.strip()
subject = re.sub(r'[\s]+', ' ', subject)
return subject | python | def normalize_UNTL(subject):
"""Normalize a UNTL subject heading for consistency."""
subject = subject.strip()
subject = re.sub(r'[\s]+', ' ', subject)
return subject | [
"def",
"normalize_UNTL",
"(",
"subject",
")",
":",
"subject",
"=",
"subject",
".",
"strip",
"(",
")",
"subject",
"=",
"re",
".",
"sub",
"(",
"r'[\\s]+'",
",",
"' '",
",",
"subject",
")",
"return",
"subject"
] | Normalize a UNTL subject heading for consistency. | [
"Normalize",
"a",
"UNTL",
"subject",
"heading",
"for",
"consistency",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/util.py#L19-L23 | train | Normalize a UNTL subject heading for consistency. |
unt-libraries/pyuntl | pyuntl/util.py | UNTL_to_encodedUNTL | def UNTL_to_encodedUNTL(subject):
"""Normalize a UNTL subject heading to be used in SOLR."""
subject = normalize_UNTL(subject)
subject = subject.replace(' ', '_')
subject = subject.replace('_-_', '/')
return subject | python | def UNTL_to_encodedUNTL(subject):
"""Normalize a UNTL subject heading to be used in SOLR."""
subject = normalize_UNTL(subject)
subject = subject.replace(' ', '_')
subject = subject.replace('_-_', '/')
return subject | [
"def",
"UNTL_to_encodedUNTL",
"(",
"subject",
")",
":",
"subject",
"=",
"normalize_UNTL",
"(",
"subject",
")",
"subject",
"=",
"subject",
".",
"replace",
"(",
"' '",
",",
"'_'",
")",
"subject",
"=",
"subject",
".",
"replace",
"(",
"'_-_'",
",",
"'/'",
")... | Normalize a UNTL subject heading to be used in SOLR. | [
"Normalize",
"a",
"UNTL",
"subject",
"heading",
"to",
"be",
"used",
"in",
"SOLR",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/util.py#L26-L31 | train | Normalize a UNTL subject heading to be used in SOLR. |
unt-libraries/pyuntl | pyuntl/util.py | untldict_normalizer | def untldict_normalizer(untl_dict, normalizations):
"""Normalize UNTL elements by their qualifier.
Takes a UNTL descriptive metadata dictionary and a dictionary of
the elements and the qualifiers for normalization:
{'element1': ['qualifier1', 'qualifier2'],
'element2': ['qualifier3']}
and norm... | python | def untldict_normalizer(untl_dict, normalizations):
"""Normalize UNTL elements by their qualifier.
Takes a UNTL descriptive metadata dictionary and a dictionary of
the elements and the qualifiers for normalization:
{'element1': ['qualifier1', 'qualifier2'],
'element2': ['qualifier3']}
and norm... | [
"def",
"untldict_normalizer",
"(",
"untl_dict",
",",
"normalizations",
")",
":",
"# Loop through the element types in the UNTL metadata.",
"for",
"element_type",
",",
"element_list",
"in",
"untl_dict",
".",
"items",
"(",
")",
":",
"# A normalization is required for that eleme... | Normalize UNTL elements by their qualifier.
Takes a UNTL descriptive metadata dictionary and a dictionary of
the elements and the qualifiers for normalization:
{'element1': ['qualifier1', 'qualifier2'],
'element2': ['qualifier3']}
and normalizes the elements with that qualifier. | [
"Normalize",
"UNTL",
"elements",
"by",
"their",
"qualifier",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/util.py#L41-L73 | train | Normalize UNTL elements by their qualifier. |
peterbe/gg | gg/builtins/start/gg_start.py | start | def start(config, bugnumber=""):
"""Create a new topic branch."""
repo = config.repo
if bugnumber:
summary, bugnumber, url = get_summary(config, bugnumber)
else:
url = None
summary = None
if summary:
summary = input('Summary ["{}"]: '.format(summary)).strip() or sum... | python | def start(config, bugnumber=""):
"""Create a new topic branch."""
repo = config.repo
if bugnumber:
summary, bugnumber, url = get_summary(config, bugnumber)
else:
url = None
summary = None
if summary:
summary = input('Summary ["{}"]: '.format(summary)).strip() or sum... | [
"def",
"start",
"(",
"config",
",",
"bugnumber",
"=",
"\"\"",
")",
":",
"repo",
"=",
"config",
".",
"repo",
"if",
"bugnumber",
":",
"summary",
",",
"bugnumber",
",",
"url",
"=",
"get_summary",
"(",
"config",
",",
"bugnumber",
")",
"else",
":",
"url",
... | Create a new topic branch. | [
"Create",
"a",
"new",
"topic",
"branch",
"."
] | 2aace5bdb4a9b1cb65bea717784edf54c63b7bad | https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/start/gg_start.py#L18-L65 | train | Create a new topic branch. |
peterbe/gg | gg/builtins/start/gg_start.py | get_summary | def get_summary(config, bugnumber):
"""return a summary for this bug/issue. If it can't be found,
return None."""
bugzilla_url_regex = re.compile(
re.escape("https://bugzilla.mozilla.org/show_bug.cgi?id=") + r"(\d+)$"
)
# The user could have pasted in a bugzilla ID or a bugzilla URL
if... | python | def get_summary(config, bugnumber):
"""return a summary for this bug/issue. If it can't be found,
return None."""
bugzilla_url_regex = re.compile(
re.escape("https://bugzilla.mozilla.org/show_bug.cgi?id=") + r"(\d+)$"
)
# The user could have pasted in a bugzilla ID or a bugzilla URL
if... | [
"def",
"get_summary",
"(",
"config",
",",
"bugnumber",
")",
":",
"bugzilla_url_regex",
"=",
"re",
".",
"compile",
"(",
"re",
".",
"escape",
"(",
"\"https://bugzilla.mozilla.org/show_bug.cgi?id=\"",
")",
"+",
"r\"(\\d+)$\"",
")",
"# The user could have pasted in a bugzil... | return a summary for this bug/issue. If it can't be found,
return None. | [
"return",
"a",
"summary",
"for",
"this",
"bug",
"/",
"issue",
".",
"If",
"it",
"can",
"t",
"be",
"found",
"return",
"None",
"."
] | 2aace5bdb4a9b1cb65bea717784edf54c63b7bad | https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/start/gg_start.py#L68-L136 | train | return a summary for this bug number or None |
peterbe/gg | gg/builtins/start/gg_start.py | parse_remote_url | def parse_remote_url(url):
"""return a tuple of (org, repo) from the remote git URL"""
# The URL will either be git@github.com:org/repo.git or
# https://github.com/org/repo.git and in both cases
# it's not guarantee that the domain is github.com.
# FIXME: Make it work non-github.com domains
if u... | python | def parse_remote_url(url):
"""return a tuple of (org, repo) from the remote git URL"""
# The URL will either be git@github.com:org/repo.git or
# https://github.com/org/repo.git and in both cases
# it's not guarantee that the domain is github.com.
# FIXME: Make it work non-github.com domains
if u... | [
"def",
"parse_remote_url",
"(",
"url",
")",
":",
"# The URL will either be git@github.com:org/repo.git or",
"# https://github.com/org/repo.git and in both cases",
"# it's not guarantee that the domain is github.com.",
"# FIXME: Make it work non-github.com domains",
"if",
"url",
".",
"start... | return a tuple of (org, repo) from the remote git URL | [
"return",
"a",
"tuple",
"of",
"(",
"org",
"repo",
")",
"from",
"the",
"remote",
"git",
"URL"
] | 2aace5bdb4a9b1cb65bea717784edf54c63b7bad | https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/start/gg_start.py#L139-L153 | train | return a tuple of org repo from the remote git URL |
255BITS/hyperchamber | examples/shared/ops.py | conv_cond_concat | def conv_cond_concat(x, y):
"""Concatenate conditioning vector on feature map axis."""
x_shapes = x.get_shape()
y_shapes = y.get_shape()
return tf.concat(3, [x, y*tf.ones([x_shapes[0], x_shapes[1], x_shapes[2], y_shapes[3]])]) | python | def conv_cond_concat(x, y):
"""Concatenate conditioning vector on feature map axis."""
x_shapes = x.get_shape()
y_shapes = y.get_shape()
return tf.concat(3, [x, y*tf.ones([x_shapes[0], x_shapes[1], x_shapes[2], y_shapes[3]])]) | [
"def",
"conv_cond_concat",
"(",
"x",
",",
"y",
")",
":",
"x_shapes",
"=",
"x",
".",
"get_shape",
"(",
")",
"y_shapes",
"=",
"y",
".",
"get_shape",
"(",
")",
"return",
"tf",
".",
"concat",
"(",
"3",
",",
"[",
"x",
",",
"y",
"*",
"tf",
".",
"ones... | Concatenate conditioning vector on feature map axis. | [
"Concatenate",
"conditioning",
"vector",
"on",
"feature",
"map",
"axis",
"."
] | 4d5774bde9ea6ce1113f77a069ffc605148482b8 | https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/ops.py#L106-L110 | train | Concatenate conditioning vector on feature map axis. |
255BITS/hyperchamber | examples/shared/ops.py | lrelu_sq | def lrelu_sq(x):
"""
Concatenates lrelu and square
"""
dim = len(x.get_shape()) - 1
return tf.concat(dim, [lrelu(x), tf.minimum(tf.abs(x), tf.square(x))]) | python | def lrelu_sq(x):
"""
Concatenates lrelu and square
"""
dim = len(x.get_shape()) - 1
return tf.concat(dim, [lrelu(x), tf.minimum(tf.abs(x), tf.square(x))]) | [
"def",
"lrelu_sq",
"(",
"x",
")",
":",
"dim",
"=",
"len",
"(",
"x",
".",
"get_shape",
"(",
")",
")",
"-",
"1",
"return",
"tf",
".",
"concat",
"(",
"dim",
",",
"[",
"lrelu",
"(",
"x",
")",
",",
"tf",
".",
"minimum",
"(",
"tf",
".",
"abs",
"(... | Concatenates lrelu and square | [
"Concatenates",
"lrelu",
"and",
"square"
] | 4d5774bde9ea6ce1113f77a069ffc605148482b8 | https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/ops.py#L223-L228 | train | Concatenates lrelu and square
|
255BITS/hyperchamber | examples/shared/ops.py | avg_grads | def avg_grads(tower_grads):
"""Calculate the average gradient for each shared variable across all towers.
Note that this function provides a synchronization point across all towers.
Args:
tower_grads: List of lists of (gradient, variable) tuples. The outer list
is over individual gradients. The inner ... | python | def avg_grads(tower_grads):
"""Calculate the average gradient for each shared variable across all towers.
Note that this function provides a synchronization point across all towers.
Args:
tower_grads: List of lists of (gradient, variable) tuples. The outer list
is over individual gradients. The inner ... | [
"def",
"avg_grads",
"(",
"tower_grads",
")",
":",
"average_grads",
"=",
"[",
"]",
"for",
"grad_and_vars",
"in",
"zip",
"(",
"*",
"tower_grads",
")",
":",
"# Note that each grad_and_vars looks like the following:",
"# ((grad0_gpu0, var0_gpu0), ... , (grad0_gpuN, var0_gpuN))"... | Calculate the average gradient for each shared variable across all towers.
Note that this function provides a synchronization point across all towers.
Args:
tower_grads: List of lists of (gradient, variable) tuples. The outer list
is over individual gradients. The inner list is over the gradient
c... | [
"Calculate",
"the",
"average",
"gradient",
"for",
"each",
"shared",
"variable",
"across",
"all",
"towers",
"."
] | 4d5774bde9ea6ce1113f77a069ffc605148482b8 | https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/ops.py#L264-L299 | train | Calculate the average gradient for each shared variable across all towers. |
kwlzn/blast | blast/main.py | stream_template | def stream_template(template_name, **context):
''' allow streaming of jinja templates for reduced page load start latency (e.g. for large lists) '''
app.update_template_context(context)
t = app.jinja_env.get_template(template_name)
rv = t.stream(context)
rv.enable_buffering(5)
return rv | python | def stream_template(template_name, **context):
''' allow streaming of jinja templates for reduced page load start latency (e.g. for large lists) '''
app.update_template_context(context)
t = app.jinja_env.get_template(template_name)
rv = t.stream(context)
rv.enable_buffering(5)
return rv | [
"def",
"stream_template",
"(",
"template_name",
",",
"*",
"*",
"context",
")",
":",
"app",
".",
"update_template_context",
"(",
"context",
")",
"t",
"=",
"app",
".",
"jinja_env",
".",
"get_template",
"(",
"template_name",
")",
"rv",
"=",
"t",
".",
"stream"... | allow streaming of jinja templates for reduced page load start latency (e.g. for large lists) | [
"allow",
"streaming",
"of",
"jinja",
"templates",
"for",
"reduced",
"page",
"load",
"start",
"latency",
"(",
"e",
".",
"g",
".",
"for",
"large",
"lists",
")"
] | ae18a19182a6884c453bf9b2a3c6386bd3b2655a | https://github.com/kwlzn/blast/blob/ae18a19182a6884c453bf9b2a3c6386bd3b2655a/blast/main.py#L33-L39 | train | allow streaming of jinja templates for reduced page load start latency |
kwlzn/blast | blast/main.py | unescape_utf8 | def unescape_utf8(msg):
''' convert escaped unicode web entities to unicode '''
def sub(m):
text = m.group(0)
if text[:3] == "&#x": return unichr(int(text[3:-1], 16))
else: return unichr(int(text[2:-1]))
return re.sub("&#?\w+;", sub, urllib.unquote(msg)) | python | def unescape_utf8(msg):
''' convert escaped unicode web entities to unicode '''
def sub(m):
text = m.group(0)
if text[:3] == "&#x": return unichr(int(text[3:-1], 16))
else: return unichr(int(text[2:-1]))
return re.sub("&#?\w+;", sub, urllib.unquote(msg)) | [
"def",
"unescape_utf8",
"(",
"msg",
")",
":",
"def",
"sub",
"(",
"m",
")",
":",
"text",
"=",
"m",
".",
"group",
"(",
"0",
")",
"if",
"text",
"[",
":",
"3",
"]",
"==",
"\"&#x\"",
":",
"return",
"unichr",
"(",
"int",
"(",
"text",
"[",
"3",
":",... | convert escaped unicode web entities to unicode | [
"convert",
"escaped",
"unicode",
"web",
"entities",
"to",
"unicode"
] | ae18a19182a6884c453bf9b2a3c6386bd3b2655a | https://github.com/kwlzn/blast/blob/ae18a19182a6884c453bf9b2a3c6386bd3b2655a/blast/main.py#L41-L47 | train | convert escaped unicode web entities to unicode |
kwlzn/blast | blast/main.py | iterplayables | def iterplayables():
''' fast iterator of playable file object/dicts found on disk '''
ls = DirScanner(stripdot=True)
## filter out just mp3 files (and dirs to support recursion)
filt = lambda x: ( os.path.isdir(x) or x[-4:].lower() in ALLOWED_TYPES )
## take the last two segments of the path as the... | python | def iterplayables():
''' fast iterator of playable file object/dicts found on disk '''
ls = DirScanner(stripdot=True)
## filter out just mp3 files (and dirs to support recursion)
filt = lambda x: ( os.path.isdir(x) or x[-4:].lower() in ALLOWED_TYPES )
## take the last two segments of the path as the... | [
"def",
"iterplayables",
"(",
")",
":",
"ls",
"=",
"DirScanner",
"(",
"stripdot",
"=",
"True",
")",
"## filter out just mp3 files (and dirs to support recursion)",
"filt",
"=",
"lambda",
"x",
":",
"(",
"os",
".",
"path",
".",
"isdir",
"(",
"x",
")",
"or",
"x"... | fast iterator of playable file object/dicts found on disk | [
"fast",
"iterator",
"of",
"playable",
"file",
"object",
"/",
"dicts",
"found",
"on",
"disk"
] | ae18a19182a6884c453bf9b2a3c6386bd3b2655a | https://github.com/kwlzn/blast/blob/ae18a19182a6884c453bf9b2a3c6386bd3b2655a/blast/main.py#L53-L63 | train | fast iterator of playable file objects found on disk |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/extractSplits.py | extractSplits | def extractSplits(root: LNode):
"""
convert group of indexed assignments witch are splitting signal to Split node
a = sig[0]
b = sig[1]
to
a, b = sig
:param toL: dictionary {hdl object: layout object}
"""
toL = root._node2lnode
signals = root.originObj._ctx.signals
# searc... | python | def extractSplits(root: LNode):
"""
convert group of indexed assignments witch are splitting signal to Split node
a = sig[0]
b = sig[1]
to
a, b = sig
:param toL: dictionary {hdl object: layout object}
"""
toL = root._node2lnode
signals = root.originObj._ctx.signals
# searc... | [
"def",
"extractSplits",
"(",
"root",
":",
"LNode",
")",
":",
"toL",
"=",
"root",
".",
"_node2lnode",
"signals",
"=",
"root",
".",
"originObj",
".",
"_ctx",
".",
"signals",
"# search from \"sig\" side (look at doc string)",
"for",
"s",
"in",
"signals",
":",
"if... | convert group of indexed assignments witch are splitting signal to Split node
a = sig[0]
b = sig[1]
to
a, b = sig
:param toL: dictionary {hdl object: layout object} | [
"convert",
"group",
"of",
"indexed",
"assignments",
"witch",
"are",
"splitting",
"signal",
"to",
"Split",
"node"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/extractSplits.py#L14-L124 | train | extracts split nodes from the root node |
legnaleurc/wcpan.telegram | wcpan/telegram/util.py | encode_multipart_formdata | def encode_multipart_formdata(fields):
"""
fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data to be
uploaded as files.
Return (content_type, body) ready for httplib.HTTP instance
"""
BOUNDARY = '----------T... | python | def encode_multipart_formdata(fields):
"""
fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data to be
uploaded as files.
Return (content_type, body) ready for httplib.HTTP instance
"""
BOUNDARY = '----------T... | [
"def",
"encode_multipart_formdata",
"(",
"fields",
")",
":",
"BOUNDARY",
"=",
"'----------ThIs_Is_tHe_bouNdaRY_$'",
"CRLF",
"=",
"'\\r\\n'",
".",
"encode",
"(",
"'utf-8'",
")",
"L",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"value",
")",
"in",
"fields",
":",
... | fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data to be
uploaded as files.
Return (content_type, body) ready for httplib.HTTP instance | [
"fields",
"is",
"a",
"sequence",
"of",
"(",
"name",
"value",
")",
"elements",
"for",
"regular",
"form",
"fields",
".",
"files",
"is",
"a",
"sequence",
"of",
"(",
"name",
"filename",
"value",
")",
"elements",
"for",
"data",
"to",
"be",
"uploaded",
"as",
... | 61a172203ff69b6490e52a64bf55d47aeef1e148 | https://github.com/legnaleurc/wcpan.telegram/blob/61a172203ff69b6490e52a64bf55d47aeef1e148/wcpan/telegram/util.py#L4-L30 | train | Encodes a list of fields and files into a multipart form data. |
rhayes777/PyAutoFit | autofit/tools/fit_util.py | residual_map_from_data_mask_and_model_data | def residual_map_from_data_mask_and_model_data(data, mask, model_data):
"""Compute the residual map between a masked observed data and model data, where:
Residuals = (Data - Model_Data).
Parameters
-----------
data : np.ndarray
The observed data that is fitted.
mask : np.ndarray
... | python | def residual_map_from_data_mask_and_model_data(data, mask, model_data):
"""Compute the residual map between a masked observed data and model data, where:
Residuals = (Data - Model_Data).
Parameters
-----------
data : np.ndarray
The observed data that is fitted.
mask : np.ndarray
... | [
"def",
"residual_map_from_data_mask_and_model_data",
"(",
"data",
",",
"mask",
",",
"model_data",
")",
":",
"return",
"np",
".",
"subtract",
"(",
"data",
",",
"model_data",
",",
"out",
"=",
"np",
".",
"zeros_like",
"(",
"data",
")",
",",
"where",
"=",
"np"... | Compute the residual map between a masked observed data and model data, where:
Residuals = (Data - Model_Data).
Parameters
-----------
data : np.ndarray
The observed data that is fitted.
mask : np.ndarray
The mask applied to the data, where *False* entries are included in the calcu... | [
"Compute",
"the",
"residual",
"map",
"between",
"a",
"masked",
"observed",
"data",
"and",
"model",
"data",
"where",
":"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/fit_util.py#L4-L18 | train | Compute the residual map between a masked observed data and a model data. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.