repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
zetaops/zengine | zengine/client_queue.py | ClientQueue.send_to_default_exchange | def send_to_default_exchange(self, sess_id, message=None):
"""
Send messages through RabbitMQ's default exchange,
which will be delivered through routing_key (sess_id).
This method only used for un-authenticated users, i.e. login process.
Args:
sess_id string: Sessi... | python | def send_to_default_exchange(self, sess_id, message=None):
"""
Send messages through RabbitMQ's default exchange,
which will be delivered through routing_key (sess_id).
This method only used for un-authenticated users, i.e. login process.
Args:
sess_id string: Sessi... | [
"def",
"send_to_default_exchange",
"(",
"self",
",",
"sess_id",
",",
"message",
"=",
"None",
")",
":",
"msg",
"=",
"json",
".",
"dumps",
"(",
"message",
",",
"cls",
"=",
"ZEngineJSONEncoder",
")",
"log",
".",
"debug",
"(",
"\"Sending following message to %s qu... | Send messages through RabbitMQ's default exchange,
which will be delivered through routing_key (sess_id).
This method only used for un-authenticated users, i.e. login process.
Args:
sess_id string: Session id
message dict: Message object. | [
"Send",
"messages",
"through",
"RabbitMQ",
"s",
"default",
"exchange",
"which",
"will",
"be",
"delivered",
"through",
"routing_key",
"(",
"sess_id",
")",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/client_queue.py#L59-L73 | train |
zetaops/zengine | zengine/client_queue.py | ClientQueue.send_to_prv_exchange | def send_to_prv_exchange(self, user_id, message=None):
"""
Send messages through logged in users private exchange.
Args:
user_id string: User key
message dict: Message object
"""
exchange = 'prv_%s' % user_id.lower()
msg = json.dumps(message, cls... | python | def send_to_prv_exchange(self, user_id, message=None):
"""
Send messages through logged in users private exchange.
Args:
user_id string: User key
message dict: Message object
"""
exchange = 'prv_%s' % user_id.lower()
msg = json.dumps(message, cls... | [
"def",
"send_to_prv_exchange",
"(",
"self",
",",
"user_id",
",",
"message",
"=",
"None",
")",
":",
"exchange",
"=",
"'prv_%s'",
"%",
"user_id",
".",
"lower",
"(",
")",
"msg",
"=",
"json",
".",
"dumps",
"(",
"message",
",",
"cls",
"=",
"ZEngineJSONEncoder... | Send messages through logged in users private exchange.
Args:
user_id string: User key
message dict: Message object | [
"Send",
"messages",
"through",
"logged",
"in",
"users",
"private",
"exchange",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/client_queue.py#L75-L87 | train |
cimm-kzn/CGRtools | CGRtools/algorithms/compose.py | Compose.compose | def compose(self, other):
"""
compose 2 graphs to CGR
:param other: Molecule or CGR Container
:return: CGRContainer
"""
if not isinstance(other, Compose):
raise TypeError('CGRContainer or MoleculeContainer [sub]class expected')
cgr = self._get_subcla... | python | def compose(self, other):
"""
compose 2 graphs to CGR
:param other: Molecule or CGR Container
:return: CGRContainer
"""
if not isinstance(other, Compose):
raise TypeError('CGRContainer or MoleculeContainer [sub]class expected')
cgr = self._get_subcla... | [
"def",
"compose",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Compose",
")",
":",
"raise",
"TypeError",
"(",
"'CGRContainer or MoleculeContainer [sub]class expected'",
")",
"cgr",
"=",
"self",
".",
"_get_subclass",
"(",
... | compose 2 graphs to CGR
:param other: Molecule or CGR Container
:return: CGRContainer | [
"compose",
"2",
"graphs",
"to",
"CGR"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/compose.py#L30-L172 | train |
cimm-kzn/CGRtools | CGRtools/algorithms/compose.py | CGRCompose.decompose | def decompose(self):
"""
decompose CGR to pair of Molecules, which represents reactants and products state of reaction
:return: tuple of two molecules
"""
mc = self._get_subclass('MoleculeContainer')
reactants = mc()
products = mc()
for n, atom in self.a... | python | def decompose(self):
"""
decompose CGR to pair of Molecules, which represents reactants and products state of reaction
:return: tuple of two molecules
"""
mc = self._get_subclass('MoleculeContainer')
reactants = mc()
products = mc()
for n, atom in self.a... | [
"def",
"decompose",
"(",
"self",
")",
":",
"mc",
"=",
"self",
".",
"_get_subclass",
"(",
"'MoleculeContainer'",
")",
"reactants",
"=",
"mc",
"(",
")",
"products",
"=",
"mc",
"(",
")",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
"... | decompose CGR to pair of Molecules, which represents reactants and products state of reaction
:return: tuple of two molecules | [
"decompose",
"CGR",
"to",
"pair",
"of",
"Molecules",
"which",
"represents",
"reactants",
"and",
"products",
"state",
"of",
"reaction"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/compose.py#L182-L201 | train |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.cycle_data | def cycle_data(self, verbose=False, result_cycle=None, result_size=None, result_edges=None,changelog=True):
"""Get data from JIRA for cycle/flow times and story points size change.
Build a numerically indexed data frame with the following 'fixed'
columns: `key`, 'url', 'issue_type', `summary`, ... | python | def cycle_data(self, verbose=False, result_cycle=None, result_size=None, result_edges=None,changelog=True):
"""Get data from JIRA for cycle/flow times and story points size change.
Build a numerically indexed data frame with the following 'fixed'
columns: `key`, 'url', 'issue_type', `summary`, ... | [
"def",
"cycle_data",
"(",
"self",
",",
"verbose",
"=",
"False",
",",
"result_cycle",
"=",
"None",
",",
"result_size",
"=",
"None",
",",
"result_edges",
"=",
"None",
",",
"changelog",
"=",
"True",
")",
":",
"cycle_names",
"=",
"[",
"s",
"[",
"'name'",
"... | Get data from JIRA for cycle/flow times and story points size change.
Build a numerically indexed data frame with the following 'fixed'
columns: `key`, 'url', 'issue_type', `summary`, `status`, and
`resolution` from JIRA, as well as the value of any fields set in
the `fields` dict in `s... | [
"Get",
"data",
"from",
"JIRA",
"for",
"cycle",
"/",
"flow",
"times",
"and",
"story",
"points",
"size",
"change",
"."
] | 56443211b3e1200f3def79173a21e0232332ae17 | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L86-L357 | train |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.size_history | def size_history(self,size_data):
"""Return the a DataFrame,
indexed by day, with columns containing story size for each issue.
In addition, columns are soted by Jira Issue key. First by Project and then by id number.
"""
def my_merge(df1, df2):
# http://stackoverfl... | python | def size_history(self,size_data):
"""Return the a DataFrame,
indexed by day, with columns containing story size for each issue.
In addition, columns are soted by Jira Issue key. First by Project and then by id number.
"""
def my_merge(df1, df2):
# http://stackoverfl... | [
"def",
"size_history",
"(",
"self",
",",
"size_data",
")",
":",
"def",
"my_merge",
"(",
"df1",
",",
"df2",
")",
":",
"# http://stackoverflow.com/questions/34411495/pandas-merge-several-dataframes",
"res",
"=",
"pd",
".",
"merge",
"(",
"df1",
",",
"df2",
",",
"ho... | Return the a DataFrame,
indexed by day, with columns containing story size for each issue.
In addition, columns are soted by Jira Issue key. First by Project and then by id number. | [
"Return",
"the",
"a",
"DataFrame",
"indexed",
"by",
"day",
"with",
"columns",
"containing",
"story",
"size",
"for",
"each",
"issue",
"."
] | 56443211b3e1200f3def79173a21e0232332ae17 | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L359-L407 | train |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.cfd | def cfd(self, cycle_data,size_history= None, pointscolumn= None, stacked = True ):
"""Return the data to build a cumulative flow diagram: a DataFrame,
indexed by day, with columns containing cumulative counts for each
of the items in the configured cycle.
In addition, a column called `c... | python | def cfd(self, cycle_data,size_history= None, pointscolumn= None, stacked = True ):
"""Return the data to build a cumulative flow diagram: a DataFrame,
indexed by day, with columns containing cumulative counts for each
of the items in the configured cycle.
In addition, a column called `c... | [
"def",
"cfd",
"(",
"self",
",",
"cycle_data",
",",
"size_history",
"=",
"None",
",",
"pointscolumn",
"=",
"None",
",",
"stacked",
"=",
"True",
")",
":",
"# Define helper function",
"def",
"cumulativeColumnStates",
"(",
"df",
",",
"stacked",
")",
":",
"\"\"\"... | Return the data to build a cumulative flow diagram: a DataFrame,
indexed by day, with columns containing cumulative counts for each
of the items in the configured cycle.
In addition, a column called `cycle_time` contains the approximate
average cycle time of that day based on the first ... | [
"Return",
"the",
"data",
"to",
"build",
"a",
"cumulative",
"flow",
"diagram",
":",
"a",
"DataFrame",
"indexed",
"by",
"day",
"with",
"columns",
"containing",
"cumulative",
"counts",
"for",
"each",
"of",
"the",
"items",
"in",
"the",
"configured",
"cycle",
"."... | 56443211b3e1200f3def79173a21e0232332ae17 | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L410-L641 | train |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.histogram | def histogram(self, cycle_data, bins=10):
"""Return histogram data for the cycle times in `cycle_data`. Returns
a dictionary with keys `bin_values` and `bin_edges` of numpy arrays
"""
values, edges = np.histogram(cycle_data['cycle_time'].astype('timedelta64[D]').dropna(), bins=bins)
... | python | def histogram(self, cycle_data, bins=10):
"""Return histogram data for the cycle times in `cycle_data`. Returns
a dictionary with keys `bin_values` and `bin_edges` of numpy arrays
"""
values, edges = np.histogram(cycle_data['cycle_time'].astype('timedelta64[D]').dropna(), bins=bins)
... | [
"def",
"histogram",
"(",
"self",
",",
"cycle_data",
",",
"bins",
"=",
"10",
")",
":",
"values",
",",
"edges",
"=",
"np",
".",
"histogram",
"(",
"cycle_data",
"[",
"'cycle_time'",
"]",
".",
"astype",
"(",
"'timedelta64[D]'",
")",
".",
"dropna",
"(",
")"... | Return histogram data for the cycle times in `cycle_data`. Returns
a dictionary with keys `bin_values` and `bin_edges` of numpy arrays | [
"Return",
"histogram",
"data",
"for",
"the",
"cycle",
"times",
"in",
"cycle_data",
".",
"Returns",
"a",
"dictionary",
"with",
"keys",
"bin_values",
"and",
"bin_edges",
"of",
"numpy",
"arrays"
] | 56443211b3e1200f3def79173a21e0232332ae17 | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L644-L656 | train |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.throughput_data | def throughput_data(self, cycle_data, frequency='1D',pointscolumn= None):
"""Return a data frame with columns `completed_timestamp` of the
given frequency, either
`count`, where count is the number of items
'sum', where sum is the sum of value specified by pointscolumn. Expected to be 'S... | python | def throughput_data(self, cycle_data, frequency='1D',pointscolumn= None):
"""Return a data frame with columns `completed_timestamp` of the
given frequency, either
`count`, where count is the number of items
'sum', where sum is the sum of value specified by pointscolumn. Expected to be 'S... | [
"def",
"throughput_data",
"(",
"self",
",",
"cycle_data",
",",
"frequency",
"=",
"'1D'",
",",
"pointscolumn",
"=",
"None",
")",
":",
"if",
"len",
"(",
"cycle_data",
")",
"<",
"1",
":",
"return",
"None",
"# Note completed items yet, return None",
"if",
"pointsc... | Return a data frame with columns `completed_timestamp` of the
given frequency, either
`count`, where count is the number of items
'sum', where sum is the sum of value specified by pointscolumn. Expected to be 'StoryPoints'
completed at that timestamp (e.g. daily). | [
"Return",
"a",
"data",
"frame",
"with",
"columns",
"completed_timestamp",
"of",
"the",
"given",
"frequency",
"either",
"count",
"where",
"count",
"is",
"the",
"number",
"of",
"items",
"sum",
"where",
"sum",
"is",
"the",
"sum",
"of",
"value",
"specified",
"by... | 56443211b3e1200f3def79173a21e0232332ae17 | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L658-L679 | train |
rnwolf/jira-metrics-extract | jira_metrics_extract/cycletime.py | CycleTimeQueries.scatterplot | def scatterplot(self, cycle_data):
"""Return scatterplot data for the cycle times in `cycle_data`. Returns
a data frame containing only those items in `cycle_data` where values
are set for `completed_timestamp` and `cycle_time`, and with those two
columns as the first two, both normalise... | python | def scatterplot(self, cycle_data):
"""Return scatterplot data for the cycle times in `cycle_data`. Returns
a data frame containing only those items in `cycle_data` where values
are set for `completed_timestamp` and `cycle_time`, and with those two
columns as the first two, both normalise... | [
"def",
"scatterplot",
"(",
"self",
",",
"cycle_data",
")",
":",
"columns",
"=",
"list",
"(",
"cycle_data",
".",
"columns",
")",
"columns",
".",
"remove",
"(",
"'cycle_time'",
")",
"columns",
".",
"remove",
"(",
"'completed_timestamp'",
")",
"columns",
"=",
... | Return scatterplot data for the cycle times in `cycle_data`. Returns
a data frame containing only those items in `cycle_data` where values
are set for `completed_timestamp` and `cycle_time`, and with those two
columns as the first two, both normalised to whole days, and with
`completed_t... | [
"Return",
"scatterplot",
"data",
"for",
"the",
"cycle",
"times",
"in",
"cycle_data",
".",
"Returns",
"a",
"data",
"frame",
"containing",
"only",
"those",
"items",
"in",
"cycle_data",
"where",
"values",
"are",
"set",
"for",
"completed_timestamp",
"and",
"cycle_ti... | 56443211b3e1200f3def79173a21e0232332ae17 | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/cycletime.py#L681-L703 | train |
deep-compute/logagg | logagg/nsqsender.py | NSQSender._is_ready | def _is_ready(self, topic_name):
'''
Is NSQ running and have space to receive messages?
'''
url = 'http://%s/stats?format=json&topic=%s' % (self.nsqd_http_address, topic_name)
#Cheacking for ephmeral channels
if '#' in topic_name:
topic_name, tag =topic_name.s... | python | def _is_ready(self, topic_name):
'''
Is NSQ running and have space to receive messages?
'''
url = 'http://%s/stats?format=json&topic=%s' % (self.nsqd_http_address, topic_name)
#Cheacking for ephmeral channels
if '#' in topic_name:
topic_name, tag =topic_name.s... | [
"def",
"_is_ready",
"(",
"self",
",",
"topic_name",
")",
":",
"url",
"=",
"'http://%s/stats?format=json&topic=%s'",
"%",
"(",
"self",
".",
"nsqd_http_address",
",",
"topic_name",
")",
"#Cheacking for ephmeral channels",
"if",
"'#'",
"in",
"topic_name",
":",
"topic_n... | Is NSQ running and have space to receive messages? | [
"Is",
"NSQ",
"running",
"and",
"have",
"space",
"to",
"receive",
"messages?"
] | 7863bc1b5ddf3e67c4d4b55746799304180589a0 | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/nsqsender.py#L39-L74 | train |
cimm-kzn/CGRtools | CGRtools/containers/query.py | QueryContainer._matcher | def _matcher(self, other):
"""
QueryContainer < MoleculeContainer
QueryContainer < QueryContainer[more general]
QueryContainer < QueryCGRContainer[more general]
"""
if isinstance(other, MoleculeContainer):
return GraphMatcher(other, self, lambda x, y: y == x, ... | python | def _matcher(self, other):
"""
QueryContainer < MoleculeContainer
QueryContainer < QueryContainer[more general]
QueryContainer < QueryCGRContainer[more general]
"""
if isinstance(other, MoleculeContainer):
return GraphMatcher(other, self, lambda x, y: y == x, ... | [
"def",
"_matcher",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"MoleculeContainer",
")",
":",
"return",
"GraphMatcher",
"(",
"other",
",",
"self",
",",
"lambda",
"x",
",",
"y",
":",
"y",
"==",
"x",
",",
"lambda",
"x",
... | QueryContainer < MoleculeContainer
QueryContainer < QueryContainer[more general]
QueryContainer < QueryCGRContainer[more general] | [
"QueryContainer",
"<",
"MoleculeContainer",
"QueryContainer",
"<",
"QueryContainer",
"[",
"more",
"general",
"]",
"QueryContainer",
"<",
"QueryCGRContainer",
"[",
"more",
"general",
"]"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/query.py#L31-L41 | train |
cimm-kzn/CGRtools | CGRtools/containers/query.py | QueryCGRContainer._matcher | def _matcher(self, other):
"""
QueryCGRContainer < CGRContainer
QueryContainer < QueryCGRContainer[more general]
"""
if isinstance(other, CGRContainer):
return GraphMatcher(other, self, lambda x, y: y == x, lambda x, y: y == x)
elif isinstance(other, QueryCGRC... | python | def _matcher(self, other):
"""
QueryCGRContainer < CGRContainer
QueryContainer < QueryCGRContainer[more general]
"""
if isinstance(other, CGRContainer):
return GraphMatcher(other, self, lambda x, y: y == x, lambda x, y: y == x)
elif isinstance(other, QueryCGRC... | [
"def",
"_matcher",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"CGRContainer",
")",
":",
"return",
"GraphMatcher",
"(",
"other",
",",
"self",
",",
"lambda",
"x",
",",
"y",
":",
"y",
"==",
"x",
",",
"lambda",
"x",
","... | QueryCGRContainer < CGRContainer
QueryContainer < QueryCGRContainer[more general] | [
"QueryCGRContainer",
"<",
"CGRContainer",
"QueryContainer",
"<",
"QueryCGRContainer",
"[",
"more",
"general",
"]"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/query.py#L48-L57 | train |
cimm-kzn/CGRtools | CGRtools/algorithms/calculate2d.py | Calculate2D.calculate2d | def calculate2d(self, force=False, scale=1):
"""
recalculate 2d coordinates. currently rings can be calculated badly.
:param scale: rescale calculated positions.
:param force: ignore existing coordinates of atoms
"""
dist = {}
# length forces
for n, m_bon... | python | def calculate2d(self, force=False, scale=1):
"""
recalculate 2d coordinates. currently rings can be calculated badly.
:param scale: rescale calculated positions.
:param force: ignore existing coordinates of atoms
"""
dist = {}
# length forces
for n, m_bon... | [
"def",
"calculate2d",
"(",
"self",
",",
"force",
"=",
"False",
",",
"scale",
"=",
"1",
")",
":",
"dist",
"=",
"{",
"}",
"# length forces",
"for",
"n",
",",
"m_bond",
"in",
"self",
".",
"_adj",
".",
"items",
"(",
")",
":",
"dist",
"[",
"n",
"]",
... | recalculate 2d coordinates. currently rings can be calculated badly.
:param scale: rescale calculated positions.
:param force: ignore existing coordinates of atoms | [
"recalculate",
"2d",
"coordinates",
".",
"currently",
"rings",
"can",
"be",
"calculated",
"badly",
"."
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/calculate2d.py#L24-L79 | train |
LordDarkula/chess_py | chess_py/pieces/knight.py | Knight.possible_moves | def possible_moves(self, position):
"""
Finds all possible knight moves
:type: position Board
:rtype: list
"""
for direction in [0, 1, 2, 3]:
angles = self._rotate_direction_ninety_degrees(direction)
for angle in angles:
try:
... | python | def possible_moves(self, position):
"""
Finds all possible knight moves
:type: position Board
:rtype: list
"""
for direction in [0, 1, 2, 3]:
angles = self._rotate_direction_ninety_degrees(direction)
for angle in angles:
try:
... | [
"def",
"possible_moves",
"(",
"self",
",",
"position",
")",
":",
"for",
"direction",
"in",
"[",
"0",
",",
"1",
",",
"2",
",",
"3",
"]",
":",
"angles",
"=",
"self",
".",
"_rotate_direction_ninety_degrees",
"(",
"direction",
")",
"for",
"angle",
"in",
"a... | Finds all possible knight moves
:type: position Board
:rtype: list | [
"Finds",
"all",
"possible",
"knight",
"moves",
":",
"type",
":",
"position",
"Board",
":",
"rtype",
":",
"list"
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/knight.py#L57-L81 | train |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.centers_list | def centers_list(self):
""" get a list of lists of atoms of reaction centers
"""
center = set()
adj = defaultdict(set)
for n, atom in self.atoms():
if atom._reactant != atom._product:
center.add(n)
for n, m, bond in self.bonds():
i... | python | def centers_list(self):
""" get a list of lists of atoms of reaction centers
"""
center = set()
adj = defaultdict(set)
for n, atom in self.atoms():
if atom._reactant != atom._product:
center.add(n)
for n, m, bond in self.bonds():
i... | [
"def",
"centers_list",
"(",
"self",
")",
":",
"center",
"=",
"set",
"(",
")",
"adj",
"=",
"defaultdict",
"(",
"set",
")",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"if",
"atom",
".",
"_reactant",
"!=",
"atom",
".",
"_pro... | get a list of lists of atoms of reaction centers | [
"get",
"a",
"list",
"of",
"lists",
"of",
"atoms",
"of",
"reaction",
"centers"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L37-L63 | train |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.center_atoms | def center_atoms(self):
""" get list of atoms of reaction center (atoms with dynamic: bonds, charges, radicals).
"""
nodes = set()
for n, atom in self.atoms():
if atom._reactant != atom._product:
nodes.add(n)
for n, m, bond in self.bonds():
... | python | def center_atoms(self):
""" get list of atoms of reaction center (atoms with dynamic: bonds, charges, radicals).
"""
nodes = set()
for n, atom in self.atoms():
if atom._reactant != atom._product:
nodes.add(n)
for n, m, bond in self.bonds():
... | [
"def",
"center_atoms",
"(",
"self",
")",
":",
"nodes",
"=",
"set",
"(",
")",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"if",
"atom",
".",
"_reactant",
"!=",
"atom",
".",
"_product",
":",
"nodes",
".",
"add",
"(",
"n",
... | get list of atoms of reaction center (atoms with dynamic: bonds, charges, radicals). | [
"get",
"list",
"of",
"atoms",
"of",
"reaction",
"center",
"(",
"atoms",
"with",
"dynamic",
":",
"bonds",
"charges",
"radicals",
")",
"."
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L66-L79 | train |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.center_bonds | def center_bonds(self):
""" get list of bonds of reaction center (bonds with dynamic orders).
"""
return [(n, m) for n, m, bond in self.bonds() if bond._reactant != bond._product] | python | def center_bonds(self):
""" get list of bonds of reaction center (bonds with dynamic orders).
"""
return [(n, m) for n, m, bond in self.bonds() if bond._reactant != bond._product] | [
"def",
"center_bonds",
"(",
"self",
")",
":",
"return",
"[",
"(",
"n",
",",
"m",
")",
"for",
"n",
",",
"m",
",",
"bond",
"in",
"self",
".",
"bonds",
"(",
")",
"if",
"bond",
".",
"_reactant",
"!=",
"bond",
".",
"_product",
"]"
] | get list of bonds of reaction center (bonds with dynamic orders). | [
"get",
"list",
"of",
"bonds",
"of",
"reaction",
"center",
"(",
"bonds",
"with",
"dynamic",
"orders",
")",
"."
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L82-L85 | train |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.reset_query_marks | def reset_query_marks(self):
"""
set or reset hyb and neighbors marks to atoms.
"""
for i, atom in self.atoms():
neighbors = 0
hybridization = 1
p_neighbors = 0
p_hybridization = 1
# hyb 1- sp3; 2- sp2; 3- sp1; 4- aromatic
... | python | def reset_query_marks(self):
"""
set or reset hyb and neighbors marks to atoms.
"""
for i, atom in self.atoms():
neighbors = 0
hybridization = 1
p_neighbors = 0
p_hybridization = 1
# hyb 1- sp3; 2- sp2; 3- sp1; 4- aromatic
... | [
"def",
"reset_query_marks",
"(",
"self",
")",
":",
"for",
"i",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"neighbors",
"=",
"0",
"hybridization",
"=",
"1",
"p_neighbors",
"=",
"0",
"p_hybridization",
"=",
"1",
"# hyb 1- sp3; 2- sp2; 3- sp1; 4- a... | set or reset hyb and neighbors marks to atoms. | [
"set",
"or",
"reset",
"hyb",
"and",
"neighbors",
"marks",
"to",
"atoms",
"."
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L87-L134 | train |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.substructure | def substructure(self, atoms, meta=False, as_view=True):
"""
create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view pr... | python | def substructure(self, atoms, meta=False, as_view=True):
"""
create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view pr... | [
"def",
"substructure",
"(",
"self",
",",
"atoms",
",",
"meta",
"=",
"False",
",",
"as_view",
"=",
"True",
")",
":",
"s",
"=",
"super",
"(",
")",
".",
"substructure",
"(",
"atoms",
",",
"meta",
",",
"as_view",
")",
"if",
"as_view",
":",
"s",
".",
... | create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view provides a read-only view
of the original structure scaffold withou... | [
"create",
"substructure",
"containing",
"atoms",
"from",
"nbunch",
"list"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L136-L148 | train |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer._matcher | def _matcher(self, other):
"""
CGRContainer < CGRContainer
"""
if isinstance(other, CGRContainer):
return GraphMatcher(other, self, lambda x, y: x == y, lambda x, y: x == y)
raise TypeError('only cgr-cgr possible') | python | def _matcher(self, other):
"""
CGRContainer < CGRContainer
"""
if isinstance(other, CGRContainer):
return GraphMatcher(other, self, lambda x, y: x == y, lambda x, y: x == y)
raise TypeError('only cgr-cgr possible') | [
"def",
"_matcher",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"CGRContainer",
")",
":",
"return",
"GraphMatcher",
"(",
"other",
",",
"self",
",",
"lambda",
"x",
",",
"y",
":",
"x",
"==",
"y",
",",
"lambda",
"x",
","... | CGRContainer < CGRContainer | [
"CGRContainer",
"<",
"CGRContainer"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L150-L156 | train |
cimm-kzn/CGRtools | CGRtools/containers/cgr.py | CGRContainer.__plain_bfs | def __plain_bfs(adj, source):
"""modified NX fast BFS node generator"""
seen = set()
nextlevel = {source}
while nextlevel:
thislevel = nextlevel
nextlevel = set()
for v in thislevel:
if v not in seen:
yield v
... | python | def __plain_bfs(adj, source):
"""modified NX fast BFS node generator"""
seen = set()
nextlevel = {source}
while nextlevel:
thislevel = nextlevel
nextlevel = set()
for v in thislevel:
if v not in seen:
yield v
... | [
"def",
"__plain_bfs",
"(",
"adj",
",",
"source",
")",
":",
"seen",
"=",
"set",
"(",
")",
"nextlevel",
"=",
"{",
"source",
"}",
"while",
"nextlevel",
":",
"thislevel",
"=",
"nextlevel",
"nextlevel",
"=",
"set",
"(",
")",
"for",
"v",
"in",
"thislevel",
... | modified NX fast BFS node generator | [
"modified",
"NX",
"fast",
"BFS",
"node",
"generator"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/cgr.py#L159-L170 | train |
cocaine/cocaine-framework-python | cocaine/detail/defaults.py | DefaultOptions.token | def token(self):
"""
Returns authorization token provided by Cocaine.
The real meaning of the token is determined by its type. For example OAUTH2 token will
have "bearer" type.
:return: A tuple of token type and body.
"""
if self._token is None:
toke... | python | def token(self):
"""
Returns authorization token provided by Cocaine.
The real meaning of the token is determined by its type. For example OAUTH2 token will
have "bearer" type.
:return: A tuple of token type and body.
"""
if self._token is None:
toke... | [
"def",
"token",
"(",
"self",
")",
":",
"if",
"self",
".",
"_token",
"is",
"None",
":",
"token_type",
"=",
"os",
".",
"getenv",
"(",
"TOKEN_TYPE_KEY",
",",
"''",
")",
"token_body",
"=",
"os",
".",
"getenv",
"(",
"TOKEN_BODY_KEY",
",",
"''",
")",
"self... | Returns authorization token provided by Cocaine.
The real meaning of the token is determined by its type. For example OAUTH2 token will
have "bearer" type.
:return: A tuple of token type and body. | [
"Returns",
"authorization",
"token",
"provided",
"by",
"Cocaine",
"."
] | d8a30074b6338bac4389eb996e00d404338115e4 | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/defaults.py#L116-L129 | train |
cocaine/cocaine-framework-python | cocaine/detail/logger.py | Logger._send | def _send(self):
""" Send a message lazy formatted with args.
External log attributes can be passed via named attribute `extra`,
like in logging from the standart library.
Note:
* Attrs must be dict, otherwise the whole message would be skipped.
* The key field i... | python | def _send(self):
""" Send a message lazy formatted with args.
External log attributes can be passed via named attribute `extra`,
like in logging from the standart library.
Note:
* Attrs must be dict, otherwise the whole message would be skipped.
* The key field i... | [
"def",
"_send",
"(",
"self",
")",
":",
"buff",
"=",
"BytesIO",
"(",
")",
"while",
"True",
":",
"msgs",
"=",
"list",
"(",
")",
"try",
":",
"msg",
"=",
"yield",
"self",
".",
"queue",
".",
"get",
"(",
")",
"# we need to connect first, as we issue verbosity ... | Send a message lazy formatted with args.
External log attributes can be passed via named attribute `extra`,
like in logging from the standart library.
Note:
* Attrs must be dict, otherwise the whole message would be skipped.
* The key field in an attr is converted to str... | [
"Send",
"a",
"message",
"lazy",
"formatted",
"with",
"args",
".",
"External",
"log",
"attributes",
"can",
"be",
"passed",
"via",
"named",
"attribute",
"extra",
"like",
"in",
"logging",
"from",
"the",
"standart",
"library",
"."
] | d8a30074b6338bac4389eb996e00d404338115e4 | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/logger.py#L147-L186 | train |
LordDarkula/chess_py | chess_py/pieces/rook.py | Rook.moves_in_direction | def moves_in_direction(self, direction, position):
"""
Finds moves in a given direction
:type: direction: lambda
:type: position: Board
:rtype: list
"""
current_square = self.location
while True:
try:
current_square = directio... | python | def moves_in_direction(self, direction, position):
"""
Finds moves in a given direction
:type: direction: lambda
:type: position: Board
:rtype: list
"""
current_square = self.location
while True:
try:
current_square = directio... | [
"def",
"moves_in_direction",
"(",
"self",
",",
"direction",
",",
"position",
")",
":",
"current_square",
"=",
"self",
".",
"location",
"while",
"True",
":",
"try",
":",
"current_square",
"=",
"direction",
"(",
"current_square",
")",
"except",
"IndexError",
":"... | Finds moves in a given direction
:type: direction: lambda
:type: position: Board
:rtype: list | [
"Finds",
"moves",
"in",
"a",
"given",
"direction"
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/rook.py#L48-L70 | train |
LordDarkula/chess_py | chess_py/pieces/rook.py | Rook.possible_moves | def possible_moves(self, position):
"""
Returns all possible rook moves.
:type: position: Board
:rtype: list
"""
for move in itertools.chain(*[self.moves_in_direction(fn, position) for fn in self.cross_fn]):
yield move | python | def possible_moves(self, position):
"""
Returns all possible rook moves.
:type: position: Board
:rtype: list
"""
for move in itertools.chain(*[self.moves_in_direction(fn, position) for fn in self.cross_fn]):
yield move | [
"def",
"possible_moves",
"(",
"self",
",",
"position",
")",
":",
"for",
"move",
"in",
"itertools",
".",
"chain",
"(",
"*",
"[",
"self",
".",
"moves_in_direction",
"(",
"fn",
",",
"position",
")",
"for",
"fn",
"in",
"self",
".",
"cross_fn",
"]",
")",
... | Returns all possible rook moves.
:type: position: Board
:rtype: list | [
"Returns",
"all",
"possible",
"rook",
"moves",
"."
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/rook.py#L72-L80 | train |
spacetelescope/synphot_refactor | synphot/utils.py | overlap_status | def overlap_status(a, b):
"""Check overlap between two arrays.
Parameters
----------
a, b : array-like
Arrays to check. Assumed to be in the same unit.
Returns
-------
result : {'full', 'partial', 'none'}
* 'full' - ``a`` is within or same as ``b``
* 'partial' - ``a... | python | def overlap_status(a, b):
"""Check overlap between two arrays.
Parameters
----------
a, b : array-like
Arrays to check. Assumed to be in the same unit.
Returns
-------
result : {'full', 'partial', 'none'}
* 'full' - ``a`` is within or same as ``b``
* 'partial' - ``a... | [
"def",
"overlap_status",
"(",
"a",
",",
"b",
")",
":",
"# Get the endpoints",
"a1",
",",
"a2",
"=",
"a",
".",
"min",
"(",
")",
",",
"a",
".",
"max",
"(",
")",
"b1",
",",
"b2",
"=",
"b",
".",
"min",
"(",
")",
",",
"b",
".",
"max",
"(",
")",
... | Check overlap between two arrays.
Parameters
----------
a, b : array-like
Arrays to check. Assumed to be in the same unit.
Returns
-------
result : {'full', 'partial', 'none'}
* 'full' - ``a`` is within or same as ``b``
* 'partial' - ``a`` partially overlaps with ``b``
... | [
"Check",
"overlap",
"between",
"two",
"arrays",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L23-L51 | train |
spacetelescope/synphot_refactor | synphot/utils.py | validate_totalflux | def validate_totalflux(totalflux):
"""Check integrated flux for invalid values.
Parameters
----------
totalflux : float
Integrated flux.
Raises
------
synphot.exceptions.SynphotError
Input is zero, negative, or not a number.
"""
if totalflux <= 0.0:
raise e... | python | def validate_totalflux(totalflux):
"""Check integrated flux for invalid values.
Parameters
----------
totalflux : float
Integrated flux.
Raises
------
synphot.exceptions.SynphotError
Input is zero, negative, or not a number.
"""
if totalflux <= 0.0:
raise e... | [
"def",
"validate_totalflux",
"(",
"totalflux",
")",
":",
"if",
"totalflux",
"<=",
"0.0",
":",
"raise",
"exceptions",
".",
"SynphotError",
"(",
"'Integrated flux is <= 0'",
")",
"elif",
"np",
".",
"isnan",
"(",
"totalflux",
")",
":",
"raise",
"exceptions",
".",... | Check integrated flux for invalid values.
Parameters
----------
totalflux : float
Integrated flux.
Raises
------
synphot.exceptions.SynphotError
Input is zero, negative, or not a number. | [
"Check",
"integrated",
"flux",
"for",
"invalid",
"values",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L54-L73 | train |
spacetelescope/synphot_refactor | synphot/utils.py | validate_wavelengths | def validate_wavelengths(wavelengths):
"""Check wavelengths for ``synphot`` compatibility.
Wavelengths must satisfy these conditions:
* valid unit type, if given
* no zeroes
* monotonic ascending or descending
* no duplicate values
Parameters
----------
wavelengths... | python | def validate_wavelengths(wavelengths):
"""Check wavelengths for ``synphot`` compatibility.
Wavelengths must satisfy these conditions:
* valid unit type, if given
* no zeroes
* monotonic ascending or descending
* no duplicate values
Parameters
----------
wavelengths... | [
"def",
"validate_wavelengths",
"(",
"wavelengths",
")",
":",
"if",
"isinstance",
"(",
"wavelengths",
",",
"u",
".",
"Quantity",
")",
":",
"units",
".",
"validate_wave_unit",
"(",
"wavelengths",
".",
"unit",
")",
"wave",
"=",
"wavelengths",
".",
"value",
"els... | Check wavelengths for ``synphot`` compatibility.
Wavelengths must satisfy these conditions:
* valid unit type, if given
* no zeroes
* monotonic ascending or descending
* no duplicate values
Parameters
----------
wavelengths : array-like or `~astropy.units.quantity.Quan... | [
"Check",
"wavelengths",
"for",
"synphot",
"compatibility",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L76-L139 | train |
spacetelescope/synphot_refactor | synphot/utils.py | generate_wavelengths | def generate_wavelengths(minwave=500, maxwave=26000, num=10000, delta=None,
log=True, wave_unit=u.AA):
"""Generate wavelength array to be used for spectrum sampling.
.. math::
minwave \\le \\lambda < maxwave
Parameters
----------
minwave, maxwave : float
L... | python | def generate_wavelengths(minwave=500, maxwave=26000, num=10000, delta=None,
log=True, wave_unit=u.AA):
"""Generate wavelength array to be used for spectrum sampling.
.. math::
minwave \\le \\lambda < maxwave
Parameters
----------
minwave, maxwave : float
L... | [
"def",
"generate_wavelengths",
"(",
"minwave",
"=",
"500",
",",
"maxwave",
"=",
"26000",
",",
"num",
"=",
"10000",
",",
"delta",
"=",
"None",
",",
"log",
"=",
"True",
",",
"wave_unit",
"=",
"u",
".",
"AA",
")",
":",
"wave_unit",
"=",
"units",
".",
... | Generate wavelength array to be used for spectrum sampling.
.. math::
minwave \\le \\lambda < maxwave
Parameters
----------
minwave, maxwave : float
Lower and upper limits of the wavelengths.
These must be values in linear space regardless of ``log``.
num : int
Th... | [
"Generate",
"wavelength",
"array",
"to",
"be",
"used",
"for",
"spectrum",
"sampling",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L142-L205 | train |
spacetelescope/synphot_refactor | synphot/utils.py | merge_wavelengths | def merge_wavelengths(waveset1, waveset2, threshold=1e-12):
"""Return the union of the two sets of wavelengths using
:func:`numpy.union1d`.
The merged wavelengths may sometimes contain numbers which are nearly
equal but differ at levels as small as 1e-14. Having values this
close together can cause... | python | def merge_wavelengths(waveset1, waveset2, threshold=1e-12):
"""Return the union of the two sets of wavelengths using
:func:`numpy.union1d`.
The merged wavelengths may sometimes contain numbers which are nearly
equal but differ at levels as small as 1e-14. Having values this
close together can cause... | [
"def",
"merge_wavelengths",
"(",
"waveset1",
",",
"waveset2",
",",
"threshold",
"=",
"1e-12",
")",
":",
"if",
"waveset1",
"is",
"None",
"and",
"waveset2",
"is",
"None",
":",
"out_wavelengths",
"=",
"None",
"elif",
"waveset1",
"is",
"not",
"None",
"and",
"w... | Return the union of the two sets of wavelengths using
:func:`numpy.union1d`.
The merged wavelengths may sometimes contain numbers which are nearly
equal but differ at levels as small as 1e-14. Having values this
close together can cause problems down the line. So, here we test
whether any such smal... | [
"Return",
"the",
"union",
"of",
"the",
"two",
"sets",
"of",
"wavelengths",
"using",
":",
"func",
":",
"numpy",
".",
"union1d",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L208-L252 | train |
spacetelescope/synphot_refactor | synphot/utils.py | download_data | def download_data(cdbs_root, verbose=True, dry_run=False):
"""Download CDBS data files to given root directory.
Download is skipped if a data file already exists.
Parameters
----------
cdbs_root : str
Root directory for CDBS data files.
verbose : bool
Print extra information to... | python | def download_data(cdbs_root, verbose=True, dry_run=False):
"""Download CDBS data files to given root directory.
Download is skipped if a data file already exists.
Parameters
----------
cdbs_root : str
Root directory for CDBS data files.
verbose : bool
Print extra information to... | [
"def",
"download_data",
"(",
"cdbs_root",
",",
"verbose",
"=",
"True",
",",
"dry_run",
"=",
"False",
")",
":",
"from",
".",
"config",
"import",
"conf",
"# Avoid potential circular import",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"cdbs_root",
")",... | Download CDBS data files to given root directory.
Download is skipped if a data file already exists.
Parameters
----------
cdbs_root : str
Root directory for CDBS data files.
verbose : bool
Print extra information to screen.
dry_run : bool
Go through the logic but skip... | [
"Download",
"CDBS",
"data",
"files",
"to",
"given",
"root",
"directory",
".",
"Download",
"is",
"skipped",
"if",
"a",
"data",
"file",
"already",
"exists",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/utils.py#L255-L336 | train |
Julius2342/pyvlx | examples/demo.py | main | async def main(loop):
"""Demonstrate functionality of PyVLX."""
pyvlx = PyVLX('pyvlx.yaml', loop=loop)
# Alternative:
# pyvlx = PyVLX(host="192.168.2.127", password="velux123", loop=loop)
# Runing scenes:
await pyvlx.load_scenes()
await pyvlx.scenes["All Windows Closed"].run()
# Changi... | python | async def main(loop):
"""Demonstrate functionality of PyVLX."""
pyvlx = PyVLX('pyvlx.yaml', loop=loop)
# Alternative:
# pyvlx = PyVLX(host="192.168.2.127", password="velux123", loop=loop)
# Runing scenes:
await pyvlx.load_scenes()
await pyvlx.scenes["All Windows Closed"].run()
# Changi... | [
"async",
"def",
"main",
"(",
"loop",
")",
":",
"pyvlx",
"=",
"PyVLX",
"(",
"'pyvlx.yaml'",
",",
"loop",
"=",
"loop",
")",
"# Alternative:",
"# pyvlx = PyVLX(host=\"192.168.2.127\", password=\"velux123\", loop=loop)",
"# Runing scenes:",
"await",
"pyvlx",
".",
"load_scen... | Demonstrate functionality of PyVLX. | [
"Demonstrate",
"functionality",
"of",
"PyVLX",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/examples/demo.py#L7-L30 | train |
Julius2342/pyvlx | pyvlx/frames/frame_password_enter.py | FramePasswordEnterRequest.get_payload | def get_payload(self):
"""Return Payload."""
if self.password is None:
raise PyVLXException("password is none")
if len(self.password) > self.MAX_SIZE:
raise PyVLXException("password is too long")
return string_to_bytes(self.password, self.MAX_SIZE) | python | def get_payload(self):
"""Return Payload."""
if self.password is None:
raise PyVLXException("password is none")
if len(self.password) > self.MAX_SIZE:
raise PyVLXException("password is too long")
return string_to_bytes(self.password, self.MAX_SIZE) | [
"def",
"get_payload",
"(",
"self",
")",
":",
"if",
"self",
".",
"password",
"is",
"None",
":",
"raise",
"PyVLXException",
"(",
"\"password is none\"",
")",
"if",
"len",
"(",
"self",
".",
"password",
")",
">",
"self",
".",
"MAX_SIZE",
":",
"raise",
"PyVLX... | Return Payload. | [
"Return",
"Payload",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_password_enter.py#L22-L28 | train |
Julius2342/pyvlx | pyvlx/nodes.py | Nodes.add | def add(self, node):
"""Add Node, replace existing node if node with node_id is present."""
if not isinstance(node, Node):
raise TypeError()
for i, j in enumerate(self.__nodes):
if j.node_id == node.node_id:
self.__nodes[i] = node
return
... | python | def add(self, node):
"""Add Node, replace existing node if node with node_id is present."""
if not isinstance(node, Node):
raise TypeError()
for i, j in enumerate(self.__nodes):
if j.node_id == node.node_id:
self.__nodes[i] = node
return
... | [
"def",
"add",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"isinstance",
"(",
"node",
",",
"Node",
")",
":",
"raise",
"TypeError",
"(",
")",
"for",
"i",
",",
"j",
"in",
"enumerate",
"(",
"self",
".",
"__nodes",
")",
":",
"if",
"j",
".",
"no... | Add Node, replace existing node if node with node_id is present. | [
"Add",
"Node",
"replace",
"existing",
"node",
"if",
"node",
"with",
"node_id",
"is",
"present",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/nodes.py#L51-L59 | train |
Julius2342/pyvlx | pyvlx/nodes.py | Nodes.load | async def load(self, node_id=None):
"""Load nodes from KLF 200, if no node_id is specified all nodes are loaded."""
if node_id is not None:
await self._load_node(node_id=node_id)
else:
await self._load_all_nodes() | python | async def load(self, node_id=None):
"""Load nodes from KLF 200, if no node_id is specified all nodes are loaded."""
if node_id is not None:
await self._load_node(node_id=node_id)
else:
await self._load_all_nodes() | [
"async",
"def",
"load",
"(",
"self",
",",
"node_id",
"=",
"None",
")",
":",
"if",
"node_id",
"is",
"not",
"None",
":",
"await",
"self",
".",
"_load_node",
"(",
"node_id",
"=",
"node_id",
")",
"else",
":",
"await",
"self",
".",
"_load_all_nodes",
"(",
... | Load nodes from KLF 200, if no node_id is specified all nodes are loaded. | [
"Load",
"nodes",
"from",
"KLF",
"200",
"if",
"no",
"node_id",
"is",
"specified",
"all",
"nodes",
"are",
"loaded",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/nodes.py#L65-L70 | train |
Julius2342/pyvlx | pyvlx/nodes.py | Nodes._load_node | async def _load_node(self, node_id):
"""Load single node via API."""
get_node_information = GetNodeInformation(pyvlx=self.pyvlx, node_id=node_id)
await get_node_information.do_api_call()
if not get_node_information.success:
raise PyVLXException("Unable to retrieve node inform... | python | async def _load_node(self, node_id):
"""Load single node via API."""
get_node_information = GetNodeInformation(pyvlx=self.pyvlx, node_id=node_id)
await get_node_information.do_api_call()
if not get_node_information.success:
raise PyVLXException("Unable to retrieve node inform... | [
"async",
"def",
"_load_node",
"(",
"self",
",",
"node_id",
")",
":",
"get_node_information",
"=",
"GetNodeInformation",
"(",
"pyvlx",
"=",
"self",
".",
"pyvlx",
",",
"node_id",
"=",
"node_id",
")",
"await",
"get_node_information",
".",
"do_api_call",
"(",
")",... | Load single node via API. | [
"Load",
"single",
"node",
"via",
"API",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/nodes.py#L72-L81 | train |
Julius2342/pyvlx | pyvlx/nodes.py | Nodes._load_all_nodes | async def _load_all_nodes(self):
"""Load all nodes via API."""
get_all_nodes_information = GetAllNodesInformation(pyvlx=self.pyvlx)
await get_all_nodes_information.do_api_call()
if not get_all_nodes_information.success:
raise PyVLXException("Unable to retrieve node informatio... | python | async def _load_all_nodes(self):
"""Load all nodes via API."""
get_all_nodes_information = GetAllNodesInformation(pyvlx=self.pyvlx)
await get_all_nodes_information.do_api_call()
if not get_all_nodes_information.success:
raise PyVLXException("Unable to retrieve node informatio... | [
"async",
"def",
"_load_all_nodes",
"(",
"self",
")",
":",
"get_all_nodes_information",
"=",
"GetAllNodesInformation",
"(",
"pyvlx",
"=",
"self",
".",
"pyvlx",
")",
"await",
"get_all_nodes_information",
".",
"do_api_call",
"(",
")",
"if",
"not",
"get_all_nodes_inform... | Load all nodes via API. | [
"Load",
"all",
"nodes",
"via",
"API",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/nodes.py#L83-L93 | train |
Julius2342/pyvlx | pyvlx/get_all_nodes_information.py | GetAllNodesInformation.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetAllNodesInformationConfirmation):
self.number_of_nodes = frame.number_of_nodes
# We are still waiting for FrameGetAllNodesInformationNoti... | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetAllNodesInformationConfirmation):
self.number_of_nodes = frame.number_of_nodes
# We are still waiting for FrameGetAllNodesInformationNoti... | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"isinstance",
"(",
"frame",
",",
"FrameGetAllNodesInformationConfirmation",
")",
":",
"self",
".",
"number_of_nodes",
"=",
"frame",
".",
"number_of_nodes",
"# We are still waiting for FrameGetA... | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_all_nodes_information.py#L21-L34 | train |
Julius2342/pyvlx | pyvlx/get_node_information.py | GetNodeInformation.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetNodeInformationConfirmation) and frame.node_id == self.node_id:
# We are still waiting for GetNodeInformationNotification
return False
... | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetNodeInformationConfirmation) and frame.node_id == self.node_id:
# We are still waiting for GetNodeInformationNotification
return False
... | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"isinstance",
"(",
"frame",
",",
"FrameGetNodeInformationConfirmation",
")",
"and",
"frame",
".",
"node_id",
"==",
"self",
".",
"node_id",
":",
"# We are still waiting for GetNodeInformationN... | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_node_information.py#L18-L27 | train |
Julius2342/pyvlx | pyvlx/heartbeat.py | Heartbeat.start | def start(self):
"""Create loop task."""
self.run_task = self.pyvlx.loop.create_task(
self.loop()) | python | def start(self):
"""Create loop task."""
self.run_task = self.pyvlx.loop.create_task(
self.loop()) | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"run_task",
"=",
"self",
".",
"pyvlx",
".",
"loop",
".",
"create_task",
"(",
"self",
".",
"loop",
"(",
")",
")"
] | Create loop task. | [
"Create",
"loop",
"task",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/heartbeat.py#L25-L28 | train |
Julius2342/pyvlx | pyvlx/heartbeat.py | Heartbeat.stop | async def stop(self):
"""Stop heartbeat."""
self.stopped = True
self.loop_event.set()
# Waiting for shutdown of loop()
await self.stopped_event.wait() | python | async def stop(self):
"""Stop heartbeat."""
self.stopped = True
self.loop_event.set()
# Waiting for shutdown of loop()
await self.stopped_event.wait() | [
"async",
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"stopped",
"=",
"True",
"self",
".",
"loop_event",
".",
"set",
"(",
")",
"# Waiting for shutdown of loop()",
"await",
"self",
".",
"stopped_event",
".",
"wait",
"(",
")"
] | Stop heartbeat. | [
"Stop",
"heartbeat",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/heartbeat.py#L30-L35 | train |
Julius2342/pyvlx | pyvlx/heartbeat.py | Heartbeat.loop | async def loop(self):
"""Pulse every timeout seconds until stopped."""
while not self.stopped:
self.timeout_handle = self.pyvlx.connection.loop.call_later(
self.timeout_in_seconds, self.loop_timeout)
await self.loop_event.wait()
if not self.stopped:
... | python | async def loop(self):
"""Pulse every timeout seconds until stopped."""
while not self.stopped:
self.timeout_handle = self.pyvlx.connection.loop.call_later(
self.timeout_in_seconds, self.loop_timeout)
await self.loop_event.wait()
if not self.stopped:
... | [
"async",
"def",
"loop",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"stopped",
":",
"self",
".",
"timeout_handle",
"=",
"self",
".",
"pyvlx",
".",
"connection",
".",
"loop",
".",
"call_later",
"(",
"self",
".",
"timeout_in_seconds",
",",
"self",
... | Pulse every timeout seconds until stopped. | [
"Pulse",
"every",
"timeout",
"seconds",
"until",
"stopped",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/heartbeat.py#L37-L47 | train |
Julius2342/pyvlx | pyvlx/heartbeat.py | Heartbeat.pulse | async def pulse(self):
"""Send get state request to API to keep the connection alive."""
get_state = GetState(pyvlx=self.pyvlx)
await get_state.do_api_call()
if not get_state.success:
raise PyVLXException("Unable to send get state.") | python | async def pulse(self):
"""Send get state request to API to keep the connection alive."""
get_state = GetState(pyvlx=self.pyvlx)
await get_state.do_api_call()
if not get_state.success:
raise PyVLXException("Unable to send get state.") | [
"async",
"def",
"pulse",
"(",
"self",
")",
":",
"get_state",
"=",
"GetState",
"(",
"pyvlx",
"=",
"self",
".",
"pyvlx",
")",
"await",
"get_state",
".",
"do_api_call",
"(",
")",
"if",
"not",
"get_state",
".",
"success",
":",
"raise",
"PyVLXException",
"(",... | Send get state request to API to keep the connection alive. | [
"Send",
"get",
"state",
"request",
"to",
"API",
"to",
"keep",
"the",
"connection",
"alive",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/heartbeat.py#L59-L64 | train |
Julius2342/pyvlx | pyvlx/frames/frame_get_state.py | FrameGetStateConfirmation.get_payload | def get_payload(self):
"""Return Payload."""
payload = bytes([self.gateway_state.value, self.gateway_sub_state.value])
payload += bytes(4) # State date, reserved for future use
return payload | python | def get_payload(self):
"""Return Payload."""
payload = bytes([self.gateway_state.value, self.gateway_sub_state.value])
payload += bytes(4) # State date, reserved for future use
return payload | [
"def",
"get_payload",
"(",
"self",
")",
":",
"payload",
"=",
"bytes",
"(",
"[",
"self",
".",
"gateway_state",
".",
"value",
",",
"self",
".",
"gateway_sub_state",
".",
"value",
"]",
")",
"payload",
"+=",
"bytes",
"(",
"4",
")",
"# State date, reserved for ... | Return Payload. | [
"Return",
"Payload",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_state.py#L53-L57 | train |
Julius2342/pyvlx | pyvlx/frames/frame_get_state.py | FrameGetStateConfirmation.from_payload | def from_payload(self, payload):
"""Init frame from binary data."""
self.gateway_state = GatewayState(payload[0])
self.gateway_sub_state = GatewaySubState(payload[1]) | python | def from_payload(self, payload):
"""Init frame from binary data."""
self.gateway_state = GatewayState(payload[0])
self.gateway_sub_state = GatewaySubState(payload[1]) | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"gateway_state",
"=",
"GatewayState",
"(",
"payload",
"[",
"0",
"]",
")",
"self",
".",
"gateway_sub_state",
"=",
"GatewaySubState",
"(",
"payload",
"[",
"1",
"]",
")"
] | Init frame from binary data. | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_state.py#L59-L62 | train |
Julius2342/pyvlx | pyvlx/string_helper.py | string_to_bytes | def string_to_bytes(string, size):
"""Convert string to bytes add padding."""
if len(string) > size:
raise PyVLXException("string_to_bytes::string_to_large")
encoded = bytes(string, encoding='utf-8')
return encoded + bytes(size-len(encoded)) | python | def string_to_bytes(string, size):
"""Convert string to bytes add padding."""
if len(string) > size:
raise PyVLXException("string_to_bytes::string_to_large")
encoded = bytes(string, encoding='utf-8')
return encoded + bytes(size-len(encoded)) | [
"def",
"string_to_bytes",
"(",
"string",
",",
"size",
")",
":",
"if",
"len",
"(",
"string",
")",
">",
"size",
":",
"raise",
"PyVLXException",
"(",
"\"string_to_bytes::string_to_large\"",
")",
"encoded",
"=",
"bytes",
"(",
"string",
",",
"encoding",
"=",
"'ut... | Convert string to bytes add padding. | [
"Convert",
"string",
"to",
"bytes",
"add",
"padding",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/string_helper.py#L5-L10 | train |
Julius2342/pyvlx | pyvlx/string_helper.py | bytes_to_string | def bytes_to_string(raw):
"""Convert bytes to string."""
ret = bytes()
for byte in raw:
if byte == 0x00:
return ret.decode("utf-8")
ret += bytes([byte])
return ret.decode("utf-8") | python | def bytes_to_string(raw):
"""Convert bytes to string."""
ret = bytes()
for byte in raw:
if byte == 0x00:
return ret.decode("utf-8")
ret += bytes([byte])
return ret.decode("utf-8") | [
"def",
"bytes_to_string",
"(",
"raw",
")",
":",
"ret",
"=",
"bytes",
"(",
")",
"for",
"byte",
"in",
"raw",
":",
"if",
"byte",
"==",
"0x00",
":",
"return",
"ret",
".",
"decode",
"(",
"\"utf-8\"",
")",
"ret",
"+=",
"bytes",
"(",
"[",
"byte",
"]",
"... | Convert bytes to string. | [
"Convert",
"bytes",
"to",
"string",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/string_helper.py#L13-L20 | train |
Julius2342/pyvlx | pyvlx/frames/frame_node_state_position_changed_notification.py | FrameNodeStatePositionChangedNotification.get_payload | def get_payload(self):
"""Return Payload."""
payload = bytes([self.node_id])
payload += bytes([self.state])
payload += bytes(self.current_position.raw)
payload += bytes(self.target.raw)
payload += bytes(self.current_position_fp1.raw)
payload += bytes(self.current_... | python | def get_payload(self):
"""Return Payload."""
payload = bytes([self.node_id])
payload += bytes([self.state])
payload += bytes(self.current_position.raw)
payload += bytes(self.target.raw)
payload += bytes(self.current_position_fp1.raw)
payload += bytes(self.current_... | [
"def",
"get_payload",
"(",
"self",
")",
":",
"payload",
"=",
"bytes",
"(",
"[",
"self",
".",
"node_id",
"]",
")",
"payload",
"+=",
"bytes",
"(",
"[",
"self",
".",
"state",
"]",
")",
"payload",
"+=",
"bytes",
"(",
"self",
".",
"current_position",
".",... | Return Payload. | [
"Return",
"Payload",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_node_state_position_changed_notification.py#L30-L42 | train |
Julius2342/pyvlx | pyvlx/frames/frame_node_state_position_changed_notification.py | FrameNodeStatePositionChangedNotification.from_payload | def from_payload(self, payload):
"""Init frame from binary data."""
self.node_id = payload[0]
self.state = payload[1]
self.current_position = Parameter(payload[2:4])
self.target = Parameter(payload[4:6])
self.current_position_fp1 = Parameter(payload[6:8])
self.cur... | python | def from_payload(self, payload):
"""Init frame from binary data."""
self.node_id = payload[0]
self.state = payload[1]
self.current_position = Parameter(payload[2:4])
self.target = Parameter(payload[4:6])
self.current_position_fp1 = Parameter(payload[6:8])
self.cur... | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"node_id",
"=",
"payload",
"[",
"0",
"]",
"self",
".",
"state",
"=",
"payload",
"[",
"1",
"]",
"self",
".",
"current_position",
"=",
"Parameter",
"(",
"payload",
"[",
"2",
":"... | Init frame from binary data. | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_node_state_position_changed_notification.py#L44-L57 | train |
Julius2342/pyvlx | pyvlx/house_status_monitor.py | house_status_monitor_enable | async def house_status_monitor_enable(pyvlx):
"""Enable house status monitor."""
status_monitor_enable = HouseStatusMonitorEnable(pyvlx=pyvlx)
await status_monitor_enable.do_api_call()
if not status_monitor_enable.success:
raise PyVLXException("Unable enable house status monitor.") | python | async def house_status_monitor_enable(pyvlx):
"""Enable house status monitor."""
status_monitor_enable = HouseStatusMonitorEnable(pyvlx=pyvlx)
await status_monitor_enable.do_api_call()
if not status_monitor_enable.success:
raise PyVLXException("Unable enable house status monitor.") | [
"async",
"def",
"house_status_monitor_enable",
"(",
"pyvlx",
")",
":",
"status_monitor_enable",
"=",
"HouseStatusMonitorEnable",
"(",
"pyvlx",
"=",
"pyvlx",
")",
"await",
"status_monitor_enable",
".",
"do_api_call",
"(",
")",
"if",
"not",
"status_monitor_enable",
".",... | Enable house status monitor. | [
"Enable",
"house",
"status",
"monitor",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/house_status_monitor.py#L51-L56 | train |
Julius2342/pyvlx | pyvlx/house_status_monitor.py | house_status_monitor_disable | async def house_status_monitor_disable(pyvlx):
"""Disable house status monitor."""
status_monitor_disable = HouseStatusMonitorDisable(pyvlx=pyvlx)
await status_monitor_disable.do_api_call()
if not status_monitor_disable.success:
raise PyVLXException("Unable disable house status monitor.") | python | async def house_status_monitor_disable(pyvlx):
"""Disable house status monitor."""
status_monitor_disable = HouseStatusMonitorDisable(pyvlx=pyvlx)
await status_monitor_disable.do_api_call()
if not status_monitor_disable.success:
raise PyVLXException("Unable disable house status monitor.") | [
"async",
"def",
"house_status_monitor_disable",
"(",
"pyvlx",
")",
":",
"status_monitor_disable",
"=",
"HouseStatusMonitorDisable",
"(",
"pyvlx",
"=",
"pyvlx",
")",
"await",
"status_monitor_disable",
".",
"do_api_call",
"(",
")",
"if",
"not",
"status_monitor_disable",
... | Disable house status monitor. | [
"Disable",
"house",
"status",
"monitor",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/house_status_monitor.py#L59-L64 | train |
Julius2342/pyvlx | pyvlx/house_status_monitor.py | HouseStatusMonitorEnable.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameHouseStatusMonitorEnableConfirmation):
return False
self.success = True
return True | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameHouseStatusMonitorEnableConfirmation):
return False
self.success = True
return True | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"isinstance",
"(",
"frame",
",",
"FrameHouseStatusMonitorEnableConfirmation",
")",
":",
"return",
"False",
"self",
".",
"success",
"=",
"True",
"return",
"True"
] | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/house_status_monitor.py#L19-L24 | train |
Julius2342/pyvlx | pyvlx/house_status_monitor.py | HouseStatusMonitorDisable.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameHouseStatusMonitorDisableConfirmation):
return False
self.success = True
return True | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameHouseStatusMonitorDisableConfirmation):
return False
self.success = True
return True | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"isinstance",
"(",
"frame",
",",
"FrameHouseStatusMonitorDisableConfirmation",
")",
":",
"return",
"False",
"self",
".",
"success",
"=",
"True",
"return",
"True"
] | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/house_status_monitor.py#L39-L44 | train |
tbielawa/bitmath | bitmath/integrations.py | BitmathType | def BitmathType(bmstring):
"""An 'argument type' for integrations with the argparse module.
For more information, see
https://docs.python.org/2/library/argparse.html#type Of particular
interest to us is this bit:
``type=`` can take any callable that takes a single string
argument and returns the converted v... | python | def BitmathType(bmstring):
"""An 'argument type' for integrations with the argparse module.
For more information, see
https://docs.python.org/2/library/argparse.html#type Of particular
interest to us is this bit:
``type=`` can take any callable that takes a single string
argument and returns the converted v... | [
"def",
"BitmathType",
"(",
"bmstring",
")",
":",
"try",
":",
"argvalue",
"=",
"bitmath",
".",
"parse_string",
"(",
"bmstring",
")",
"except",
"ValueError",
":",
"raise",
"argparse",
".",
"ArgumentTypeError",
"(",
"\"'%s' can not be parsed into a valid bitmath object\"... | An 'argument type' for integrations with the argparse module.
For more information, see
https://docs.python.org/2/library/argparse.html#type Of particular
interest to us is this bit:
``type=`` can take any callable that takes a single string
argument and returns the converted value
I.e., ``type`` can be a func... | [
"An",
"argument",
"type",
"for",
"integrations",
"with",
"the",
"argparse",
"module",
"."
] | 58ad3ac5f076cc6e53f36a91af055c6028c850a5 | https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/integrations.py#L33-L80 | train |
tbielawa/bitmath | bitmath/integrations.py | BitmathFileTransferSpeed.update | def update(self, pbar):
"""Updates the widget with the current NIST/SI speed.
Basically, this calculates the average rate of update and figures out
how to make a "pretty" prefix unit"""
if pbar.seconds_elapsed < 2e-6 or pbar.currval < 2e-6:
scaled = bitmath.Byte()
else:
... | python | def update(self, pbar):
"""Updates the widget with the current NIST/SI speed.
Basically, this calculates the average rate of update and figures out
how to make a "pretty" prefix unit"""
if pbar.seconds_elapsed < 2e-6 or pbar.currval < 2e-6:
scaled = bitmath.Byte()
else:
... | [
"def",
"update",
"(",
"self",
",",
"pbar",
")",
":",
"if",
"pbar",
".",
"seconds_elapsed",
"<",
"2e-6",
"or",
"pbar",
".",
"currval",
"<",
"2e-6",
":",
"scaled",
"=",
"bitmath",
".",
"Byte",
"(",
")",
"else",
":",
"speed",
"=",
"pbar",
".",
"currva... | Updates the widget with the current NIST/SI speed.
Basically, this calculates the average rate of update and figures out
how to make a "pretty" prefix unit | [
"Updates",
"the",
"widget",
"with",
"the",
"current",
"NIST",
"/",
"SI",
"speed",
"."
] | 58ad3ac5f076cc6e53f36a91af055c6028c850a5 | https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/integrations.py#L92-L104 | train |
Julius2342/pyvlx | pyvlx/command_send.py | CommandSend.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameCommandSendConfirmation) and frame.session_id == self.session_id:
if frame.status == CommandSendConfirmationStatus.ACCEPTED:
self.succes... | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameCommandSendConfirmation) and frame.session_id == self.session_id:
if frame.status == CommandSendConfirmationStatus.ACCEPTED:
self.succes... | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"isinstance",
"(",
"frame",
",",
"FrameCommandSendConfirmation",
")",
"and",
"frame",
".",
"session_id",
"==",
"self",
".",
"session_id",
":",
"if",
"frame",
".",
"status",
"==",
"C... | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/command_send.py#L22-L37 | train |
Julius2342/pyvlx | pyvlx/command_send.py | CommandSend.request_frame | def request_frame(self):
"""Construct initiating frame."""
self.session_id = get_new_session_id()
return FrameCommandSendRequest(node_ids=[self.node_id], parameter=self.parameter, session_id=self.session_id) | python | def request_frame(self):
"""Construct initiating frame."""
self.session_id = get_new_session_id()
return FrameCommandSendRequest(node_ids=[self.node_id], parameter=self.parameter, session_id=self.session_id) | [
"def",
"request_frame",
"(",
"self",
")",
":",
"self",
".",
"session_id",
"=",
"get_new_session_id",
"(",
")",
"return",
"FrameCommandSendRequest",
"(",
"node_ids",
"=",
"[",
"self",
".",
"node_id",
"]",
",",
"parameter",
"=",
"self",
".",
"parameter",
",",
... | Construct initiating frame. | [
"Construct",
"initiating",
"frame",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/command_send.py#L39-L42 | train |
Julius2342/pyvlx | pyvlx/config.py | Config.read_config | def read_config(self, path):
"""Read configuration file."""
PYVLXLOG.info('Reading config file: %s', path)
try:
with open(path, 'r') as filehandle:
doc = yaml.safe_load(filehandle)
self.test_configuration(doc, path)
self.host = doc['con... | python | def read_config(self, path):
"""Read configuration file."""
PYVLXLOG.info('Reading config file: %s', path)
try:
with open(path, 'r') as filehandle:
doc = yaml.safe_load(filehandle)
self.test_configuration(doc, path)
self.host = doc['con... | [
"def",
"read_config",
"(",
"self",
",",
"path",
")",
":",
"PYVLXLOG",
".",
"info",
"(",
"'Reading config file: %s'",
",",
"path",
")",
"try",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"filehandle",
":",
"doc",
"=",
"yaml",
".",
"safe_loa... | Read configuration file. | [
"Read",
"configuration",
"file",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/config.py#L22-L34 | train |
pyQode/pyqode.qt | pyqode/qt/__init__.py | setup_apiv2 | def setup_apiv2():
"""
Setup apiv2 when using PyQt4 and Python2.
"""
# setup PyQt api to version 2
if sys.version_info[0] == 2:
logging.getLogger(__name__).debug(
'setting up SIP API to version 2')
import sip
try:
sip.setapi("QString", 2)
s... | python | def setup_apiv2():
"""
Setup apiv2 when using PyQt4 and Python2.
"""
# setup PyQt api to version 2
if sys.version_info[0] == 2:
logging.getLogger(__name__).debug(
'setting up SIP API to version 2')
import sip
try:
sip.setapi("QString", 2)
s... | [
"def",
"setup_apiv2",
"(",
")",
":",
"# setup PyQt api to version 2",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"2",
":",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"debug",
"(",
"'setting up SIP API to version 2'",
")",
"import",
"si... | Setup apiv2 when using PyQt4 and Python2. | [
"Setup",
"apiv2",
"when",
"using",
"PyQt4",
"and",
"Python2",
"."
] | 56ee08fdcd4d9c4441dcf85f89b51d4ae3a727bd | https://github.com/pyQode/pyqode.qt/blob/56ee08fdcd4d9c4441dcf85f89b51d4ae3a727bd/pyqode/qt/__init__.py#L79-L94 | train |
pyQode/pyqode.qt | pyqode/qt/__init__.py | autodetect | def autodetect():
"""
Auto-detects and use the first available QT_API by importing them in the
following order:
1) PyQt5
2) PyQt4
3) PySide
"""
logging.getLogger(__name__).debug('auto-detecting QT_API')
try:
logging.getLogger(__name__).debug('trying PyQt5')
import Py... | python | def autodetect():
"""
Auto-detects and use the first available QT_API by importing them in the
following order:
1) PyQt5
2) PyQt4
3) PySide
"""
logging.getLogger(__name__).debug('auto-detecting QT_API')
try:
logging.getLogger(__name__).debug('trying PyQt5')
import Py... | [
"def",
"autodetect",
"(",
")",
":",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"debug",
"(",
"'auto-detecting QT_API'",
")",
"try",
":",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"debug",
"(",
"'trying PyQt5'",
")",
"import",
"Py... | Auto-detects and use the first available QT_API by importing them in the
following order:
1) PyQt5
2) PyQt4
3) PySide | [
"Auto",
"-",
"detects",
"and",
"use",
"the",
"first",
"available",
"QT_API",
"by",
"importing",
"them",
"in",
"the",
"following",
"order",
":"
] | 56ee08fdcd4d9c4441dcf85f89b51d4ae3a727bd | https://github.com/pyQode/pyqode.qt/blob/56ee08fdcd4d9c4441dcf85f89b51d4ae3a727bd/pyqode/qt/__init__.py#L97-L126 | train |
Julius2342/pyvlx | old_api/pyvlx/rollershutter.py | RollerShutter.from_config | def from_config(cls, pyvlx, item):
"""Read roller shutter from config."""
name = item['name']
ident = item['id']
subtype = item['subtype']
typeid = item['typeId']
return cls(pyvlx, ident, name, subtype, typeid) | python | def from_config(cls, pyvlx, item):
"""Read roller shutter from config."""
name = item['name']
ident = item['id']
subtype = item['subtype']
typeid = item['typeId']
return cls(pyvlx, ident, name, subtype, typeid) | [
"def",
"from_config",
"(",
"cls",
",",
"pyvlx",
",",
"item",
")",
":",
"name",
"=",
"item",
"[",
"'name'",
"]",
"ident",
"=",
"item",
"[",
"'id'",
"]",
"subtype",
"=",
"item",
"[",
"'subtype'",
"]",
"typeid",
"=",
"item",
"[",
"'typeId'",
"]",
"ret... | Read roller shutter from config. | [
"Read",
"roller",
"shutter",
"from",
"config",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/rollershutter.py#L19-L25 | train |
Julius2342/pyvlx | pyvlx/get_scene_list.py | GetSceneList.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetSceneListConfirmation):
self.count_scenes = frame.count_scenes
if self.count_scenes == 0:
self.success = True
... | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if isinstance(frame, FrameGetSceneListConfirmation):
self.count_scenes = frame.count_scenes
if self.count_scenes == 0:
self.success = True
... | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"isinstance",
"(",
"frame",
",",
"FrameGetSceneListConfirmation",
")",
":",
"self",
".",
"count_scenes",
"=",
"frame",
".",
"count_scenes",
"if",
"self",
".",
"count_scenes",
"==",
"0... | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_scene_list.py#L19-L37 | train |
Julius2342/pyvlx | pyvlx/frames/frame_get_scene_list.py | FrameGetSceneListNotification.get_payload | def get_payload(self):
"""Return Payload."""
ret = bytes([len(self.scenes)])
for number, name in self.scenes:
ret += bytes([number])
ret += string_to_bytes(name, 64)
ret += bytes([self.remaining_scenes])
return ret | python | def get_payload(self):
"""Return Payload."""
ret = bytes([len(self.scenes)])
for number, name in self.scenes:
ret += bytes([number])
ret += string_to_bytes(name, 64)
ret += bytes([self.remaining_scenes])
return ret | [
"def",
"get_payload",
"(",
"self",
")",
":",
"ret",
"=",
"bytes",
"(",
"[",
"len",
"(",
"self",
".",
"scenes",
")",
"]",
")",
"for",
"number",
",",
"name",
"in",
"self",
".",
"scenes",
":",
"ret",
"+=",
"bytes",
"(",
"[",
"number",
"]",
")",
"r... | Return Payload. | [
"Return",
"Payload",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_scene_list.py#L51-L58 | train |
Julius2342/pyvlx | pyvlx/frames/frame_get_scene_list.py | FrameGetSceneListNotification.from_payload | def from_payload(self, payload):
"""Init frame from binary data."""
number_of_objects = payload[0]
self.remaining_scenes = payload[-1]
predicted_len = number_of_objects * 65 + 2
if len(payload) != predicted_len:
raise PyVLXException('scene_list_notification_wrong_leng... | python | def from_payload(self, payload):
"""Init frame from binary data."""
number_of_objects = payload[0]
self.remaining_scenes = payload[-1]
predicted_len = number_of_objects * 65 + 2
if len(payload) != predicted_len:
raise PyVLXException('scene_list_notification_wrong_leng... | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"number_of_objects",
"=",
"payload",
"[",
"0",
"]",
"self",
".",
"remaining_scenes",
"=",
"payload",
"[",
"-",
"1",
"]",
"predicted_len",
"=",
"number_of_objects",
"*",
"65",
"+",
"2",
"if",
"... | Init frame from binary data. | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_scene_list.py#L60-L72 | train |
spacetelescope/synphot_refactor | synphot/specio.py | read_remote_spec | def read_remote_spec(filename, encoding='binary', cache=True,
show_progress=True, **kwargs):
"""Read FITS or ASCII spectrum from a remote location.
Parameters
----------
filename : str
Spectrum filename.
encoding, cache, show_progress
See :func:`~astropy.utils.... | python | def read_remote_spec(filename, encoding='binary', cache=True,
show_progress=True, **kwargs):
"""Read FITS or ASCII spectrum from a remote location.
Parameters
----------
filename : str
Spectrum filename.
encoding, cache, show_progress
See :func:`~astropy.utils.... | [
"def",
"read_remote_spec",
"(",
"filename",
",",
"encoding",
"=",
"'binary'",
",",
"cache",
"=",
"True",
",",
"show_progress",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"get_readable_fileobj",
"(",
"filename",
",",
"encoding",
"=",
"encoding",
... | Read FITS or ASCII spectrum from a remote location.
Parameters
----------
filename : str
Spectrum filename.
encoding, cache, show_progress
See :func:`~astropy.utils.data.get_readable_fileobj`.
kwargs : dict
Keywords acceptable by :func:`read_fits_spec` (if FITS) or
... | [
"Read",
"FITS",
"or",
"ASCII",
"spectrum",
"from",
"a",
"remote",
"location",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/specio.py#L26-L55 | train |
spacetelescope/synphot_refactor | synphot/specio.py | read_spec | def read_spec(filename, fname='', **kwargs):
"""Read FITS or ASCII spectrum.
Parameters
----------
filename : str or file pointer
Spectrum file name or pointer.
fname : str
Filename. This is *only* used if ``filename`` is a pointer.
kwargs : dict
Keywords acceptable by... | python | def read_spec(filename, fname='', **kwargs):
"""Read FITS or ASCII spectrum.
Parameters
----------
filename : str or file pointer
Spectrum file name or pointer.
fname : str
Filename. This is *only* used if ``filename`` is a pointer.
kwargs : dict
Keywords acceptable by... | [
"def",
"read_spec",
"(",
"filename",
",",
"fname",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"str",
")",
":",
"fname",
"=",
"filename",
"elif",
"not",
"fname",
":",
"# pragma: no cover",
"raise",
"exceptions"... | Read FITS or ASCII spectrum.
Parameters
----------
filename : str or file pointer
Spectrum file name or pointer.
fname : str
Filename. This is *only* used if ``filename`` is a pointer.
kwargs : dict
Keywords acceptable by :func:`read_fits_spec` (if FITS) or
:func:`... | [
"Read",
"FITS",
"or",
"ASCII",
"spectrum",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/specio.py#L58-L97 | train |
spacetelescope/synphot_refactor | synphot/specio.py | read_ascii_spec | def read_ascii_spec(filename, wave_unit=u.AA, flux_unit=units.FLAM, **kwargs):
"""Read ASCII spectrum.
ASCII table must have following columns:
#. Wavelength data
#. Flux data
It can have more than 2 columns but the rest is ignored.
Comments are discarded.
Parameters
--------... | python | def read_ascii_spec(filename, wave_unit=u.AA, flux_unit=units.FLAM, **kwargs):
"""Read ASCII spectrum.
ASCII table must have following columns:
#. Wavelength data
#. Flux data
It can have more than 2 columns but the rest is ignored.
Comments are discarded.
Parameters
--------... | [
"def",
"read_ascii_spec",
"(",
"filename",
",",
"wave_unit",
"=",
"u",
".",
"AA",
",",
"flux_unit",
"=",
"units",
".",
"FLAM",
",",
"*",
"*",
"kwargs",
")",
":",
"header",
"=",
"{",
"}",
"dat",
"=",
"ascii",
".",
"read",
"(",
"filename",
",",
"*",
... | Read ASCII spectrum.
ASCII table must have following columns:
#. Wavelength data
#. Flux data
It can have more than 2 columns but the rest is ignored.
Comments are discarded.
Parameters
----------
filename : str or file pointer
Spectrum file name or pointer.
wave... | [
"Read",
"ASCII",
"spectrum",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/specio.py#L100-L144 | train |
spacetelescope/synphot_refactor | synphot/specio.py | read_fits_spec | def read_fits_spec(filename, ext=1, wave_col='WAVELENGTH', flux_col='FLUX',
wave_unit=u.AA, flux_unit=units.FLAM):
"""Read FITS spectrum.
Wavelength and flux units are extracted from ``TUNIT1`` and ``TUNIT2``
keywords, respectively, from data table (not primary) header.
If these keyw... | python | def read_fits_spec(filename, ext=1, wave_col='WAVELENGTH', flux_col='FLUX',
wave_unit=u.AA, flux_unit=units.FLAM):
"""Read FITS spectrum.
Wavelength and flux units are extracted from ``TUNIT1`` and ``TUNIT2``
keywords, respectively, from data table (not primary) header.
If these keyw... | [
"def",
"read_fits_spec",
"(",
"filename",
",",
"ext",
"=",
"1",
",",
"wave_col",
"=",
"'WAVELENGTH'",
",",
"flux_col",
"=",
"'FLUX'",
",",
"wave_unit",
"=",
"u",
".",
"AA",
",",
"flux_unit",
"=",
"units",
".",
"FLAM",
")",
":",
"fs",
"=",
"fits",
"."... | Read FITS spectrum.
Wavelength and flux units are extracted from ``TUNIT1`` and ``TUNIT2``
keywords, respectively, from data table (not primary) header.
If these keywords are not present, units are taken from
``wave_unit`` and ``flux_unit`` instead.
Parameters
----------
filename : str or ... | [
"Read",
"FITS",
"spectrum",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/specio.py#L147-L215 | train |
spacetelescope/synphot_refactor | synphot/specio.py | write_fits_spec | def write_fits_spec(filename, wavelengths, fluxes, pri_header={},
ext_header={}, overwrite=False, trim_zero=True,
pad_zero_ends=True, precision=None, epsilon=0.00032,
wave_col='WAVELENGTH', flux_col='FLUX',
wave_unit=u.AA, flux_unit=units.F... | python | def write_fits_spec(filename, wavelengths, fluxes, pri_header={},
ext_header={}, overwrite=False, trim_zero=True,
pad_zero_ends=True, precision=None, epsilon=0.00032,
wave_col='WAVELENGTH', flux_col='FLUX',
wave_unit=u.AA, flux_unit=units.F... | [
"def",
"write_fits_spec",
"(",
"filename",
",",
"wavelengths",
",",
"fluxes",
",",
"pri_header",
"=",
"{",
"}",
",",
"ext_header",
"=",
"{",
"}",
",",
"overwrite",
"=",
"False",
",",
"trim_zero",
"=",
"True",
",",
"pad_zero_ends",
"=",
"True",
",",
"prec... | Write FITS spectrum.
.. warning::
If data is being written out as single-precision but wavelengths
are in double-precision, some rows may be omitted.
Parameters
----------
filename : str
Output spectrum filename.
wavelengths, fluxes : array-like or `~astropy.units.quantit... | [
"Write",
"FITS",
"spectrum",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/specio.py#L218-L384 | train |
spacetelescope/synphot_refactor | synphot/units.py | spectral_density_vega | def spectral_density_vega(wav, vegaflux):
"""Flux equivalencies between PHOTLAM and VEGAMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
vegaflux : `~astropy.units.quantity.Quantity`... | python | def spectral_density_vega(wav, vegaflux):
"""Flux equivalencies between PHOTLAM and VEGAMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
vegaflux : `~astropy.units.quantity.Quantity`... | [
"def",
"spectral_density_vega",
"(",
"wav",
",",
"vegaflux",
")",
":",
"vega_photlam",
"=",
"vegaflux",
".",
"to",
"(",
"PHOTLAM",
",",
"equivalencies",
"=",
"u",
".",
"spectral_density",
"(",
"wav",
")",
")",
".",
"value",
"def",
"converter",
"(",
"x",
... | Flux equivalencies between PHOTLAM and VEGAMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
vegaflux : `~astropy.units.quantity.Quantity`
Flux of Vega at ``wav``.
Returns
... | [
"Flux",
"equivalencies",
"between",
"PHOTLAM",
"and",
"VEGAMAG",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L64-L99 | train |
spacetelescope/synphot_refactor | synphot/units.py | spectral_density_count | def spectral_density_count(wav, area):
"""Flux equivalencies between PHOTLAM and count/OBMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
area : `~astropy.units.quantity.Quantity`
... | python | def spectral_density_count(wav, area):
"""Flux equivalencies between PHOTLAM and count/OBMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
area : `~astropy.units.quantity.Quantity`
... | [
"def",
"spectral_density_count",
"(",
"wav",
",",
"area",
")",
":",
"from",
".",
"binning",
"import",
"calculate_bin_widths",
",",
"calculate_bin_edges",
"wav",
"=",
"wav",
".",
"to",
"(",
"u",
".",
"AA",
",",
"equivalencies",
"=",
"u",
".",
"spectral",
"(... | Flux equivalencies between PHOTLAM and count/OBMAG.
Parameters
----------
wav : `~astropy.units.quantity.Quantity`
Quantity associated with values being converted
(e.g., wavelength or frequency).
area : `~astropy.units.quantity.Quantity`
Telescope collecting area.
Returns
... | [
"Flux",
"equivalencies",
"between",
"PHOTLAM",
"and",
"count",
"/",
"OBMAG",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L102-L140 | train |
spacetelescope/synphot_refactor | synphot/units.py | convert_flux | def convert_flux(wavelengths, fluxes, out_flux_unit, **kwargs):
"""Perform conversion for :ref:`supported flux units <synphot-flux-units>`.
Parameters
----------
wavelengths : array-like or `~astropy.units.quantity.Quantity`
Wavelength values. If not a Quantity, assumed to be in
Angstro... | python | def convert_flux(wavelengths, fluxes, out_flux_unit, **kwargs):
"""Perform conversion for :ref:`supported flux units <synphot-flux-units>`.
Parameters
----------
wavelengths : array-like or `~astropy.units.quantity.Quantity`
Wavelength values. If not a Quantity, assumed to be in
Angstro... | [
"def",
"convert_flux",
"(",
"wavelengths",
",",
"fluxes",
",",
"out_flux_unit",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"fluxes",
",",
"u",
".",
"Quantity",
")",
":",
"fluxes",
"=",
"fluxes",
"*",
"PHOTLAM",
"out_flux_unit",
"=... | Perform conversion for :ref:`supported flux units <synphot-flux-units>`.
Parameters
----------
wavelengths : array-like or `~astropy.units.quantity.Quantity`
Wavelength values. If not a Quantity, assumed to be in
Angstrom.
fluxes : array-like or `~astropy.units.quantity.Quantity`
... | [
"Perform",
"conversion",
"for",
":",
"ref",
":",
"supported",
"flux",
"units",
"<synphot",
"-",
"flux",
"-",
"units",
">",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L143-L225 | train |
spacetelescope/synphot_refactor | synphot/units.py | _convert_flux | def _convert_flux(wavelengths, fluxes, out_flux_unit, area=None,
vegaspec=None):
"""Flux conversion for PHOTLAM <-> X."""
flux_unit_names = (fluxes.unit.to_string(), out_flux_unit.to_string())
if PHOTLAM.to_string() not in flux_unit_names:
raise exceptions.SynphotError(
... | python | def _convert_flux(wavelengths, fluxes, out_flux_unit, area=None,
vegaspec=None):
"""Flux conversion for PHOTLAM <-> X."""
flux_unit_names = (fluxes.unit.to_string(), out_flux_unit.to_string())
if PHOTLAM.to_string() not in flux_unit_names:
raise exceptions.SynphotError(
... | [
"def",
"_convert_flux",
"(",
"wavelengths",
",",
"fluxes",
",",
"out_flux_unit",
",",
"area",
"=",
"None",
",",
"vegaspec",
"=",
"None",
")",
":",
"flux_unit_names",
"=",
"(",
"fluxes",
".",
"unit",
".",
"to_string",
"(",
")",
",",
"out_flux_unit",
".",
... | Flux conversion for PHOTLAM <-> X. | [
"Flux",
"conversion",
"for",
"PHOTLAM",
"<",
"-",
">",
"X",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L228-L268 | train |
spacetelescope/synphot_refactor | synphot/units.py | validate_unit | def validate_unit(input_unit):
"""Validate unit.
To be compatible with existing SYNPHOT data files:
* 'angstroms' and 'inversemicrons' are accepted although
unrecognized by astropy units
* 'transmission', 'extinction', and 'emissivity' are
converted to astropy dimensionless... | python | def validate_unit(input_unit):
"""Validate unit.
To be compatible with existing SYNPHOT data files:
* 'angstroms' and 'inversemicrons' are accepted although
unrecognized by astropy units
* 'transmission', 'extinction', and 'emissivity' are
converted to astropy dimensionless... | [
"def",
"validate_unit",
"(",
"input_unit",
")",
":",
"if",
"isinstance",
"(",
"input_unit",
",",
"str",
")",
":",
"input_unit_lowcase",
"=",
"input_unit",
".",
"lower",
"(",
")",
"# Backward-compatibility",
"if",
"input_unit_lowcase",
"==",
"'angstroms'",
":",
"... | Validate unit.
To be compatible with existing SYNPHOT data files:
* 'angstroms' and 'inversemicrons' are accepted although
unrecognized by astropy units
* 'transmission', 'extinction', and 'emissivity' are
converted to astropy dimensionless unit
Parameters
----------
... | [
"Validate",
"unit",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L275-L335 | train |
spacetelescope/synphot_refactor | synphot/units.py | validate_wave_unit | def validate_wave_unit(wave_unit):
"""Like :func:`validate_unit` but specific to wavelength."""
output_unit = validate_unit(wave_unit)
unit_type = output_unit.physical_type
if unit_type not in ('length', 'wavenumber', 'frequency'):
raise exceptions.SynphotError(
'wavelength physical... | python | def validate_wave_unit(wave_unit):
"""Like :func:`validate_unit` but specific to wavelength."""
output_unit = validate_unit(wave_unit)
unit_type = output_unit.physical_type
if unit_type not in ('length', 'wavenumber', 'frequency'):
raise exceptions.SynphotError(
'wavelength physical... | [
"def",
"validate_wave_unit",
"(",
"wave_unit",
")",
":",
"output_unit",
"=",
"validate_unit",
"(",
"wave_unit",
")",
"unit_type",
"=",
"output_unit",
".",
"physical_type",
"if",
"unit_type",
"not",
"in",
"(",
"'length'",
",",
"'wavenumber'",
",",
"'frequency'",
... | Like :func:`validate_unit` but specific to wavelength. | [
"Like",
":",
"func",
":",
"validate_unit",
"but",
"specific",
"to",
"wavelength",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L338-L348 | train |
spacetelescope/synphot_refactor | synphot/units.py | validate_quantity | def validate_quantity(input_value, output_unit, equivalencies=[]):
"""Validate quantity (value and unit).
.. note::
For flux conversion, use :func:`convert_flux` instead.
Parameters
----------
input_value : number, array-like, or `~astropy.units.quantity.Quantity`
Quantity to vali... | python | def validate_quantity(input_value, output_unit, equivalencies=[]):
"""Validate quantity (value and unit).
.. note::
For flux conversion, use :func:`convert_flux` instead.
Parameters
----------
input_value : number, array-like, or `~astropy.units.quantity.Quantity`
Quantity to vali... | [
"def",
"validate_quantity",
"(",
"input_value",
",",
"output_unit",
",",
"equivalencies",
"=",
"[",
"]",
")",
":",
"output_unit",
"=",
"validate_unit",
"(",
"output_unit",
")",
"if",
"isinstance",
"(",
"input_value",
",",
"u",
".",
"Quantity",
")",
":",
"out... | Validate quantity (value and unit).
.. note::
For flux conversion, use :func:`convert_flux` instead.
Parameters
----------
input_value : number, array-like, or `~astropy.units.quantity.Quantity`
Quantity to validate. If not a Quantity, assumed to be
already in output unit.
... | [
"Validate",
"quantity",
"(",
"value",
"and",
"unit",
")",
"."
] | 9c064f3cff0c41dd8acadc0f67c6350931275b9f | https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/units.py#L351-L383 | train |
Julius2342/pyvlx | old_api/pyvlx/devices.py | Devices.add | def add(self, device):
"""Add device."""
if not isinstance(device, Device):
raise TypeError()
self.__devices.append(device) | python | def add(self, device):
"""Add device."""
if not isinstance(device, Device):
raise TypeError()
self.__devices.append(device) | [
"def",
"add",
"(",
"self",
",",
"device",
")",
":",
"if",
"not",
"isinstance",
"(",
"device",
",",
"Device",
")",
":",
"raise",
"TypeError",
"(",
")",
"self",
".",
"__devices",
".",
"append",
"(",
"device",
")"
] | Add device. | [
"Add",
"device",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/devices.py#L36-L40 | train |
Julius2342/pyvlx | old_api/pyvlx/devices.py | Devices.data_import | def data_import(self, json_response):
"""Import data from json response."""
if 'data' not in json_response:
raise PyVLXException('no element data found: {0}'.format(
json.dumps(json_response)))
data = json_response['data']
for item in data:
if 'ca... | python | def data_import(self, json_response):
"""Import data from json response."""
if 'data' not in json_response:
raise PyVLXException('no element data found: {0}'.format(
json.dumps(json_response)))
data = json_response['data']
for item in data:
if 'ca... | [
"def",
"data_import",
"(",
"self",
",",
"json_response",
")",
":",
"if",
"'data'",
"not",
"in",
"json_response",
":",
"raise",
"PyVLXException",
"(",
"'no element data found: {0}'",
".",
"format",
"(",
"json",
".",
"dumps",
"(",
"json_response",
")",
")",
")",... | Import data from json response. | [
"Import",
"data",
"from",
"json",
"response",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/devices.py#L47-L67 | train |
Julius2342/pyvlx | old_api/pyvlx/devices.py | Devices.load_window_opener | def load_window_opener(self, item):
"""Load window opener from JSON."""
window = Window.from_config(self.pyvlx, item)
self.add(window) | python | def load_window_opener(self, item):
"""Load window opener from JSON."""
window = Window.from_config(self.pyvlx, item)
self.add(window) | [
"def",
"load_window_opener",
"(",
"self",
",",
"item",
")",
":",
"window",
"=",
"Window",
".",
"from_config",
"(",
"self",
".",
"pyvlx",
",",
"item",
")",
"self",
".",
"add",
"(",
"window",
")"
] | Load window opener from JSON. | [
"Load",
"window",
"opener",
"from",
"JSON",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/devices.py#L69-L72 | train |
Julius2342/pyvlx | old_api/pyvlx/devices.py | Devices.load_roller_shutter | def load_roller_shutter(self, item):
"""Load roller shutter from JSON."""
rollershutter = RollerShutter.from_config(self.pyvlx, item)
self.add(rollershutter) | python | def load_roller_shutter(self, item):
"""Load roller shutter from JSON."""
rollershutter = RollerShutter.from_config(self.pyvlx, item)
self.add(rollershutter) | [
"def",
"load_roller_shutter",
"(",
"self",
",",
"item",
")",
":",
"rollershutter",
"=",
"RollerShutter",
".",
"from_config",
"(",
"self",
".",
"pyvlx",
",",
"item",
")",
"self",
".",
"add",
"(",
"rollershutter",
")"
] | Load roller shutter from JSON. | [
"Load",
"roller",
"shutter",
"from",
"JSON",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/devices.py#L74-L77 | train |
Julius2342/pyvlx | old_api/pyvlx/devices.py | Devices.load_blind | def load_blind(self, item):
"""Load blind from JSON."""
blind = Blind.from_config(self.pyvlx, item)
self.add(blind) | python | def load_blind(self, item):
"""Load blind from JSON."""
blind = Blind.from_config(self.pyvlx, item)
self.add(blind) | [
"def",
"load_blind",
"(",
"self",
",",
"item",
")",
":",
"blind",
"=",
"Blind",
".",
"from_config",
"(",
"self",
".",
"pyvlx",
",",
"item",
")",
"self",
".",
"add",
"(",
"blind",
")"
] | Load blind from JSON. | [
"Load",
"blind",
"from",
"JSON",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/devices.py#L79-L82 | train |
cs50/style50 | style50/_api.py | get_terminal_size | def get_terminal_size(fallback=(80, 24)):
"""
Return tuple containing columns and rows of controlling terminal, trying harder
than shutil.get_terminal_size to find a tty before returning fallback.
Theoretically, stdout, stderr, and stdin could all be different ttys that could
cause us to get the wr... | python | def get_terminal_size(fallback=(80, 24)):
"""
Return tuple containing columns and rows of controlling terminal, trying harder
than shutil.get_terminal_size to find a tty before returning fallback.
Theoretically, stdout, stderr, and stdin could all be different ttys that could
cause us to get the wr... | [
"def",
"get_terminal_size",
"(",
"fallback",
"=",
"(",
"80",
",",
"24",
")",
")",
":",
"for",
"stream",
"in",
"[",
"sys",
".",
"__stdout__",
",",
"sys",
".",
"__stderr__",
",",
"sys",
".",
"__stdin__",
"]",
":",
"try",
":",
"# Make WINSIZE call to termin... | Return tuple containing columns and rows of controlling terminal, trying harder
than shutil.get_terminal_size to find a tty before returning fallback.
Theoretically, stdout, stderr, and stdin could all be different ttys that could
cause us to get the wrong measurements (instead of using the fallback) but t... | [
"Return",
"tuple",
"containing",
"columns",
"and",
"rows",
"of",
"controlling",
"terminal",
"trying",
"harder",
"than",
"shutil",
".",
"get_terminal_size",
"to",
"find",
"a",
"tty",
"before",
"returning",
"fallback",
"."
] | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L23-L45 | train |
cs50/style50 | style50/_api.py | Style50.run_diff | def run_diff(self):
"""
Run checks on self.files, printing diff of styled/unstyled output to stdout.
"""
files = tuple(self.files)
# Use same header as more.
header, footer = (termcolor.colored("{0}\n{{}}\n{0}\n".format(
":" * 14), "cyan"), "\n") if len(files)... | python | def run_diff(self):
"""
Run checks on self.files, printing diff of styled/unstyled output to stdout.
"""
files = tuple(self.files)
# Use same header as more.
header, footer = (termcolor.colored("{0}\n{{}}\n{0}\n".format(
":" * 14), "cyan"), "\n") if len(files)... | [
"def",
"run_diff",
"(",
"self",
")",
":",
"files",
"=",
"tuple",
"(",
"self",
".",
"files",
")",
"# Use same header as more.",
"header",
",",
"footer",
"=",
"(",
"termcolor",
".",
"colored",
"(",
"\"{0}\\n{{}}\\n{0}\\n\"",
".",
"format",
"(",
"\":\"",
"*",
... | Run checks on self.files, printing diff of styled/unstyled output to stdout. | [
"Run",
"checks",
"on",
"self",
".",
"files",
"printing",
"diff",
"of",
"styled",
"/",
"unstyled",
"output",
"to",
"stdout",
"."
] | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L96-L134 | train |
cs50/style50 | style50/_api.py | Style50.run_json | def run_json(self):
"""
Run checks on self.files, printing json object
containing information relavent to the CS50 IDE plugin at the end.
"""
checks = {}
for file in self.files:
try:
results = self._check(file)
except Error as e:
... | python | def run_json(self):
"""
Run checks on self.files, printing json object
containing information relavent to the CS50 IDE plugin at the end.
"""
checks = {}
for file in self.files:
try:
results = self._check(file)
except Error as e:
... | [
"def",
"run_json",
"(",
"self",
")",
":",
"checks",
"=",
"{",
"}",
"for",
"file",
"in",
"self",
".",
"files",
":",
"try",
":",
"results",
"=",
"self",
".",
"_check",
"(",
"file",
")",
"except",
"Error",
"as",
"e",
":",
"checks",
"[",
"file",
"]",... | Run checks on self.files, printing json object
containing information relavent to the CS50 IDE plugin at the end. | [
"Run",
"checks",
"on",
"self",
".",
"files",
"printing",
"json",
"object",
"containing",
"information",
"relavent",
"to",
"the",
"CS50",
"IDE",
"plugin",
"at",
"the",
"end",
"."
] | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L136-L157 | train |
cs50/style50 | style50/_api.py | Style50.run_score | def run_score(self):
"""
Run checks on self.files, printing raw percentage to stdout.
"""
diffs = 0
lines = 0
for file in self.files:
try:
results = self._check(file)
except Error as e:
termcolor.cprint(e.msg, "yell... | python | def run_score(self):
"""
Run checks on self.files, printing raw percentage to stdout.
"""
diffs = 0
lines = 0
for file in self.files:
try:
results = self._check(file)
except Error as e:
termcolor.cprint(e.msg, "yell... | [
"def",
"run_score",
"(",
"self",
")",
":",
"diffs",
"=",
"0",
"lines",
"=",
"0",
"for",
"file",
"in",
"self",
".",
"files",
":",
"try",
":",
"results",
"=",
"self",
".",
"_check",
"(",
"file",
")",
"except",
"Error",
"as",
"e",
":",
"termcolor",
... | Run checks on self.files, printing raw percentage to stdout. | [
"Run",
"checks",
"on",
"self",
".",
"files",
"printing",
"raw",
"percentage",
"to",
"stdout",
"."
] | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L159-L179 | train |
cs50/style50 | style50/_api.py | Style50._check | def _check(self, file):
"""
Run apropriate check based on `file`'s extension and return it,
otherwise raise an Error
"""
if not os.path.exists(file):
raise Error("file \"{}\" not found".format(file))
_, extension = os.path.splitext(file)
try:
... | python | def _check(self, file):
"""
Run apropriate check based on `file`'s extension and return it,
otherwise raise an Error
"""
if not os.path.exists(file):
raise Error("file \"{}\" not found".format(file))
_, extension = os.path.splitext(file)
try:
... | [
"def",
"_check",
"(",
"self",
",",
"file",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"file",
")",
":",
"raise",
"Error",
"(",
"\"file \\\"{}\\\" not found\"",
".",
"format",
"(",
"file",
")",
")",
"_",
",",
"extension",
"=",
"os",... | Run apropriate check based on `file`'s extension and return it,
otherwise raise an Error | [
"Run",
"apropriate",
"check",
"based",
"on",
"file",
"s",
"extension",
"and",
"return",
"it",
"otherwise",
"raise",
"an",
"Error"
] | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L181-L215 | train |
cs50/style50 | style50/_api.py | Style50.split_diff | def split_diff(old, new):
"""
Returns a generator yielding the side-by-side diff of `old` and `new`).
"""
return map(lambda l: l.rstrip(),
icdiff.ConsoleDiff(cols=COLUMNS).make_table(old.splitlines(), new.splitlines())) | python | def split_diff(old, new):
"""
Returns a generator yielding the side-by-side diff of `old` and `new`).
"""
return map(lambda l: l.rstrip(),
icdiff.ConsoleDiff(cols=COLUMNS).make_table(old.splitlines(), new.splitlines())) | [
"def",
"split_diff",
"(",
"old",
",",
"new",
")",
":",
"return",
"map",
"(",
"lambda",
"l",
":",
"l",
".",
"rstrip",
"(",
")",
",",
"icdiff",
".",
"ConsoleDiff",
"(",
"cols",
"=",
"COLUMNS",
")",
".",
"make_table",
"(",
"old",
".",
"splitlines",
"(... | Returns a generator yielding the side-by-side diff of `old` and `new`). | [
"Returns",
"a",
"generator",
"yielding",
"the",
"side",
"-",
"by",
"-",
"side",
"diff",
"of",
"old",
"and",
"new",
")",
"."
] | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L218-L223 | train |
cs50/style50 | style50/_api.py | Style50.unified | def unified(old, new):
"""
Returns a generator yielding a unified diff between `old` and `new`.
"""
for diff in difflib.ndiff(old.splitlines(), new.splitlines()):
if diff[0] == " ":
yield diff
elif diff[0] == "?":
continue
... | python | def unified(old, new):
"""
Returns a generator yielding a unified diff between `old` and `new`.
"""
for diff in difflib.ndiff(old.splitlines(), new.splitlines()):
if diff[0] == " ":
yield diff
elif diff[0] == "?":
continue
... | [
"def",
"unified",
"(",
"old",
",",
"new",
")",
":",
"for",
"diff",
"in",
"difflib",
".",
"ndiff",
"(",
"old",
".",
"splitlines",
"(",
")",
",",
"new",
".",
"splitlines",
"(",
")",
")",
":",
"if",
"diff",
"[",
"0",
"]",
"==",
"\" \"",
":",
"yiel... | Returns a generator yielding a unified diff between `old` and `new`. | [
"Returns",
"a",
"generator",
"yielding",
"a",
"unified",
"diff",
"between",
"old",
"and",
"new",
"."
] | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L226-L236 | train |
cs50/style50 | style50/_api.py | Style50.html_diff | def html_diff(self, old, new):
"""
Return HTML formatted character-based diff between old and new (used for CS50 IDE).
"""
def html_transition(old_type, new_type):
tags = []
for tag in [("/", old_type), ("", new_type)]:
if tag[1] not in ["+", "-"]:... | python | def html_diff(self, old, new):
"""
Return HTML formatted character-based diff between old and new (used for CS50 IDE).
"""
def html_transition(old_type, new_type):
tags = []
for tag in [("/", old_type), ("", new_type)]:
if tag[1] not in ["+", "-"]:... | [
"def",
"html_diff",
"(",
"self",
",",
"old",
",",
"new",
")",
":",
"def",
"html_transition",
"(",
"old_type",
",",
"new_type",
")",
":",
"tags",
"=",
"[",
"]",
"for",
"tag",
"in",
"[",
"(",
"\"/\"",
",",
"old_type",
")",
",",
"(",
"\"\"",
",",
"n... | Return HTML formatted character-based diff between old and new (used for CS50 IDE). | [
"Return",
"HTML",
"formatted",
"character",
"-",
"based",
"diff",
"between",
"old",
"and",
"new",
"(",
"used",
"for",
"CS50",
"IDE",
")",
"."
] | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L238-L250 | train |
cs50/style50 | style50/_api.py | Style50.char_diff | def char_diff(self, old, new):
"""
Return color-coded character-based diff between `old` and `new`.
"""
def color_transition(old_type, new_type):
new_color = termcolor.colored("", None, "on_red" if new_type ==
"-" else "on_green" if n... | python | def char_diff(self, old, new):
"""
Return color-coded character-based diff between `old` and `new`.
"""
def color_transition(old_type, new_type):
new_color = termcolor.colored("", None, "on_red" if new_type ==
"-" else "on_green" if n... | [
"def",
"char_diff",
"(",
"self",
",",
"old",
",",
"new",
")",
":",
"def",
"color_transition",
"(",
"old_type",
",",
"new_type",
")",
":",
"new_color",
"=",
"termcolor",
".",
"colored",
"(",
"\"\"",
",",
"None",
",",
"\"on_red\"",
"if",
"new_type",
"==",
... | Return color-coded character-based diff between `old` and `new`. | [
"Return",
"color",
"-",
"coded",
"character",
"-",
"based",
"diff",
"between",
"old",
"and",
"new",
"."
] | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L252-L261 | train |
cs50/style50 | style50/_api.py | Style50._char_diff | def _char_diff(self, old, new, transition, fmt=lambda c: c):
"""
Returns a char-based diff between `old` and `new` where each character
is formatted by `fmt` and transitions between blocks are determined by `transition`.
"""
differ = difflib.ndiff(old, new)
# Type of di... | python | def _char_diff(self, old, new, transition, fmt=lambda c: c):
"""
Returns a char-based diff between `old` and `new` where each character
is formatted by `fmt` and transitions between blocks are determined by `transition`.
"""
differ = difflib.ndiff(old, new)
# Type of di... | [
"def",
"_char_diff",
"(",
"self",
",",
"old",
",",
"new",
",",
"transition",
",",
"fmt",
"=",
"lambda",
"c",
":",
"c",
")",
":",
"differ",
"=",
"difflib",
".",
"ndiff",
"(",
"old",
",",
"new",
")",
"# Type of difference.",
"dtype",
"=",
"None",
"# Bu... | Returns a char-based diff between `old` and `new` where each character
is formatted by `fmt` and transitions between blocks are determined by `transition`. | [
"Returns",
"a",
"char",
"-",
"based",
"diff",
"between",
"old",
"and",
"new",
"where",
"each",
"character",
"is",
"formatted",
"by",
"fmt",
"and",
"transitions",
"between",
"blocks",
"are",
"determined",
"by",
"transition",
"."
] | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L263-L309 | train |
cs50/style50 | style50/_api.py | StyleCheck.count_lines | def count_lines(self, code):
"""
Count lines of code (by default ignores empty lines, but child could override to do more).
"""
return sum(bool(line.strip()) for line in code.splitlines()) | python | def count_lines(self, code):
"""
Count lines of code (by default ignores empty lines, but child could override to do more).
"""
return sum(bool(line.strip()) for line in code.splitlines()) | [
"def",
"count_lines",
"(",
"self",
",",
"code",
")",
":",
"return",
"sum",
"(",
"bool",
"(",
"line",
".",
"strip",
"(",
")",
")",
"for",
"line",
"in",
"code",
".",
"splitlines",
"(",
")",
")"
] | Count lines of code (by default ignores empty lines, but child could override to do more). | [
"Count",
"lines",
"of",
"code",
"(",
"by",
"default",
"ignores",
"empty",
"lines",
"but",
"child",
"could",
"override",
"to",
"do",
"more",
")",
"."
] | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L366-L370 | train |
cs50/style50 | style50/_api.py | StyleCheck.run | def run(command, input=None, exit=0, shell=False):
"""
Run `command` passing it stdin from `input`, throwing a DependencyError if comand is not found.
Throws Error if exit code of command is not `exit` (unless `exit` is None).
"""
if isinstance(input, str):
input = in... | python | def run(command, input=None, exit=0, shell=False):
"""
Run `command` passing it stdin from `input`, throwing a DependencyError if comand is not found.
Throws Error if exit code of command is not `exit` (unless `exit` is None).
"""
if isinstance(input, str):
input = in... | [
"def",
"run",
"(",
"command",
",",
"input",
"=",
"None",
",",
"exit",
"=",
"0",
",",
"shell",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"input",
",",
"str",
")",
":",
"input",
"=",
"input",
".",
"encode",
"(",
")",
"# Only pipe stdin if we hav... | Run `command` passing it stdin from `input`, throwing a DependencyError if comand is not found.
Throws Error if exit code of command is not `exit` (unless `exit` is None). | [
"Run",
"command",
"passing",
"it",
"stdin",
"from",
"input",
"throwing",
"a",
"DependencyError",
"if",
"comand",
"is",
"not",
"found",
".",
"Throws",
"Error",
"if",
"exit",
"code",
"of",
"command",
"is",
"not",
"exit",
"(",
"unless",
"exit",
"is",
"None",
... | 2dfe5957f7b727ee5163499e7b8191275aee914c | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L373-L394 | train |
Julius2342/pyvlx | pyvlx/frame_creation.py | frame_from_raw | def frame_from_raw(raw):
"""Create and return frame from raw bytes."""
command, payload = extract_from_frame(raw)
frame = create_frame(command)
if frame is None:
PYVLXLOG.warning("Command %s not implemented, raw: %s", command, ":".join("{:02x}".format(c) for c in raw))
return None
fr... | python | def frame_from_raw(raw):
"""Create and return frame from raw bytes."""
command, payload = extract_from_frame(raw)
frame = create_frame(command)
if frame is None:
PYVLXLOG.warning("Command %s not implemented, raw: %s", command, ":".join("{:02x}".format(c) for c in raw))
return None
fr... | [
"def",
"frame_from_raw",
"(",
"raw",
")",
":",
"command",
",",
"payload",
"=",
"extract_from_frame",
"(",
"raw",
")",
"frame",
"=",
"create_frame",
"(",
"command",
")",
"if",
"frame",
"is",
"None",
":",
"PYVLXLOG",
".",
"warning",
"(",
"\"Command %s not impl... | Create and return frame from raw bytes. | [
"Create",
"and",
"return",
"frame",
"from",
"raw",
"bytes",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frame_creation.py#L32-L41 | train |
Julius2342/pyvlx | pyvlx/frame_creation.py | create_frame | def create_frame(command):
"""Create and return empty Frame from Command."""
# pylint: disable=too-many-branches,too-many-return-statements
if command == Command.GW_ERROR_NTF:
return FrameErrorNotification()
if command == Command.GW_COMMAND_SEND_REQ:
return FrameCommandSendRequest()
... | python | def create_frame(command):
"""Create and return empty Frame from Command."""
# pylint: disable=too-many-branches,too-many-return-statements
if command == Command.GW_ERROR_NTF:
return FrameErrorNotification()
if command == Command.GW_COMMAND_SEND_REQ:
return FrameCommandSendRequest()
... | [
"def",
"create_frame",
"(",
"command",
")",
":",
"# pylint: disable=too-many-branches,too-many-return-statements",
"if",
"command",
"==",
"Command",
".",
"GW_ERROR_NTF",
":",
"return",
"FrameErrorNotification",
"(",
")",
"if",
"command",
"==",
"Command",
".",
"GW_COMMAN... | Create and return empty Frame from Command. | [
"Create",
"and",
"return",
"empty",
"Frame",
"from",
"Command",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frame_creation.py#L44-L142 | train |
Julius2342/pyvlx | pyvlx/login.py | Login.handle_frame | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FramePasswordEnterConfirmation):
return False
if frame.status == PasswordEnterConfirmationStatus.FAILED:
PYVLXLOG.warning('Failed to ... | python | async def handle_frame(self, frame):
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FramePasswordEnterConfirmation):
return False
if frame.status == PasswordEnterConfirmationStatus.FAILED:
PYVLXLOG.warning('Failed to ... | [
"async",
"def",
"handle_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"isinstance",
"(",
"frame",
",",
"FramePasswordEnterConfirmation",
")",
":",
"return",
"False",
"if",
"frame",
".",
"status",
"==",
"PasswordEnterConfirmationStatus",
".",
"FAILED"... | Handle incoming API frame, return True if this was the expected frame. | [
"Handle",
"incoming",
"API",
"frame",
"return",
"True",
"if",
"this",
"was",
"the",
"expected",
"frame",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/login.py#L18-L27 | train |
Julius2342/pyvlx | pyvlx/frames/frame_get_protocol_version.py | FrameGetProtocolVersionConfirmation.get_payload | def get_payload(self):
"""Return Payload."""
return bytes(
[self.major_version >> 8 & 255, self.major_version & 255,
self.minor_version >> 8 & 255, self.minor_version & 255]) | python | def get_payload(self):
"""Return Payload."""
return bytes(
[self.major_version >> 8 & 255, self.major_version & 255,
self.minor_version >> 8 & 255, self.minor_version & 255]) | [
"def",
"get_payload",
"(",
"self",
")",
":",
"return",
"bytes",
"(",
"[",
"self",
".",
"major_version",
">>",
"8",
"&",
"255",
",",
"self",
".",
"major_version",
"&",
"255",
",",
"self",
".",
"minor_version",
">>",
"8",
"&",
"255",
",",
"self",
".",
... | Return Payload. | [
"Return",
"Payload",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_protocol_version.py#L33-L37 | train |
Julius2342/pyvlx | pyvlx/frames/frame_get_protocol_version.py | FrameGetProtocolVersionConfirmation.from_payload | def from_payload(self, payload):
"""Init frame from binary data."""
self.major_version = payload[0] * 256 + payload[1]
self.minor_version = payload[2] * 256 + payload[3] | python | def from_payload(self, payload):
"""Init frame from binary data."""
self.major_version = payload[0] * 256 + payload[1]
self.minor_version = payload[2] * 256 + payload[3] | [
"def",
"from_payload",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"major_version",
"=",
"payload",
"[",
"0",
"]",
"*",
"256",
"+",
"payload",
"[",
"1",
"]",
"self",
".",
"minor_version",
"=",
"payload",
"[",
"2",
"]",
"*",
"256",
"+",
"pay... | Init frame from binary data. | [
"Init",
"frame",
"from",
"binary",
"data",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_protocol_version.py#L39-L42 | train |
Julius2342/pyvlx | pyvlx/connection.py | TCPTransport.data_received | def data_received(self, data):
"""Handle data received."""
self.tokenizer.feed(data)
while self.tokenizer.has_tokens():
raw = self.tokenizer.get_next_token()
frame = frame_from_raw(raw)
if frame is not None:
self.frame_received_cb(frame) | python | def data_received(self, data):
"""Handle data received."""
self.tokenizer.feed(data)
while self.tokenizer.has_tokens():
raw = self.tokenizer.get_next_token()
frame = frame_from_raw(raw)
if frame is not None:
self.frame_received_cb(frame) | [
"def",
"data_received",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"tokenizer",
".",
"feed",
"(",
"data",
")",
"while",
"self",
".",
"tokenizer",
".",
"has_tokens",
"(",
")",
":",
"raw",
"=",
"self",
".",
"tokenizer",
".",
"get_next_token",
"(",
... | Handle data received. | [
"Handle",
"data",
"received",
"."
] | ee78e1324bcb1be5b8d1a9d05ab5496b72eae848 | https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/connection.py#L47-L54 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.