partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | AdvancedHTTPServer.auth_add_creds | Add a valid set of credentials to be accepted for authentication.
Calling this function will automatically enable requiring
authentication. Passwords can be provided in either plaintext or
as a hash by specifying the hash type in the *pwtype* argument.
:param str username: The username of the credentials to be... | advancedhttpserver.py | def auth_add_creds(self, username, password, pwtype='plain'):
"""
Add a valid set of credentials to be accepted for authentication.
Calling this function will automatically enable requiring
authentication. Passwords can be provided in either plaintext or
as a hash by specifying the hash type in the *pwtype* a... | def auth_add_creds(self, username, password, pwtype='plain'):
"""
Add a valid set of credentials to be accepted for authentication.
Calling this function will automatically enable requiring
authentication. Passwords can be provided in either plaintext or
as a hash by specifying the hash type in the *pwtype* a... | [
"Add",
"a",
"valid",
"set",
"of",
"credentials",
"to",
"be",
"accepted",
"for",
"authentication",
".",
"Calling",
"this",
"function",
"will",
"automatically",
"enable",
"requiring",
"authentication",
".",
"Passwords",
"can",
"be",
"provided",
"in",
"either",
"pl... | zeroSteiner/AdvancedHTTPServer | python | https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L2076-L2109 | [
"def",
"auth_add_creds",
"(",
"self",
",",
"username",
",",
"password",
",",
"pwtype",
"=",
"'plain'",
")",
":",
"if",
"not",
"isinstance",
"(",
"password",
",",
"(",
"bytes",
",",
"str",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"auth_add_creds() argume... | 8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a |
train | setattr_context | Context manager to temporarily change the values of object attributes
while executing a function.
Example
-------
>>> class Foo: pass
>>> f = Foo(); f.attr = 'hello'
>>> with setattr_context(f, attr='goodbye'):
... print(f.attr)
goodbye
>>> print(f.attr)
hello | supersmoother/utils.py | def setattr_context(obj, **kwargs):
"""
Context manager to temporarily change the values of object attributes
while executing a function.
Example
-------
>>> class Foo: pass
>>> f = Foo(); f.attr = 'hello'
>>> with setattr_context(f, attr='goodbye'):
... print(f.attr)
goodby... | def setattr_context(obj, **kwargs):
"""
Context manager to temporarily change the values of object attributes
while executing a function.
Example
-------
>>> class Foo: pass
>>> f = Foo(); f.attr = 'hello'
>>> with setattr_context(f, attr='goodbye'):
... print(f.attr)
goodby... | [
"Context",
"manager",
"to",
"temporarily",
"change",
"the",
"values",
"of",
"object",
"attributes",
"while",
"executing",
"a",
"function",
"."
] | jakevdp/supersmoother | python | https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/utils.py#L10-L30 | [
"def",
"setattr_context",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"old_kwargs",
"=",
"dict",
"(",
"[",
"(",
"key",
",",
"getattr",
"(",
"obj",
",",
"key",
")",
")",
"for",
"key",
"in",
"kwargs",
"]",
")",
"[",
"setattr",
"(",
"obj",
",",
... | 0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f |
train | validate_inputs | Validate input arrays
This checks that
- Arrays are mutually broadcastable
- Broadcasted arrays are one-dimensional
Optionally, arrays are sorted according to the ``sort_by`` argument.
Parameters
----------
*args : ndarrays
All non-keyword arguments are arrays which will be valida... | supersmoother/utils.py | def validate_inputs(*arrays, **kwargs):
"""Validate input arrays
This checks that
- Arrays are mutually broadcastable
- Broadcasted arrays are one-dimensional
Optionally, arrays are sorted according to the ``sort_by`` argument.
Parameters
----------
*args : ndarrays
All non-ke... | def validate_inputs(*arrays, **kwargs):
"""Validate input arrays
This checks that
- Arrays are mutually broadcastable
- Broadcasted arrays are one-dimensional
Optionally, arrays are sorted according to the ``sort_by`` argument.
Parameters
----------
*args : ndarrays
All non-ke... | [
"Validate",
"input",
"arrays"
] | jakevdp/supersmoother | python | https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/utils.py#L43-L73 | [
"def",
"validate_inputs",
"(",
"*",
"arrays",
",",
"*",
"*",
"kwargs",
")",
":",
"arrays",
"=",
"np",
".",
"broadcast_arrays",
"(",
"*",
"arrays",
")",
"sort_by",
"=",
"kwargs",
".",
"pop",
"(",
"'sort_by'",
",",
"None",
")",
"if",
"kwargs",
":",
"ra... | 0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f |
train | _prep_smooth | Private function to prepare & check variables for smooth utilities | supersmoother/utils.py | def _prep_smooth(t, y, dy, span, t_out, span_out, period):
"""Private function to prepare & check variables for smooth utilities"""
# If period is provided, sort by phases. Otherwise sort by t
if period:
t = t % period
if t_out is not None:
t_out = t_out % period
t, y, dy =... | def _prep_smooth(t, y, dy, span, t_out, span_out, period):
"""Private function to prepare & check variables for smooth utilities"""
# If period is provided, sort by phases. Otherwise sort by t
if period:
t = t % period
if t_out is not None:
t_out = t_out % period
t, y, dy =... | [
"Private",
"function",
"to",
"prepare",
"&",
"check",
"variables",
"for",
"smooth",
"utilities"
] | jakevdp/supersmoother | python | https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/utils.py#L76-L99 | [
"def",
"_prep_smooth",
"(",
"t",
",",
"y",
",",
"dy",
",",
"span",
",",
"t_out",
",",
"span_out",
",",
"period",
")",
":",
"# If period is provided, sort by phases. Otherwise sort by t",
"if",
"period",
":",
"t",
"=",
"t",
"%",
"period",
"if",
"t_out",
"is",... | 0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f |
train | moving_average_smooth | Perform a moving-average smooth of the data
Parameters
----------
t, y, dy : array_like
time, value, and error in value of the input data
span : array_like
the integer spans of the data
cv : boolean (default=True)
if True, treat the problem as a cross-validation, i.e. don't ... | supersmoother/utils.py | def moving_average_smooth(t, y, dy, span=None, cv=True,
t_out=None, span_out=None, period=None):
"""Perform a moving-average smooth of the data
Parameters
----------
t, y, dy : array_like
time, value, and error in value of the input data
span : array_like
t... | def moving_average_smooth(t, y, dy, span=None, cv=True,
t_out=None, span_out=None, period=None):
"""Perform a moving-average smooth of the data
Parameters
----------
t, y, dy : array_like
time, value, and error in value of the input data
span : array_like
t... | [
"Perform",
"a",
"moving",
"-",
"average",
"smooth",
"of",
"the",
"data"
] | jakevdp/supersmoother | python | https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/utils.py#L102-L138 | [
"def",
"moving_average_smooth",
"(",
"t",
",",
"y",
",",
"dy",
",",
"span",
"=",
"None",
",",
"cv",
"=",
"True",
",",
"t_out",
"=",
"None",
",",
"span_out",
"=",
"None",
",",
"period",
"=",
"None",
")",
":",
"prep",
"=",
"_prep_smooth",
"(",
"t",
... | 0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f |
train | linear_smooth | Perform a linear smooth of the data
Parameters
----------
t, y, dy : array_like
time, value, and error in value of the input data
span : array_like
the integer spans of the data
cv : boolean (default=True)
if True, treat the problem as a cross-validation, i.e. don't use
... | supersmoother/utils.py | def linear_smooth(t, y, dy, span=None, cv=True,
t_out=None, span_out=None, period=None):
"""Perform a linear smooth of the data
Parameters
----------
t, y, dy : array_like
time, value, and error in value of the input data
span : array_like
the integer spans of the ... | def linear_smooth(t, y, dy, span=None, cv=True,
t_out=None, span_out=None, period=None):
"""Perform a linear smooth of the data
Parameters
----------
t, y, dy : array_like
time, value, and error in value of the input data
span : array_like
the integer spans of the ... | [
"Perform",
"a",
"linear",
"smooth",
"of",
"the",
"data"
] | jakevdp/supersmoother | python | https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/utils.py#L141-L192 | [
"def",
"linear_smooth",
"(",
"t",
",",
"y",
",",
"dy",
",",
"span",
"=",
"None",
",",
"cv",
"=",
"True",
",",
"t_out",
"=",
"None",
",",
"span_out",
"=",
"None",
",",
"period",
"=",
"None",
")",
":",
"t_input",
"=",
"t",
"prep",
"=",
"_prep_smoot... | 0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f |
train | multinterp | Multiple linear interpolations
Parameters
----------
x : array_like, shape=(N,)
sorted array of x values
y : array_like, shape=(N, M)
array of y values corresponding to each x value
xquery : array_like, shape=(M,)
array of query values
slow : boolean, default=False
... | supersmoother/utils.py | def multinterp(x, y, xquery, slow=False):
"""Multiple linear interpolations
Parameters
----------
x : array_like, shape=(N,)
sorted array of x values
y : array_like, shape=(N, M)
array of y values corresponding to each x value
xquery : array_like, shape=(M,)
array of que... | def multinterp(x, y, xquery, slow=False):
"""Multiple linear interpolations
Parameters
----------
x : array_like, shape=(N,)
sorted array of x values
y : array_like, shape=(N, M)
array of y values corresponding to each x value
xquery : array_like, shape=(M,)
array of que... | [
"Multiple",
"linear",
"interpolations"
] | jakevdp/supersmoother | python | https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/utils.py#L195-L235 | [
"def",
"multinterp",
"(",
"x",
",",
"y",
",",
"xquery",
",",
"slow",
"=",
"False",
")",
":",
"x",
",",
"y",
",",
"xquery",
"=",
"map",
"(",
"np",
".",
"asarray",
",",
"(",
"x",
",",
"y",
",",
"xquery",
")",
")",
"assert",
"x",
".",
"ndim",
... | 0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f |
train | Consul._create_session | Create a consulate.session object, and query for its leader to ensure
that the connection is made.
:param test_connection: call .leader() to ensure that the connection
is valid
:type test_connection: bool
:return consulate.Session instance | flask_consulate/consul.py | def _create_session(self, test_connection=False):
"""
Create a consulate.session object, and query for its leader to ensure
that the connection is made.
:param test_connection: call .leader() to ensure that the connection
is valid
:type test_connection: bool
... | def _create_session(self, test_connection=False):
"""
Create a consulate.session object, and query for its leader to ensure
that the connection is made.
:param test_connection: call .leader() to ensure that the connection
is valid
:type test_connection: bool
... | [
"Create",
"a",
"consulate",
".",
"session",
"object",
"and",
"query",
"for",
"its",
"leader",
"to",
"ensure",
"that",
"the",
"connection",
"is",
"made",
"."
] | vsudilov/flask-consulate | python | https://github.com/vsudilov/flask-consulate/blob/514f8754e7186f960237ed2836206993d5d3d3b6/flask_consulate/consul.py#L62-L75 | [
"def",
"_create_session",
"(",
"self",
",",
"test_connection",
"=",
"False",
")",
":",
"session",
"=",
"consulate",
".",
"Session",
"(",
"host",
"=",
"self",
".",
"host",
",",
"port",
"=",
"self",
".",
"port",
")",
"if",
"test_connection",
":",
"session"... | 514f8754e7186f960237ed2836206993d5d3d3b6 |
train | Consul.apply_remote_config | Applies all config values defined in consul's kv store to self.app.
There is no guarantee that these values will not be overwritten later
elsewhere.
:param namespace: kv namespace/directory. Defaults to
DEFAULT_KV_NAMESPACE
:return: None | flask_consulate/consul.py | def apply_remote_config(self, namespace=None):
"""
Applies all config values defined in consul's kv store to self.app.
There is no guarantee that these values will not be overwritten later
elsewhere.
:param namespace: kv namespace/directory. Defaults to
DEFAULT_... | def apply_remote_config(self, namespace=None):
"""
Applies all config values defined in consul's kv store to self.app.
There is no guarantee that these values will not be overwritten later
elsewhere.
:param namespace: kv namespace/directory. Defaults to
DEFAULT_... | [
"Applies",
"all",
"config",
"values",
"defined",
"in",
"consul",
"s",
"kv",
"store",
"to",
"self",
".",
"app",
"."
] | vsudilov/flask-consulate | python | https://github.com/vsudilov/flask-consulate/blob/514f8754e7186f960237ed2836206993d5d3d3b6/flask_consulate/consul.py#L78-L109 | [
"def",
"apply_remote_config",
"(",
"self",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"namespace",
"is",
"None",
":",
"namespace",
"=",
"\"config/{service}/{environment}/\"",
".",
"format",
"(",
"service",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'SE... | 514f8754e7186f960237ed2836206993d5d3d3b6 |
train | Consul.register_service | register this service with consul
kwargs passed to Consul.agent.service.register | flask_consulate/consul.py | def register_service(self, **kwargs):
"""
register this service with consul
kwargs passed to Consul.agent.service.register
"""
kwargs.setdefault('name', self.app.name)
self.session.agent.service.register(**kwargs) | def register_service(self, **kwargs):
"""
register this service with consul
kwargs passed to Consul.agent.service.register
"""
kwargs.setdefault('name', self.app.name)
self.session.agent.service.register(**kwargs) | [
"register",
"this",
"service",
"with",
"consul",
"kwargs",
"passed",
"to",
"Consul",
".",
"agent",
".",
"service",
".",
"register"
] | vsudilov/flask-consulate | python | https://github.com/vsudilov/flask-consulate/blob/514f8754e7186f960237ed2836206993d5d3d3b6/flask_consulate/consul.py#L112-L118 | [
"def",
"register_service",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'name'",
",",
"self",
".",
"app",
".",
"name",
")",
"self",
".",
"session",
".",
"agent",
".",
"service",
".",
"register",
"(",
"*",
"*",
... | 514f8754e7186f960237ed2836206993d5d3d3b6 |
train | ConsulService._resolve | Query the consul DNS server for the service IP and port | flask_consulate/service.py | def _resolve(self):
"""
Query the consul DNS server for the service IP and port
"""
endpoints = {}
r = self.resolver.query(self.service, 'SRV')
for rec in r.response.additional:
name = rec.name.to_text()
addr = rec.items[0].address
endp... | def _resolve(self):
"""
Query the consul DNS server for the service IP and port
"""
endpoints = {}
r = self.resolver.query(self.service, 'SRV')
for rec in r.response.additional:
name = rec.name.to_text()
addr = rec.items[0].address
endp... | [
"Query",
"the",
"consul",
"DNS",
"server",
"for",
"the",
"service",
"IP",
"and",
"port"
] | vsudilov/flask-consulate | python | https://github.com/vsudilov/flask-consulate/blob/514f8754e7186f960237ed2836206993d5d3d3b6/flask_consulate/service.py#L55-L72 | [
"def",
"_resolve",
"(",
"self",
")",
":",
"endpoints",
"=",
"{",
"}",
"r",
"=",
"self",
".",
"resolver",
".",
"query",
"(",
"self",
".",
"service",
",",
"'SRV'",
")",
"for",
"rec",
"in",
"r",
".",
"response",
".",
"additional",
":",
"name",
"=",
... | 514f8754e7186f960237ed2836206993d5d3d3b6 |
train | ConsulService.request | Proxy to requests.request
:param method: str formatted http method
:param endpoint: service endpoint
:param kwargs: kwargs passed directly to requests.request
:return: | flask_consulate/service.py | def request(self, method, endpoint, **kwargs):
"""
Proxy to requests.request
:param method: str formatted http method
:param endpoint: service endpoint
:param kwargs: kwargs passed directly to requests.request
:return:
"""
kwargs.setdefault('timeout', (1, ... | def request(self, method, endpoint, **kwargs):
"""
Proxy to requests.request
:param method: str formatted http method
:param endpoint: service endpoint
:param kwargs: kwargs passed directly to requests.request
:return:
"""
kwargs.setdefault('timeout', (1, ... | [
"Proxy",
"to",
"requests",
".",
"request",
":",
"param",
"method",
":",
"str",
"formatted",
"http",
"method",
":",
"param",
"endpoint",
":",
"service",
"endpoint",
":",
"param",
"kwargs",
":",
"kwargs",
"passed",
"directly",
"to",
"requests",
".",
"request",... | vsudilov/flask-consulate | python | https://github.com/vsudilov/flask-consulate/blob/514f8754e7186f960237ed2836206993d5d3d3b6/flask_consulate/service.py#L82-L95 | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"endpoint",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'timeout'",
",",
"(",
"1",
",",
"30",
")",
")",
"return",
"self",
".",
"session",
".",
"request",
"(",
"method",
",... | 514f8754e7186f960237ed2836206993d5d3d3b6 |
train | with_retry_connections | Decorator that wraps an entire function in a try/except clause. On
requests.exceptions.ConnectionError, will re-run the function code
until success or max_tries is reached.
:param max_tries: maximum number of attempts before giving up
:param sleep: time to sleep between tries, or None | flask_consulate/decorators.py | def with_retry_connections(max_tries=3, sleep=0.05):
"""
Decorator that wraps an entire function in a try/except clause. On
requests.exceptions.ConnectionError, will re-run the function code
until success or max_tries is reached.
:param max_tries: maximum number of attempts before giving up
:pa... | def with_retry_connections(max_tries=3, sleep=0.05):
"""
Decorator that wraps an entire function in a try/except clause. On
requests.exceptions.ConnectionError, will re-run the function code
until success or max_tries is reached.
:param max_tries: maximum number of attempts before giving up
:pa... | [
"Decorator",
"that",
"wraps",
"an",
"entire",
"function",
"in",
"a",
"try",
"/",
"except",
"clause",
".",
"On",
"requests",
".",
"exceptions",
".",
"ConnectionError",
"will",
"re",
"-",
"run",
"the",
"function",
"code",
"until",
"success",
"or",
"max_tries",... | vsudilov/flask-consulate | python | https://github.com/vsudilov/flask-consulate/blob/514f8754e7186f960237ed2836206993d5d3d3b6/flask_consulate/decorators.py#L11-L34 | [
"def",
"with_retry_connections",
"(",
"max_tries",
"=",
"3",
",",
"sleep",
"=",
"0.05",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"f_retry",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")... | 514f8754e7186f960237ed2836206993d5d3d3b6 |
train | crop | Crop the generator to a finite number of frames
Return a generator which outputs the provided generator limited
to enough samples to produce seconds seconds of audio (default 5s)
at the provided frame rate. | audiogen/util.py | def crop(gens, seconds=5, cropper=None):
'''
Crop the generator to a finite number of frames
Return a generator which outputs the provided generator limited
to enough samples to produce seconds seconds of audio (default 5s)
at the provided frame rate.
'''
if hasattr(gens, "next"):
# single generator
gens = ... | def crop(gens, seconds=5, cropper=None):
'''
Crop the generator to a finite number of frames
Return a generator which outputs the provided generator limited
to enough samples to produce seconds seconds of audio (default 5s)
at the provided frame rate.
'''
if hasattr(gens, "next"):
# single generator
gens = ... | [
"Crop",
"the",
"generator",
"to",
"a",
"finite",
"number",
"of",
"frames"
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/util.py#L15-L31 | [
"def",
"crop",
"(",
"gens",
",",
"seconds",
"=",
"5",
",",
"cropper",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"gens",
",",
"\"next\"",
")",
":",
"# single generator",
"gens",
"=",
"(",
"gens",
",",
")",
"if",
"cropper",
"==",
"None",
":",
"cro... | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | crop_at_zero_crossing | Crop the generator, ending at a zero-crossing
Crop the generator to produce approximately seconds seconds
(default 5s) of audio at the provided FRAME_RATE, attempting
to end the clip at a zero crossing point to avoid clicking. | audiogen/util.py | def crop_at_zero_crossing(gen, seconds=5, error=0.1):
'''
Crop the generator, ending at a zero-crossing
Crop the generator to produce approximately seconds seconds
(default 5s) of audio at the provided FRAME_RATE, attempting
to end the clip at a zero crossing point to avoid clicking.
'''
source = iter(gen)
... | def crop_at_zero_crossing(gen, seconds=5, error=0.1):
'''
Crop the generator, ending at a zero-crossing
Crop the generator to produce approximately seconds seconds
(default 5s) of audio at the provided FRAME_RATE, attempting
to end the clip at a zero crossing point to avoid clicking.
'''
source = iter(gen)
... | [
"Crop",
"the",
"generator",
"ending",
"at",
"a",
"zero",
"-",
"crossing"
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/util.py#L86-L123 | [
"def",
"crop_at_zero_crossing",
"(",
"gen",
",",
"seconds",
"=",
"5",
",",
"error",
"=",
"0.1",
")",
":",
"source",
"=",
"iter",
"(",
"gen",
")",
"buffer_length",
"=",
"int",
"(",
"2",
"*",
"error",
"*",
"sampler",
".",
"FRAME_RATE",
")",
"# split the ... | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | volume | Change the volume of gen by dB decibles | audiogen/util.py | def volume(gen, dB=0):
'''Change the volume of gen by dB decibles'''
if not hasattr(dB, 'next'):
# not a generator
scale = 10 ** (dB / 20.)
else:
def scale_gen():
while True:
yield 10 ** (next(dB) / 20.)
scale = scale_gen()
return envelope(gen, scale) | def volume(gen, dB=0):
'''Change the volume of gen by dB decibles'''
if not hasattr(dB, 'next'):
# not a generator
scale = 10 ** (dB / 20.)
else:
def scale_gen():
while True:
yield 10 ** (next(dB) / 20.)
scale = scale_gen()
return envelope(gen, scale) | [
"Change",
"the",
"volume",
"of",
"gen",
"by",
"dB",
"decibles"
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/util.py#L161-L171 | [
"def",
"volume",
"(",
"gen",
",",
"dB",
"=",
"0",
")",
":",
"if",
"not",
"hasattr",
"(",
"dB",
",",
"'next'",
")",
":",
"# not a generator",
"scale",
"=",
"10",
"**",
"(",
"dB",
"/",
"20.",
")",
"else",
":",
"def",
"scale_gen",
"(",
")",
":",
"... | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | mixer | Mix `inputs` together based on `mix` tuple
`inputs` should be a tuple of *n* generators.
`mix` should be a tuple of *m* tuples, one per desired
output channel. Each of the *m* tuples should contain
*n* generators, corresponding to the time-sequence of
the desired mix levels for each of the *n* input channels.
... | audiogen/util.py | def mixer(inputs, mix=None):
'''
Mix `inputs` together based on `mix` tuple
`inputs` should be a tuple of *n* generators.
`mix` should be a tuple of *m* tuples, one per desired
output channel. Each of the *m* tuples should contain
*n* generators, corresponding to the time-sequence of
the desired mix levels f... | def mixer(inputs, mix=None):
'''
Mix `inputs` together based on `mix` tuple
`inputs` should be a tuple of *n* generators.
`mix` should be a tuple of *m* tuples, one per desired
output channel. Each of the *m* tuples should contain
*n* generators, corresponding to the time-sequence of
the desired mix levels f... | [
"Mix",
"inputs",
"together",
"based",
"on",
"mix",
"tuple"
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/util.py#L199-L250 | [
"def",
"mixer",
"(",
"inputs",
",",
"mix",
"=",
"None",
")",
":",
"if",
"mix",
"==",
"None",
":",
"# by default, mix all inputs down to one channel",
"mix",
"=",
"(",
"[",
"constant",
"(",
"1.0",
"/",
"len",
"(",
"inputs",
")",
")",
"]",
"*",
"len",
"(... | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | channelize | Break multi-channel generator into one sub-generator per channel
Takes a generator producing n-tuples of samples and returns n generators,
each producing samples for a single channel.
Since multi-channel generators are the only reasonable way to synchronize samples
across channels, and the sampler functions only ... | audiogen/util.py | def channelize(gen, channels):
'''
Break multi-channel generator into one sub-generator per channel
Takes a generator producing n-tuples of samples and returns n generators,
each producing samples for a single channel.
Since multi-channel generators are the only reasonable way to synchronize samples
across chan... | def channelize(gen, channels):
'''
Break multi-channel generator into one sub-generator per channel
Takes a generator producing n-tuples of samples and returns n generators,
each producing samples for a single channel.
Since multi-channel generators are the only reasonable way to synchronize samples
across chan... | [
"Break",
"multi",
"-",
"channel",
"generator",
"into",
"one",
"sub",
"-",
"generator",
"per",
"channel"
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/util.py#L252-L266 | [
"def",
"channelize",
"(",
"gen",
",",
"channels",
")",
":",
"def",
"pick",
"(",
"g",
",",
"channel",
")",
":",
"for",
"samples",
"in",
"g",
":",
"yield",
"samples",
"[",
"channel",
"]",
"return",
"[",
"pick",
"(",
"gen_copy",
",",
"channel",
")",
"... | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | file_is_seekable | Returns True if file `f` is seekable, and False if not
Useful to determine, for example, if `f` is STDOUT to
a pipe. | audiogen/sampler.py | def file_is_seekable(f):
'''
Returns True if file `f` is seekable, and False if not
Useful to determine, for example, if `f` is STDOUT to
a pipe.
'''
try:
f.tell()
logger.info("File is seekable!")
except IOError, e:
if e.errno == errno.ESPIPE:
return False
else:
raise
return True | def file_is_seekable(f):
'''
Returns True if file `f` is seekable, and False if not
Useful to determine, for example, if `f` is STDOUT to
a pipe.
'''
try:
f.tell()
logger.info("File is seekable!")
except IOError, e:
if e.errno == errno.ESPIPE:
return False
else:
raise
return True | [
"Returns",
"True",
"if",
"file",
"f",
"is",
"seekable",
"and",
"False",
"if",
"not",
"Useful",
"to",
"determine",
"for",
"example",
"if",
"f",
"is",
"STDOUT",
"to",
"a",
"pipe",
"."
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/sampler.py#L54-L69 | [
"def",
"file_is_seekable",
"(",
"f",
")",
":",
"try",
":",
"f",
".",
"tell",
"(",
")",
"logger",
".",
"info",
"(",
"\"File is seekable!\"",
")",
"except",
"IOError",
",",
"e",
":",
"if",
"e",
".",
"errno",
"==",
"errno",
".",
"ESPIPE",
":",
"return",... | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | sample | Convert audio waveform generator into packed sample generator. | audiogen/sampler.py | def sample(generator, min=-1, max=1, width=SAMPLE_WIDTH):
'''Convert audio waveform generator into packed sample generator.'''
# select signed char, short, or in based on sample width
fmt = { 1: '<B', 2: '<h', 4: '<i' }[width]
return (struct.pack(fmt, int(sample)) for sample in \
normalize(hard_clip(generator, m... | def sample(generator, min=-1, max=1, width=SAMPLE_WIDTH):
'''Convert audio waveform generator into packed sample generator.'''
# select signed char, short, or in based on sample width
fmt = { 1: '<B', 2: '<h', 4: '<i' }[width]
return (struct.pack(fmt, int(sample)) for sample in \
normalize(hard_clip(generator, m... | [
"Convert",
"audio",
"waveform",
"generator",
"into",
"packed",
"sample",
"generator",
"."
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/sampler.py#L72-L78 | [
"def",
"sample",
"(",
"generator",
",",
"min",
"=",
"-",
"1",
",",
"max",
"=",
"1",
",",
"width",
"=",
"SAMPLE_WIDTH",
")",
":",
"# select signed char, short, or in based on sample width",
"fmt",
"=",
"{",
"1",
":",
"'<B'",
",",
"2",
":",
"'<h'",
",",
"4... | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | sample_all | Convert list of audio waveform generators into list of packed sample generators. | audiogen/sampler.py | def sample_all(generators, *args, **kwargs):
'''Convert list of audio waveform generators into list of packed sample generators.'''
return [sample(gen, *args, **kwargs) for gen in generators] | def sample_all(generators, *args, **kwargs):
'''Convert list of audio waveform generators into list of packed sample generators.'''
return [sample(gen, *args, **kwargs) for gen in generators] | [
"Convert",
"list",
"of",
"audio",
"waveform",
"generators",
"into",
"list",
"of",
"packed",
"sample",
"generators",
"."
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/sampler.py#L82-L84 | [
"def",
"sample_all",
"(",
"generators",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"[",
"sample",
"(",
"gen",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"for",
"gen",
"in",
"generators",
"]"
] | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | buffer | Buffer the generator into byte strings of buffer_size samples
Return a generator that outputs reasonably sized byte strings
containing buffer_size samples from the generator stream.
This allows us to outputing big chunks of the audio stream to
disk at once for faster writes. | audiogen/sampler.py | def buffer(stream, buffer_size=BUFFER_SIZE):
'''
Buffer the generator into byte strings of buffer_size samples
Return a generator that outputs reasonably sized byte strings
containing buffer_size samples from the generator stream.
This allows us to outputing big chunks of the audio stream to
disk at once for ... | def buffer(stream, buffer_size=BUFFER_SIZE):
'''
Buffer the generator into byte strings of buffer_size samples
Return a generator that outputs reasonably sized byte strings
containing buffer_size samples from the generator stream.
This allows us to outputing big chunks of the audio stream to
disk at once for ... | [
"Buffer",
"the",
"generator",
"into",
"byte",
"strings",
"of",
"buffer_size",
"samples"
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/sampler.py#L97-L108 | [
"def",
"buffer",
"(",
"stream",
",",
"buffer_size",
"=",
"BUFFER_SIZE",
")",
":",
"i",
"=",
"iter",
"(",
"stream",
")",
"return",
"iter",
"(",
"lambda",
":",
"\"\"",
".",
"join",
"(",
"itertools",
".",
"islice",
"(",
"i",
",",
"buffer_size",
")",
")"... | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | wave_module_patched | True if wave module can write data size of 0xFFFFFFFF, False otherwise. | audiogen/sampler.py | def wave_module_patched():
'''True if wave module can write data size of 0xFFFFFFFF, False otherwise.'''
f = StringIO()
w = wave.open(f, "wb")
w.setparams((1, 2, 44100, 0, "NONE", "no compression"))
patched = True
try:
w.setnframes((0xFFFFFFFF - 36) / w.getnchannels() / w.getsampwidth())
w._ensure_header_writ... | def wave_module_patched():
'''True if wave module can write data size of 0xFFFFFFFF, False otherwise.'''
f = StringIO()
w = wave.open(f, "wb")
w.setparams((1, 2, 44100, 0, "NONE", "no compression"))
patched = True
try:
w.setnframes((0xFFFFFFFF - 36) / w.getnchannels() / w.getsampwidth())
w._ensure_header_writ... | [
"True",
"if",
"wave",
"module",
"can",
"write",
"data",
"size",
"of",
"0xFFFFFFFF",
"False",
"otherwise",
"."
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/sampler.py#L134-L148 | [
"def",
"wave_module_patched",
"(",
")",
":",
"f",
"=",
"StringIO",
"(",
")",
"w",
"=",
"wave",
".",
"open",
"(",
"f",
",",
"\"wb\"",
")",
"w",
".",
"setparams",
"(",
"(",
"1",
",",
"2",
",",
"44100",
",",
"0",
",",
"\"NONE\"",
",",
"\"no compress... | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | cache_finite_samples | Decorator to cache audio samples produced by the wrapped generator. | audiogen/sampler.py | def cache_finite_samples(f):
'''Decorator to cache audio samples produced by the wrapped generator.'''
cache = {}
def wrap(*args):
key = FRAME_RATE, args
if key not in cache:
cache[key] = [sample for sample in f(*args)]
return (sample for sample in cache[key])
return wrap | def cache_finite_samples(f):
'''Decorator to cache audio samples produced by the wrapped generator.'''
cache = {}
def wrap(*args):
key = FRAME_RATE, args
if key not in cache:
cache[key] = [sample for sample in f(*args)]
return (sample for sample in cache[key])
return wrap | [
"Decorator",
"to",
"cache",
"audio",
"samples",
"produced",
"by",
"the",
"wrapped",
"generator",
"."
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/sampler.py#L189-L197 | [
"def",
"cache_finite_samples",
"(",
"f",
")",
":",
"cache",
"=",
"{",
"}",
"def",
"wrap",
"(",
"*",
"args",
")",
":",
"key",
"=",
"FRAME_RATE",
",",
"args",
"if",
"key",
"not",
"in",
"cache",
":",
"cache",
"[",
"key",
"]",
"=",
"[",
"sample",
"fo... | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | play | Play the contents of the generator using PyAudio
Play to the system soundcard using PyAudio. PyAudio, an otherwise optional
depenency, must be installed for this feature to work. | audiogen/sampler.py | def play(channels, blocking=True, raw_samples=False):
'''
Play the contents of the generator using PyAudio
Play to the system soundcard using PyAudio. PyAudio, an otherwise optional
depenency, must be installed for this feature to work.
'''
if not pyaudio_loaded:
raise Exception("Soundcard playback requires P... | def play(channels, blocking=True, raw_samples=False):
'''
Play the contents of the generator using PyAudio
Play to the system soundcard using PyAudio. PyAudio, an otherwise optional
depenency, must be installed for this feature to work.
'''
if not pyaudio_loaded:
raise Exception("Soundcard playback requires P... | [
"Play",
"the",
"contents",
"of",
"the",
"generator",
"using",
"PyAudio"
] | casebeer/audiogen | python | https://github.com/casebeer/audiogen/blob/184dee2ca32c2bb4315a0f18e62288728fcd7881/audiogen/sampler.py#L211-L245 | [
"def",
"play",
"(",
"channels",
",",
"blocking",
"=",
"True",
",",
"raw_samples",
"=",
"False",
")",
":",
"if",
"not",
"pyaudio_loaded",
":",
"raise",
"Exception",
"(",
"\"Soundcard playback requires PyAudio. Install with `pip install pyaudio`.\"",
")",
"channel_count",... | 184dee2ca32c2bb4315a0f18e62288728fcd7881 |
train | windowed_sum_slow | Compute the windowed sum of the given arrays.
This is a slow function, used primarily for testing and validation
of the faster version of ``windowed_sum()``
Parameters
----------
arrays : tuple of arrays
arrays to window
span : int or array of ints
The span to use for the sum a... | supersmoother/windowed_sum.py | def windowed_sum_slow(arrays, span, t=None, indices=None, tpowers=0,
period=None, subtract_mid=False):
"""Compute the windowed sum of the given arrays.
This is a slow function, used primarily for testing and validation
of the faster version of ``windowed_sum()``
Parameters
--... | def windowed_sum_slow(arrays, span, t=None, indices=None, tpowers=0,
period=None, subtract_mid=False):
"""Compute the windowed sum of the given arrays.
This is a slow function, used primarily for testing and validation
of the faster version of ``windowed_sum()``
Parameters
--... | [
"Compute",
"the",
"windowed",
"sum",
"of",
"the",
"given",
"arrays",
"."
] | jakevdp/supersmoother | python | https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/windowed_sum.py#L4-L84 | [
"def",
"windowed_sum_slow",
"(",
"arrays",
",",
"span",
",",
"t",
"=",
"None",
",",
"indices",
"=",
"None",
",",
"tpowers",
"=",
"0",
",",
"period",
"=",
"None",
",",
"subtract_mid",
"=",
"False",
")",
":",
"span",
"=",
"np",
".",
"asarray",
"(",
"... | 0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f |
train | windowed_sum | Compute the windowed sum of the given arrays.
Parameters
----------
arrays : tuple of arrays
arrays to window
span : int or array of ints
The span to use for the sum at each point. If array is provided,
it must be broadcastable with ``indices``
indices : array
the in... | supersmoother/windowed_sum.py | def windowed_sum(arrays, span, t=None, indices=None, tpowers=0,
period=None, subtract_mid=False):
"""Compute the windowed sum of the given arrays.
Parameters
----------
arrays : tuple of arrays
arrays to window
span : int or array of ints
The span to use for the sum... | def windowed_sum(arrays, span, t=None, indices=None, tpowers=0,
period=None, subtract_mid=False):
"""Compute the windowed sum of the given arrays.
Parameters
----------
arrays : tuple of arrays
arrays to window
span : int or array of ints
The span to use for the sum... | [
"Compute",
"the",
"windowed",
"sum",
"of",
"the",
"given",
"arrays",
"."
] | jakevdp/supersmoother | python | https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/windowed_sum.py#L87-L212 | [
"def",
"windowed_sum",
"(",
"arrays",
",",
"span",
",",
"t",
"=",
"None",
",",
"indices",
"=",
"None",
",",
"tpowers",
"=",
"0",
",",
"period",
"=",
"None",
",",
"subtract_mid",
"=",
"False",
")",
":",
"span",
"=",
"np",
".",
"asarray",
"(",
"span"... | 0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f |
train | _pad_arrays | Internal routine to pad arrays for periodic models. | supersmoother/windowed_sum.py | def _pad_arrays(t, arrays, indices, span, period):
"""Internal routine to pad arrays for periodic models."""
N = len(t)
if indices is None:
indices = np.arange(N)
pad_left = max(0, 0 - np.min(indices - span // 2))
pad_right = max(0, np.max(indices + span - span // 2) - (N - 1))
if pad_... | def _pad_arrays(t, arrays, indices, span, period):
"""Internal routine to pad arrays for periodic models."""
N = len(t)
if indices is None:
indices = np.arange(N)
pad_left = max(0, 0 - np.min(indices - span // 2))
pad_right = max(0, np.max(indices + span - span // 2) - (N - 1))
if pad_... | [
"Internal",
"routine",
"to",
"pad",
"arrays",
"for",
"periodic",
"models",
"."
] | jakevdp/supersmoother | python | https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/windowed_sum.py#L215-L242 | [
"def",
"_pad_arrays",
"(",
"t",
",",
"arrays",
",",
"indices",
",",
"span",
",",
"period",
")",
":",
"N",
"=",
"len",
"(",
"t",
")",
"if",
"indices",
"is",
"None",
":",
"indices",
"=",
"np",
".",
"arange",
"(",
"N",
")",
"pad_left",
"=",
"max",
... | 0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f |
train | Device.get_i2c_bus_numbers | Search all the available I2C devices in the system | pca9685_driver/device.py | def get_i2c_bus_numbers(glober = glob.glob):
"""Search all the available I2C devices in the system"""
res = []
for device in glober("/dev/i2c-*"):
r = re.match("/dev/i2c-([\d]){1,2}", device)
res.append(int(r.group(1)))
return res | def get_i2c_bus_numbers(glober = glob.glob):
"""Search all the available I2C devices in the system"""
res = []
for device in glober("/dev/i2c-*"):
r = re.match("/dev/i2c-([\d]){1,2}", device)
res.append(int(r.group(1)))
return res | [
"Search",
"all",
"the",
"available",
"I2C",
"devices",
"in",
"the",
"system"
] | voidpp/PCA9685-driver | python | https://github.com/voidpp/PCA9685-driver/blob/774790028cbced30fd69384f945198148b1793fc/pca9685_driver/device.py#L69-L75 | [
"def",
"get_i2c_bus_numbers",
"(",
"glober",
"=",
"glob",
".",
"glob",
")",
":",
"res",
"=",
"[",
"]",
"for",
"device",
"in",
"glober",
"(",
"\"/dev/i2c-*\"",
")",
":",
"r",
"=",
"re",
".",
"match",
"(",
"\"/dev/i2c-([\\d]){1,2}\"",
",",
"device",
")",
... | 774790028cbced30fd69384f945198148b1793fc |
train | Device.get_led_register_from_name | Parse the name for led number
:param name: attribute name, like: led_1 | pca9685_driver/device.py | def get_led_register_from_name(self, name):
"""Parse the name for led number
:param name: attribute name, like: led_1
"""
res = re.match('^led_([0-9]{1,2})$', name)
if res is None:
raise AttributeError("Unknown attribute: '%s'" % name)
led_num = int(res.group... | def get_led_register_from_name(self, name):
"""Parse the name for led number
:param name: attribute name, like: led_1
"""
res = re.match('^led_([0-9]{1,2})$', name)
if res is None:
raise AttributeError("Unknown attribute: '%s'" % name)
led_num = int(res.group... | [
"Parse",
"the",
"name",
"for",
"led",
"number"
] | voidpp/PCA9685-driver | python | https://github.com/voidpp/PCA9685-driver/blob/774790028cbced30fd69384f945198148b1793fc/pca9685_driver/device.py#L87-L98 | [
"def",
"get_led_register_from_name",
"(",
"self",
",",
"name",
")",
":",
"res",
"=",
"re",
".",
"match",
"(",
"'^led_([0-9]{1,2})$'",
",",
"name",
")",
"if",
"res",
"is",
"None",
":",
"raise",
"AttributeError",
"(",
"\"Unknown attribute: '%s'\"",
"%",
"name",
... | 774790028cbced30fd69384f945198148b1793fc |
train | Device.set_pwm | Set PWM value for the specified LED
:param led_num: LED number (0-15)
:param value: the 12 bit value (0-4095) | pca9685_driver/device.py | def set_pwm(self, led_num, value):
"""Set PWM value for the specified LED
:param led_num: LED number (0-15)
:param value: the 12 bit value (0-4095)
"""
self.__check_range('led_number', led_num)
self.__check_range('led_value', value)
register_low = self.calc_led_... | def set_pwm(self, led_num, value):
"""Set PWM value for the specified LED
:param led_num: LED number (0-15)
:param value: the 12 bit value (0-4095)
"""
self.__check_range('led_number', led_num)
self.__check_range('led_value', value)
register_low = self.calc_led_... | [
"Set",
"PWM",
"value",
"for",
"the",
"specified",
"LED"
] | voidpp/PCA9685-driver | python | https://github.com/voidpp/PCA9685-driver/blob/774790028cbced30fd69384f945198148b1793fc/pca9685_driver/device.py#L115-L127 | [
"def",
"set_pwm",
"(",
"self",
",",
"led_num",
",",
"value",
")",
":",
"self",
".",
"__check_range",
"(",
"'led_number'",
",",
"led_num",
")",
"self",
".",
"__check_range",
"(",
"'led_value'",
",",
"value",
")",
"register_low",
"=",
"self",
".",
"calc_led_... | 774790028cbced30fd69384f945198148b1793fc |
train | Device.get_pwm | Generic getter for all LED PWM value | pca9685_driver/device.py | def get_pwm(self, led_num):
"""Generic getter for all LED PWM value"""
self.__check_range('led_number', led_num)
register_low = self.calc_led_register(led_num)
return self.__get_led_value(register_low) | def get_pwm(self, led_num):
"""Generic getter for all LED PWM value"""
self.__check_range('led_number', led_num)
register_low = self.calc_led_register(led_num)
return self.__get_led_value(register_low) | [
"Generic",
"getter",
"for",
"all",
"LED",
"PWM",
"value"
] | voidpp/PCA9685-driver | python | https://github.com/voidpp/PCA9685-driver/blob/774790028cbced30fd69384f945198148b1793fc/pca9685_driver/device.py#L134-L138 | [
"def",
"get_pwm",
"(",
"self",
",",
"led_num",
")",
":",
"self",
".",
"__check_range",
"(",
"'led_number'",
",",
"led_num",
")",
"register_low",
"=",
"self",
".",
"calc_led_register",
"(",
"led_num",
")",
"return",
"self",
".",
"__get_led_value",
"(",
"regis... | 774790028cbced30fd69384f945198148b1793fc |
train | Device.sleep | Send the controller to sleep | pca9685_driver/device.py | def sleep(self):
"""Send the controller to sleep"""
logger.debug("Sleep the controller")
self.write(Registers.MODE_1, self.mode_1 | (1 << Mode1.SLEEP)) | def sleep(self):
"""Send the controller to sleep"""
logger.debug("Sleep the controller")
self.write(Registers.MODE_1, self.mode_1 | (1 << Mode1.SLEEP)) | [
"Send",
"the",
"controller",
"to",
"sleep"
] | voidpp/PCA9685-driver | python | https://github.com/voidpp/PCA9685-driver/blob/774790028cbced30fd69384f945198148b1793fc/pca9685_driver/device.py#L145-L148 | [
"def",
"sleep",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Sleep the controller\"",
")",
"self",
".",
"write",
"(",
"Registers",
".",
"MODE_1",
",",
"self",
".",
"mode_1",
"|",
"(",
"1",
"<<",
"Mode1",
".",
"SLEEP",
")",
")"
] | 774790028cbced30fd69384f945198148b1793fc |
train | Device.write | Write raw byte value to the specified register
:param reg: the register number (0-69, 250-255)
:param value: byte value | pca9685_driver/device.py | def write(self, reg, value):
"""Write raw byte value to the specified register
:param reg: the register number (0-69, 250-255)
:param value: byte value
"""
# TODO: check reg: 0-69, 250-255
self.__check_range('register_value', value)
logger.debug("Write '%s' to re... | def write(self, reg, value):
"""Write raw byte value to the specified register
:param reg: the register number (0-69, 250-255)
:param value: byte value
"""
# TODO: check reg: 0-69, 250-255
self.__check_range('register_value', value)
logger.debug("Write '%s' to re... | [
"Write",
"raw",
"byte",
"value",
"to",
"the",
"specified",
"register"
] | voidpp/PCA9685-driver | python | https://github.com/voidpp/PCA9685-driver/blob/774790028cbced30fd69384f945198148b1793fc/pca9685_driver/device.py#L155-L164 | [
"def",
"write",
"(",
"self",
",",
"reg",
",",
"value",
")",
":",
"# TODO: check reg: 0-69, 250-255",
"self",
".",
"__check_range",
"(",
"'register_value'",
",",
"value",
")",
"logger",
".",
"debug",
"(",
"\"Write '%s' to register '%s'\"",
"%",
"(",
"value",
",",... | 774790028cbced30fd69384f945198148b1793fc |
train | Device.set_pwm_frequency | Set the frequency for all PWM output
:param value: the frequency in Hz | pca9685_driver/device.py | def set_pwm_frequency(self, value):
"""Set the frequency for all PWM output
:param value: the frequency in Hz
"""
self.__check_range('pwm_frequency', value)
reg_val = self.calc_pre_scale(value)
logger.debug("Calculated prescale value is %s" % reg_val)
self.sleep(... | def set_pwm_frequency(self, value):
"""Set the frequency for all PWM output
:param value: the frequency in Hz
"""
self.__check_range('pwm_frequency', value)
reg_val = self.calc_pre_scale(value)
logger.debug("Calculated prescale value is %s" % reg_val)
self.sleep(... | [
"Set",
"the",
"frequency",
"for",
"all",
"PWM",
"output"
] | voidpp/PCA9685-driver | python | https://github.com/voidpp/PCA9685-driver/blob/774790028cbced30fd69384f945198148b1793fc/pca9685_driver/device.py#L180-L190 | [
"def",
"set_pwm_frequency",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"__check_range",
"(",
"'pwm_frequency'",
",",
"value",
")",
"reg_val",
"=",
"self",
".",
"calc_pre_scale",
"(",
"value",
")",
"logger",
".",
"debug",
"(",
"\"Calculated prescale valu... | 774790028cbced30fd69384f945198148b1793fc |
train | levenshtein_norm | Calculates the normalized Levenshtein distance between two string
arguments. The result will be a float in the range [0.0, 1.0], with 1.0
signifying the biggest possible distance between strings with these lengths | stringdist/pystringdist/levenshtein.py | def levenshtein_norm(source, target):
"""Calculates the normalized Levenshtein distance between two string
arguments. The result will be a float in the range [0.0, 1.0], with 1.0
signifying the biggest possible distance between strings with these lengths
"""
# Compute Levenshtein distance using hel... | def levenshtein_norm(source, target):
"""Calculates the normalized Levenshtein distance between two string
arguments. The result will be a float in the range [0.0, 1.0], with 1.0
signifying the biggest possible distance between strings with these lengths
"""
# Compute Levenshtein distance using hel... | [
"Calculates",
"the",
"normalized",
"Levenshtein",
"distance",
"between",
"two",
"string",
"arguments",
".",
"The",
"result",
"will",
"be",
"a",
"float",
"in",
"the",
"range",
"[",
"0",
".",
"0",
"1",
".",
"0",
"]",
"with",
"1",
".",
"0",
"signifying",
... | obulkin/string-dist | python | https://github.com/obulkin/string-dist/blob/38d04352d617a5d43b06832cc1bf0aee8978559f/stringdist/pystringdist/levenshtein.py#L15-L25 | [
"def",
"levenshtein_norm",
"(",
"source",
",",
"target",
")",
":",
"# Compute Levenshtein distance using helper function. The max is always",
"# just the length of the longer string, so this is used to normalize result",
"# before returning it",
"distance",
"=",
"_levenshtein_compute",
"... | 38d04352d617a5d43b06832cc1bf0aee8978559f |
train | check_valid_color | Check if the color provided by the user is valid.
If color is invalid the default is returned. | nanoplotter/nanoplotter_main.py | def check_valid_color(color):
"""Check if the color provided by the user is valid.
If color is invalid the default is returned.
"""
if color in list(mcolors.CSS4_COLORS.keys()) + ["#4CB391"]:
logging.info("Nanoplotter: Valid color {}.".format(color))
return color
else:
loggi... | def check_valid_color(color):
"""Check if the color provided by the user is valid.
If color is invalid the default is returned.
"""
if color in list(mcolors.CSS4_COLORS.keys()) + ["#4CB391"]:
logging.info("Nanoplotter: Valid color {}.".format(color))
return color
else:
loggi... | [
"Check",
"if",
"the",
"color",
"provided",
"by",
"the",
"user",
"is",
"valid",
"."
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/nanoplotter_main.py#L43-L54 | [
"def",
"check_valid_color",
"(",
"color",
")",
":",
"if",
"color",
"in",
"list",
"(",
"mcolors",
".",
"CSS4_COLORS",
".",
"keys",
"(",
")",
")",
"+",
"[",
"\"#4CB391\"",
"]",
":",
"logging",
".",
"info",
"(",
"\"Nanoplotter: Valid color {}.\"",
".",
"forma... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | check_valid_format | Check if the specified figure format is valid.
If format is invalid the default is returned.
Probably installation-dependent | nanoplotter/nanoplotter_main.py | def check_valid_format(figformat):
"""Check if the specified figure format is valid.
If format is invalid the default is returned.
Probably installation-dependent
"""
fig = plt.figure()
if figformat in list(fig.canvas.get_supported_filetypes().keys()):
logging.info("Nanoplotter: valid o... | def check_valid_format(figformat):
"""Check if the specified figure format is valid.
If format is invalid the default is returned.
Probably installation-dependent
"""
fig = plt.figure()
if figformat in list(fig.canvas.get_supported_filetypes().keys()):
logging.info("Nanoplotter: valid o... | [
"Check",
"if",
"the",
"specified",
"figure",
"format",
"is",
"valid",
"."
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/nanoplotter_main.py#L57-L70 | [
"def",
"check_valid_format",
"(",
"figformat",
")",
":",
"fig",
"=",
"plt",
".",
"figure",
"(",
")",
"if",
"figformat",
"in",
"list",
"(",
"fig",
".",
"canvas",
".",
"get_supported_filetypes",
"(",
")",
".",
"keys",
"(",
")",
")",
":",
"logging",
".",
... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | scatter | Create bivariate plots.
Create four types of bivariate plots of x vs y, containing marginal summaries
-A scatter plot with histograms on axes
-A hexagonal binned plot with histograms on axes
-A kernel density plot with density curves on axes
-A pauvre-style plot using code from https://github.com/c... | nanoplotter/nanoplotter_main.py | def scatter(x, y, names, path, plots, color="#4CB391", figformat="png",
stat=None, log=False, minvalx=0, minvaly=0, title=None, plot_settings=None):
"""Create bivariate plots.
Create four types of bivariate plots of x vs y, containing marginal summaries
-A scatter plot with histograms on axes
... | def scatter(x, y, names, path, plots, color="#4CB391", figformat="png",
stat=None, log=False, minvalx=0, minvaly=0, title=None, plot_settings=None):
"""Create bivariate plots.
Create four types of bivariate plots of x vs y, containing marginal summaries
-A scatter plot with histograms on axes
... | [
"Create",
"bivariate",
"plots",
"."
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/nanoplotter_main.py#L78-L206 | [
"def",
"scatter",
"(",
"x",
",",
"y",
",",
"names",
",",
"path",
",",
"plots",
",",
"color",
"=",
"\"#4CB391\"",
",",
"figformat",
"=",
"\"png\"",
",",
"stat",
"=",
"None",
",",
"log",
"=",
"False",
",",
"minvalx",
"=",
"0",
",",
"minvaly",
"=",
... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | contains_variance | Make sure both arrays for bivariate ("scatter") plot have a stddev > 0 | nanoplotter/nanoplotter_main.py | def contains_variance(arrays, names):
"""
Make sure both arrays for bivariate ("scatter") plot have a stddev > 0
"""
for ar, name in zip(arrays, names):
if np.std(ar) == 0:
sys.stderr.write(
"No variation in '{}', skipping bivariate plots.\n".format(name.lower()))
... | def contains_variance(arrays, names):
"""
Make sure both arrays for bivariate ("scatter") plot have a stddev > 0
"""
for ar, name in zip(arrays, names):
if np.std(ar) == 0:
sys.stderr.write(
"No variation in '{}', skipping bivariate plots.\n".format(name.lower()))
... | [
"Make",
"sure",
"both",
"arrays",
"for",
"bivariate",
"(",
"scatter",
")",
"plot",
"have",
"a",
"stddev",
">",
"0"
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/nanoplotter_main.py#L209-L220 | [
"def",
"contains_variance",
"(",
"arrays",
",",
"names",
")",
":",
"for",
"ar",
",",
"name",
"in",
"zip",
"(",
"arrays",
",",
"names",
")",
":",
"if",
"np",
".",
"std",
"(",
"ar",
")",
"==",
"0",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | length_plots | Create histogram of normal and log transformed read lengths. | nanoplotter/nanoplotter_main.py | def length_plots(array, name, path, title=None, n50=None, color="#4CB391", figformat="png"):
"""Create histogram of normal and log transformed read lengths."""
logging.info("Nanoplotter: Creating length plots for {}.".format(name))
maxvalx = np.amax(array)
if n50:
logging.info("Nanoplotter: Usin... | def length_plots(array, name, path, title=None, n50=None, color="#4CB391", figformat="png"):
"""Create histogram of normal and log transformed read lengths."""
logging.info("Nanoplotter: Creating length plots for {}.".format(name))
maxvalx = np.amax(array)
if n50:
logging.info("Nanoplotter: Usin... | [
"Create",
"histogram",
"of",
"normal",
"and",
"log",
"transformed",
"read",
"lengths",
"."
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/nanoplotter_main.py#L223-L298 | [
"def",
"length_plots",
"(",
"array",
",",
"name",
",",
"path",
",",
"title",
"=",
"None",
",",
"n50",
"=",
"None",
",",
"color",
"=",
"\"#4CB391\"",
",",
"figformat",
"=",
"\"png\"",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoplotter: Creating length pl... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | make_layout | Make the physical layout of the MinION flowcell.
based on https://bioinformatics.stackexchange.com/a/749/681
returned as a numpy array | nanoplotter/spatial_heatmap.py | def make_layout(maxval):
"""Make the physical layout of the MinION flowcell.
based on https://bioinformatics.stackexchange.com/a/749/681
returned as a numpy array
"""
if maxval > 512:
return Layout(
structure=np.concatenate([np.array([list(range(10 * i + 1, i * 10 + 11))
... | def make_layout(maxval):
"""Make the physical layout of the MinION flowcell.
based on https://bioinformatics.stackexchange.com/a/749/681
returned as a numpy array
"""
if maxval > 512:
return Layout(
structure=np.concatenate([np.array([list(range(10 * i + 1, i * 10 + 11))
... | [
"Make",
"the",
"physical",
"layout",
"of",
"the",
"MinION",
"flowcell",
".",
"based",
"on",
"https",
":",
"//",
"bioinformatics",
".",
"stackexchange",
".",
"com",
"/",
"a",
"/",
"749",
"/",
"681",
"returned",
"as",
"a",
"numpy",
"array"
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/spatial_heatmap.py#L17-L43 | [
"def",
"make_layout",
"(",
"maxval",
")",
":",
"if",
"maxval",
">",
"512",
":",
"return",
"Layout",
"(",
"structure",
"=",
"np",
".",
"concatenate",
"(",
"[",
"np",
".",
"array",
"(",
"[",
"list",
"(",
"range",
"(",
"10",
"*",
"i",
"+",
"1",
",",... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | spatial_heatmap | Taking channel information and creating post run channel activity plots. | nanoplotter/spatial_heatmap.py | def spatial_heatmap(array, path, title=None, color="Greens", figformat="png"):
"""Taking channel information and creating post run channel activity plots."""
logging.info("Nanoplotter: Creating heatmap of reads per channel using {} reads."
.format(array.size))
activity_map = Plot(
p... | def spatial_heatmap(array, path, title=None, color="Greens", figformat="png"):
"""Taking channel information and creating post run channel activity plots."""
logging.info("Nanoplotter: Creating heatmap of reads per channel using {} reads."
.format(array.size))
activity_map = Plot(
p... | [
"Taking",
"channel",
"information",
"and",
"creating",
"post",
"run",
"channel",
"activity",
"plots",
"."
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/spatial_heatmap.py#L46-L70 | [
"def",
"spatial_heatmap",
"(",
"array",
",",
"path",
",",
"title",
"=",
"None",
",",
"color",
"=",
"\"Greens\"",
",",
"figformat",
"=",
"\"png\"",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoplotter: Creating heatmap of reads per channel using {} reads.\"",
".",
... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | main | Generate CSV files from a CronosPro/CronosPlus database. | cronos/cli.py | def main(database_dir, target_dir):
"""Generate CSV files from a CronosPro/CronosPlus database."""
if not os.path.isdir(database_dir):
raise click.ClickException("Database directory does not exist!")
try:
os.makedirs(target_dir)
except:
pass
try:
parse(database_dir, t... | def main(database_dir, target_dir):
"""Generate CSV files from a CronosPro/CronosPlus database."""
if not os.path.isdir(database_dir):
raise click.ClickException("Database directory does not exist!")
try:
os.makedirs(target_dir)
except:
pass
try:
parse(database_dir, t... | [
"Generate",
"CSV",
"files",
"from",
"a",
"CronosPro",
"/",
"CronosPlus",
"database",
"."
] | occrp/cronosparser | python | https://github.com/occrp/cronosparser/blob/e7748a1a98992b2cc2191f4ce3b1621db1365c3f/cronos/cli.py#L11-L22 | [
"def",
"main",
"(",
"database_dir",
",",
"target_dir",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"database_dir",
")",
":",
"raise",
"click",
".",
"ClickException",
"(",
"\"Database directory does not exist!\"",
")",
"try",
":",
"os",
".",
... | e7748a1a98992b2cc2191f4ce3b1621db1365c3f |
train | check_valid_time_and_sort | Check if the data contains reads created within the same `days` timeframe.
if not, print warning and only return part of the data which is within `days` days
Resetting the index twice to get also an "index" column for plotting the cum_yield_reads plot | nanoplotter/timeplots.py | def check_valid_time_and_sort(df, timescol, days=5, warning=True):
"""Check if the data contains reads created within the same `days` timeframe.
if not, print warning and only return part of the data which is within `days` days
Resetting the index twice to get also an "index" column for plotting the cum_yi... | def check_valid_time_and_sort(df, timescol, days=5, warning=True):
"""Check if the data contains reads created within the same `days` timeframe.
if not, print warning and only return part of the data which is within `days` days
Resetting the index twice to get also an "index" column for plotting the cum_yi... | [
"Check",
"if",
"the",
"data",
"contains",
"reads",
"created",
"within",
"the",
"same",
"days",
"timeframe",
"."
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/timeplots.py#L12-L34 | [
"def",
"check_valid_time_and_sort",
"(",
"df",
",",
"timescol",
",",
"days",
"=",
"5",
",",
"warning",
"=",
"True",
")",
":",
"timediff",
"=",
"(",
"df",
"[",
"timescol",
"]",
".",
"max",
"(",
")",
"-",
"df",
"[",
"timescol",
"]",
".",
"min",
"(",
... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | time_plots | Making plots of time vs read length, time vs quality and cumulative yield. | nanoplotter/timeplots.py | def time_plots(df, path, title=None, color="#4CB391", figformat="png",
log_length=False, plot_settings=None):
"""Making plots of time vs read length, time vs quality and cumulative yield."""
dfs = check_valid_time_and_sort(df, "start_time")
logging.info("Nanoplotter: Creating timeplots using ... | def time_plots(df, path, title=None, color="#4CB391", figformat="png",
log_length=False, plot_settings=None):
"""Making plots of time vs read length, time vs quality and cumulative yield."""
dfs = check_valid_time_and_sort(df, "start_time")
logging.info("Nanoplotter: Creating timeplots using ... | [
"Making",
"plots",
"of",
"time",
"vs",
"read",
"length",
"time",
"vs",
"quality",
"and",
"cumulative",
"yield",
"."
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/timeplots.py#L37-L58 | [
"def",
"time_plots",
"(",
"df",
",",
"path",
",",
"title",
"=",
"None",
",",
"color",
"=",
"\"#4CB391\"",
",",
"figformat",
"=",
"\"png\"",
",",
"log_length",
"=",
"False",
",",
"plot_settings",
"=",
"None",
")",
":",
"dfs",
"=",
"check_valid_time_and_sort... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | violin_or_box_plot | Create a violin or boxplot from the received DataFrame.
The x-axis should be divided based on the 'dataset' column,
the y-axis is specified in the arguments | nanoplotter/compplots.py | def violin_or_box_plot(df, y, figformat, path, y_name,
title=None, plot="violin", log=False, palette=None):
"""Create a violin or boxplot from the received DataFrame.
The x-axis should be divided based on the 'dataset' column,
the y-axis is specified in the arguments
"""
comp... | def violin_or_box_plot(df, y, figformat, path, y_name,
title=None, plot="violin", log=False, palette=None):
"""Create a violin or boxplot from the received DataFrame.
The x-axis should be divided based on the 'dataset' column,
the y-axis is specified in the arguments
"""
comp... | [
"Create",
"a",
"violin",
"or",
"boxplot",
"from",
"the",
"received",
"DataFrame",
"."
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/compplots.py#L13-L68 | [
"def",
"violin_or_box_plot",
"(",
"df",
",",
"y",
",",
"figformat",
",",
"path",
",",
"y_name",
",",
"title",
"=",
"None",
",",
"plot",
"=",
"\"violin\"",
",",
"log",
"=",
"False",
",",
"palette",
"=",
"None",
")",
":",
"comp",
"=",
"Plot",
"(",
"p... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | output_barplot | Create barplots based on number of reads and total sum of nucleotides sequenced. | nanoplotter/compplots.py | def output_barplot(df, figformat, path, title=None, palette=None):
"""Create barplots based on number of reads and total sum of nucleotides sequenced."""
logging.info("Nanoplotter: Creating barplots for number of reads and total throughput.")
read_count = Plot(path=path + "NanoComp_number_of_reads." + figfo... | def output_barplot(df, figformat, path, title=None, palette=None):
"""Create barplots based on number of reads and total sum of nucleotides sequenced."""
logging.info("Nanoplotter: Creating barplots for number of reads and total throughput.")
read_count = Plot(path=path + "NanoComp_number_of_reads." + figfo... | [
"Create",
"barplots",
"based",
"on",
"number",
"of",
"reads",
"and",
"total",
"sum",
"of",
"nucleotides",
"sequenced",
"."
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/compplots.py#L83-L116 | [
"def",
"output_barplot",
"(",
"df",
",",
"figformat",
",",
"path",
",",
"title",
"=",
"None",
",",
"palette",
"=",
"None",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoplotter: Creating barplots for number of reads and total throughput.\"",
")",
"read_count",
"=",
... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | overlay_histogram | Use plotly to create an overlay of length histograms
Return html code, but also save as png
Only has 10 colors, which get recycled up to 5 times. | nanoplotter/compplots.py | def overlay_histogram(df, path, palette=None):
"""
Use plotly to create an overlay of length histograms
Return html code, but also save as png
Only has 10 colors, which get recycled up to 5 times.
"""
if palette is None:
palette = plotly.colors.DEFAULT_PLOTLY_COLORS * 5
hist = Plot... | def overlay_histogram(df, path, palette=None):
"""
Use plotly to create an overlay of length histograms
Return html code, but also save as png
Only has 10 colors, which get recycled up to 5 times.
"""
if palette is None:
palette = plotly.colors.DEFAULT_PLOTLY_COLORS * 5
hist = Plot... | [
"Use",
"plotly",
"to",
"create",
"an",
"overlay",
"of",
"length",
"histograms",
"Return",
"html",
"code",
"but",
"also",
"save",
"as",
"png"
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/compplots.py#L178-L210 | [
"def",
"overlay_histogram",
"(",
"df",
",",
"path",
",",
"palette",
"=",
"None",
")",
":",
"if",
"palette",
"is",
"None",
":",
"palette",
"=",
"plotly",
".",
"colors",
".",
"DEFAULT_PLOTLY_COLORS",
"*",
"5",
"hist",
"=",
"Plot",
"(",
"path",
"=",
"path... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | plot_log_histogram | Plot overlaying histograms with log transformation of length
Return both html and fig for png | nanoplotter/compplots.py | def plot_log_histogram(df, palette, title, histnorm=""):
"""
Plot overlaying histograms with log transformation of length
Return both html and fig for png
"""
data = [go.Histogram(x=np.log10(df.loc[df["dataset"] == d, "lengths"]),
opacity=0.4,
name=d... | def plot_log_histogram(df, palette, title, histnorm=""):
"""
Plot overlaying histograms with log transformation of length
Return both html and fig for png
"""
data = [go.Histogram(x=np.log10(df.loc[df["dataset"] == d, "lengths"]),
opacity=0.4,
name=d... | [
"Plot",
"overlaying",
"histograms",
"with",
"log",
"transformation",
"of",
"length",
"Return",
"both",
"html",
"and",
"fig",
"for",
"png"
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/compplots.py#L233-L259 | [
"def",
"plot_log_histogram",
"(",
"df",
",",
"palette",
",",
"title",
",",
"histnorm",
"=",
"\"\"",
")",
":",
"data",
"=",
"[",
"go",
".",
"Histogram",
"(",
"x",
"=",
"np",
".",
"log10",
"(",
"df",
".",
"loc",
"[",
"df",
"[",
"\"dataset\"",
"]",
... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | get_file | Glob for the poor. | cronos/parser.py | def get_file(db_folder, file_name):
"""Glob for the poor."""
if not os.path.isdir(db_folder):
return
file_name = file_name.lower().strip()
for cand_name in os.listdir(db_folder):
if cand_name.lower().strip() == file_name:
return os.path.join(db_folder, cand_name) | def get_file(db_folder, file_name):
"""Glob for the poor."""
if not os.path.isdir(db_folder):
return
file_name = file_name.lower().strip()
for cand_name in os.listdir(db_folder):
if cand_name.lower().strip() == file_name:
return os.path.join(db_folder, cand_name) | [
"Glob",
"for",
"the",
"poor",
"."
] | occrp/cronosparser | python | https://github.com/occrp/cronosparser/blob/e7748a1a98992b2cc2191f4ce3b1621db1365c3f/cronos/parser.py#L270-L277 | [
"def",
"get_file",
"(",
"db_folder",
",",
"file_name",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"db_folder",
")",
":",
"return",
"file_name",
"=",
"file_name",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
"for",
"cand_name",
"i... | e7748a1a98992b2cc2191f4ce3b1621db1365c3f |
train | parse | Parse a cronos database.
Convert the database located in ``db_folder`` into CSV files in the
directory ``out_folder``. | cronos/parser.py | def parse(db_folder, out_folder):
"""
Parse a cronos database.
Convert the database located in ``db_folder`` into CSV files in the
directory ``out_folder``.
"""
# The database structure, containing table and column definitions as
# well as other data.
stru_dat = get_file(db_folder, 'Cro... | def parse(db_folder, out_folder):
"""
Parse a cronos database.
Convert the database located in ``db_folder`` into CSV files in the
directory ``out_folder``.
"""
# The database structure, containing table and column definitions as
# well as other data.
stru_dat = get_file(db_folder, 'Cro... | [
"Parse",
"a",
"cronos",
"database",
"."
] | occrp/cronosparser | python | https://github.com/occrp/cronosparser/blob/e7748a1a98992b2cc2191f4ce3b1621db1365c3f/cronos/parser.py#L280-L309 | [
"def",
"parse",
"(",
"db_folder",
",",
"out_folder",
")",
":",
"# The database structure, containing table and column definitions as",
"# well as other data.",
"stru_dat",
"=",
"get_file",
"(",
"db_folder",
",",
"'CroStru.dat'",
")",
"# Index file for the database, which contains... | e7748a1a98992b2cc2191f4ce3b1621db1365c3f |
train | Plot.encode1 | Return the base64 encoding of the figure file and insert in html image tag. | nanoplotter/plot.py | def encode1(self):
"""Return the base64 encoding of the figure file and insert in html image tag."""
data_uri = b64encode(open(self.path, 'rb').read()).decode('utf-8').replace('\n', '')
return '<img src="data:image/png;base64,{0}">'.format(data_uri) | def encode1(self):
"""Return the base64 encoding of the figure file and insert in html image tag."""
data_uri = b64encode(open(self.path, 'rb').read()).decode('utf-8').replace('\n', '')
return '<img src="data:image/png;base64,{0}">'.format(data_uri) | [
"Return",
"the",
"base64",
"encoding",
"of",
"the",
"figure",
"file",
"and",
"insert",
"in",
"html",
"image",
"tag",
"."
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/plot.py#L26-L29 | [
"def",
"encode1",
"(",
"self",
")",
":",
"data_uri",
"=",
"b64encode",
"(",
"open",
"(",
"self",
".",
"path",
",",
"'rb'",
")",
".",
"read",
"(",
")",
")",
".",
"decode",
"(",
"'utf-8'",
")",
".",
"replace",
"(",
"'\\n'",
",",
"''",
")",
"return"... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | Plot.encode2 | Return the base64 encoding of the fig attribute and insert in html image tag. | nanoplotter/plot.py | def encode2(self):
"""Return the base64 encoding of the fig attribute and insert in html image tag."""
buf = BytesIO()
self.fig.savefig(buf, format='png', bbox_inches='tight', dpi=100)
buf.seek(0)
string = b64encode(buf.read())
return '<img src="data:image/png;base64,{0}"... | def encode2(self):
"""Return the base64 encoding of the fig attribute and insert in html image tag."""
buf = BytesIO()
self.fig.savefig(buf, format='png', bbox_inches='tight', dpi=100)
buf.seek(0)
string = b64encode(buf.read())
return '<img src="data:image/png;base64,{0}"... | [
"Return",
"the",
"base64",
"encoding",
"of",
"the",
"fig",
"attribute",
"and",
"insert",
"in",
"html",
"image",
"tag",
"."
] | wdecoster/nanoplotter | python | https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/plot.py#L31-L37 | [
"def",
"encode2",
"(",
"self",
")",
":",
"buf",
"=",
"BytesIO",
"(",
")",
"self",
".",
"fig",
".",
"savefig",
"(",
"buf",
",",
"format",
"=",
"'png'",
",",
"bbox_inches",
"=",
"'tight'",
",",
"dpi",
"=",
"100",
")",
"buf",
".",
"seek",
"(",
"0",
... | 80908dd1be585f450da5a66989de9de4d544ec85 |
train | rdlevenshtein_norm | Calculates the normalized restricted Damerau-Levenshtein distance
(a.k.a. the normalized optimal string alignment distance) between two
string arguments. The result will be a float in the range [0.0, 1.0], with
1.0 signifying the maximum distance between strings with these lengths | stringdist/pystringdist/rdlevenshtein.py | def rdlevenshtein_norm(source, target):
"""Calculates the normalized restricted Damerau-Levenshtein distance
(a.k.a. the normalized optimal string alignment distance) between two
string arguments. The result will be a float in the range [0.0, 1.0], with
1.0 signifying the maximum distance between string... | def rdlevenshtein_norm(source, target):
"""Calculates the normalized restricted Damerau-Levenshtein distance
(a.k.a. the normalized optimal string alignment distance) between two
string arguments. The result will be a float in the range [0.0, 1.0], with
1.0 signifying the maximum distance between string... | [
"Calculates",
"the",
"normalized",
"restricted",
"Damerau",
"-",
"Levenshtein",
"distance",
"(",
"a",
".",
"k",
".",
"a",
".",
"the",
"normalized",
"optimal",
"string",
"alignment",
"distance",
")",
"between",
"two",
"string",
"arguments",
".",
"The",
"result"... | obulkin/string-dist | python | https://github.com/obulkin/string-dist/blob/38d04352d617a5d43b06832cc1bf0aee8978559f/stringdist/pystringdist/rdlevenshtein.py#L18-L29 | [
"def",
"rdlevenshtein_norm",
"(",
"source",
",",
"target",
")",
":",
"# Compute restricted Damerau-Levenshtein distance using helper function.",
"# The max is always just the length of the longer string, so this is used",
"# to normalize result before returning it",
"distance",
"=",
"_leve... | 38d04352d617a5d43b06832cc1bf0aee8978559f |
train | _levenshtein_compute | Computes the Levenshtein
(https://en.wikipedia.org/wiki/Levenshtein_distance)
and restricted Damerau-Levenshtein
(https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance)
distances between two Unicode strings with given lengths using the
Wagner-Fischer algorithm
(https://en.wikipedia.... | stringdist/pystringdist/levenshtein_shared.py | def _levenshtein_compute(source, target, rd_flag):
"""Computes the Levenshtein
(https://en.wikipedia.org/wiki/Levenshtein_distance)
and restricted Damerau-Levenshtein
(https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance)
distances between two Unicode strings with given lengths using t... | def _levenshtein_compute(source, target, rd_flag):
"""Computes the Levenshtein
(https://en.wikipedia.org/wiki/Levenshtein_distance)
and restricted Damerau-Levenshtein
(https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance)
distances between two Unicode strings with given lengths using t... | [
"Computes",
"the",
"Levenshtein",
"(",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Levenshtein_distance",
")",
"and",
"restricted",
"Damerau",
"-",
"Levenshtein",
"(",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
... | obulkin/string-dist | python | https://github.com/obulkin/string-dist/blob/38d04352d617a5d43b06832cc1bf0aee8978559f/stringdist/pystringdist/levenshtein_shared.py#L5-L65 | [
"def",
"_levenshtein_compute",
"(",
"source",
",",
"target",
",",
"rd_flag",
")",
":",
"# Create matrix of correct size (this is s_len + 1 * t_len + 1 so that the",
"# empty prefixes \"\" can also be included). The leftmost column represents",
"# transforming various source prefixes into an ... | 38d04352d617a5d43b06832cc1bf0aee8978559f |
train | main | The main entry point. | setup.py | def main():
"""The main entry point."""
if sys.version_info < (2, 7):
sys.exit('crispy requires at least Python 2.7')
elif sys.version_info[0] == 3 and sys.version_info < (3, 4):
sys.exit('crispy requires at least Python 3.4')
kwargs = dict(
name='crispy',
version=get_ve... | def main():
"""The main entry point."""
if sys.version_info < (2, 7):
sys.exit('crispy requires at least Python 2.7')
elif sys.version_info[0] == 3 and sys.version_info < (3, 4):
sys.exit('crispy requires at least Python 3.4')
kwargs = dict(
name='crispy',
version=get_ve... | [
"The",
"main",
"entry",
"point",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/setup.py#L68-L145 | [
"def",
"main",
"(",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"2",
",",
"7",
")",
":",
"sys",
".",
"exit",
"(",
"'crispy requires at least Python 2.7'",
")",
"elif",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"3",
"and",
"sys",
".",... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | QuantySpectra.loadFromDisk | Read the spectra from the files generated by Quanty and store them
as a list of spectum objects. | crispy/gui/quanty.py | def loadFromDisk(self, calculation):
"""
Read the spectra from the files generated by Quanty and store them
as a list of spectum objects.
"""
suffixes = {
'Isotropic': 'iso',
'Circular Dichroism (R-L)': 'cd',
'Right Polarized (R)': 'r',
... | def loadFromDisk(self, calculation):
"""
Read the spectra from the files generated by Quanty and store them
as a list of spectum objects.
"""
suffixes = {
'Isotropic': 'iso',
'Circular Dichroism (R-L)': 'cd',
'Right Polarized (R)': 'r',
... | [
"Read",
"the",
"spectra",
"from",
"the",
"files",
"generated",
"by",
"Quanty",
"and",
"store",
"them",
"as",
"a",
"list",
"of",
"spectum",
"objects",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/quanty.py#L284-L372 | [
"def",
"loadFromDisk",
"(",
"self",
",",
"calculation",
")",
":",
"suffixes",
"=",
"{",
"'Isotropic'",
":",
"'iso'",
",",
"'Circular Dichroism (R-L)'",
":",
"'cd'",
",",
"'Right Polarized (R)'",
":",
"'r'",
",",
"'Left Polarized (L)'",
":",
"'l'",
",",
"'Linear ... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | QuantyDockWidget.populateWidget | Populate the widget using data stored in the state
object. The order in which the individual widgets are populated
follows their arrangment.
The models are recreated every time the function is called.
This might seem to be an overkill, but in practice it is very fast.
Don't try ... | crispy/gui/quanty.py | def populateWidget(self):
"""
Populate the widget using data stored in the state
object. The order in which the individual widgets are populated
follows their arrangment.
The models are recreated every time the function is called.
This might seem to be an overkill, but i... | def populateWidget(self):
"""
Populate the widget using data stored in the state
object. The order in which the individual widgets are populated
follows their arrangment.
The models are recreated every time the function is called.
This might seem to be an overkill, but i... | [
"Populate",
"the",
"widget",
"using",
"data",
"stored",
"in",
"the",
"state",
"object",
".",
"The",
"order",
"in",
"which",
"the",
"individual",
"widgets",
"are",
"populated",
"follows",
"their",
"arrangment",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/quanty.py#L754-L899 | [
"def",
"populateWidget",
"(",
"self",
")",
":",
"self",
".",
"elementComboBox",
".",
"setItems",
"(",
"self",
".",
"state",
".",
"_elements",
",",
"self",
".",
"state",
".",
"element",
")",
"self",
".",
"chargeComboBox",
".",
"setItems",
"(",
"self",
"."... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | QuantyDockWidget.updateResultsView | Update the selection to contain only the result specified by
the index. This should be the last index of the model. Finally updade
the context menu.
The selectionChanged signal is used to trigger the update of
the Quanty dock widget and result details dialog.
:param index: Inde... | crispy/gui/quanty.py | def updateResultsView(self, index):
"""
Update the selection to contain only the result specified by
the index. This should be the last index of the model. Finally updade
the context menu.
The selectionChanged signal is used to trigger the update of
the Quanty dock widge... | def updateResultsView(self, index):
"""
Update the selection to contain only the result specified by
the index. This should be the last index of the model. Finally updade
the context menu.
The selectionChanged signal is used to trigger the update of
the Quanty dock widge... | [
"Update",
"the",
"selection",
"to",
"contain",
"only",
"the",
"result",
"specified",
"by",
"the",
"index",
".",
"This",
"should",
"be",
"the",
"last",
"index",
"of",
"the",
"model",
".",
"Finally",
"updade",
"the",
"context",
"menu",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/quanty.py#L1774-L1791 | [
"def",
"updateResultsView",
"(",
"self",
",",
"index",
")",
":",
"flags",
"=",
"(",
"QItemSelectionModel",
".",
"Clear",
"|",
"QItemSelectionModel",
".",
"Rows",
"|",
"QItemSelectionModel",
".",
"Select",
")",
"self",
".",
"resultsView",
".",
"selectionModel",
... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | QuantyDockWidget.updatePlotWidget | Updating the plotting widget should not require any information
about the current state of the widget. | crispy/gui/quanty.py | def updatePlotWidget(self):
"""Updating the plotting widget should not require any information
about the current state of the widget."""
pw = self.getPlotWidget()
pw.reset()
results = self.resultsModel.getCheckedItems()
for result in results:
if isinstance(r... | def updatePlotWidget(self):
"""Updating the plotting widget should not require any information
about the current state of the widget."""
pw = self.getPlotWidget()
pw.reset()
results = self.resultsModel.getCheckedItems()
for result in results:
if isinstance(r... | [
"Updating",
"the",
"plotting",
"widget",
"should",
"not",
"require",
"any",
"information",
"about",
"the",
"current",
"state",
"of",
"the",
"widget",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/quanty.py#L1832-L1854 | [
"def",
"updatePlotWidget",
"(",
"self",
")",
":",
"pw",
"=",
"self",
".",
"getPlotWidget",
"(",
")",
"pw",
".",
"reset",
"(",
")",
"results",
"=",
"self",
".",
"resultsModel",
".",
"getCheckedItems",
"(",
")",
"for",
"result",
"in",
"results",
":",
"if... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | HamiltonianItem.row | Return the row of the child. | crispy/gui/models.py | def row(self):
"""Return the row of the child."""
if self.parent is not None:
children = self.parent.getChildren()
# The index method of the list object.
return children.index(self)
else:
return 0 | def row(self):
"""Return the row of the child."""
if self.parent is not None:
children = self.parent.getChildren()
# The index method of the list object.
return children.index(self)
else:
return 0 | [
"Return",
"the",
"row",
"of",
"the",
"child",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L254-L261 | [
"def",
"row",
"(",
"self",
")",
":",
"if",
"self",
".",
"parent",
"is",
"not",
"None",
":",
"children",
"=",
"self",
".",
"parent",
".",
"getChildren",
"(",
")",
"# The index method of the list object.",
"return",
"children",
".",
"index",
"(",
"self",
")"... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | HamiltonianModel.index | Return the index of the item in the model specified by the
given row, column, and parent index. | crispy/gui/models.py | def index(self, row, column, parent=QModelIndex()):
"""Return the index of the item in the model specified by the
given row, column, and parent index.
"""
if parent is not None and not parent.isValid():
parentItem = self.rootItem
else:
parentItem = self.it... | def index(self, row, column, parent=QModelIndex()):
"""Return the index of the item in the model specified by the
given row, column, and parent index.
"""
if parent is not None and not parent.isValid():
parentItem = self.rootItem
else:
parentItem = self.it... | [
"Return",
"the",
"index",
"of",
"the",
"item",
"in",
"the",
"model",
"specified",
"by",
"the",
"given",
"row",
"column",
"and",
"parent",
"index",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L307-L323 | [
"def",
"index",
"(",
"self",
",",
"row",
",",
"column",
",",
"parent",
"=",
"QModelIndex",
"(",
")",
")",
":",
"if",
"parent",
"is",
"not",
"None",
"and",
"not",
"parent",
".",
"isValid",
"(",
")",
":",
"parentItem",
"=",
"self",
".",
"rootItem",
"... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | HamiltonianModel.parent | Return the index of the parent for a given index of the
child. Unfortunately, the name of the method has to be parent,
even though a more verbose name like parentIndex, would avoid
confusion about what parent actually is - an index or an item. | crispy/gui/models.py | def parent(self, index):
"""Return the index of the parent for a given index of the
child. Unfortunately, the name of the method has to be parent,
even though a more verbose name like parentIndex, would avoid
confusion about what parent actually is - an index or an item.
"""
... | def parent(self, index):
"""Return the index of the parent for a given index of the
child. Unfortunately, the name of the method has to be parent,
even though a more verbose name like parentIndex, would avoid
confusion about what parent actually is - an index or an item.
"""
... | [
"Return",
"the",
"index",
"of",
"the",
"parent",
"for",
"a",
"given",
"index",
"of",
"the",
"child",
".",
"Unfortunately",
"the",
"name",
"of",
"the",
"method",
"has",
"to",
"be",
"parent",
"even",
"though",
"a",
"more",
"verbose",
"name",
"like",
"paren... | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L325-L339 | [
"def",
"parent",
"(",
"self",
",",
"index",
")",
":",
"childItem",
"=",
"self",
".",
"item",
"(",
"index",
")",
"parentItem",
"=",
"childItem",
".",
"parent",
"if",
"parentItem",
"==",
"self",
".",
"rootItem",
":",
"parentIndex",
"=",
"QModelIndex",
"(",... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | HamiltonianModel.rowCount | Return the number of rows under the given parent. When the
parentIndex is valid, rowCount() returns the number of children
of the parent. For this it uses item() method to extract the
parentItem from the parentIndex, and calls the childCount() of
the item to get number of children. | crispy/gui/models.py | def rowCount(self, parentIndex):
"""Return the number of rows under the given parent. When the
parentIndex is valid, rowCount() returns the number of children
of the parent. For this it uses item() method to extract the
parentItem from the parentIndex, and calls the childCount() of
... | def rowCount(self, parentIndex):
"""Return the number of rows under the given parent. When the
parentIndex is valid, rowCount() returns the number of children
of the parent. For this it uses item() method to extract the
parentItem from the parentIndex, and calls the childCount() of
... | [
"Return",
"the",
"number",
"of",
"rows",
"under",
"the",
"given",
"parent",
".",
"When",
"the",
"parentIndex",
"is",
"valid",
"rowCount",
"()",
"returns",
"the",
"number",
"of",
"children",
"of",
"the",
"parent",
".",
"For",
"this",
"it",
"uses",
"item",
... | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L358-L373 | [
"def",
"rowCount",
"(",
"self",
",",
"parentIndex",
")",
":",
"if",
"parentIndex",
".",
"column",
"(",
")",
">",
"0",
":",
"return",
"0",
"if",
"not",
"parentIndex",
".",
"isValid",
"(",
")",
":",
"parentItem",
"=",
"self",
".",
"rootItem",
"else",
"... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | HamiltonianModel.data | Return role specific data for the item referred by
index.column(). | crispy/gui/models.py | def data(self, index, role):
"""Return role specific data for the item referred by
index.column()."""
if not index.isValid():
return
item = self.item(index)
column = index.column()
value = item.getItemData(column)
if role == Qt.DisplayRole:
... | def data(self, index, role):
"""Return role specific data for the item referred by
index.column()."""
if not index.isValid():
return
item = self.item(index)
column = index.column()
value = item.getItemData(column)
if role == Qt.DisplayRole:
... | [
"Return",
"role",
"specific",
"data",
"for",
"the",
"item",
"referred",
"by",
"index",
".",
"column",
"()",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L382-L418 | [
"def",
"data",
"(",
"self",
",",
"index",
",",
"role",
")",
":",
"if",
"not",
"index",
".",
"isValid",
"(",
")",
":",
"return",
"item",
"=",
"self",
".",
"item",
"(",
"index",
")",
"column",
"=",
"index",
".",
"column",
"(",
")",
"value",
"=",
... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | HamiltonianModel.setData | Set the role data for the item at index to value. | crispy/gui/models.py | def setData(self, index, value, role):
"""Set the role data for the item at index to value."""
if not index.isValid():
return False
item = self.item(index)
column = index.column()
if role == Qt.EditRole:
items = list()
items.append(item)
... | def setData(self, index, value, role):
"""Set the role data for the item at index to value."""
if not index.isValid():
return False
item = self.item(index)
column = index.column()
if role == Qt.EditRole:
items = list()
items.append(item)
... | [
"Set",
"the",
"role",
"data",
"for",
"the",
"item",
"at",
"index",
"to",
"value",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L420-L459 | [
"def",
"setData",
"(",
"self",
",",
"index",
",",
"value",
",",
"role",
")",
":",
"if",
"not",
"index",
".",
"isValid",
"(",
")",
":",
"return",
"False",
"item",
"=",
"self",
".",
"item",
"(",
"index",
")",
"column",
"=",
"index",
".",
"column",
... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | HamiltonianModel.flags | Return the active flags for the given index. Add editable
flag to items other than the first column. | crispy/gui/models.py | def flags(self, index):
"""Return the active flags for the given index. Add editable
flag to items other than the first column.
"""
activeFlags = (Qt.ItemIsEnabled | Qt.ItemIsSelectable |
Qt.ItemIsUserCheckable)
item = self.item(index)
column = ind... | def flags(self, index):
"""Return the active flags for the given index. Add editable
flag to items other than the first column.
"""
activeFlags = (Qt.ItemIsEnabled | Qt.ItemIsSelectable |
Qt.ItemIsUserCheckable)
item = self.item(index)
column = ind... | [
"Return",
"the",
"active",
"flags",
"for",
"the",
"given",
"index",
".",
"Add",
"editable",
"flag",
"to",
"items",
"other",
"than",
"the",
"first",
"column",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L464-L477 | [
"def",
"flags",
"(",
"self",
",",
"index",
")",
":",
"activeFlags",
"=",
"(",
"Qt",
".",
"ItemIsEnabled",
"|",
"Qt",
".",
"ItemIsSelectable",
"|",
"Qt",
".",
"ItemIsUserCheckable",
")",
"item",
"=",
"self",
".",
"item",
"(",
"index",
")",
"column",
"="... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | HamiltonianModel._getModelData | Return the data contained in the model. | crispy/gui/models.py | def _getModelData(self, modelData, parentItem=None):
"""Return the data contained in the model."""
if parentItem is None:
parentItem = self.rootItem
for item in parentItem.getChildren():
key = item.getItemData(0)
if item.childCount():
modelDat... | def _getModelData(self, modelData, parentItem=None):
"""Return the data contained in the model."""
if parentItem is None:
parentItem = self.rootItem
for item in parentItem.getChildren():
key = item.getItemData(0)
if item.childCount():
modelDat... | [
"Return",
"the",
"data",
"contained",
"in",
"the",
"model",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L533-L547 | [
"def",
"_getModelData",
"(",
"self",
",",
"modelData",
",",
"parentItem",
"=",
"None",
")",
":",
"if",
"parentItem",
"is",
"None",
":",
"parentItem",
"=",
"self",
".",
"rootItem",
"for",
"item",
"in",
"parentItem",
".",
"getChildren",
"(",
")",
":",
"key... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | HamiltonianModel.getNodesCheckState | Return the check state (disabled, tristate, enable) of all items
belonging to a parent. | crispy/gui/models.py | def getNodesCheckState(self, parentItem=None):
"""Return the check state (disabled, tristate, enable) of all items
belonging to a parent.
"""
if parentItem is None:
parentItem = self.rootItem
checkStates = odict()
children = parentItem.getChildren()
... | def getNodesCheckState(self, parentItem=None):
"""Return the check state (disabled, tristate, enable) of all items
belonging to a parent.
"""
if parentItem is None:
parentItem = self.rootItem
checkStates = odict()
children = parentItem.getChildren()
... | [
"Return",
"the",
"check",
"state",
"(",
"disabled",
"tristate",
"enable",
")",
"of",
"all",
"items",
"belonging",
"to",
"a",
"parent",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L567-L580 | [
"def",
"getNodesCheckState",
"(",
"self",
",",
"parentItem",
"=",
"None",
")",
":",
"if",
"parentItem",
"is",
"None",
":",
"parentItem",
"=",
"self",
".",
"rootItem",
"checkStates",
"=",
"odict",
"(",
")",
"children",
"=",
"parentItem",
".",
"getChildren",
... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | calc_hexversion | Calculate the hexadecimal version number from the tuple version_info:
:param major: integer
:param minor: integer
:param micro: integer
:param relev: integer or string
:param serial: integer
:return: integerm always increasing with revision numbers | crispy/version.py | def calc_hexversion(major=0, minor=0, micro=0, releaselevel='dev', serial=0):
"""Calculate the hexadecimal version number from the tuple version_info:
:param major: integer
:param minor: integer
:param micro: integer
:param relev: integer or string
:param serial: integer
:return: integerm a... | def calc_hexversion(major=0, minor=0, micro=0, releaselevel='dev', serial=0):
"""Calculate the hexadecimal version number from the tuple version_info:
:param major: integer
:param minor: integer
:param micro: integer
:param relev: integer or string
:param serial: integer
:return: integerm a... | [
"Calculate",
"the",
"hexadecimal",
"version",
"number",
"from",
"the",
"tuple",
"version_info",
":"
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/version.py#L89-L109 | [
"def",
"calc_hexversion",
"(",
"major",
"=",
"0",
",",
"minor",
"=",
"0",
",",
"micro",
"=",
"0",
",",
"releaselevel",
"=",
"'dev'",
",",
"serial",
"=",
"0",
")",
":",
"try",
":",
"releaselevel",
"=",
"int",
"(",
"releaselevel",
")",
"except",
"Value... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | MainPlotWidget._contextMenu | Handle plot area customContextMenuRequested signal.
:param QPoint pos: Mouse position relative to plot area | crispy/gui/plot.py | def _contextMenu(self, pos):
"""Handle plot area customContextMenuRequested signal.
:param QPoint pos: Mouse position relative to plot area
"""
# Create the context menu.
menu = QMenu(self)
menu.addAction(self._zoomBackAction)
# Displaying the context menu at th... | def _contextMenu(self, pos):
"""Handle plot area customContextMenuRequested signal.
:param QPoint pos: Mouse position relative to plot area
"""
# Create the context menu.
menu = QMenu(self)
menu.addAction(self._zoomBackAction)
# Displaying the context menu at th... | [
"Handle",
"plot",
"area",
"customContextMenuRequested",
"signal",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/plot.py#L247-L262 | [
"def",
"_contextMenu",
"(",
"self",
",",
"pos",
")",
":",
"# Create the context menu.",
"menu",
"=",
"QMenu",
"(",
"self",
")",
"menu",
".",
"addAction",
"(",
"self",
".",
"_zoomBackAction",
")",
"# Displaying the context menu at the mouse position requires",
"# a glo... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | convolve_fft | Convolve an array with a kernel using FFT.
Implemntation based on the convolve_fft function from astropy.
https://github.com/astropy/astropy/blob/master/astropy/convolution/convolve.py | crispy/utils/broaden.py | def convolve_fft(array, kernel):
"""
Convolve an array with a kernel using FFT.
Implemntation based on the convolve_fft function from astropy.
https://github.com/astropy/astropy/blob/master/astropy/convolution/convolve.py
"""
array = np.asarray(array, dtype=np.complex)
kernel = np.asarray(... | def convolve_fft(array, kernel):
"""
Convolve an array with a kernel using FFT.
Implemntation based on the convolve_fft function from astropy.
https://github.com/astropy/astropy/blob/master/astropy/convolution/convolve.py
"""
array = np.asarray(array, dtype=np.complex)
kernel = np.asarray(... | [
"Convolve",
"an",
"array",
"with",
"a",
"kernel",
"using",
"FFT",
".",
"Implemntation",
"based",
"on",
"the",
"convolve_fft",
"function",
"from",
"astropy",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/utils/broaden.py#L65-L114 | [
"def",
"convolve_fft",
"(",
"array",
",",
"kernel",
")",
":",
"array",
"=",
"np",
".",
"asarray",
"(",
"array",
",",
"dtype",
"=",
"np",
".",
"complex",
")",
"kernel",
"=",
"np",
".",
"asarray",
"(",
"kernel",
",",
"dtype",
"=",
"np",
".",
"complex... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | Tensor.diagonalize | Diagonalize the tensor. | crispy/modules/orca/parser.py | def diagonalize(self):
'''Diagonalize the tensor.'''
self.eigvals, self.eigvecs = np.linalg.eig(
(self.tensor.transpose() + self.tensor) / 2.0)
self.eigvals = np.diag(np.dot(
np.dot(self.eigvecs.transpose(), self.tensor), self.eigvecs)) | def diagonalize(self):
'''Diagonalize the tensor.'''
self.eigvals, self.eigvecs = np.linalg.eig(
(self.tensor.transpose() + self.tensor) / 2.0)
self.eigvals = np.diag(np.dot(
np.dot(self.eigvecs.transpose(), self.tensor), self.eigvecs)) | [
"Diagonalize",
"the",
"tensor",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/modules/orca/parser.py#L61-L66 | [
"def",
"diagonalize",
"(",
"self",
")",
":",
"self",
".",
"eigvals",
",",
"self",
".",
"eigvecs",
"=",
"np",
".",
"linalg",
".",
"eig",
"(",
"(",
"self",
".",
"tensor",
".",
"transpose",
"(",
")",
"+",
"self",
".",
"tensor",
")",
"/",
"2.0",
")",... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | Tensor.euler_angles_and_eigenframes | Calculate the Euler angles only if the rotation matrix
(eigenframe) has positive determinant. | crispy/modules/orca/parser.py | def euler_angles_and_eigenframes(self):
'''Calculate the Euler angles only if the rotation matrix
(eigenframe) has positive determinant.'''
signs = np.array([[1, 1, 1], [-1, 1, 1], [1, -1, 1],
[1, 1, -1], [-1, -1, 1], [-1, 1, -1],
[1, -1, -1... | def euler_angles_and_eigenframes(self):
'''Calculate the Euler angles only if the rotation matrix
(eigenframe) has positive determinant.'''
signs = np.array([[1, 1, 1], [-1, 1, 1], [1, -1, 1],
[1, 1, -1], [-1, -1, 1], [-1, 1, -1],
[1, -1, -1... | [
"Calculate",
"the",
"Euler",
"angles",
"only",
"if",
"the",
"rotation",
"matrix",
"(",
"eigenframe",
")",
"has",
"positive",
"determinant",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/modules/orca/parser.py#L75-L92 | [
"def",
"euler_angles_and_eigenframes",
"(",
"self",
")",
":",
"signs",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1",
",",
"1",
",",
"1",
"]",
",",
"[",
"-",
"1",
",",
"1",
",",
"1",
"]",
",",
"[",
"1",
",",
"-",
"1",
",",
"1",
"]",
",",
"[... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | OutputData._skip_lines | Skip a number of lines from the output. | crispy/modules/orca/parser.py | def _skip_lines(self, n):
'''Skip a number of lines from the output.'''
for i in range(n):
self.line = next(self.output)
return self.line | def _skip_lines(self, n):
'''Skip a number of lines from the output.'''
for i in range(n):
self.line = next(self.output)
return self.line | [
"Skip",
"a",
"number",
"of",
"lines",
"from",
"the",
"output",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/modules/orca/parser.py#L151-L155 | [
"def",
"_skip_lines",
"(",
"self",
",",
"n",
")",
":",
"for",
"i",
"in",
"range",
"(",
"n",
")",
":",
"self",
".",
"line",
"=",
"next",
"(",
"self",
".",
"output",
")",
"return",
"self",
".",
"line"
] | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | OutputData._parse_tensor | Parse a tensor. | crispy/modules/orca/parser.py | def _parse_tensor(self, indices=False):
'''Parse a tensor.'''
if indices:
self.line = self._skip_lines(1)
tensor = np.zeros((3, 3))
for i in range(3):
tokens = self.line.split()
if indices:
tensor[i][0] = float(tokens[1])
... | def _parse_tensor(self, indices=False):
'''Parse a tensor.'''
if indices:
self.line = self._skip_lines(1)
tensor = np.zeros((3, 3))
for i in range(3):
tokens = self.line.split()
if indices:
tensor[i][0] = float(tokens[1])
... | [
"Parse",
"a",
"tensor",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/modules/orca/parser.py#L157-L174 | [
"def",
"_parse_tensor",
"(",
"self",
",",
"indices",
"=",
"False",
")",
":",
"if",
"indices",
":",
"self",
".",
"line",
"=",
"self",
".",
"_skip_lines",
"(",
"1",
")",
"tensor",
"=",
"np",
".",
"zeros",
"(",
"(",
"3",
",",
"3",
")",
")",
"for",
... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | OutputData.parse | Iterate over the lines and extract the required data. | crispy/modules/orca/parser.py | def parse(self):
'''Iterate over the lines and extract the required data.'''
for self.line in self.output:
# Parse general data: charge, multiplicity, coordinates, etc.
self.index = 0
if self.line[1:13] == 'Total Charge':
tokens = self.line.split()
... | def parse(self):
'''Iterate over the lines and extract the required data.'''
for self.line in self.output:
# Parse general data: charge, multiplicity, coordinates, etc.
self.index = 0
if self.line[1:13] == 'Total Charge':
tokens = self.line.split()
... | [
"Iterate",
"over",
"the",
"lines",
"and",
"extract",
"the",
"required",
"data",
"."
] | mretegan/crispy | python | https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/modules/orca/parser.py#L185-L275 | [
"def",
"parse",
"(",
"self",
")",
":",
"for",
"self",
".",
"line",
"in",
"self",
".",
"output",
":",
"# Parse general data: charge, multiplicity, coordinates, etc.",
"self",
".",
"index",
"=",
"0",
"if",
"self",
".",
"line",
"[",
"1",
":",
"13",
"]",
"==",... | 7e241ac1a48d34ca769f3a6183c430360b5f6725 |
train | FlaskValidator.__validate | Method executed when the event 'set' is triggered.
:param target: Object triggered
:param value: New value
:param oldvalue: Previous value
:param initiator: Column modified
:return: :raise ValidateError: | flask_validator/validator.py | def __validate(self, target, value, oldvalue, initiator):
""" Method executed when the event 'set' is triggered.
:param target: Object triggered
:param value: New value
:param oldvalue: Previous value
:param initiator: Column modified
:return: :raise ValidateError:
... | def __validate(self, target, value, oldvalue, initiator):
""" Method executed when the event 'set' is triggered.
:param target: Object triggered
:param value: New value
:param oldvalue: Previous value
:param initiator: Column modified
:return: :raise ValidateError:
... | [
"Method",
"executed",
"when",
"the",
"event",
"set",
"is",
"triggered",
"."
] | xeBuz/Flask-Validator | python | https://github.com/xeBuz/Flask-Validator/blob/ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9/flask_validator/validator.py#L35-L62 | [
"def",
"__validate",
"(",
"self",
",",
"target",
",",
"value",
",",
"oldvalue",
",",
"initiator",
")",
":",
"if",
"value",
"==",
"oldvalue",
":",
"return",
"value",
"if",
"self",
".",
"allow_null",
"and",
"value",
"is",
"None",
":",
"return",
"value",
... | ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9 |
train | FlaskValidator.__create_event | Create an SQLAlchemy event listening the 'set' in a particular column.
:rtype : object | flask_validator/validator.py | def __create_event(self):
""" Create an SQLAlchemy event listening the 'set' in a particular column.
:rtype : object
"""
if not event.contains(self.field, 'set', self.__validate):
event.listen(self.field, 'set', self.__validate, retval=True) | def __create_event(self):
""" Create an SQLAlchemy event listening the 'set' in a particular column.
:rtype : object
"""
if not event.contains(self.field, 'set', self.__validate):
event.listen(self.field, 'set', self.__validate, retval=True) | [
"Create",
"an",
"SQLAlchemy",
"event",
"listening",
"the",
"set",
"in",
"a",
"particular",
"column",
"."
] | xeBuz/Flask-Validator | python | https://github.com/xeBuz/Flask-Validator/blob/ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9/flask_validator/validator.py#L64-L70 | [
"def",
"__create_event",
"(",
"self",
")",
":",
"if",
"not",
"event",
".",
"contains",
"(",
"self",
".",
"field",
",",
"'set'",
",",
"self",
".",
"__validate",
")",
":",
"event",
".",
"listen",
"(",
"self",
".",
"field",
",",
"'set'",
",",
"self",
... | ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9 |
train | FlaskValidator.stop | Remove the listener to stop the validation | flask_validator/validator.py | def stop(self):
""" Remove the listener to stop the validation
"""
if event.contains(self.field, 'set', self.__validate):
event.remove(self.field, 'set', self.__validate) | def stop(self):
""" Remove the listener to stop the validation
"""
if event.contains(self.field, 'set', self.__validate):
event.remove(self.field, 'set', self.__validate) | [
"Remove",
"the",
"listener",
"to",
"stop",
"the",
"validation"
] | xeBuz/Flask-Validator | python | https://github.com/xeBuz/Flask-Validator/blob/ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9/flask_validator/validator.py#L80-L84 | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"event",
".",
"contains",
"(",
"self",
".",
"field",
",",
"'set'",
",",
"self",
".",
"__validate",
")",
":",
"event",
".",
"remove",
"(",
"self",
".",
"field",
",",
"'set'",
",",
"self",
".",
"__validate"... | ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9 |
train | FlaskValidator.start | Restart the listener | flask_validator/validator.py | def start(self):
""" Restart the listener
"""
if not event.contains(self.field, 'set', self.__validate):
self.__create_event() | def start(self):
""" Restart the listener
"""
if not event.contains(self.field, 'set', self.__validate):
self.__create_event() | [
"Restart",
"the",
"listener"
] | xeBuz/Flask-Validator | python | https://github.com/xeBuz/Flask-Validator/blob/ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9/flask_validator/validator.py#L86-L90 | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"event",
".",
"contains",
"(",
"self",
".",
"field",
",",
"'set'",
",",
"self",
".",
"__validate",
")",
":",
"self",
".",
"__create_event",
"(",
")"
] | ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9 |
train | diaBan.nhapDaiHan | Nhap dai han
Args:
cucSo (TYPE): Description
gioiTinh (TYPE): Description
Returns:
TYPE: Description | lasotuvi/DiaBan.py | def nhapDaiHan(self, cucSo, gioiTinh):
"""Nhap dai han
Args:
cucSo (TYPE): Description
gioiTinh (TYPE): Description
Returns:
TYPE: Description
"""
for cung in self.thapNhiCung:
khoangCach = khoangCachCung(cung.cungSo, self.cungMen... | def nhapDaiHan(self, cucSo, gioiTinh):
"""Nhap dai han
Args:
cucSo (TYPE): Description
gioiTinh (TYPE): Description
Returns:
TYPE: Description
"""
for cung in self.thapNhiCung:
khoangCach = khoangCachCung(cung.cungSo, self.cungMen... | [
"Nhap",
"dai",
"han"
] | doanguyen/lasotuvi | python | https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/DiaBan.py#L153-L166 | [
"def",
"nhapDaiHan",
"(",
"self",
",",
"cucSo",
",",
"gioiTinh",
")",
":",
"for",
"cung",
"in",
"self",
".",
"thapNhiCung",
":",
"khoangCach",
"=",
"khoangCachCung",
"(",
"cung",
".",
"cungSo",
",",
"self",
".",
"cungMenh",
",",
"gioiTinh",
")",
"cung",
... | 98383a3056f0a0633d6937d364c37eb788661c0d |
train | solve_gfl | A very easy-to-use version of GFL solver that just requires the data and
the edges. | pygfl/easy.py | def solve_gfl(data, edges=None, weights=None,
minlam=0.2, maxlam=1000.0, numlam=30,
alpha=0.2, inflate=2., converge=1e-6,
maxsteps=1000000, lam=None, verbose=0,
missing_val=None, full_path=False,
loss='normal'):
'''A very easy-to-use version of G... | def solve_gfl(data, edges=None, weights=None,
minlam=0.2, maxlam=1000.0, numlam=30,
alpha=0.2, inflate=2., converge=1e-6,
maxsteps=1000000, lam=None, verbose=0,
missing_val=None, full_path=False,
loss='normal'):
'''A very easy-to-use version of G... | [
"A",
"very",
"easy",
"-",
"to",
"-",
"use",
"version",
"of",
"GFL",
"solver",
"that",
"just",
"requires",
"the",
"data",
"and",
"the",
"edges",
"."
] | tansey/gfl | python | https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/easy.py#L27-L113 | [
"def",
"solve_gfl",
"(",
"data",
",",
"edges",
"=",
"None",
",",
"weights",
"=",
"None",
",",
"minlam",
"=",
"0.2",
",",
"maxlam",
"=",
"1000.0",
",",
"numlam",
"=",
"30",
",",
"alpha",
"=",
"0.2",
",",
"inflate",
"=",
"2.",
",",
"converge",
"=",
... | ae0f078bab57aba9e827ed6162f247ff9dc2aa19 |
train | ngayThangNam | Summary
Args:
nn (TYPE): ngay
tt (TYPE): thang
nnnn (TYPE): nam
duongLich (bool, optional): bool
timeZone (int, optional): +7 Vietnam
Returns:
TYPE: Description
Raises:
Exception: Description | lasotuvi/AmDuong.py | def ngayThangNam(nn, tt, nnnn, duongLich=True, timeZone=7):
"""Summary
Args:
nn (TYPE): ngay
tt (TYPE): thang
nnnn (TYPE): nam
duongLich (bool, optional): bool
timeZone (int, optional): +7 Vietnam
Returns:
TYPE: Description
Raises:
Exception: De... | def ngayThangNam(nn, tt, nnnn, duongLich=True, timeZone=7):
"""Summary
Args:
nn (TYPE): ngay
tt (TYPE): thang
nnnn (TYPE): nam
duongLich (bool, optional): bool
timeZone (int, optional): +7 Vietnam
Returns:
TYPE: Description
Raises:
Exception: De... | [
"Summary"
] | doanguyen/lasotuvi | python | https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L218-L242 | [
"def",
"ngayThangNam",
"(",
"nn",
",",
"tt",
",",
"nnnn",
",",
"duongLich",
"=",
"True",
",",
"timeZone",
"=",
"7",
")",
":",
"thangNhuan",
"=",
"0",
"# if nnnn > 1000 and nnnn < 3000 and nn > 0 and \\",
"if",
"nn",
">",
"0",
"and",
"nn",
"<",
"32",
"and",... | 98383a3056f0a0633d6937d364c37eb788661c0d |
train | canChiNgay | Summary
Args:
nn (int): ngày
tt (int): tháng
nnnn (int): năm
duongLich (bool, optional): True nếu là dương lịch, False âm lịch
timeZone (int, optional): Múi giờ
thangNhuan (bool, optional): Có phải là tháng nhuận không?
Returns:
TYPE: Description | lasotuvi/AmDuong.py | def canChiNgay(nn, tt, nnnn, duongLich=True, timeZone=7, thangNhuan=False):
"""Summary
Args:
nn (int): ngày
tt (int): tháng
nnnn (int): năm
duongLich (bool, optional): True nếu là dương lịch, False âm lịch
timeZone (int, optional): Múi giờ
thangNhuan (bool, optio... | def canChiNgay(nn, tt, nnnn, duongLich=True, timeZone=7, thangNhuan=False):
"""Summary
Args:
nn (int): ngày
tt (int): tháng
nnnn (int): năm
duongLich (bool, optional): True nếu là dương lịch, False âm lịch
timeZone (int, optional): Múi giờ
thangNhuan (bool, optio... | [
"Summary"
] | doanguyen/lasotuvi | python | https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L245-L265 | [
"def",
"canChiNgay",
"(",
"nn",
",",
"tt",
",",
"nnnn",
",",
"duongLich",
"=",
"True",
",",
"timeZone",
"=",
"7",
",",
"thangNhuan",
"=",
"False",
")",
":",
"if",
"duongLich",
"is",
"False",
":",
"[",
"nn",
",",
"tt",
",",
"nnnn",
"]",
"=",
"L2S"... | 98383a3056f0a0633d6937d364c37eb788661c0d |
train | ngayThangNamCanChi | chuyển đổi năm, tháng âm/dương lịch sang Can, Chi trong tiếng Việt.
Không tính đến can ngày vì phải chuyển đổi qua lịch Julius.
Hàm tìm can ngày là hàm canChiNgay(nn, tt, nnnn, duongLich=True,\
timeZone=7, thangNhuan=False)
Args:
nn (int): Ngày
tt (int):... | lasotuvi/AmDuong.py | def ngayThangNamCanChi(nn, tt, nnnn, duongLich=True, timeZone=7):
"""chuyển đổi năm, tháng âm/dương lịch sang Can, Chi trong tiếng Việt.
Không tính đến can ngày vì phải chuyển đổi qua lịch Julius.
Hàm tìm can ngày là hàm canChiNgay(nn, tt, nnnn, duongLich=True,\
timeZone... | def ngayThangNamCanChi(nn, tt, nnnn, duongLich=True, timeZone=7):
"""chuyển đổi năm, tháng âm/dương lịch sang Can, Chi trong tiếng Việt.
Không tính đến can ngày vì phải chuyển đổi qua lịch Julius.
Hàm tìm can ngày là hàm canChiNgay(nn, tt, nnnn, duongLich=True,\
timeZone... | [
"chuyển",
"đổi",
"năm",
"tháng",
"âm",
"/",
"dương",
"lịch",
"sang",
"Can",
"Chi",
"trong",
"tiếng",
"Việt",
".",
"Không",
"tính",
"đến",
"can",
"ngày",
"vì",
"phải",
"chuyển",
"đổi",
"qua",
"lịch",
"Julius",
"."
] | doanguyen/lasotuvi | python | https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L281-L305 | [
"def",
"ngayThangNamCanChi",
"(",
"nn",
",",
"tt",
",",
"nnnn",
",",
"duongLich",
"=",
"True",
",",
"timeZone",
"=",
"7",
")",
":",
"if",
"duongLich",
"is",
"True",
":",
"[",
"nn",
",",
"tt",
",",
"nnnn",
",",
"thangNhuan",
"]",
"=",
"ngayThangNam",
... | 98383a3056f0a0633d6937d364c37eb788661c0d |
train | nguHanh | Args:
tenHanh (string): Tên Hành trong ngũ hành, Kim hoặc K, Moc hoặc M,
Thuy hoặc T, Hoa hoặc H, Tho hoặc O
Returns:
Dictionary: ID của Hành, tên đầy đủ của Hành, số Cục của Hành
Raises:
Exception: Description | lasotuvi/AmDuong.py | def nguHanh(tenHanh):
"""
Args:
tenHanh (string): Tên Hành trong ngũ hành, Kim hoặc K, Moc hoặc M,
Thuy hoặc T, Hoa hoặc H, Tho hoặc O
Returns:
Dictionary: ID của Hành, tên đầy đủ của Hành, số Cục của Hành
Raises:
Exception: Description
"""
if tenHanh in ["Kim",... | def nguHanh(tenHanh):
"""
Args:
tenHanh (string): Tên Hành trong ngũ hành, Kim hoặc K, Moc hoặc M,
Thuy hoặc T, Hoa hoặc H, Tho hoặc O
Returns:
Dictionary: ID của Hành, tên đầy đủ của Hành, số Cục của Hành
Raises:
Exception: Description
"""
if tenHanh in ["Kim",... | [
"Args",
":",
"tenHanh",
"(",
"string",
")",
":",
"Tên",
"Hành",
"trong",
"ngũ",
"hành",
"Kim",
"hoặc",
"K",
"Moc",
"hoặc",
"M",
"Thuy",
"hoặc",
"T",
"Hoa",
"hoặc",
"H",
"Tho",
"hoặc",
"O"
] | doanguyen/lasotuvi | python | https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L308-L338 | [
"def",
"nguHanh",
"(",
"tenHanh",
")",
":",
"if",
"tenHanh",
"in",
"[",
"\"Kim\"",
",",
"\"K\"",
"]",
":",
"return",
"{",
"\"id\"",
":",
"1",
",",
"\"tenHanh\"",
":",
"\"Kim\"",
",",
"\"cuc\"",
":",
"4",
",",
"\"tenCuc\"",
":",
"\"Kim tứ Cục\",",
"",
... | 98383a3056f0a0633d6937d364c37eb788661c0d |
train | nguHanhNapAm | Sử dụng Ngũ Hành nạp âm để tính Hành của năm.
Args:
diaChi (integer): Số thứ tự của địa chi (Tý=1, Sửu=2,...)
thienCan (integer): Số thứ tự của thiên can (Giáp=1, Ất=2,...)
Returns:
Trả về chữ viết tắt Hành của năm (K, T, H, O, M) | lasotuvi/AmDuong.py | def nguHanhNapAm(diaChi, thienCan, xuatBanMenh=False):
"""Sử dụng Ngũ Hành nạp âm để tính Hành của năm.
Args:
diaChi (integer): Số thứ tự của địa chi (Tý=1, Sửu=2,...)
thienCan (integer): Số thứ tự của thiên can (Giáp=1, Ất=2,...)
Returns:
Trả về chữ viết tắt Hành của năm (K, T, H,... | def nguHanhNapAm(diaChi, thienCan, xuatBanMenh=False):
"""Sử dụng Ngũ Hành nạp âm để tính Hành của năm.
Args:
diaChi (integer): Số thứ tự của địa chi (Tý=1, Sửu=2,...)
thienCan (integer): Số thứ tự của thiên can (Giáp=1, Ất=2,...)
Returns:
Trả về chữ viết tắt Hành của năm (K, T, H,... | [
"Sử",
"dụng",
"Ngũ",
"Hành",
"nạp",
"âm",
"để",
"tính",
"Hành",
"của",
"năm",
"."
] | doanguyen/lasotuvi | python | https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L361-L425 | [
"def",
"nguHanhNapAm",
"(",
"diaChi",
",",
"thienCan",
",",
"xuatBanMenh",
"=",
"False",
")",
":",
"banMenh",
"=",
"{",
"\"K1\"",
":",
"\"HẢI TRUNG KIM\",",
"",
"\"T1\"",
":",
"\"GIÁNG HẠ THỦY\",",
"",
"\"H1\"",
":",
"\"TÍCH LỊCH HỎA\",",
"",
"\"O1\"",
":",
... | 98383a3056f0a0633d6937d364c37eb788661c0d |
train | timTuVi | Tìm vị trí của sao Tử vi
Args:
cuc (TYPE): Description
ngaySinhAmLich (TYPE): Description
Returns:
TYPE: Description
Raises:
Exception: Description | lasotuvi/AmDuong.py | def timTuVi(cuc, ngaySinhAmLich):
"""Tìm vị trí của sao Tử vi
Args:
cuc (TYPE): Description
ngaySinhAmLich (TYPE): Description
Returns:
TYPE: Description
Raises:
Exception: Description
"""
cungDan = 3 # Vị trí cung Dần ban đầu là 3
cucBanDau = cuc
if c... | def timTuVi(cuc, ngaySinhAmLich):
"""Tìm vị trí của sao Tử vi
Args:
cuc (TYPE): Description
ngaySinhAmLich (TYPE): Description
Returns:
TYPE: Description
Raises:
Exception: Description
"""
cungDan = 3 # Vị trí cung Dần ban đầu là 3
cucBanDau = cuc
if c... | [
"Tìm",
"vị",
"trí",
"của",
"sao",
"Tử",
"vi"
] | doanguyen/lasotuvi | python | https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L452-L475 | [
"def",
"timTuVi",
"(",
"cuc",
",",
"ngaySinhAmLich",
")",
":",
"cungDan",
"=",
"3",
"# Vị trí cung Dần ban đầu là 3",
"cucBanDau",
"=",
"cuc",
"if",
"cuc",
"not",
"in",
"[",
"2",
",",
"3",
",",
"4",
",",
"5",
",",
"6",
"]",
":",
"# Tránh trường hợp infin... | 98383a3056f0a0633d6937d364c37eb788661c0d |
train | nt2aa | Translate a nucleotide sequence into an amino acid sequence.
Parameters
----------
ntseq : str
Nucleotide sequence composed of A, C, G, or T (uppercase or lowercase)
Returns
-------
aaseq : str
Amino acid sequence
Example
--------
>>> nt2aa('TGTGCCTGGAGTGTAGCTC... | olga/utils.py | def nt2aa(ntseq):
"""Translate a nucleotide sequence into an amino acid sequence.
Parameters
----------
ntseq : str
Nucleotide sequence composed of A, C, G, or T (uppercase or lowercase)
Returns
-------
aaseq : str
Amino acid sequence
Example
--------
>>> n... | def nt2aa(ntseq):
"""Translate a nucleotide sequence into an amino acid sequence.
Parameters
----------
ntseq : str
Nucleotide sequence composed of A, C, G, or T (uppercase or lowercase)
Returns
-------
aaseq : str
Amino acid sequence
Example
--------
>>> n... | [
"Translate",
"a",
"nucleotide",
"sequence",
"into",
"an",
"amino",
"acid",
"sequence",
"."
] | zsethna/OLGA | python | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L31-L53 | [
"def",
"nt2aa",
"(",
"ntseq",
")",
":",
"nt2num",
"=",
"{",
"'A'",
":",
"0",
",",
"'C'",
":",
"1",
",",
"'G'",
":",
"2",
",",
"'T'",
":",
"3",
",",
"'a'",
":",
"0",
",",
"'c'",
":",
"1",
",",
"'g'",
":",
"2",
",",
"'t'",
":",
"3",
"}",
... | e825c333f0f9a4eb02132e0bcf86f0dca9123114 |
train | nt2codon_rep | Represent nucleotide sequence by sequence of codon symbols.
'Translates' the nucleotide sequence into a symbolic representation of
'amino acids' where each codon gets its own unique character symbol. These
characters should be reserved only for representing the 64 individual
codons --- note that this... | olga/utils.py | def nt2codon_rep(ntseq):
"""Represent nucleotide sequence by sequence of codon symbols.
'Translates' the nucleotide sequence into a symbolic representation of
'amino acids' where each codon gets its own unique character symbol. These
characters should be reserved only for representing the 64 individua... | def nt2codon_rep(ntseq):
"""Represent nucleotide sequence by sequence of codon symbols.
'Translates' the nucleotide sequence into a symbolic representation of
'amino acids' where each codon gets its own unique character symbol. These
characters should be reserved only for representing the 64 individua... | [
"Represent",
"nucleotide",
"sequence",
"by",
"sequence",
"of",
"codon",
"symbols",
"."
] | zsethna/OLGA | python | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L55-L92 | [
"def",
"nt2codon_rep",
"(",
"ntseq",
")",
":",
"#",
"nt2num",
"=",
"{",
"'A'",
":",
"0",
",",
"'C'",
":",
"1",
",",
"'G'",
":",
"2",
",",
"'T'",
":",
"3",
",",
"'a'",
":",
"0",
",",
"'c'",
":",
"1",
",",
"'g'",
":",
"2",
",",
"'t'",
":",
... | e825c333f0f9a4eb02132e0bcf86f0dca9123114 |
train | cutR_seq | Cut genomic sequence from the right.
Parameters
----------
seq : str
Nucleotide sequence to be cut from the right
cutR : int
cutR - max_palindrome = how many nucleotides to cut from the right.
Negative cutR implies complementary palindromic insertions.
max_palindrome : int
... | olga/utils.py | def cutR_seq(seq, cutR, max_palindrome):
"""Cut genomic sequence from the right.
Parameters
----------
seq : str
Nucleotide sequence to be cut from the right
cutR : int
cutR - max_palindrome = how many nucleotides to cut from the right.
Negative cutR implies complementary pa... | def cutR_seq(seq, cutR, max_palindrome):
"""Cut genomic sequence from the right.
Parameters
----------
seq : str
Nucleotide sequence to be cut from the right
cutR : int
cutR - max_palindrome = how many nucleotides to cut from the right.
Negative cutR implies complementary pa... | [
"Cut",
"genomic",
"sequence",
"from",
"the",
"right",
"."
] | zsethna/OLGA | python | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L95-L127 | [
"def",
"cutR_seq",
"(",
"seq",
",",
"cutR",
",",
"max_palindrome",
")",
":",
"complement_dict",
"=",
"{",
"'A'",
":",
"'T'",
",",
"'C'",
":",
"'G'",
",",
"'G'",
":",
"'C'",
",",
"'T'",
":",
"'A'",
"}",
"#can include lower case if wanted",
"if",
"cutR",
... | e825c333f0f9a4eb02132e0bcf86f0dca9123114 |
train | cutL_seq | Cut genomic sequence from the left.
Parameters
----------
seq : str
Nucleotide sequence to be cut from the right
cutL : int
cutL - max_palindrome = how many nucleotides to cut from the left.
Negative cutL implies complementary palindromic insertions.
max_palindrome : int
... | olga/utils.py | def cutL_seq(seq, cutL, max_palindrome):
"""Cut genomic sequence from the left.
Parameters
----------
seq : str
Nucleotide sequence to be cut from the right
cutL : int
cutL - max_palindrome = how many nucleotides to cut from the left.
Negative cutL implies complementary pali... | def cutL_seq(seq, cutL, max_palindrome):
"""Cut genomic sequence from the left.
Parameters
----------
seq : str
Nucleotide sequence to be cut from the right
cutL : int
cutL - max_palindrome = how many nucleotides to cut from the left.
Negative cutL implies complementary pali... | [
"Cut",
"genomic",
"sequence",
"from",
"the",
"left",
"."
] | zsethna/OLGA | python | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L129-L162 | [
"def",
"cutL_seq",
"(",
"seq",
",",
"cutL",
",",
"max_palindrome",
")",
":",
"complement_dict",
"=",
"{",
"'A'",
":",
"'T'",
",",
"'C'",
":",
"'G'",
",",
"'G'",
":",
"'C'",
",",
"'T'",
":",
"'A'",
"}",
"#can include lower case if wanted",
"if",
"cutL",
... | e825c333f0f9a4eb02132e0bcf86f0dca9123114 |
train | construct_codons_dict | Generate the sub_codons_right dictionary of codon suffixes.
syntax of custom alphabet_files:
char: list,of,amino,acids,or,codons,separated,by,commas
Parameters
----------
alphabet_file : str
File name for a custom alphabet definition. If no file is provided, the
... | olga/utils.py | def construct_codons_dict(alphabet_file = None):
"""Generate the sub_codons_right dictionary of codon suffixes.
syntax of custom alphabet_files:
char: list,of,amino,acids,or,codons,separated,by,commas
Parameters
----------
alphabet_file : str
File name for a custom al... | def construct_codons_dict(alphabet_file = None):
"""Generate the sub_codons_right dictionary of codon suffixes.
syntax of custom alphabet_files:
char: list,of,amino,acids,or,codons,separated,by,commas
Parameters
----------
alphabet_file : str
File name for a custom al... | [
"Generate",
"the",
"sub_codons_right",
"dictionary",
"of",
"codon",
"suffixes",
"."
] | zsethna/OLGA | python | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L165-L259 | [
"def",
"construct_codons_dict",
"(",
"alphabet_file",
"=",
"None",
")",
":",
"#Some symbols can't be used in the CDR3 sequences in order to allow for",
"#regular expression parsing and general manipulation.",
"protected_symbols",
"=",
"[",
"' '",
",",
"'\\t'",
",",
"'\\n'",
",",
... | e825c333f0f9a4eb02132e0bcf86f0dca9123114 |
train | generate_sub_codons_left | Generate the sub_codons_left dictionary of codon prefixes.
Parameters
----------
codons_dict : dict
Dictionary, keyed by the allowed 'amino acid' symbols with the values
being lists of codons corresponding to the symbol.
Returns
-------
sub_codons_left : dict
Dictionar... | olga/utils.py | def generate_sub_codons_left(codons_dict):
"""Generate the sub_codons_left dictionary of codon prefixes.
Parameters
----------
codons_dict : dict
Dictionary, keyed by the allowed 'amino acid' symbols with the values
being lists of codons corresponding to the symbol.
Returns
--... | def generate_sub_codons_left(codons_dict):
"""Generate the sub_codons_left dictionary of codon prefixes.
Parameters
----------
codons_dict : dict
Dictionary, keyed by the allowed 'amino acid' symbols with the values
being lists of codons corresponding to the symbol.
Returns
--... | [
"Generate",
"the",
"sub_codons_left",
"dictionary",
"of",
"codon",
"prefixes",
"."
] | zsethna/OLGA | python | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L261-L281 | [
"def",
"generate_sub_codons_left",
"(",
"codons_dict",
")",
":",
"sub_codons_left",
"=",
"{",
"}",
"for",
"aa",
"in",
"codons_dict",
".",
"keys",
"(",
")",
":",
"sub_codons_left",
"[",
"aa",
"]",
"=",
"list",
"(",
"set",
"(",
"[",
"x",
"[",
"0",
"]",
... | e825c333f0f9a4eb02132e0bcf86f0dca9123114 |
train | generate_sub_codons_right | Generate the sub_codons_right dictionary of codon suffixes.
Parameters
----------
codons_dict : dict
Dictionary, keyed by the allowed 'amino acid' symbols with the values
being lists of codons corresponding to the symbol.
Returns
-------
sub_codons_right : dict
Diction... | olga/utils.py | def generate_sub_codons_right(codons_dict):
"""Generate the sub_codons_right dictionary of codon suffixes.
Parameters
----------
codons_dict : dict
Dictionary, keyed by the allowed 'amino acid' symbols with the values
being lists of codons corresponding to the symbol.
Returns
... | def generate_sub_codons_right(codons_dict):
"""Generate the sub_codons_right dictionary of codon suffixes.
Parameters
----------
codons_dict : dict
Dictionary, keyed by the allowed 'amino acid' symbols with the values
being lists of codons corresponding to the symbol.
Returns
... | [
"Generate",
"the",
"sub_codons_right",
"dictionary",
"of",
"codon",
"suffixes",
"."
] | zsethna/OLGA | python | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L283-L303 | [
"def",
"generate_sub_codons_right",
"(",
"codons_dict",
")",
":",
"sub_codons_right",
"=",
"{",
"}",
"for",
"aa",
"in",
"codons_dict",
".",
"keys",
"(",
")",
":",
"sub_codons_right",
"[",
"aa",
"]",
"=",
"list",
"(",
"set",
"(",
"[",
"x",
"[",
"-",
"1"... | e825c333f0f9a4eb02132e0bcf86f0dca9123114 |
train | determine_seq_type | Determine the type of a sequence.
Parameters
----------
seq : str
Sequence to be typed.
aa_alphabet : str
String of all characters recoginized as 'amino acids'. (i.e. the keys
of codons_dict: aa_alphabet = ''.join(codons_dict.keys()) )
Returns
-------
seq_type... | olga/utils.py | def determine_seq_type(seq, aa_alphabet):
"""Determine the type of a sequence.
Parameters
----------
seq : str
Sequence to be typed.
aa_alphabet : str
String of all characters recoginized as 'amino acids'. (i.e. the keys
of codons_dict: aa_alphabet = ''.join(codons_dict... | def determine_seq_type(seq, aa_alphabet):
"""Determine the type of a sequence.
Parameters
----------
seq : str
Sequence to be typed.
aa_alphabet : str
String of all characters recoginized as 'amino acids'. (i.e. the keys
of codons_dict: aa_alphabet = ''.join(codons_dict... | [
"Determine",
"the",
"type",
"of",
"a",
"sequence",
".",
"Parameters",
"----------"
] | zsethna/OLGA | python | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L305-L336 | [
"def",
"determine_seq_type",
"(",
"seq",
",",
"aa_alphabet",
")",
":",
"if",
"all",
"(",
"[",
"x",
"in",
"'ACGTacgt'",
"for",
"x",
"in",
"seq",
"]",
")",
":",
"return",
"'ntseq'",
"elif",
"all",
"(",
"[",
"x",
"in",
"aa_alphabet",
"for",
"x",
"in",
... | e825c333f0f9a4eb02132e0bcf86f0dca9123114 |
train | calc_steady_state_dist | Calculate the steady state dist of a 4 state markov transition matrix.
Parameters
----------
R : ndarray
Markov transition matrix
Returns
-------
p_ss : ndarray
Steady state probability distribution | olga/utils.py | def calc_steady_state_dist(R):
"""Calculate the steady state dist of a 4 state markov transition matrix.
Parameters
----------
R : ndarray
Markov transition matrix
Returns
-------
p_ss : ndarray
Steady state probability distribution
"""
#Calc steady state d... | def calc_steady_state_dist(R):
"""Calculate the steady state dist of a 4 state markov transition matrix.
Parameters
----------
R : ndarray
Markov transition matrix
Returns
-------
p_ss : ndarray
Steady state probability distribution
"""
#Calc steady state d... | [
"Calculate",
"the",
"steady",
"state",
"dist",
"of",
"a",
"4",
"state",
"markov",
"transition",
"matrix",
"."
] | zsethna/OLGA | python | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L340-L361 | [
"def",
"calc_steady_state_dist",
"(",
"R",
")",
":",
"#Calc steady state distribution for a dinucleotide bias matrix",
"w",
",",
"v",
"=",
"np",
".",
"linalg",
".",
"eig",
"(",
"R",
")",
"for",
"i",
"in",
"range",
"(",
"4",
")",
":",
"if",
"np",
".",
"abs"... | e825c333f0f9a4eb02132e0bcf86f0dca9123114 |
train | rnd_ins_seq | Generate a random insertion nucleotide sequence of length ins_len.
Draws the sequence identity (for a set length) from the distribution
defined by the dinucleotide markov model of transition matrix R.
Parameters
----------
ins_len : int
Length of nucleotide sequence to be inserted.
C_R... | olga/sequence_generation.py | def rnd_ins_seq(ins_len, C_R, CP_first_nt):
"""Generate a random insertion nucleotide sequence of length ins_len.
Draws the sequence identity (for a set length) from the distribution
defined by the dinucleotide markov model of transition matrix R.
Parameters
----------
ins_len : int
Le... | def rnd_ins_seq(ins_len, C_R, CP_first_nt):
"""Generate a random insertion nucleotide sequence of length ins_len.
Draws the sequence identity (for a set length) from the distribution
defined by the dinucleotide markov model of transition matrix R.
Parameters
----------
ins_len : int
Le... | [
"Generate",
"a",
"random",
"insertion",
"nucleotide",
"sequence",
"of",
"length",
"ins_len",
"."
] | zsethna/OLGA | python | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/sequence_generation.py#L457-L502 | [
"def",
"rnd_ins_seq",
"(",
"ins_len",
",",
"C_R",
",",
"CP_first_nt",
")",
":",
"nt2num",
"=",
"{",
"'A'",
":",
"0",
",",
"'C'",
":",
"1",
",",
"'G'",
":",
"2",
",",
"'T'",
":",
"3",
"}",
"num2nt",
"=",
"'ACGT'",
"if",
"ins_len",
"==",
"0",
":"... | e825c333f0f9a4eb02132e0bcf86f0dca9123114 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.