partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | R.gauge | Set the value for a Gauge.
* ``slug`` -- the unique identifier (or key) for the Gauge
* ``current_value`` -- the value that the gauge should display | redis_metrics/models.py | def gauge(self, slug, current_value):
"""Set the value for a Gauge.
* ``slug`` -- the unique identifier (or key) for the Gauge
* ``current_value`` -- the value that the gauge should display
"""
k = self._gauge_key(slug)
self.r.sadd(self._gauge_slugs_key, slug) # keep t... | def gauge(self, slug, current_value):
"""Set the value for a Gauge.
* ``slug`` -- the unique identifier (or key) for the Gauge
* ``current_value`` -- the value that the gauge should display
"""
k = self._gauge_key(slug)
self.r.sadd(self._gauge_slugs_key, slug) # keep t... | [
"Set",
"the",
"value",
"for",
"a",
"Gauge",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L605-L614 | [
"def",
"gauge",
"(",
"self",
",",
"slug",
",",
"current_value",
")",
":",
"k",
"=",
"self",
".",
"_gauge_key",
"(",
"slug",
")",
"self",
".",
"r",
".",
"sadd",
"(",
"self",
".",
"_gauge_slugs_key",
",",
"slug",
")",
"# keep track of all Gauges",
"self",
... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | R.delete_gauge | Removes all gauges with the given ``slug``. | redis_metrics/models.py | def delete_gauge(self, slug):
"""Removes all gauges with the given ``slug``."""
key = self._gauge_key(slug)
self.r.delete(key) # Remove the Gauge
self.r.srem(self._gauge_slugs_key, slug) | def delete_gauge(self, slug):
"""Removes all gauges with the given ``slug``."""
key = self._gauge_key(slug)
self.r.delete(key) # Remove the Gauge
self.r.srem(self._gauge_slugs_key, slug) | [
"Removes",
"all",
"gauges",
"with",
"the",
"given",
"slug",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/models.py#L620-L624 | [
"def",
"delete_gauge",
"(",
"self",
",",
"slug",
")",
":",
"key",
"=",
"self",
".",
"_gauge_key",
"(",
"slug",
")",
"self",
".",
"r",
".",
"delete",
"(",
"key",
")",
"# Remove the Gauge",
"self",
".",
"r",
".",
"srem",
"(",
"self",
".",
"_gauge_slugs... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | metrics_since | Renders a template with a menu to view a metric (or metrics) for a
given number of years.
* ``slugs`` -- A Slug or a set/list of slugs
* ``years`` -- Number of years to show past metrics
* ``link_type`` -- What type of chart do we want ("history" or "aggregate")
* history -- use when displayin... | redis_metrics/templatetags/redis_metric_tags.py | def metrics_since(slugs, years, link_type="detail", granularity=None):
"""Renders a template with a menu to view a metric (or metrics) for a
given number of years.
* ``slugs`` -- A Slug or a set/list of slugs
* ``years`` -- Number of years to show past metrics
* ``link_type`` -- What type of chart ... | def metrics_since(slugs, years, link_type="detail", granularity=None):
"""Renders a template with a menu to view a metric (or metrics) for a
given number of years.
* ``slugs`` -- A Slug or a set/list of slugs
* ``years`` -- Number of years to show past metrics
* ``link_type`` -- What type of chart ... | [
"Renders",
"a",
"template",
"with",
"a",
"menu",
"to",
"view",
"a",
"metric",
"(",
"or",
"metrics",
")",
"for",
"a",
"given",
"number",
"of",
"years",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L12-L49 | [
"def",
"metrics_since",
"(",
"slugs",
",",
"years",
",",
"link_type",
"=",
"\"detail\"",
",",
"granularity",
"=",
"None",
")",
":",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"# Determine if we're looking at one slug or multiple slugs",
"if",
"type",
"(",
... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | gauge | Include a Donut Chart for the specified Gauge.
* ``slug`` -- the unique slug for the Gauge.
* ``maximum`` -- The maximum value for the gauge (default is 9000)
* ``size`` -- The size (in pixels) of the gauge (default is 200)
* ``coerce`` -- type to which gauge values should be coerced. The default
... | redis_metrics/templatetags/redis_metric_tags.py | def gauge(slug, maximum=9000, size=200, coerce='float'):
"""Include a Donut Chart for the specified Gauge.
* ``slug`` -- the unique slug for the Gauge.
* ``maximum`` -- The maximum value for the gauge (default is 9000)
* ``size`` -- The size (in pixels) of the gauge (default is 200)
* ``coerce`` --... | def gauge(slug, maximum=9000, size=200, coerce='float'):
"""Include a Donut Chart for the specified Gauge.
* ``slug`` -- the unique slug for the Gauge.
* ``maximum`` -- The maximum value for the gauge (default is 9000)
* ``size`` -- The size (in pixels) of the gauge (default is 200)
* ``coerce`` --... | [
"Include",
"a",
"Donut",
"Chart",
"for",
"the",
"specified",
"Gauge",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L53-L81 | [
"def",
"gauge",
"(",
"slug",
",",
"maximum",
"=",
"9000",
",",
"size",
"=",
"200",
",",
"coerce",
"=",
"'float'",
")",
":",
"coerce_options",
"=",
"{",
"'float'",
":",
"float",
",",
"'int'",
":",
"int",
",",
"'str'",
":",
"str",
"}",
"coerce",
"=",... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | metric_detail | Template Tag to display a metric's *current* detail.
* ``slug`` -- the metric's unique slug
* ``with_data_table`` -- if True, prints the raw data in a table. | redis_metrics/templatetags/redis_metric_tags.py | def metric_detail(slug, with_data_table=False):
"""Template Tag to display a metric's *current* detail.
* ``slug`` -- the metric's unique slug
* ``with_data_table`` -- if True, prints the raw data in a table.
"""
r = get_r()
granularities = list(r._granularities())
metrics = r.get_metric(s... | def metric_detail(slug, with_data_table=False):
"""Template Tag to display a metric's *current* detail.
* ``slug`` -- the metric's unique slug
* ``with_data_table`` -- if True, prints the raw data in a table.
"""
r = get_r()
granularities = list(r._granularities())
metrics = r.get_metric(s... | [
"Template",
"Tag",
"to",
"display",
"a",
"metric",
"s",
"*",
"current",
"*",
"detail",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L93-L112 | [
"def",
"metric_detail",
"(",
"slug",
",",
"with_data_table",
"=",
"False",
")",
":",
"r",
"=",
"get_r",
"(",
")",
"granularities",
"=",
"list",
"(",
"r",
".",
"_granularities",
"(",
")",
")",
"metrics",
"=",
"r",
".",
"get_metric",
"(",
"slug",
")",
... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | metric_history | Template Tag to display a metric's history.
* ``slug`` -- the metric's unique slug
* ``granularity`` -- the granularity: daily, hourly, weekly, monthly, yearly
* ``since`` -- a datetime object or a string string matching one of the
following patterns: "YYYY-mm-dd" for a date or "YYYY-mm-dd HH:MM:SS" ... | redis_metrics/templatetags/redis_metric_tags.py | def metric_history(slug, granularity="daily", since=None, to=None,
with_data_table=False):
"""Template Tag to display a metric's history.
* ``slug`` -- the metric's unique slug
* ``granularity`` -- the granularity: daily, hourly, weekly, monthly, yearly
* ``since`` -- a datetime obje... | def metric_history(slug, granularity="daily", since=None, to=None,
with_data_table=False):
"""Template Tag to display a metric's history.
* ``slug`` -- the metric's unique slug
* ``granularity`` -- the granularity: daily, hourly, weekly, monthly, yearly
* ``since`` -- a datetime obje... | [
"Template",
"Tag",
"to",
"display",
"a",
"metric",
"s",
"history",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L116-L159 | [
"def",
"metric_history",
"(",
"slug",
",",
"granularity",
"=",
"\"daily\"",
",",
"since",
"=",
"None",
",",
"to",
"=",
"None",
",",
"with_data_table",
"=",
"False",
")",
":",
"r",
"=",
"get_r",
"(",
")",
"try",
":",
"if",
"since",
"and",
"len",
"(",
... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | aggregate_detail | Template Tag to display multiple metrics.
* ``slug_list`` -- A list of slugs to display
* ``with_data_table`` -- if True, prints the raw data in a table. | redis_metrics/templatetags/redis_metric_tags.py | def aggregate_detail(slug_list, with_data_table=False):
"""Template Tag to display multiple metrics.
* ``slug_list`` -- A list of slugs to display
* ``with_data_table`` -- if True, prints the raw data in a table.
"""
r = get_r()
metrics_data = []
granularities = r._granularities()
# X... | def aggregate_detail(slug_list, with_data_table=False):
"""Template Tag to display multiple metrics.
* ``slug_list`` -- A list of slugs to display
* ``with_data_table`` -- if True, prints the raw data in a table.
"""
r = get_r()
metrics_data = []
granularities = r._granularities()
# X... | [
"Template",
"Tag",
"to",
"display",
"multiple",
"metrics",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L163-L195 | [
"def",
"aggregate_detail",
"(",
"slug_list",
",",
"with_data_table",
"=",
"False",
")",
":",
"r",
"=",
"get_r",
"(",
")",
"metrics_data",
"=",
"[",
"]",
"granularities",
"=",
"r",
".",
"_granularities",
"(",
")",
"# XXX converting granularties into their key-name ... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | aggregate_history | Template Tag to display history for multiple metrics.
* ``slug_list`` -- A list of slugs to display
* ``granularity`` -- the granularity: seconds, minutes, hourly,
daily, weekly, monthly, yearly
* ``since`` -- a datetime object or a string string matching one of the
following... | redis_metrics/templatetags/redis_metric_tags.py | def aggregate_history(slugs, granularity="daily", since=None, with_data_table=False):
"""Template Tag to display history for multiple metrics.
* ``slug_list`` -- A list of slugs to display
* ``granularity`` -- the granularity: seconds, minutes, hourly,
daily, weekly, monthly, yearl... | def aggregate_history(slugs, granularity="daily", since=None, with_data_table=False):
"""Template Tag to display history for multiple metrics.
* ``slug_list`` -- A list of slugs to display
* ``granularity`` -- the granularity: seconds, minutes, hourly,
daily, weekly, monthly, yearl... | [
"Template",
"Tag",
"to",
"display",
"history",
"for",
"multiple",
"metrics",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metric_tags.py#L199-L236 | [
"def",
"aggregate_history",
"(",
"slugs",
",",
"granularity",
"=",
"\"daily\"",
",",
"since",
"=",
"None",
",",
"with_data_table",
"=",
"False",
")",
":",
"r",
"=",
"get_r",
"(",
")",
"slugs",
"=",
"list",
"(",
"slugs",
")",
"try",
":",
"if",
"since",
... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | apply | Run 'query' on 'vars' and return the result(s).
Arguments:
query: A query object or string with the query.
replacements: Built-time parameters to the query, either as dict or
as an array (for positional interpolation).
vars: The variables to be supplied to the query solver.
... | efilter/api.py | def apply(query, replacements=None, vars=None, allow_io=False,
libs=("stdcore", "stdmath")):
"""Run 'query' on 'vars' and return the result(s).
Arguments:
query: A query object or string with the query.
replacements: Built-time parameters to the query, either as dict or
as... | def apply(query, replacements=None, vars=None, allow_io=False,
libs=("stdcore", "stdmath")):
"""Run 'query' on 'vars' and return the result(s).
Arguments:
query: A query object or string with the query.
replacements: Built-time parameters to the query, either as dict or
as... | [
"Run",
"query",
"on",
"vars",
"and",
"return",
"the",
"result",
"(",
"s",
")",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/api.py#L35-L127 | [
"def",
"apply",
"(",
"query",
",",
"replacements",
"=",
"None",
",",
"vars",
"=",
"None",
",",
"allow_io",
"=",
"False",
",",
"libs",
"=",
"(",
"\"stdcore\"",
",",
"\"stdmath\"",
")",
")",
":",
"if",
"vars",
"is",
"None",
":",
"vars",
"=",
"{",
"}"... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | user_func | Create an EFILTER-callable version of function 'func'.
As a security precaution, EFILTER will not execute Python callables
unless they implement the IApplicative protocol. There is a perfectly good
implementation of this protocol in the standard library and user functions
can inherit from it.
This... | efilter/api.py | def user_func(func, arg_types=None, return_type=None):
"""Create an EFILTER-callable version of function 'func'.
As a security precaution, EFILTER will not execute Python callables
unless they implement the IApplicative protocol. There is a perfectly good
implementation of this protocol in the standard... | def user_func(func, arg_types=None, return_type=None):
"""Create an EFILTER-callable version of function 'func'.
As a security precaution, EFILTER will not execute Python callables
unless they implement the IApplicative protocol. There is a perfectly good
implementation of this protocol in the standard... | [
"Create",
"an",
"EFILTER",
"-",
"callable",
"version",
"of",
"function",
"func",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/api.py#L148-L193 | [
"def",
"user_func",
"(",
"func",
",",
"arg_types",
"=",
"None",
",",
"return_type",
"=",
"None",
")",
":",
"class",
"UserFunction",
"(",
"std_core",
".",
"TypedFunction",
")",
":",
"name",
"=",
"func",
".",
"__name__",
"def",
"__call__",
"(",
"self",
","... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | infer | Determine the type of the query's output without actually running it.
Arguments:
query: A query object or string with the query.
replacements: Built-time parameters to the query, either as dict or as
an array (for positional interpolation).
root_type: The types of variables to b... | efilter/api.py | def infer(query, replacements=None, root_type=None,
libs=("stdcore", "stdmath")):
"""Determine the type of the query's output without actually running it.
Arguments:
query: A query object or string with the query.
replacements: Built-time parameters to the query, either as dict or as
... | def infer(query, replacements=None, root_type=None,
libs=("stdcore", "stdmath")):
"""Determine the type of the query's output without actually running it.
Arguments:
query: A query object or string with the query.
replacements: Built-time parameters to the query, either as dict or as
... | [
"Determine",
"the",
"type",
"of",
"the",
"query",
"s",
"output",
"without",
"actually",
"running",
"it",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/api.py#L196-L247 | [
"def",
"infer",
"(",
"query",
",",
"replacements",
"=",
"None",
",",
"root_type",
"=",
"None",
",",
"libs",
"=",
"(",
"\"stdcore\"",
",",
"\"stdmath\"",
")",
")",
":",
"# Always make the scope stack start with stdcore.",
"if",
"root_type",
":",
"type_scope",
"="... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | search | Yield objects from 'data' that match the 'query'. | efilter/api.py | def search(query, data, replacements=None):
"""Yield objects from 'data' that match the 'query'."""
query = q.Query(query, params=replacements)
for entry in data:
if solve.solve(query, entry).value:
yield entry | def search(query, data, replacements=None):
"""Yield objects from 'data' that match the 'query'."""
query = q.Query(query, params=replacements)
for entry in data:
if solve.solve(query, entry).value:
yield entry | [
"Yield",
"objects",
"from",
"data",
"that",
"match",
"the",
"query",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/api.py#L250-L255 | [
"def",
"search",
"(",
"query",
",",
"data",
",",
"replacements",
"=",
"None",
")",
":",
"query",
"=",
"q",
".",
"Query",
"(",
"query",
",",
"params",
"=",
"replacements",
")",
"for",
"entry",
"in",
"data",
":",
"if",
"solve",
".",
"solve",
"(",
"qu... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | LazyTokenizer.peek | Look ahead, doesn't affect current_token and next_token. | efilter/parsers/common/tokenizer.py | def peek(self, steps=1):
"""Look ahead, doesn't affect current_token and next_token."""
try:
tokens = iter(self)
for _ in six.moves.range(steps):
next(tokens)
return next(tokens)
except StopIteration:
return None | def peek(self, steps=1):
"""Look ahead, doesn't affect current_token and next_token."""
try:
tokens = iter(self)
for _ in six.moves.range(steps):
next(tokens)
return next(tokens)
except StopIteration:
return None | [
"Look",
"ahead",
"doesn",
"t",
"affect",
"current_token",
"and",
"next_token",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L226-L235 | [
"def",
"peek",
"(",
"self",
",",
"steps",
"=",
"1",
")",
":",
"try",
":",
"tokens",
"=",
"iter",
"(",
"self",
")",
"for",
"_",
"in",
"six",
".",
"moves",
".",
"range",
"(",
"steps",
")",
":",
"next",
"(",
"tokens",
")",
"return",
"next",
"(",
... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | LazyTokenizer.skip | Skip ahead by 'steps' tokens. | efilter/parsers/common/tokenizer.py | def skip(self, steps=1):
"""Skip ahead by 'steps' tokens."""
for _ in six.moves.range(steps):
self.next_token() | def skip(self, steps=1):
"""Skip ahead by 'steps' tokens."""
for _ in six.moves.range(steps):
self.next_token() | [
"Skip",
"ahead",
"by",
"steps",
"tokens",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L237-L240 | [
"def",
"skip",
"(",
"self",
",",
"steps",
"=",
"1",
")",
":",
"for",
"_",
"in",
"six",
".",
"moves",
".",
"range",
"(",
"steps",
")",
":",
"self",
".",
"next_token",
"(",
")"
] | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | LazyTokenizer.next_token | Returns the next logical token, advancing the tokenizer. | efilter/parsers/common/tokenizer.py | def next_token(self):
"""Returns the next logical token, advancing the tokenizer."""
if self.lookahead:
self.current_token = self.lookahead.popleft()
return self.current_token
self.current_token = self._parse_next_token()
return self.current_token | def next_token(self):
"""Returns the next logical token, advancing the tokenizer."""
if self.lookahead:
self.current_token = self.lookahead.popleft()
return self.current_token
self.current_token = self._parse_next_token()
return self.current_token | [
"Returns",
"the",
"next",
"logical",
"token",
"advancing",
"the",
"tokenizer",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L242-L249 | [
"def",
"next_token",
"(",
"self",
")",
":",
"if",
"self",
".",
"lookahead",
":",
"self",
".",
"current_token",
"=",
"self",
".",
"lookahead",
".",
"popleft",
"(",
")",
"return",
"self",
".",
"current_token",
"self",
".",
"current_token",
"=",
"self",
"."... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | LazyTokenizer._parse_next_token | Will parse patterns until it gets to the next token or EOF. | efilter/parsers/common/tokenizer.py | def _parse_next_token(self):
"""Will parse patterns until it gets to the next token or EOF."""
while self._position < self.limit:
token = self._next_pattern()
if token:
return token
return None | def _parse_next_token(self):
"""Will parse patterns until it gets to the next token or EOF."""
while self._position < self.limit:
token = self._next_pattern()
if token:
return token
return None | [
"Will",
"parse",
"patterns",
"until",
"it",
"gets",
"to",
"the",
"next",
"token",
"or",
"EOF",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L259-L266 | [
"def",
"_parse_next_token",
"(",
"self",
")",
":",
"while",
"self",
".",
"_position",
"<",
"self",
".",
"limit",
":",
"token",
"=",
"self",
".",
"_next_pattern",
"(",
")",
"if",
"token",
":",
"return",
"token",
"return",
"None"
] | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | LazyTokenizer._next_pattern | Parses the next pattern by matching each in turn. | efilter/parsers/common/tokenizer.py | def _next_pattern(self):
"""Parses the next pattern by matching each in turn."""
current_state = self.state_stack[-1]
position = self._position
for pattern in self.patterns:
if current_state not in pattern.states:
continue
m = pattern.regex.match(... | def _next_pattern(self):
"""Parses the next pattern by matching each in turn."""
current_state = self.state_stack[-1]
position = self._position
for pattern in self.patterns:
if current_state not in pattern.states:
continue
m = pattern.regex.match(... | [
"Parses",
"the",
"next",
"pattern",
"by",
"matching",
"each",
"in",
"turn",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L268-L305 | [
"def",
"_next_pattern",
"(",
"self",
")",
":",
"current_state",
"=",
"self",
".",
"state_stack",
"[",
"-",
"1",
"]",
"position",
"=",
"self",
".",
"_position",
"for",
"pattern",
"in",
"self",
".",
"patterns",
":",
"if",
"current_state",
"not",
"in",
"pat... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | LazyTokenizer._error | Raise a nice error, with the token highlighted. | efilter/parsers/common/tokenizer.py | def _error(self, message, start, end=None):
"""Raise a nice error, with the token highlighted."""
raise errors.EfilterParseError(
source=self.source, start=start, end=end, message=message) | def _error(self, message, start, end=None):
"""Raise a nice error, with the token highlighted."""
raise errors.EfilterParseError(
source=self.source, start=start, end=end, message=message) | [
"Raise",
"a",
"nice",
"error",
"with",
"the",
"token",
"highlighted",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L307-L310 | [
"def",
"_error",
"(",
"self",
",",
"message",
",",
"start",
",",
"end",
"=",
"None",
")",
":",
"raise",
"errors",
".",
"EfilterParseError",
"(",
"source",
"=",
"self",
".",
"source",
",",
"start",
"=",
"start",
",",
"end",
"=",
"end",
",",
"message",... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | LazyTokenizer.emit | Emits a token using the current pattern match and pattern label. | efilter/parsers/common/tokenizer.py | def emit(self, string, match, pattern, **_):
"""Emits a token using the current pattern match and pattern label."""
return grammar.Token(name=pattern.name, value=string,
start=match.start(), end=match.end()) | def emit(self, string, match, pattern, **_):
"""Emits a token using the current pattern match and pattern label."""
return grammar.Token(name=pattern.name, value=string,
start=match.start(), end=match.end()) | [
"Emits",
"a",
"token",
"using",
"the",
"current",
"pattern",
"match",
"and",
"pattern",
"label",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L314-L317 | [
"def",
"emit",
"(",
"self",
",",
"string",
",",
"match",
",",
"pattern",
",",
"*",
"*",
"_",
")",
":",
"return",
"grammar",
".",
"Token",
"(",
"name",
"=",
"pattern",
".",
"name",
",",
"value",
"=",
"string",
",",
"start",
"=",
"match",
".",
"sta... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | get_pkg_version | Get version string by parsing PKG-INFO. | efilter/version.py | def get_pkg_version():
"""Get version string by parsing PKG-INFO."""
try:
with open("PKG-INFO", "r") as fp:
rgx = re.compile(r"Version: (\d+)")
for line in fp.readlines():
match = rgx.match(line)
if match:
return match.group(1)
... | def get_pkg_version():
"""Get version string by parsing PKG-INFO."""
try:
with open("PKG-INFO", "r") as fp:
rgx = re.compile(r"Version: (\d+)")
for line in fp.readlines():
match = rgx.match(line)
if match:
return match.group(1)
... | [
"Get",
"version",
"string",
"by",
"parsing",
"PKG",
"-",
"INFO",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/version.py#L78-L88 | [
"def",
"get_pkg_version",
"(",
")",
":",
"try",
":",
"with",
"open",
"(",
"\"PKG-INFO\"",
",",
"\"r\"",
")",
"as",
"fp",
":",
"rgx",
"=",
"re",
".",
"compile",
"(",
"r\"Version: (\\d+)\"",
")",
"for",
"line",
"in",
"fp",
".",
"readlines",
"(",
")",
"... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | get_version | Generates a version string.
Arguments:
dev_version: Generate a verbose development version from git commits.
Examples:
1.1
1.1.dev43 # If 'dev_version' was passed. | efilter/version.py | def get_version(dev_version=False):
"""Generates a version string.
Arguments:
dev_version: Generate a verbose development version from git commits.
Examples:
1.1
1.1.dev43 # If 'dev_version' was passed.
"""
if dev_version:
version = git_dev_version()
if not ... | def get_version(dev_version=False):
"""Generates a version string.
Arguments:
dev_version: Generate a verbose development version from git commits.
Examples:
1.1
1.1.dev43 # If 'dev_version' was passed.
"""
if dev_version:
version = git_dev_version()
if not ... | [
"Generates",
"a",
"version",
"string",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/version.py#L100-L117 | [
"def",
"get_version",
"(",
"dev_version",
"=",
"False",
")",
":",
"if",
"dev_version",
":",
"version",
"=",
"git_dev_version",
"(",
")",
"if",
"not",
"version",
":",
"raise",
"RuntimeError",
"(",
"\"Could not generate dev version from git.\"",
")",
"return",
"vers... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | Base_TaskManager._heartbeat | **Purpose**: Method to be executed in the heartbeat thread. This method sends a 'request' to the
heartbeat-req queue. It expects a 'response' message from the 'heartbeart-res' queue within 10 seconds. This
message should contain the same correlation id. If no message if received in 10 seconds, the tmgr ... | src/radical/entk/execman/base/task_manager.py | def _heartbeat(self):
"""
**Purpose**: Method to be executed in the heartbeat thread. This method sends a 'request' to the
heartbeat-req queue. It expects a 'response' message from the 'heartbeart-res' queue within 10 seconds. This
message should contain the same correlation id. If no me... | def _heartbeat(self):
"""
**Purpose**: Method to be executed in the heartbeat thread. This method sends a 'request' to the
heartbeat-req queue. It expects a 'response' message from the 'heartbeart-res' queue within 10 seconds. This
message should contain the same correlation id. If no me... | [
"**",
"Purpose",
"**",
":",
"Method",
"to",
"be",
"executed",
"in",
"the",
"heartbeat",
"thread",
".",
"This",
"method",
"sends",
"a",
"request",
"to",
"the",
"heartbeat",
"-",
"req",
"queue",
".",
"It",
"expects",
"a",
"response",
"message",
"from",
"th... | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/task_manager.py#L110-L179 | [
"def",
"_heartbeat",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_prof",
".",
"prof",
"(",
"'heartbeat thread started'",
",",
"uid",
"=",
"self",
".",
"_uid",
")",
"mq_connection",
"=",
"pika",
".",
"BlockingConnection",
"(",
"pika",
".",
"ConnectionP... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Base_TaskManager._tmgr | **Purpose**: Method to be run by the tmgr process. This method receives a Task from the pending_queue
and submits it to the RTS. At all state transititons, they are synced (blocking) with the AppManager
in the master process.
In addition, the tmgr also receives heartbeat 'request' msgs from the... | src/radical/entk/execman/base/task_manager.py | def _tmgr(self, uid, rmgr, logger, mq_hostname, port, pending_queue, completed_queue):
"""
**Purpose**: Method to be run by the tmgr process. This method receives a Task from the pending_queue
and submits it to the RTS. At all state transititons, they are synced (blocking) with the AppManager
... | def _tmgr(self, uid, rmgr, logger, mq_hostname, port, pending_queue, completed_queue):
"""
**Purpose**: Method to be run by the tmgr process. This method receives a Task from the pending_queue
and submits it to the RTS. At all state transititons, they are synced (blocking) with the AppManager
... | [
"**",
"Purpose",
"**",
":",
"Method",
"to",
"be",
"run",
"by",
"the",
"tmgr",
"process",
".",
"This",
"method",
"receives",
"a",
"Task",
"from",
"the",
"pending_queue",
"and",
"submits",
"it",
"to",
"the",
"RTS",
".",
"At",
"all",
"state",
"transititons"... | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/task_manager.py#L181-L196 | [
"def",
"_tmgr",
"(",
"self",
",",
"uid",
",",
"rmgr",
",",
"logger",
",",
"mq_hostname",
",",
"port",
",",
"pending_queue",
",",
"completed_queue",
")",
":",
"raise",
"NotImplementedError",
"(",
"'_tmgr() method '",
"+",
"'not implemented in TaskManager for %s'",
... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Base_TaskManager.start_heartbeat | **Purpose**: Method to start the heartbeat thread. The heartbeat function
is not to be accessed directly. The function is started in a separate
thread using this method. | src/radical/entk/execman/base/task_manager.py | def start_heartbeat(self):
"""
**Purpose**: Method to start the heartbeat thread. The heartbeat function
is not to be accessed directly. The function is started in a separate
thread using this method.
"""
if not self._hb_thread:
try:
self._l... | def start_heartbeat(self):
"""
**Purpose**: Method to start the heartbeat thread. The heartbeat function
is not to be accessed directly. The function is started in a separate
thread using this method.
"""
if not self._hb_thread:
try:
self._l... | [
"**",
"Purpose",
"**",
":",
"Method",
"to",
"start",
"the",
"heartbeat",
"thread",
".",
"The",
"heartbeat",
"function",
"is",
"not",
"to",
"be",
"accessed",
"directly",
".",
"The",
"function",
"is",
"started",
"in",
"a",
"separate",
"thread",
"using",
"thi... | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/task_manager.py#L202-L230 | [
"def",
"start_heartbeat",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_hb_thread",
":",
"try",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"'Starting heartbeat thread'",
")",
"self",
".",
"_prof",
".",
"prof",
"(",
"'creating heartbeat thread'",
","... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Base_TaskManager.terminate_heartbeat | **Purpose**: Method to terminate the heartbeat thread. This method is
blocking as it waits for the heartbeat thread to terminate (aka join).
This is the last method that is executed from the TaskManager and
hence closes the profiler. | src/radical/entk/execman/base/task_manager.py | def terminate_heartbeat(self):
"""
**Purpose**: Method to terminate the heartbeat thread. This method is
blocking as it waits for the heartbeat thread to terminate (aka join).
This is the last method that is executed from the TaskManager and
hence closes the profiler.
"... | def terminate_heartbeat(self):
"""
**Purpose**: Method to terminate the heartbeat thread. This method is
blocking as it waits for the heartbeat thread to terminate (aka join).
This is the last method that is executed from the TaskManager and
hence closes the profiler.
"... | [
"**",
"Purpose",
"**",
":",
"Method",
"to",
"terminate",
"the",
"heartbeat",
"thread",
".",
"This",
"method",
"is",
"blocking",
"as",
"it",
"waits",
"for",
"the",
"heartbeat",
"thread",
"to",
"terminate",
"(",
"aka",
"join",
")",
"."
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/task_manager.py#L232-L274 | [
"def",
"terminate_heartbeat",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"_hb_thread",
":",
"self",
".",
"_hb_terminate",
".",
"set",
"(",
")",
"if",
"self",
".",
"check_heartbeat",
"(",
")",
":",
"self",
".",
"_hb_thread",
".",
"join",
"(",... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Base_TaskManager.terminate_manager | **Purpose**: Method to terminate the tmgr process. This method is
blocking as it waits for the tmgr process to terminate (aka join). | src/radical/entk/execman/base/task_manager.py | def terminate_manager(self):
"""
**Purpose**: Method to terminate the tmgr process. This method is
blocking as it waits for the tmgr process to terminate (aka join).
"""
try:
if self._tmgr_process:
if not self._tmgr_terminate.is_set():
... | def terminate_manager(self):
"""
**Purpose**: Method to terminate the tmgr process. This method is
blocking as it waits for the tmgr process to terminate (aka join).
"""
try:
if self._tmgr_process:
if not self._tmgr_terminate.is_set():
... | [
"**",
"Purpose",
"**",
":",
"Method",
"to",
"terminate",
"the",
"tmgr",
"process",
".",
"This",
"method",
"is",
"blocking",
"as",
"it",
"waits",
"for",
"the",
"tmgr",
"process",
"to",
"terminate",
"(",
"aka",
"join",
")",
"."
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/task_manager.py#L286-L309 | [
"def",
"terminate_manager",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"_tmgr_process",
":",
"if",
"not",
"self",
".",
"_tmgr_terminate",
".",
"is_set",
"(",
")",
":",
"self",
".",
"_tmgr_terminate",
".",
"set",
"(",
")",
"if",
"self",
".",
... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | LazyRepetition.getvalues | Yields all the values from 'generator_func' and type-checks.
Yields:
Whatever 'generator_func' yields.
Raises:
TypeError: if subsequent values are of a different type than first
value.
ValueError: if subsequent iteration returns a different number o... | efilter/ext/lazy_repetition.py | def getvalues(self):
"""Yields all the values from 'generator_func' and type-checks.
Yields:
Whatever 'generator_func' yields.
Raises:
TypeError: if subsequent values are of a different type than first
value.
ValueError: if subsequent iterat... | def getvalues(self):
"""Yields all the values from 'generator_func' and type-checks.
Yields:
Whatever 'generator_func' yields.
Raises:
TypeError: if subsequent values are of a different type than first
value.
ValueError: if subsequent iterat... | [
"Yields",
"all",
"the",
"values",
"from",
"generator_func",
"and",
"type",
"-",
"checks",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/ext/lazy_repetition.py#L66-L117 | [
"def",
"getvalues",
"(",
"self",
")",
":",
"idx",
"=",
"0",
"generator",
"=",
"self",
".",
"_generator_func",
"(",
")",
"first_value",
"=",
"next",
"(",
"generator",
")",
"self",
".",
"_value_type",
"=",
"type",
"(",
"first_value",
")",
"yield",
"first_v... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | LazyRepetition.value_eq | Sorted comparison of values. | efilter/ext/lazy_repetition.py | def value_eq(self, other):
"""Sorted comparison of values."""
self_sorted = ordered.ordered(self.getvalues())
other_sorted = ordered.ordered(repeated.getvalues(other))
return self_sorted == other_sorted | def value_eq(self, other):
"""Sorted comparison of values."""
self_sorted = ordered.ordered(self.getvalues())
other_sorted = ordered.ordered(repeated.getvalues(other))
return self_sorted == other_sorted | [
"Sorted",
"comparison",
"of",
"values",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/ext/lazy_repetition.py#L127-L131 | [
"def",
"value_eq",
"(",
"self",
",",
"other",
")",
":",
"self_sorted",
"=",
"ordered",
".",
"ordered",
"(",
"self",
".",
"getvalues",
"(",
")",
")",
"other_sorted",
"=",
"ordered",
".",
"ordered",
"(",
"repeated",
".",
"getvalues",
"(",
"other",
")",
"... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | call_audit | Print a detailed audit of all calls to this function. | efilter/dispatch.py | def call_audit(func):
"""Print a detailed audit of all calls to this function."""
def audited_func(*args, **kwargs):
import traceback
stack = traceback.extract_stack()
r = func(*args, **kwargs)
func_name = func.__name__
print("@depth %d, trace %s -> %s(*%r, **%r) => %r" ... | def call_audit(func):
"""Print a detailed audit of all calls to this function."""
def audited_func(*args, **kwargs):
import traceback
stack = traceback.extract_stack()
r = func(*args, **kwargs)
func_name = func.__name__
print("@depth %d, trace %s -> %s(*%r, **%r) => %r" ... | [
"Print",
"a",
"detailed",
"audit",
"of",
"all",
"calls",
"to",
"this",
"function",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L51-L68 | [
"def",
"call_audit",
"(",
"func",
")",
":",
"def",
"audited_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"traceback",
"stack",
"=",
"traceback",
".",
"extract_stack",
"(",
")",
"r",
"=",
"func",
"(",
"*",
"args",
",",
"*",
... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | _class_dispatch | See 'class_multimethod'. | efilter/dispatch.py | def _class_dispatch(args, kwargs):
"""See 'class_multimethod'."""
_ = kwargs
if not args:
raise ValueError(
"Multimethods must be passed at least one positional arg.")
if not isinstance(args[0], type):
raise TypeError(
"class_multimethod must be called with a typ... | def _class_dispatch(args, kwargs):
"""See 'class_multimethod'."""
_ = kwargs
if not args:
raise ValueError(
"Multimethods must be passed at least one positional arg.")
if not isinstance(args[0], type):
raise TypeError(
"class_multimethod must be called with a typ... | [
"See",
"class_multimethod",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L71-L82 | [
"def",
"_class_dispatch",
"(",
"args",
",",
"kwargs",
")",
":",
"_",
"=",
"kwargs",
"if",
"not",
"args",
":",
"raise",
"ValueError",
"(",
"\"Multimethods must be passed at least one positional arg.\"",
")",
"if",
"not",
"isinstance",
"(",
"args",
"[",
"0",
"]",
... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | multimethod.prefer_type | Prefer one type over another type, all else being equivalent.
With abstract base classes (Python's abc module) it is possible for
a type to appear to be a subclass of another type without the supertype
appearing in the subtype's MRO. As such, the supertype has no order
with respect to o... | efilter/dispatch.py | def prefer_type(self, prefer, over):
"""Prefer one type over another type, all else being equivalent.
With abstract base classes (Python's abc module) it is possible for
a type to appear to be a subclass of another type without the supertype
appearing in the subtype's MRO. As such, the ... | def prefer_type(self, prefer, over):
"""Prefer one type over another type, all else being equivalent.
With abstract base classes (Python's abc module) it is possible for
a type to appear to be a subclass of another type without the supertype
appearing in the subtype's MRO. As such, the ... | [
"Prefer",
"one",
"type",
"over",
"another",
"type",
"all",
"else",
"being",
"equivalent",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L225-L252 | [
"def",
"prefer_type",
"(",
"self",
",",
"prefer",
",",
"over",
")",
":",
"self",
".",
"_write_lock",
".",
"acquire",
"(",
")",
"try",
":",
"if",
"self",
".",
"_preferred",
"(",
"preferred",
"=",
"over",
",",
"over",
"=",
"prefer",
")",
":",
"raise",
... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | multimethod._find_and_cache_best_function | Finds the best implementation of this function given a type.
This function caches the result, and uses locking for thread safety.
Returns:
Implementing function, in below order of preference:
1. Explicitly registered implementations (through
multimethod.implement... | efilter/dispatch.py | def _find_and_cache_best_function(self, dispatch_type):
"""Finds the best implementation of this function given a type.
This function caches the result, and uses locking for thread safety.
Returns:
Implementing function, in below order of preference:
1. Explicitly regis... | def _find_and_cache_best_function(self, dispatch_type):
"""Finds the best implementation of this function given a type.
This function caches the result, and uses locking for thread safety.
Returns:
Implementing function, in below order of preference:
1. Explicitly regis... | [
"Finds",
"the",
"best",
"implementation",
"of",
"this",
"function",
"given",
"a",
"type",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L254-L335 | [
"def",
"_find_and_cache_best_function",
"(",
"self",
",",
"dispatch_type",
")",
":",
"result",
"=",
"self",
".",
"_dispatch_table",
".",
"get",
"(",
"dispatch_type",
")",
"if",
"result",
":",
"return",
"result",
"# The outer try ensures the lock is always released.",
... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | multimethod.__get_types | Parse the arguments and return a tuple of types to implement for.
Raises:
ValueError or TypeError as appropriate. | efilter/dispatch.py | def __get_types(for_type=None, for_types=None):
"""Parse the arguments and return a tuple of types to implement for.
Raises:
ValueError or TypeError as appropriate.
"""
if for_type:
if for_types:
raise ValueError("Cannot pass both for_type and for... | def __get_types(for_type=None, for_types=None):
"""Parse the arguments and return a tuple of types to implement for.
Raises:
ValueError or TypeError as appropriate.
"""
if for_type:
if for_types:
raise ValueError("Cannot pass both for_type and for... | [
"Parse",
"the",
"arguments",
"and",
"return",
"a",
"tuple",
"of",
"types",
"to",
"implement",
"for",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L338-L355 | [
"def",
"__get_types",
"(",
"for_type",
"=",
"None",
",",
"for_types",
"=",
"None",
")",
":",
"if",
"for_type",
":",
"if",
"for_types",
":",
"raise",
"ValueError",
"(",
"\"Cannot pass both for_type and for_types.\"",
")",
"for_types",
"=",
"(",
"for_type",
",",
... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | multimethod.implementation | Return a decorator that will register the implementation.
Example:
@multimethod
def add(x, y):
pass
@add.implementation(for_type=int)
def add(x, y):
return x + y
@add.implementation(for_type=SomeType)
def ... | efilter/dispatch.py | def implementation(self, for_type=None, for_types=None):
"""Return a decorator that will register the implementation.
Example:
@multimethod
def add(x, y):
pass
@add.implementation(for_type=int)
def add(x, y):
return x + y
... | def implementation(self, for_type=None, for_types=None):
"""Return a decorator that will register the implementation.
Example:
@multimethod
def add(x, y):
pass
@add.implementation(for_type=int)
def add(x, y):
return x + y
... | [
"Return",
"a",
"decorator",
"that",
"will",
"register",
"the",
"implementation",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L357-L379 | [
"def",
"implementation",
"(",
"self",
",",
"for_type",
"=",
"None",
",",
"for_types",
"=",
"None",
")",
":",
"for_types",
"=",
"self",
".",
"__get_types",
"(",
"for_type",
",",
"for_types",
")",
"def",
"_decorator",
"(",
"implementation",
")",
":",
"self",... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | multimethod.implement | Registers an implementing function for for_type.
Arguments:
implementation: Callable implementation for this type.
for_type: The type this implementation applies to.
for_types: Same as for_type, but takes a tuple of types.
for_type and for_types cannot both be p... | efilter/dispatch.py | def implement(self, implementation, for_type=None, for_types=None):
"""Registers an implementing function for for_type.
Arguments:
implementation: Callable implementation for this type.
for_type: The type this implementation applies to.
for_types: Same as for_type, b... | def implement(self, implementation, for_type=None, for_types=None):
"""Registers an implementing function for for_type.
Arguments:
implementation: Callable implementation for this type.
for_type: The type this implementation applies to.
for_types: Same as for_type, b... | [
"Registers",
"an",
"implementing",
"function",
"for",
"for_type",
"."
] | google/dotty | python | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/dispatch.py#L388-L409 | [
"def",
"implement",
"(",
"self",
",",
"implementation",
",",
"for_type",
"=",
"None",
",",
"for_types",
"=",
"None",
")",
":",
"unbound_implementation",
"=",
"self",
".",
"__get_unbound_function",
"(",
"implementation",
")",
"for_types",
"=",
"self",
".",
"__g... | b145131499be0c4b755fc2e2ac19be11a50bce6a |
train | to_int_list | Converts the given list of vlues into a list of integers. If the
integer conversion fails (e.g. non-numeric strings or None-values), this
filter will include a 0 instead. | redis_metrics/templatetags/redis_metrics_filters.py | def to_int_list(values):
"""Converts the given list of vlues into a list of integers. If the
integer conversion fails (e.g. non-numeric strings or None-values), this
filter will include a 0 instead."""
results = []
for v in values:
try:
results.append(int(v))
except (Type... | def to_int_list(values):
"""Converts the given list of vlues into a list of integers. If the
integer conversion fails (e.g. non-numeric strings or None-values), this
filter will include a 0 instead."""
results = []
for v in values:
try:
results.append(int(v))
except (Type... | [
"Converts",
"the",
"given",
"list",
"of",
"vlues",
"into",
"a",
"list",
"of",
"integers",
".",
"If",
"the",
"integer",
"conversion",
"fails",
"(",
"e",
".",
"g",
".",
"non",
"-",
"numeric",
"strings",
"or",
"None",
"-",
"values",
")",
"this",
"filter",... | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/templatetags/redis_metrics_filters.py#L15-L25 | [
"def",
"to_int_list",
"(",
"values",
")",
":",
"results",
"=",
"[",
"]",
"for",
"v",
"in",
"values",
":",
"try",
":",
"results",
".",
"append",
"(",
"int",
"(",
"v",
")",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"results",
".",... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | Base_ResourceManager._validate_resource_desc | **Purpose**: Validate the resource description provided to the ResourceManager | src/radical/entk/execman/base/resource_manager.py | def _validate_resource_desc(self):
"""
**Purpose**: Validate the resource description provided to the ResourceManager
"""
self._prof.prof('validating rdesc', uid=self._uid)
self._logger.debug('Validating resource description')
expected_keys = ['resource',
... | def _validate_resource_desc(self):
"""
**Purpose**: Validate the resource description provided to the ResourceManager
"""
self._prof.prof('validating rdesc', uid=self._uid)
self._logger.debug('Validating resource description')
expected_keys = ['resource',
... | [
"**",
"Purpose",
"**",
":",
"Validate",
"the",
"resource",
"description",
"provided",
"to",
"the",
"ResourceManager"
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/resource_manager.py#L147-L196 | [
"def",
"_validate_resource_desc",
"(",
"self",
")",
":",
"self",
".",
"_prof",
".",
"prof",
"(",
"'validating rdesc'",
",",
"uid",
"=",
"self",
".",
"_uid",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"'Validating resource description'",
")",
"expected_key... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Base_ResourceManager._populate | **Purpose**: Populate the ResourceManager class with the validated
resource description | src/radical/entk/execman/base/resource_manager.py | def _populate(self):
"""
**Purpose**: Populate the ResourceManager class with the validated
resource description
"""
if self._validated:
self._prof.prof('populating rmgr', uid=self._uid)
self._logger.debug('Populating resource manager ... | def _populate(self):
"""
**Purpose**: Populate the ResourceManager class with the validated
resource description
"""
if self._validated:
self._prof.prof('populating rmgr', uid=self._uid)
self._logger.debug('Populating resource manager ... | [
"**",
"Purpose",
"**",
":",
"Populate",
"the",
"ResourceManager",
"class",
"with",
"the",
"validated",
"resource",
"description"
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/base/resource_manager.py#L198-L221 | [
"def",
"_populate",
"(",
"self",
")",
":",
"if",
"self",
".",
"_validated",
":",
"self",
".",
"_prof",
".",
"prof",
"(",
"'populating rmgr'",
",",
"uid",
"=",
"self",
".",
"_uid",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"'Populating resource mana... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | GaugesView.get_context_data | Includes the Gauge slugs and data in the context. | redis_metrics/views.py | def get_context_data(self, **kwargs):
"""Includes the Gauge slugs and data in the context."""
data = super(GaugesView, self).get_context_data(**kwargs)
data.update({'gauges': get_r().gauge_slugs()})
return data | def get_context_data(self, **kwargs):
"""Includes the Gauge slugs and data in the context."""
data = super(GaugesView, self).get_context_data(**kwargs)
data.update({'gauges': get_r().gauge_slugs()})
return data | [
"Includes",
"the",
"Gauge",
"slugs",
"and",
"data",
"in",
"the",
"context",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L51-L55 | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"super",
"(",
"GaugesView",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"data",
".",
"update",
"(",
"{",
"'gauges'",
":",
"get_r",
"(... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | MetricsListView.get_context_data | Includes the metrics slugs in the context. | redis_metrics/views.py | def get_context_data(self, **kwargs):
"""Includes the metrics slugs in the context."""
data = super(MetricsListView, self).get_context_data(**kwargs)
# Metrics organized by category, like so:
# { <category_name>: [ <slug1>, <slug2>, ... ]}
data.update({'metrics': get_r().metric_... | def get_context_data(self, **kwargs):
"""Includes the metrics slugs in the context."""
data = super(MetricsListView, self).get_context_data(**kwargs)
# Metrics organized by category, like so:
# { <category_name>: [ <slug1>, <slug2>, ... ]}
data.update({'metrics': get_r().metric_... | [
"Includes",
"the",
"metrics",
"slugs",
"in",
"the",
"context",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L61-L68 | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"super",
"(",
"MetricsListView",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"# Metrics organized by category, like so:",
"# { <category_name>: [ <... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | MetricDetailView.get_context_data | Includes the metrics slugs in the context. | redis_metrics/views.py | def get_context_data(self, **kwargs):
"""Includes the metrics slugs in the context."""
data = super(MetricDetailView, self).get_context_data(**kwargs)
data['slug'] = kwargs['slug']
data['granularities'] = list(get_r()._granularities())
return data | def get_context_data(self, **kwargs):
"""Includes the metrics slugs in the context."""
data = super(MetricDetailView, self).get_context_data(**kwargs)
data['slug'] = kwargs['slug']
data['granularities'] = list(get_r()._granularities())
return data | [
"Includes",
"the",
"metrics",
"slugs",
"in",
"the",
"context",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L74-L79 | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"super",
"(",
"MetricDetailView",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"data",
"[",
"'slug'",
"]",
"=",
"kwargs",
"[",
"'slug'",... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | MetricHistoryView.get_context_data | Includes the metrics slugs in the context. | redis_metrics/views.py | def get_context_data(self, **kwargs):
"""Includes the metrics slugs in the context."""
data = super(MetricHistoryView, self).get_context_data(**kwargs)
# Accept GET query params for ``since``
since = self.request.GET.get('since', None)
if since and len(since) == 10: # yyyy-mm-d... | def get_context_data(self, **kwargs):
"""Includes the metrics slugs in the context."""
data = super(MetricHistoryView, self).get_context_data(**kwargs)
# Accept GET query params for ``since``
since = self.request.GET.get('since', None)
if since and len(since) == 10: # yyyy-mm-d... | [
"Includes",
"the",
"metrics",
"slugs",
"in",
"the",
"context",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L85-L102 | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"super",
"(",
"MetricHistoryView",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"# Accept GET query params for ``since``",
"since",
"=",
"self",... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | AggregateFormView.get_success_url | Reverses the ``redis_metric_aggregate_detail`` URL using
``self.metric_slugs`` as an argument. | redis_metrics/views.py | def get_success_url(self):
"""Reverses the ``redis_metric_aggregate_detail`` URL using
``self.metric_slugs`` as an argument."""
slugs = '+'.join(self.metric_slugs)
url = reverse('redis_metric_aggregate_detail', args=[slugs])
# Django 1.6 quotes reversed URLs, which changes + into... | def get_success_url(self):
"""Reverses the ``redis_metric_aggregate_detail`` URL using
``self.metric_slugs`` as an argument."""
slugs = '+'.join(self.metric_slugs)
url = reverse('redis_metric_aggregate_detail', args=[slugs])
# Django 1.6 quotes reversed URLs, which changes + into... | [
"Reverses",
"the",
"redis_metric_aggregate_detail",
"URL",
"using",
"self",
".",
"metric_slugs",
"as",
"an",
"argument",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L111-L119 | [
"def",
"get_success_url",
"(",
"self",
")",
":",
"slugs",
"=",
"'+'",
".",
"join",
"(",
"self",
".",
"metric_slugs",
")",
"url",
"=",
"reverse",
"(",
"'redis_metric_aggregate_detail'",
",",
"args",
"=",
"[",
"slugs",
"]",
")",
"# Django 1.6 quotes reversed URL... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | AggregateFormView.form_valid | Pull the metrics from the submitted form, and store them as a
list of strings in ``self.metric_slugs``. | redis_metrics/views.py | def form_valid(self, form):
"""Pull the metrics from the submitted form, and store them as a
list of strings in ``self.metric_slugs``.
"""
self.metric_slugs = [k.strip() for k in form.cleaned_data['metrics']]
return super(AggregateFormView, self).form_valid(form) | def form_valid(self, form):
"""Pull the metrics from the submitted form, and store them as a
list of strings in ``self.metric_slugs``.
"""
self.metric_slugs = [k.strip() for k in form.cleaned_data['metrics']]
return super(AggregateFormView, self).form_valid(form) | [
"Pull",
"the",
"metrics",
"from",
"the",
"submitted",
"form",
"and",
"store",
"them",
"as",
"a",
"list",
"of",
"strings",
"in",
"self",
".",
"metric_slugs",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L121-L126 | [
"def",
"form_valid",
"(",
"self",
",",
"form",
")",
":",
"self",
".",
"metric_slugs",
"=",
"[",
"k",
".",
"strip",
"(",
")",
"for",
"k",
"in",
"form",
".",
"cleaned_data",
"[",
"'metrics'",
"]",
"]",
"return",
"super",
"(",
"AggregateFormView",
",",
... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | AggregateDetailView.get_context_data | Includes the metrics slugs in the context. | redis_metrics/views.py | def get_context_data(self, **kwargs):
"""Includes the metrics slugs in the context."""
r = get_r()
category = kwargs.pop('category', None)
data = super(AggregateDetailView, self).get_context_data(**kwargs)
if category:
slug_set = r._category_slugs(category)
... | def get_context_data(self, **kwargs):
"""Includes the metrics slugs in the context."""
r = get_r()
category = kwargs.pop('category', None)
data = super(AggregateDetailView, self).get_context_data(**kwargs)
if category:
slug_set = r._category_slugs(category)
... | [
"Includes",
"the",
"metrics",
"slugs",
"in",
"the",
"context",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L132-L146 | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"r",
"=",
"get_r",
"(",
")",
"category",
"=",
"kwargs",
".",
"pop",
"(",
"'category'",
",",
"None",
")",
"data",
"=",
"super",
"(",
"AggregateDetailView",
",",
"self",
")",
".... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | AggregateHistoryView.get_context_data | Includes the metrics slugs in the context. | redis_metrics/views.py | def get_context_data(self, **kwargs):
"""Includes the metrics slugs in the context."""
r = get_r()
data = super(AggregateHistoryView, self).get_context_data(**kwargs)
slug_set = set(kwargs['slugs'].split('+'))
granularity = kwargs.get('granularity', 'daily')
# Accept GET... | def get_context_data(self, **kwargs):
"""Includes the metrics slugs in the context."""
r = get_r()
data = super(AggregateHistoryView, self).get_context_data(**kwargs)
slug_set = set(kwargs['slugs'].split('+'))
granularity = kwargs.get('granularity', 'daily')
# Accept GET... | [
"Includes",
"the",
"metrics",
"slugs",
"in",
"the",
"context",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L152-L172 | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"r",
"=",
"get_r",
"(",
")",
"data",
"=",
"super",
"(",
"AggregateHistoryView",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"slug_set",
"=",
"set",
... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | CategoryFormView.get | See if this view was called with a specified category. | redis_metrics/views.py | def get(self, *args, **kwargs):
"""See if this view was called with a specified category."""
self.initial = {"category_name": kwargs.get('category_name', None)}
return super(CategoryFormView, self).get(*args, **kwargs) | def get(self, *args, **kwargs):
"""See if this view was called with a specified category."""
self.initial = {"category_name": kwargs.get('category_name', None)}
return super(CategoryFormView, self).get(*args, **kwargs) | [
"See",
"if",
"this",
"view",
"was",
"called",
"with",
"a",
"specified",
"category",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L180-L183 | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"initial",
"=",
"{",
"\"category_name\"",
":",
"kwargs",
".",
"get",
"(",
"'category_name'",
",",
"None",
")",
"}",
"return",
"super",
"(",
"CategoryFormView",... | 2c92332920113d28c39234b949aa496b39a091d1 |
train | CategoryFormView.form_valid | Get the category name/metric slugs from the form, and update the
category so contains the given metrics. | redis_metrics/views.py | def form_valid(self, form):
"""Get the category name/metric slugs from the form, and update the
category so contains the given metrics."""
form.categorize_metrics()
return super(CategoryFormView, self).form_valid(form) | def form_valid(self, form):
"""Get the category name/metric slugs from the form, and update the
category so contains the given metrics."""
form.categorize_metrics()
return super(CategoryFormView, self).form_valid(form) | [
"Get",
"the",
"category",
"name",
"/",
"metric",
"slugs",
"from",
"the",
"form",
"and",
"update",
"the",
"category",
"so",
"contains",
"the",
"given",
"metrics",
"."
] | bradmontgomery/django-redis-metrics | python | https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/views.py#L193-L197 | [
"def",
"form_valid",
"(",
"self",
",",
"form",
")",
":",
"form",
".",
"categorize_metrics",
"(",
")",
"return",
"super",
"(",
"CategoryFormView",
",",
"self",
")",
".",
"form_valid",
"(",
"form",
")"
] | 2c92332920113d28c39234b949aa496b39a091d1 |
train | Pipeline.rerun | Rerun sets the state of the Pipeline to scheduling so that the Pipeline
can be checked for new stages | src/radical/entk/pipeline/pipeline.py | def rerun(self):
"""
Rerun sets the state of the Pipeline to scheduling so that the Pipeline
can be checked for new stages
"""
self._state = states.SCHEDULING
self._completed_flag = threading.Event()
print 'Pipeline %s in %s state'%(self._uid, self._state) | def rerun(self):
"""
Rerun sets the state of the Pipeline to scheduling so that the Pipeline
can be checked for new stages
"""
self._state = states.SCHEDULING
self._completed_flag = threading.Event()
print 'Pipeline %s in %s state'%(self._uid, self._state) | [
"Rerun",
"sets",
"the",
"state",
"of",
"the",
"Pipeline",
"to",
"scheduling",
"so",
"that",
"the",
"Pipeline",
"can",
"be",
"checked",
"for",
"new",
"stages"
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L204-L213 | [
"def",
"rerun",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"states",
".",
"SCHEDULING",
"self",
".",
"_completed_flag",
"=",
"threading",
".",
"Event",
"(",
")",
"print",
"'Pipeline %s in %s state'",
"%",
"(",
"self",
".",
"_uid",
",",
"self",
".... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Pipeline.to_dict | Convert current Pipeline (i.e. its attributes) into a dictionary
:return: python dictionary | src/radical/entk/pipeline/pipeline.py | def to_dict(self):
"""
Convert current Pipeline (i.e. its attributes) into a dictionary
:return: python dictionary
"""
pipeline_desc_as_dict = {
'uid': self._uid,
'name': self._name,
'state': self._state,
'state_history': self._s... | def to_dict(self):
"""
Convert current Pipeline (i.e. its attributes) into a dictionary
:return: python dictionary
"""
pipeline_desc_as_dict = {
'uid': self._uid,
'name': self._name,
'state': self._state,
'state_history': self._s... | [
"Convert",
"current",
"Pipeline",
"(",
"i",
".",
"e",
".",
"its",
"attributes",
")",
"into",
"a",
"dictionary"
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L215-L231 | [
"def",
"to_dict",
"(",
"self",
")",
":",
"pipeline_desc_as_dict",
"=",
"{",
"'uid'",
":",
"self",
".",
"_uid",
",",
"'name'",
":",
"self",
".",
"_name",
",",
"'state'",
":",
"self",
".",
"_state",
",",
"'state_history'",
":",
"self",
".",
"_state_history... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Pipeline.from_dict | Create a Pipeline from a dictionary. The change is in inplace.
:argument: python dictionary
:return: None | src/radical/entk/pipeline/pipeline.py | def from_dict(self, d):
"""
Create a Pipeline from a dictionary. The change is in inplace.
:argument: python dictionary
:return: None
"""
if 'uid' in d:
if d['uid']:
self._uid = d['uid']
if 'name' in d:
if d['name']:
... | def from_dict(self, d):
"""
Create a Pipeline from a dictionary. The change is in inplace.
:argument: python dictionary
:return: None
"""
if 'uid' in d:
if d['uid']:
self._uid = d['uid']
if 'name' in d:
if d['name']:
... | [
"Create",
"a",
"Pipeline",
"from",
"a",
"dictionary",
".",
"The",
"change",
"is",
"in",
"inplace",
"."
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L233-L278 | [
"def",
"from_dict",
"(",
"self",
",",
"d",
")",
":",
"if",
"'uid'",
"in",
"d",
":",
"if",
"d",
"[",
"'uid'",
"]",
":",
"self",
".",
"_uid",
"=",
"d",
"[",
"'uid'",
"]",
"if",
"'name'",
"in",
"d",
":",
"if",
"d",
"[",
"'name'",
"]",
":",
"se... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Pipeline._increment_stage | Purpose: Increment stage pointer. Also check if Pipeline has completed. | src/radical/entk/pipeline/pipeline.py | def _increment_stage(self):
"""
Purpose: Increment stage pointer. Also check if Pipeline has completed.
"""
try:
if self._cur_stage < self._stage_count:
self._cur_stage += 1
else:
self._completed_flag.set()
except Excepti... | def _increment_stage(self):
"""
Purpose: Increment stage pointer. Also check if Pipeline has completed.
"""
try:
if self._cur_stage < self._stage_count:
self._cur_stage += 1
else:
self._completed_flag.set()
except Excepti... | [
"Purpose",
":",
"Increment",
"stage",
"pointer",
".",
"Also",
"check",
"if",
"Pipeline",
"has",
"completed",
"."
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L300-L313 | [
"def",
"_increment_stage",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"_cur_stage",
"<",
"self",
".",
"_stage_count",
":",
"self",
".",
"_cur_stage",
"+=",
"1",
"else",
":",
"self",
".",
"_completed_flag",
".",
"set",
"(",
")",
"except",
"Ex... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Pipeline._decrement_stage | Purpose: Decrement stage pointer. Reset completed flag. | src/radical/entk/pipeline/pipeline.py | def _decrement_stage(self):
"""
Purpose: Decrement stage pointer. Reset completed flag.
"""
try:
if self._cur_stage > 0:
self._cur_stage -= 1
self._completed_flag = threading.Event() # reset
except Exception, ex:
raise E... | def _decrement_stage(self):
"""
Purpose: Decrement stage pointer. Reset completed flag.
"""
try:
if self._cur_stage > 0:
self._cur_stage -= 1
self._completed_flag = threading.Event() # reset
except Exception, ex:
raise E... | [
"Purpose",
":",
"Decrement",
"stage",
"pointer",
".",
"Reset",
"completed",
"flag",
"."
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L315-L327 | [
"def",
"_decrement_stage",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"_cur_stage",
">",
"0",
":",
"self",
".",
"_cur_stage",
"-=",
"1",
"self",
".",
"_completed_flag",
"=",
"threading",
".",
"Event",
"(",
")",
"# reset",
"except",
"Exception"... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Pipeline._validate_entities | Purpose: Validate whether the argument 'stages' is of list of Stage objects
:argument: list of Stage objects | src/radical/entk/pipeline/pipeline.py | def _validate_entities(self, stages):
"""
Purpose: Validate whether the argument 'stages' is of list of Stage objects
:argument: list of Stage objects
"""
if not stages:
raise TypeError(expected_type=Stage, actual_type=type(stages))
if not isinstance(stages,... | def _validate_entities(self, stages):
"""
Purpose: Validate whether the argument 'stages' is of list of Stage objects
:argument: list of Stage objects
"""
if not stages:
raise TypeError(expected_type=Stage, actual_type=type(stages))
if not isinstance(stages,... | [
"Purpose",
":",
"Validate",
"whether",
"the",
"argument",
"stages",
"is",
"of",
"list",
"of",
"Stage",
"objects"
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L330-L346 | [
"def",
"_validate_entities",
"(",
"self",
",",
"stages",
")",
":",
"if",
"not",
"stages",
":",
"raise",
"TypeError",
"(",
"expected_type",
"=",
"Stage",
",",
"actual_type",
"=",
"type",
"(",
"stages",
")",
")",
"if",
"not",
"isinstance",
"(",
"stages",
"... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Pipeline._assign_uid | Purpose: Assign a uid to the current object based on the sid passed. Pass the current uid to children of
current object | src/radical/entk/pipeline/pipeline.py | def _assign_uid(self, sid):
"""
Purpose: Assign a uid to the current object based on the sid passed. Pass the current uid to children of
current object
"""
self._uid = ru.generate_id(
'pipeline.%(item_counter)04d', ru.ID_CUSTOM, namespace=sid)
for stage in sel... | def _assign_uid(self, sid):
"""
Purpose: Assign a uid to the current object based on the sid passed. Pass the current uid to children of
current object
"""
self._uid = ru.generate_id(
'pipeline.%(item_counter)04d', ru.ID_CUSTOM, namespace=sid)
for stage in sel... | [
"Purpose",
":",
"Assign",
"a",
"uid",
"to",
"the",
"current",
"object",
"based",
"on",
"the",
"sid",
"passed",
".",
"Pass",
"the",
"current",
"uid",
"to",
"children",
"of",
"current",
"object"
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L369-L379 | [
"def",
"_assign_uid",
"(",
"self",
",",
"sid",
")",
":",
"self",
".",
"_uid",
"=",
"ru",
".",
"generate_id",
"(",
"'pipeline.%(item_counter)04d'",
",",
"ru",
".",
"ID_CUSTOM",
",",
"namespace",
"=",
"sid",
")",
"for",
"stage",
"in",
"self",
".",
"_stages... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | Pipeline._pass_uid | Purpose: Pass current Pipeline's uid to all Stages.
:argument: List of Stage objects (optional) | src/radical/entk/pipeline/pipeline.py | def _pass_uid(self):
"""
Purpose: Pass current Pipeline's uid to all Stages.
:argument: List of Stage objects (optional)
"""
for stage in self._stages:
stage.parent_pipeline['uid'] = self._uid
stage.parent_pipeline['name'] = self._name
stage.... | def _pass_uid(self):
"""
Purpose: Pass current Pipeline's uid to all Stages.
:argument: List of Stage objects (optional)
"""
for stage in self._stages:
stage.parent_pipeline['uid'] = self._uid
stage.parent_pipeline['name'] = self._name
stage.... | [
"Purpose",
":",
"Pass",
"current",
"Pipeline",
"s",
"uid",
"to",
"all",
"Stages",
"."
] | radical-cybertools/radical.entk | python | https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/pipeline/pipeline.py#L381-L391 | [
"def",
"_pass_uid",
"(",
"self",
")",
":",
"for",
"stage",
"in",
"self",
".",
"_stages",
":",
"stage",
".",
"parent_pipeline",
"[",
"'uid'",
"]",
"=",
"self",
".",
"_uid",
"stage",
".",
"parent_pipeline",
"[",
"'name'",
"]",
"=",
"self",
".",
"_name",
... | 945f6c93c9a62db90ad191b306418d5c1cdd9d24 |
train | hexdump | Hexdump function by sbz and 7h3rAm on Github:
(https://gist.github.com/7h3rAm/5603718).
:param src: Source, the string to be shown in hexadecimal format
:param length: Number of hex characters to print in one row
:param sep: Unprintable characters representation
:return: | xym/xym.py | def hexdump(src, length=16, sep='.'):
"""
Hexdump function by sbz and 7h3rAm on Github:
(https://gist.github.com/7h3rAm/5603718).
:param src: Source, the string to be shown in hexadecimal format
:param length: Number of hex characters to print in one row
:param sep: Unprintable characters repres... | def hexdump(src, length=16, sep='.'):
"""
Hexdump function by sbz and 7h3rAm on Github:
(https://gist.github.com/7h3rAm/5603718).
:param src: Source, the string to be shown in hexadecimal format
:param length: Number of hex characters to print in one row
:param sep: Unprintable characters repres... | [
"Hexdump",
"function",
"by",
"sbz",
"and",
"7h3rAm",
"on",
"Github",
":",
"(",
"https",
":",
"//",
"gist",
".",
"github",
".",
"com",
"/",
"7h3rAm",
"/",
"5603718",
")",
".",
":",
"param",
"src",
":",
"Source",
"the",
"string",
"to",
"be",
"shown",
... | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L30-L48 | [
"def",
"hexdump",
"(",
"src",
",",
"length",
"=",
"16",
",",
"sep",
"=",
"'.'",
")",
":",
"filtr",
"=",
"''",
".",
"join",
"(",
"[",
"(",
"len",
"(",
"repr",
"(",
"chr",
"(",
"x",
")",
")",
")",
"==",
"3",
")",
"and",
"chr",
"(",
"x",
")"... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | xym | Extracts YANG model from an IETF RFC or draft text file.
This is the main (external) API entry for the module.
:param add_line_refs:
:param source_id: identifier (file name or URL) of a draft or RFC file containing
one or more YANG models
:param srcdir: If source_id points to a file, the opt... | xym/xym.py | def xym(source_id, srcdir, dstdir, strict=False, strict_examples=False, debug_level=0, add_line_refs=False,
force_revision_pyang=False, force_revision_regexp=False):
"""
Extracts YANG model from an IETF RFC or draft text file.
This is the main (external) API entry for the module.
:param add_lin... | def xym(source_id, srcdir, dstdir, strict=False, strict_examples=False, debug_level=0, add_line_refs=False,
force_revision_pyang=False, force_revision_regexp=False):
"""
Extracts YANG model from an IETF RFC or draft text file.
This is the main (external) API entry for the module.
:param add_lin... | [
"Extracts",
"YANG",
"model",
"from",
"an",
"IETF",
"RFC",
"or",
"draft",
"text",
"file",
".",
"This",
"is",
"the",
"main",
"(",
"external",
")",
"API",
"entry",
"for",
"the",
"module",
"."
] | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L527-L574 | [
"def",
"xym",
"(",
"source_id",
",",
"srcdir",
",",
"dstdir",
",",
"strict",
"=",
"False",
",",
"strict_examples",
"=",
"False",
",",
"debug_level",
"=",
"0",
",",
"add_line_refs",
"=",
"False",
",",
"force_revision_pyang",
"=",
"False",
",",
"force_revision... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.warning | Prints out a warning message to stderr.
:param s: The warning string to print
:return: None | xym/xym.py | def warning(self, s):
"""
Prints out a warning message to stderr.
:param s: The warning string to print
:return: None
"""
print(" WARNING: '%s', %s" % (self.src_id, s), file=sys.stderr) | def warning(self, s):
"""
Prints out a warning message to stderr.
:param s: The warning string to print
:return: None
"""
print(" WARNING: '%s', %s" % (self.src_id, s), file=sys.stderr) | [
"Prints",
"out",
"a",
"warning",
"message",
"to",
"stderr",
".",
":",
"param",
"s",
":",
"The",
"warning",
"string",
"to",
"print",
":",
"return",
":",
"None"
] | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L95-L101 | [
"def",
"warning",
"(",
"self",
",",
"s",
")",
":",
"print",
"(",
"\" WARNING: '%s', %s\"",
"%",
"(",
"self",
".",
"src_id",
",",
"s",
")",
",",
"file",
"=",
"sys",
".",
"stderr",
")"
] | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.error | Prints out an error message to stderr.
:param s: The error string to print
:return: None | xym/xym.py | def error(self, s):
"""
Prints out an error message to stderr.
:param s: The error string to print
:return: None
"""
print(" ERROR: '%s', %s" % (self.src_id, s), file=sys.stderr) | def error(self, s):
"""
Prints out an error message to stderr.
:param s: The error string to print
:return: None
"""
print(" ERROR: '%s', %s" % (self.src_id, s), file=sys.stderr) | [
"Prints",
"out",
"an",
"error",
"message",
"to",
"stderr",
".",
":",
"param",
"s",
":",
"The",
"error",
"string",
"to",
"print",
":",
"return",
":",
"None"
] | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L103-L109 | [
"def",
"error",
"(",
"self",
",",
"s",
")",
":",
"print",
"(",
"\" ERROR: '%s', %s\"",
"%",
"(",
"self",
".",
"src_id",
",",
"s",
")",
",",
"file",
"=",
"sys",
".",
"stderr",
")"
] | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.remove_leading_spaces | This function is a part of the model post-processing pipeline. It
removes leading spaces from an extracted module; depending on the
formatting of the draft/rfc text, may have multiple spaces prepended
to each line. The function also determines the length of the longest
line in the modul... | xym/xym.py | def remove_leading_spaces(self, input_model):
"""
This function is a part of the model post-processing pipeline. It
removes leading spaces from an extracted module; depending on the
formatting of the draft/rfc text, may have multiple spaces prepended
to each line. The function a... | def remove_leading_spaces(self, input_model):
"""
This function is a part of the model post-processing pipeline. It
removes leading spaces from an extracted module; depending on the
formatting of the draft/rfc text, may have multiple spaces prepended
to each line. The function a... | [
"This",
"function",
"is",
"a",
"part",
"of",
"the",
"model",
"post",
"-",
"processing",
"pipeline",
".",
"It",
"removes",
"leading",
"spaces",
"from",
"an",
"extracted",
"module",
";",
"depending",
"on",
"the",
"formatting",
"of",
"the",
"draft",
"/",
"rfc... | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L211-L235 | [
"def",
"remove_leading_spaces",
"(",
"self",
",",
"input_model",
")",
":",
"leading_spaces",
"=",
"1024",
"output_model",
"=",
"[",
"]",
"for",
"mline",
"in",
"input_model",
":",
"line",
"=",
"mline",
"[",
"0",
"]",
"if",
"line",
".",
"rstrip",
"(",
"' \... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.add_line_references | This function is a part of the model post-processing pipeline. For
each line in the module, it adds a reference to the line number in
the original draft/RFC from where the module line was extracted.
:param input_model: The YANG model to be processed
:return: Modified YANG model, where li... | xym/xym.py | def add_line_references(self, input_model):
"""
This function is a part of the model post-processing pipeline. For
each line in the module, it adds a reference to the line number in
the original draft/RFC from where the module line was extracted.
:param input_model: The YANG mode... | def add_line_references(self, input_model):
"""
This function is a part of the model post-processing pipeline. For
each line in the module, it adds a reference to the line number in
the original draft/RFC from where the module line was extracted.
:param input_model: The YANG mode... | [
"This",
"function",
"is",
"a",
"part",
"of",
"the",
"model",
"post",
"-",
"processing",
"pipeline",
".",
"For",
"each",
"line",
"in",
"the",
"module",
"it",
"adds",
"a",
"reference",
"to",
"the",
"line",
"number",
"in",
"the",
"original",
"draft",
"/",
... | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L237-L253 | [
"def",
"add_line_references",
"(",
"self",
",",
"input_model",
")",
":",
"output_model",
"=",
"[",
"]",
"for",
"ln",
"in",
"input_model",
":",
"line_len",
"=",
"len",
"(",
"ln",
"[",
"0",
"]",
")",
"line_ref",
"=",
"(",
"'// %4d'",
"%",
"ln",
"[",
"1... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.remove_extra_empty_lines | Removes superfluous newlines from a YANG model that was extracted
from a draft or RFC text. Newlines are removed whenever 2 or more
consecutive empty lines are found in the model. This function is a
part of the model post-processing pipeline.
:param input_model: The YANG model to be proc... | xym/xym.py | def remove_extra_empty_lines(self, input_model):
"""
Removes superfluous newlines from a YANG model that was extracted
from a draft or RFC text. Newlines are removed whenever 2 or more
consecutive empty lines are found in the model. This function is a
part of the model post-proce... | def remove_extra_empty_lines(self, input_model):
"""
Removes superfluous newlines from a YANG model that was extracted
from a draft or RFC text. Newlines are removed whenever 2 or more
consecutive empty lines are found in the model. This function is a
part of the model post-proce... | [
"Removes",
"superfluous",
"newlines",
"from",
"a",
"YANG",
"model",
"that",
"was",
"extracted",
"from",
"a",
"draft",
"or",
"RFC",
"text",
".",
"Newlines",
"are",
"removed",
"whenever",
"2",
"or",
"more",
"consecutive",
"empty",
"lines",
"are",
"found",
"in"... | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L255-L278 | [
"def",
"remove_extra_empty_lines",
"(",
"self",
",",
"input_model",
")",
":",
"ncnt",
"=",
"0",
"output_model",
"=",
"[",
"]",
"for",
"ln",
"in",
"input_model",
":",
"if",
"ln",
"[",
"0",
"]",
".",
"strip",
"(",
"' \\n\\r'",
")",
"is",
"''",
":",
"if... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.post_process_model | This function defines the order and execution logic for actions
that are performed in the model post-processing pipeline.
:param input_model: The YANG model to be processed in the pipeline
:param add_line_refs: Flag that controls whether line number
references should be added to the ... | xym/xym.py | def post_process_model(self, input_model, add_line_refs):
"""
This function defines the order and execution logic for actions
that are performed in the model post-processing pipeline.
:param input_model: The YANG model to be processed in the pipeline
:param add_line_refs: Flag th... | def post_process_model(self, input_model, add_line_refs):
"""
This function defines the order and execution logic for actions
that are performed in the model post-processing pipeline.
:param input_model: The YANG model to be processed in the pipeline
:param add_line_refs: Flag th... | [
"This",
"function",
"defines",
"the",
"order",
"and",
"execution",
"logic",
"for",
"actions",
"that",
"are",
"performed",
"in",
"the",
"model",
"post",
"-",
"processing",
"pipeline",
".",
":",
"param",
"input_model",
":",
"The",
"YANG",
"model",
"to",
"be",
... | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L280-L294 | [
"def",
"post_process_model",
"(",
"self",
",",
"input_model",
",",
"add_line_refs",
")",
":",
"intermediate_model",
"=",
"self",
".",
"remove_leading_spaces",
"(",
"input_model",
")",
"intermediate_model",
"=",
"self",
".",
"remove_extra_empty_lines",
"(",
"intermedia... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.write_model_to_file | Write a YANG model that was extracted from a source identifier
(URL or source .txt file) to a .yang destination file
:param mdl: YANG model, as a list of lines
:param fn: Name of the YANG model file
:return: | xym/xym.py | def write_model_to_file(self, mdl, fn):
"""
Write a YANG model that was extracted from a source identifier
(URL or source .txt file) to a .yang destination file
:param mdl: YANG model, as a list of lines
:param fn: Name of the YANG model file
:return:
"""
... | def write_model_to_file(self, mdl, fn):
"""
Write a YANG model that was extracted from a source identifier
(URL or source .txt file) to a .yang destination file
:param mdl: YANG model, as a list of lines
:param fn: Name of the YANG model file
:return:
"""
... | [
"Write",
"a",
"YANG",
"model",
"that",
"was",
"extracted",
"from",
"a",
"source",
"identifier",
"(",
"URL",
"or",
"source",
".",
"txt",
"file",
")",
"to",
"a",
".",
"yang",
"destination",
"file",
":",
"param",
"mdl",
":",
"YANG",
"model",
"as",
"a",
... | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L296-L316 | [
"def",
"write_model_to_file",
"(",
"self",
",",
"mdl",
",",
"fn",
")",
":",
"# Write the model to file",
"output",
"=",
"''",
".",
"join",
"(",
"self",
".",
"post_process_model",
"(",
"mdl",
",",
"self",
".",
"add_line_refs",
")",
")",
"if",
"fn",
":",
"... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.debug_print_line | Debug print of the currently parsed line
:param i: The line number of the line that is being currently parsed
:param level: Parser level
:param line: the line that is currently being parsed
:return: None | xym/xym.py | def debug_print_line(self, i, level, line):
"""
Debug print of the currently parsed line
:param i: The line number of the line that is being currently parsed
:param level: Parser level
:param line: the line that is currently being parsed
:return: None
"""
... | def debug_print_line(self, i, level, line):
"""
Debug print of the currently parsed line
:param i: The line number of the line that is being currently parsed
:param level: Parser level
:param line: the line that is currently being parsed
:return: None
"""
... | [
"Debug",
"print",
"of",
"the",
"currently",
"parsed",
"line",
":",
"param",
"i",
":",
"The",
"line",
"number",
"of",
"the",
"line",
"that",
"is",
"being",
"currently",
"parsed",
":",
"param",
"level",
":",
"Parser",
"level",
":",
"param",
"line",
":",
... | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L318-L330 | [
"def",
"debug_print_line",
"(",
"self",
",",
"i",
",",
"level",
",",
"line",
")",
":",
"if",
"self",
".",
"debug_level",
"==",
"2",
":",
"print",
"(",
"\"Line %d (%d): '%s'\"",
"%",
"(",
"i",
"+",
"1",
",",
"level",
",",
"line",
".",
"rstrip",
"(",
... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.debug_print_strip_msg | Debug print indicating that an empty line is being skipped
:param i: The line number of the line that is being currently parsed
:param line: the parsed line
:return: None | xym/xym.py | def debug_print_strip_msg(self, i, line):
"""
Debug print indicating that an empty line is being skipped
:param i: The line number of the line that is being currently parsed
:param line: the parsed line
:return: None
"""
if self.debug_level == 2:
print... | def debug_print_strip_msg(self, i, line):
"""
Debug print indicating that an empty line is being skipped
:param i: The line number of the line that is being currently parsed
:param line: the parsed line
:return: None
"""
if self.debug_level == 2:
print... | [
"Debug",
"print",
"indicating",
"that",
"an",
"empty",
"line",
"is",
"being",
"skipped",
":",
"param",
"i",
":",
"The",
"line",
"number",
"of",
"the",
"line",
"that",
"is",
"being",
"currently",
"parsed",
":",
"param",
"line",
":",
"the",
"parsed",
"line... | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L332-L343 | [
"def",
"debug_print_strip_msg",
"(",
"self",
",",
"i",
",",
"line",
")",
":",
"if",
"self",
".",
"debug_level",
"==",
"2",
":",
"print",
"(",
"\" Stripping Line %d: '%s'\"",
"%",
"(",
"i",
"+",
"1",
",",
"line",
".",
"rstrip",
"(",
"' \\r\\n\\t\\f'",
... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.strip_empty_lines_forward | Skip over empty lines
:param content: parsed text
:param i: current parsed line
:return: number of skipped lined | xym/xym.py | def strip_empty_lines_forward(self, content, i):
"""
Skip over empty lines
:param content: parsed text
:param i: current parsed line
:return: number of skipped lined
"""
while i < len(content):
line = content[i].strip(' \r\n\t\f')
if line !... | def strip_empty_lines_forward(self, content, i):
"""
Skip over empty lines
:param content: parsed text
:param i: current parsed line
:return: number of skipped lined
"""
while i < len(content):
line = content[i].strip(' \r\n\t\f')
if line !... | [
"Skip",
"over",
"empty",
"lines",
":",
"param",
"content",
":",
"parsed",
"text",
":",
"param",
"i",
":",
"current",
"parsed",
"line",
":",
"return",
":",
"number",
"of",
"skipped",
"lined"
] | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L345-L358 | [
"def",
"strip_empty_lines_forward",
"(",
"self",
",",
"content",
",",
"i",
")",
":",
"while",
"i",
"<",
"len",
"(",
"content",
")",
":",
"line",
"=",
"content",
"[",
"i",
"]",
".",
"strip",
"(",
"' \\r\\n\\t\\f'",
")",
"if",
"line",
"!=",
"''",
":",
... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.strip_empty_lines_backward | Strips empty lines preceding the line that is currently being parsed. This
fucntion is called when the parser encounters a Footer.
:param model: lines that were added to the model up to this point
:param line_num: the number of teh line being parsed
:param max_lines_to_strip: max number ... | xym/xym.py | def strip_empty_lines_backward(self, model, max_lines_to_strip):
"""
Strips empty lines preceding the line that is currently being parsed. This
fucntion is called when the parser encounters a Footer.
:param model: lines that were added to the model up to this point
:param line_nu... | def strip_empty_lines_backward(self, model, max_lines_to_strip):
"""
Strips empty lines preceding the line that is currently being parsed. This
fucntion is called when the parser encounters a Footer.
:param model: lines that were added to the model up to this point
:param line_nu... | [
"Strips",
"empty",
"lines",
"preceding",
"the",
"line",
"that",
"is",
"currently",
"being",
"parsed",
".",
"This",
"fucntion",
"is",
"called",
"when",
"the",
"parser",
"encounters",
"a",
"Footer",
".",
":",
"param",
"model",
":",
"lines",
"that",
"were",
"... | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L360-L373 | [
"def",
"strip_empty_lines_backward",
"(",
"self",
",",
"model",
",",
"max_lines_to_strip",
")",
":",
"for",
"l",
"in",
"range",
"(",
"0",
",",
"max_lines_to_strip",
")",
":",
"if",
"model",
"[",
"-",
"1",
"]",
"[",
"0",
"]",
".",
"strip",
"(",
"' \\r\\... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | YangModuleExtractor.extract_yang_model | Extracts one or more YANG models from an RFC or draft text string in
which the models are specified. The function skips over page
formatting (Page Headers and Footers) and performs basic YANG module
syntax checking. In strict mode, the function also enforces the
<CODE BEGINS> / <CODE END... | xym/xym.py | def extract_yang_model(self, content):
"""
Extracts one or more YANG models from an RFC or draft text string in
which the models are specified. The function skips over page
formatting (Page Headers and Footers) and performs basic YANG module
syntax checking. In strict mode, the f... | def extract_yang_model(self, content):
"""
Extracts one or more YANG models from an RFC or draft text string in
which the models are specified. The function skips over page
formatting (Page Headers and Footers) and performs basic YANG module
syntax checking. In strict mode, the f... | [
"Extracts",
"one",
"or",
"more",
"YANG",
"models",
"from",
"an",
"RFC",
"or",
"draft",
"text",
"string",
"in",
"which",
"the",
"models",
"are",
"specified",
".",
"The",
"function",
"skips",
"over",
"page",
"formatting",
"(",
"Page",
"Headers",
"and",
"Foot... | xym-tool/xym | python | https://github.com/xym-tool/xym/blob/48984e6bd41595df8f383e6dc7e6eedfecc96898/xym/xym.py#L375-L524 | [
"def",
"extract_yang_model",
"(",
"self",
",",
"content",
")",
":",
"model",
"=",
"[",
"]",
"output_file",
"=",
"None",
"in_model",
"=",
"False",
"example_match",
"=",
"False",
"i",
"=",
"0",
"level",
"=",
"0",
"quotes",
"=",
"0",
"while",
"i",
"<",
... | 48984e6bd41595df8f383e6dc7e6eedfecc96898 |
train | auto_retry | Decorator for retrying method calls, based on instance parameters. | mpdlcd/utils.py | def auto_retry(fun):
"""Decorator for retrying method calls, based on instance parameters."""
@functools.wraps(fun)
def decorated(instance, *args, **kwargs):
"""Wrapper around a decorated function."""
cfg = instance._retry_config
remaining_tries = cfg.retry_attempts
current_... | def auto_retry(fun):
"""Decorator for retrying method calls, based on instance parameters."""
@functools.wraps(fun)
def decorated(instance, *args, **kwargs):
"""Wrapper around a decorated function."""
cfg = instance._retry_config
remaining_tries = cfg.retry_attempts
current_... | [
"Decorator",
"for",
"retrying",
"method",
"calls",
"based",
"on",
"instance",
"parameters",
"."
] | rbarrois/mpdlcd | python | https://github.com/rbarrois/mpdlcd/blob/85f16c8cc0883f8abb4c2cc7f69729c3e2f857da/mpdlcd/utils.py#L50-L81 | [
"def",
"auto_retry",
"(",
"fun",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fun",
")",
"def",
"decorated",
"(",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Wrapper around a decorated function.\"\"\"",
"cfg",
"=",
"instance",
... | 85f16c8cc0883f8abb4c2cc7f69729c3e2f857da |
train | extract_pattern | Extracts used strings from a %(foo)s pattern. | mpdlcd/utils.py | def extract_pattern(fmt):
"""Extracts used strings from a %(foo)s pattern."""
class FakeDict(object):
def __init__(self):
self.seen_keys = set()
def __getitem__(self, key):
self.seen_keys.add(key)
return ''
def keys(self):
return self.see... | def extract_pattern(fmt):
"""Extracts used strings from a %(foo)s pattern."""
class FakeDict(object):
def __init__(self):
self.seen_keys = set()
def __getitem__(self, key):
self.seen_keys.add(key)
return ''
def keys(self):
return self.see... | [
"Extracts",
"used",
"strings",
"from",
"a",
"%",
"(",
"foo",
")",
"s",
"pattern",
"."
] | rbarrois/mpdlcd | python | https://github.com/rbarrois/mpdlcd/blob/85f16c8cc0883f8abb4c2cc7f69729c3e2f857da/mpdlcd/utils.py#L84-L103 | [
"def",
"extract_pattern",
"(",
"fmt",
")",
":",
"class",
"FakeDict",
"(",
"object",
")",
":",
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"seen_keys",
"=",
"set",
"(",
")",
"def",
"__getitem__",
"(",
"self",
",",
"key",
")",
":",
"self",
... | 85f16c8cc0883f8abb4c2cc7f69729c3e2f857da |
train | iso_mesh_line | Generate an isocurve from vertex data in a surface mesh.
Parameters
----------
vertices : ndarray, shape (Nv, 3)
Vertex coordinates.
tris : ndarray, shape (Nf, 3)
Indices of triangular element into the vertices array.
vertex_data : ndarray, shape (Nv,)
data at vertex.
le... | glue_vispy_viewers/extern/vispy/visuals/isoline.py | def iso_mesh_line(vertices, tris, vertex_data, levels):
"""Generate an isocurve from vertex data in a surface mesh.
Parameters
----------
vertices : ndarray, shape (Nv, 3)
Vertex coordinates.
tris : ndarray, shape (Nf, 3)
Indices of triangular element into the vertices array.
ve... | def iso_mesh_line(vertices, tris, vertex_data, levels):
"""Generate an isocurve from vertex data in a surface mesh.
Parameters
----------
vertices : ndarray, shape (Nv, 3)
Vertex coordinates.
tris : ndarray, shape (Nf, 3)
Indices of triangular element into the vertices array.
ve... | [
"Generate",
"an",
"isocurve",
"from",
"vertex",
"data",
"in",
"a",
"surface",
"mesh",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/isoline.py#L14-L91 | [
"def",
"iso_mesh_line",
"(",
"vertices",
",",
"tris",
",",
"vertex_data",
",",
"levels",
")",
":",
"lines",
"=",
"None",
"connects",
"=",
"None",
"vertex_level",
"=",
"None",
"level_index",
"=",
"None",
"if",
"not",
"all",
"(",
"[",
"isinstance",
"(",
"x... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | IsolineVisual.set_data | Set the data
Parameters
----------
vertices : ndarray, shape (Nv, 3) | None
Vertex coordinates.
tris : ndarray, shape (Nf, 3) | None
Indices into the vertex array.
data : ndarray, shape (Nv,) | None
scalar at vertices | glue_vispy_viewers/extern/vispy/visuals/isoline.py | def set_data(self, vertices=None, tris=None, data=None):
"""Set the data
Parameters
----------
vertices : ndarray, shape (Nv, 3) | None
Vertex coordinates.
tris : ndarray, shape (Nf, 3) | None
Indices into the vertex array.
data : ndarray, shape (... | def set_data(self, vertices=None, tris=None, data=None):
"""Set the data
Parameters
----------
vertices : ndarray, shape (Nv, 3) | None
Vertex coordinates.
tris : ndarray, shape (Nf, 3) | None
Indices into the vertex array.
data : ndarray, shape (... | [
"Set",
"the",
"data"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/isoline.py#L150-L172 | [
"def",
"set_data",
"(",
"self",
",",
"vertices",
"=",
"None",
",",
"tris",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"# modifier pour tenier compte des None self._recompute = True",
"if",
"data",
"is",
"not",
"None",
":",
"self",
".",
"_data",
"=",
"d... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | IsolineVisual.set_color | Set the color
Parameters
----------
color : instance of Color
The color to use. | glue_vispy_viewers/extern/vispy/visuals/isoline.py | def set_color(self, color):
"""Set the color
Parameters
----------
color : instance of Color
The color to use.
"""
if color is not None:
self._color_lev = color
self._need_color_update = True
self.update() | def set_color(self, color):
"""Set the color
Parameters
----------
color : instance of Color
The color to use.
"""
if color is not None:
self._color_lev = color
self._need_color_update = True
self.update() | [
"Set",
"the",
"color"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/isoline.py#L178-L189 | [
"def",
"set_color",
"(",
"self",
",",
"color",
")",
":",
"if",
"color",
"is",
"not",
"None",
":",
"self",
".",
"_color_lev",
"=",
"color",
"self",
".",
"_need_color_update",
"=",
"True",
"self",
".",
"update",
"(",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | IsolineVisual._compute_iso_color | compute LineVisual color from level index and corresponding level
color | glue_vispy_viewers/extern/vispy/visuals/isoline.py | def _compute_iso_color(self):
""" compute LineVisual color from level index and corresponding level
color
"""
level_color = []
colors = self._lc
for i, index in enumerate(self._li):
level_color.append(np.zeros((index, 4)) + colors[i])
self._cl = np.vst... | def _compute_iso_color(self):
""" compute LineVisual color from level index and corresponding level
color
"""
level_color = []
colors = self._lc
for i, index in enumerate(self._li):
level_color.append(np.zeros((index, 4)) + colors[i])
self._cl = np.vst... | [
"compute",
"LineVisual",
"color",
"from",
"level",
"index",
"and",
"corresponding",
"level",
"color"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/isoline.py#L214-L222 | [
"def",
"_compute_iso_color",
"(",
"self",
")",
":",
"level_color",
"=",
"[",
"]",
"colors",
"=",
"self",
".",
"_lc",
"for",
"i",
",",
"index",
"in",
"enumerate",
"(",
"self",
".",
"_li",
")",
":",
"level_color",
".",
"append",
"(",
"np",
".",
"zeros"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | VolumeLayerArtist.remove | Remove the layer artist for good | glue_vispy_viewers/volume/layer_artist.py | def remove(self):
"""
Remove the layer artist for good
"""
self._multivol.deallocate(self.id)
ARRAY_CACHE.pop(self.id, None)
PIXEL_CACHE.pop(self.id, None) | def remove(self):
"""
Remove the layer artist for good
"""
self._multivol.deallocate(self.id)
ARRAY_CACHE.pop(self.id, None)
PIXEL_CACHE.pop(self.id, None) | [
"Remove",
"the",
"layer",
"artist",
"for",
"good"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/volume/layer_artist.py#L151-L157 | [
"def",
"remove",
"(",
"self",
")",
":",
"self",
".",
"_multivol",
".",
"deallocate",
"(",
"self",
".",
"id",
")",
"ARRAY_CACHE",
".",
"pop",
"(",
"self",
".",
"id",
",",
"None",
")",
"PIXEL_CACHE",
".",
"pop",
"(",
"self",
".",
"id",
",",
"None",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _inject | Inject functions and constants from PyOpenGL but leave out the
names that are deprecated or that we provide in our API. | glue_vispy_viewers/extern/vispy/gloo/gl/glplus.py | def _inject():
""" Inject functions and constants from PyOpenGL but leave out the
names that are deprecated or that we provide in our API.
"""
# Get namespaces
NS = globals()
GLNS = _GL.__dict__
# Get names that we use in our API
used_names = []
used_names.extend([names[0] ... | def _inject():
""" Inject functions and constants from PyOpenGL but leave out the
names that are deprecated or that we provide in our API.
"""
# Get namespaces
NS = globals()
GLNS = _GL.__dict__
# Get names that we use in our API
used_names = []
used_names.extend([names[0] ... | [
"Inject",
"functions",
"and",
"constants",
"from",
"PyOpenGL",
"but",
"leave",
"out",
"the",
"names",
"that",
"are",
"deprecated",
"or",
"that",
"we",
"provide",
"in",
"our",
"API",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/gl/glplus.py#L17-L53 | [
"def",
"_inject",
"(",
")",
":",
"# Get namespaces",
"NS",
"=",
"globals",
"(",
")",
"GLNS",
"=",
"_GL",
".",
"__dict__",
"# Get names that we use in our API",
"used_names",
"=",
"[",
"]",
"used_names",
".",
"extend",
"(",
"[",
"names",
"[",
"0",
"]",
"for... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _find_module | Alternative to `imp.find_module` that can also search in subpackages. | glue_vispy_viewers/extern/vispy/ext/six.py | def _find_module(name, path=None):
"""
Alternative to `imp.find_module` that can also search in subpackages.
"""
parts = name.split('.')
for part in parts:
if path is not None:
path = [path]
fh, path, descr = imp.find_module(part, path)
if fh is not None and pa... | def _find_module(name, path=None):
"""
Alternative to `imp.find_module` that can also search in subpackages.
"""
parts = name.split('.')
for part in parts:
if path is not None:
path = [path]
fh, path, descr = imp.find_module(part, path)
if fh is not None and pa... | [
"Alternative",
"to",
"imp",
".",
"find_module",
"that",
"can",
"also",
"search",
"in",
"subpackages",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/six.py#L25-L40 | [
"def",
"_find_module",
"(",
"name",
",",
"path",
"=",
"None",
")",
":",
"parts",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"for",
"part",
"in",
"parts",
":",
"if",
"path",
"is",
"not",
"None",
":",
"path",
"=",
"[",
"path",
"]",
"fh",
",",
"p... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | triangulate | Triangulate a set of vertices
Parameters
----------
vertices : array-like
The vertices.
Returns
-------
vertices : array-like
The vertices.
tringles : array-like
The triangles. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def triangulate(vertices):
"""Triangulate a set of vertices
Parameters
----------
vertices : array-like
The vertices.
Returns
-------
vertices : array-like
The vertices.
tringles : array-like
The triangles.
"""
n = len(vertices)
vertices = np.asarray... | def triangulate(vertices):
"""Triangulate a set of vertices
Parameters
----------
vertices : array-like
The vertices.
Returns
-------
vertices : array-like
The vertices.
tringles : array-like
The triangles.
"""
n = len(vertices)
vertices = np.asarray... | [
"Triangulate",
"a",
"set",
"of",
"vertices"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L999-L1029 | [
"def",
"triangulate",
"(",
"vertices",
")",
":",
"n",
"=",
"len",
"(",
"vertices",
")",
"vertices",
"=",
"np",
".",
"asarray",
"(",
"vertices",
")",
"zmean",
"=",
"vertices",
"[",
":",
",",
"2",
"]",
".",
"mean",
"(",
")",
"vertices_2d",
"=",
"vert... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation.triangulate | Do the triangulation | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def triangulate(self):
"""Do the triangulation
"""
self._initialize()
pts = self.pts
front = self._front
## Begin sweep (sec. 3.4)
for i in range(3, pts.shape[0]):
pi = pts[i]
#debug("========== New point %d: %s ==========... | def triangulate(self):
"""Do the triangulation
"""
self._initialize()
pts = self.pts
front = self._front
## Begin sweep (sec. 3.4)
for i in range(3, pts.shape[0]):
pi = pts[i]
#debug("========== New point %d: %s ==========... | [
"Do",
"the",
"triangulation"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L128-L214 | [
"def",
"triangulate",
"(",
"self",
")",
":",
"self",
".",
"_initialize",
"(",
")",
"pts",
"=",
"self",
".",
"pts",
"front",
"=",
"self",
".",
"_front",
"## Begin sweep (sec. 3.4)",
"for",
"i",
"in",
"range",
"(",
"3",
",",
"pts",
".",
"shape",
"[",
"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._edge_event | Force edge (i, j) to be present in mesh.
This works by removing intersected triangles and filling holes up to
the cutting edge. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _edge_event(self, i, j):
"""
Force edge (i, j) to be present in mesh.
This works by removing intersected triangles and filling holes up to
the cutting edge.
"""
front_index = self._front.index(i)
#debug(" == edge event ==")
front = self._fro... | def _edge_event(self, i, j):
"""
Force edge (i, j) to be present in mesh.
This works by removing intersected triangles and filling holes up to
the cutting edge.
"""
front_index = self._front.index(i)
#debug(" == edge event ==")
front = self._fro... | [
"Force",
"edge",
"(",
"i",
"j",
")",
"to",
"be",
"present",
"in",
"mesh",
".",
"This",
"works",
"by",
"removing",
"intersected",
"triangles",
"and",
"filling",
"holes",
"up",
"to",
"the",
"cutting",
"edge",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L279-L493 | [
"def",
"_edge_event",
"(",
"self",
",",
"i",
",",
"j",
")",
":",
"front_index",
"=",
"self",
".",
"_front",
".",
"index",
"(",
"i",
")",
"#debug(\" == edge event ==\")",
"front",
"=",
"self",
".",
"_front",
"# First just see whether this edge is already present",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._find_cut_triangle | Return the triangle that has edge[0] as one of its vertices and is
bisected by edge.
Return None if no triangle is found. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _find_cut_triangle(self, edge):
"""
Return the triangle that has edge[0] as one of its vertices and is
bisected by edge.
Return None if no triangle is found.
"""
edges = [] # opposite edge for each triangle attached to edge[0]
for tri in self.tris:
... | def _find_cut_triangle(self, edge):
"""
Return the triangle that has edge[0] as one of its vertices and is
bisected by edge.
Return None if no triangle is found.
"""
edges = [] # opposite edge for each triangle attached to edge[0]
for tri in self.tris:
... | [
"Return",
"the",
"triangle",
"that",
"has",
"edge",
"[",
"0",
"]",
"as",
"one",
"of",
"its",
"vertices",
"and",
"is",
"bisected",
"by",
"edge",
".",
"Return",
"None",
"if",
"no",
"triangle",
"is",
"found",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L497-L518 | [
"def",
"_find_cut_triangle",
"(",
"self",
",",
"edge",
")",
":",
"edges",
"=",
"[",
"]",
"# opposite edge for each triangle attached to edge[0]",
"for",
"tri",
"in",
"self",
".",
"tris",
":",
"if",
"edge",
"[",
"0",
"]",
"in",
"tri",
":",
"edges",
".",
"ap... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._edge_in_front | Return the index where *edge* appears in the current front.
If the edge is not in the front, return -1 | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _edge_in_front(self, edge):
""" Return the index where *edge* appears in the current front.
If the edge is not in the front, return -1
"""
e = (list(edge), list(edge)[::-1])
for i in range(len(self._front)-1):
if self._front[i:i+2] in e:
return i
... | def _edge_in_front(self, edge):
""" Return the index where *edge* appears in the current front.
If the edge is not in the front, return -1
"""
e = (list(edge), list(edge)[::-1])
for i in range(len(self._front)-1):
if self._front[i:i+2] in e:
return i
... | [
"Return",
"the",
"index",
"where",
"*",
"edge",
"*",
"appears",
"in",
"the",
"current",
"front",
".",
"If",
"the",
"edge",
"is",
"not",
"in",
"the",
"front",
"return",
"-",
"1"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L520-L528 | [
"def",
"_edge_in_front",
"(",
"self",
",",
"edge",
")",
":",
"e",
"=",
"(",
"list",
"(",
"edge",
")",
",",
"list",
"(",
"edge",
")",
"[",
":",
":",
"-",
"1",
"]",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"_front",
")",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._edge_opposite_point | Given a triangle, return the edge that is opposite point i.
Vertexes are returned in the same orientation as in tri. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _edge_opposite_point(self, tri, i):
""" Given a triangle, return the edge that is opposite point i.
Vertexes are returned in the same orientation as in tri.
"""
ind = tri.index(i)
return (tri[(ind+1) % 3], tri[(ind+2) % 3]) | def _edge_opposite_point(self, tri, i):
""" Given a triangle, return the edge that is opposite point i.
Vertexes are returned in the same orientation as in tri.
"""
ind = tri.index(i)
return (tri[(ind+1) % 3], tri[(ind+2) % 3]) | [
"Given",
"a",
"triangle",
"return",
"the",
"edge",
"that",
"is",
"opposite",
"point",
"i",
".",
"Vertexes",
"are",
"returned",
"in",
"the",
"same",
"orientation",
"as",
"in",
"tri",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L530-L535 | [
"def",
"_edge_opposite_point",
"(",
"self",
",",
"tri",
",",
"i",
")",
":",
"ind",
"=",
"tri",
".",
"index",
"(",
"i",
")",
"return",
"(",
"tri",
"[",
"(",
"ind",
"+",
"1",
")",
"%",
"3",
"]",
",",
"tri",
"[",
"(",
"ind",
"+",
"2",
")",
"%"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._adjacent_tri | Given a triangle formed by edge and i, return the triangle that shares
edge. *i* may be either a point or the entire triangle. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _adjacent_tri(self, edge, i):
"""
Given a triangle formed by edge and i, return the triangle that shares
edge. *i* may be either a point or the entire triangle.
"""
if not np.isscalar(i):
i = [x for x in i if x not in edge][0]
try:
pt1 = self.... | def _adjacent_tri(self, edge, i):
"""
Given a triangle formed by edge and i, return the triangle that shares
edge. *i* may be either a point or the entire triangle.
"""
if not np.isscalar(i):
i = [x for x in i if x not in edge][0]
try:
pt1 = self.... | [
"Given",
"a",
"triangle",
"formed",
"by",
"edge",
"and",
"i",
"return",
"the",
"triangle",
"that",
"shares",
"edge",
".",
"*",
"i",
"*",
"may",
"be",
"either",
"a",
"point",
"or",
"the",
"entire",
"triangle",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L537-L557 | [
"def",
"_adjacent_tri",
"(",
"self",
",",
"edge",
",",
"i",
")",
":",
"if",
"not",
"np",
".",
"isscalar",
"(",
"i",
")",
":",
"i",
"=",
"[",
"x",
"for",
"x",
"in",
"i",
"if",
"x",
"not",
"in",
"edge",
"]",
"[",
"0",
"]",
"try",
":",
"pt1",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._tri_from_edge | Return the only tri that contains *edge*. If two tris share this
edge, raise an exception. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _tri_from_edge(self, edge):
"""Return the only tri that contains *edge*. If two tris share this
edge, raise an exception.
"""
edge = tuple(edge)
p1 = self._edges_lookup.get(edge, None)
p2 = self._edges_lookup.get(edge[::-1], None)
if p1 is None:
if... | def _tri_from_edge(self, edge):
"""Return the only tri that contains *edge*. If two tris share this
edge, raise an exception.
"""
edge = tuple(edge)
p1 = self._edges_lookup.get(edge, None)
p2 = self._edges_lookup.get(edge[::-1], None)
if p1 is None:
if... | [
"Return",
"the",
"only",
"tri",
"that",
"contains",
"*",
"edge",
"*",
".",
"If",
"two",
"tris",
"share",
"this",
"edge",
"raise",
"an",
"exception",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L559-L573 | [
"def",
"_tri_from_edge",
"(",
"self",
",",
"edge",
")",
":",
"edge",
"=",
"tuple",
"(",
"edge",
")",
"p1",
"=",
"self",
".",
"_edges_lookup",
".",
"get",
"(",
"edge",
",",
"None",
")",
"p2",
"=",
"self",
".",
"_edges_lookup",
".",
"get",
"(",
"edge... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._edges_in_tri_except | Return the edges in *tri*, excluding *edge*. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _edges_in_tri_except(self, tri, edge):
"""Return the edges in *tri*, excluding *edge*.
"""
edges = [(tri[i], tri[(i+1) % 3]) for i in range(3)]
try:
edges.remove(tuple(edge))
except ValueError:
edges.remove(tuple(edge[::-1]))
return edges | def _edges_in_tri_except(self, tri, edge):
"""Return the edges in *tri*, excluding *edge*.
"""
edges = [(tri[i], tri[(i+1) % 3]) for i in range(3)]
try:
edges.remove(tuple(edge))
except ValueError:
edges.remove(tuple(edge[::-1]))
return edges | [
"Return",
"the",
"edges",
"in",
"*",
"tri",
"*",
"excluding",
"*",
"edge",
"*",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L575-L583 | [
"def",
"_edges_in_tri_except",
"(",
"self",
",",
"tri",
",",
"edge",
")",
":",
"edges",
"=",
"[",
"(",
"tri",
"[",
"i",
"]",
",",
"tri",
"[",
"(",
"i",
"+",
"1",
")",
"%",
"3",
"]",
")",
"for",
"i",
"in",
"range",
"(",
"3",
")",
"]",
"try",... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._edge_below_front | Return True if *edge* is below the current front.
One of the points in *edge* must be _on_ the front, at *front_index*. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _edge_below_front(self, edge, front_index):
"""Return True if *edge* is below the current front.
One of the points in *edge* must be _on_ the front, at *front_index*.
"""
f0 = self._front[front_index-1]
f1 = self._front[front_index+1]
return (self._orientati... | def _edge_below_front(self, edge, front_index):
"""Return True if *edge* is below the current front.
One of the points in *edge* must be _on_ the front, at *front_index*.
"""
f0 = self._front[front_index-1]
f1 = self._front[front_index+1]
return (self._orientati... | [
"Return",
"True",
"if",
"*",
"edge",
"*",
"is",
"below",
"the",
"current",
"front",
".",
"One",
"of",
"the",
"points",
"in",
"*",
"edge",
"*",
"must",
"be",
"_on_",
"the",
"front",
"at",
"*",
"front_index",
"*",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L585-L593 | [
"def",
"_edge_below_front",
"(",
"self",
",",
"edge",
",",
"front_index",
")",
":",
"f0",
"=",
"self",
".",
"_front",
"[",
"front_index",
"-",
"1",
"]",
"f1",
"=",
"self",
".",
"_front",
"[",
"front_index",
"+",
"1",
"]",
"return",
"(",
"self",
".",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._intersected_edge | Given a list of *edges*, return the first that is intersected by
*cut_edge*. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _intersected_edge(self, edges, cut_edge):
""" Given a list of *edges*, return the first that is intersected by
*cut_edge*.
"""
for edge in edges:
if self._edges_intersect(edge, cut_edge):
return edge | def _intersected_edge(self, edges, cut_edge):
""" Given a list of *edges*, return the first that is intersected by
*cut_edge*.
"""
for edge in edges:
if self._edges_intersect(edge, cut_edge):
return edge | [
"Given",
"a",
"list",
"of",
"*",
"edges",
"*",
"return",
"the",
"first",
"that",
"is",
"intersected",
"by",
"*",
"cut_edge",
"*",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L601-L607 | [
"def",
"_intersected_edge",
"(",
"self",
",",
"edges",
",",
"cut_edge",
")",
":",
"for",
"edge",
"in",
"edges",
":",
"if",
"self",
".",
"_edges_intersect",
"(",
"edge",
",",
"cut_edge",
")",
":",
"return",
"edge"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._find_edge_intersections | Return a dictionary containing, for each edge in self.edges, a list
of the positions at which the edge should be split. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _find_edge_intersections(self):
"""
Return a dictionary containing, for each edge in self.edges, a list
of the positions at which the edge should be split.
"""
edges = self.pts[self.edges]
cuts = {} # { edge: [(intercept, point), ...], ... }
for i in range(ed... | def _find_edge_intersections(self):
"""
Return a dictionary containing, for each edge in self.edges, a list
of the positions at which the edge should be split.
"""
edges = self.pts[self.edges]
cuts = {} # { edge: [(intercept, point), ...], ... }
for i in range(ed... | [
"Return",
"a",
"dictionary",
"containing",
"for",
"each",
"edge",
"in",
"self",
".",
"edges",
"a",
"list",
"of",
"the",
"positions",
"at",
"which",
"the",
"edge",
"should",
"be",
"split",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L609-L655 | [
"def",
"_find_edge_intersections",
"(",
"self",
")",
":",
"edges",
"=",
"self",
".",
"pts",
"[",
"self",
".",
"edges",
"]",
"cuts",
"=",
"{",
"}",
"# { edge: [(intercept, point), ...], ... }",
"for",
"i",
"in",
"range",
"(",
"edges",
".",
"shape",
"[",
"0"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._projection | Return projection of (a,b) onto (a,c)
Arguments are point locations, not indexes. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _projection(self, a, b, c):
"""Return projection of (a,b) onto (a,c)
Arguments are point locations, not indexes.
"""
ab = b - a
ac = c - a
return a + ((ab*ac).sum() / (ac*ac).sum()) * ac | def _projection(self, a, b, c):
"""Return projection of (a,b) onto (a,c)
Arguments are point locations, not indexes.
"""
ab = b - a
ac = c - a
return a + ((ab*ac).sum() / (ac*ac).sum()) * ac | [
"Return",
"projection",
"of",
"(",
"a",
"b",
")",
"onto",
"(",
"a",
"c",
")",
"Arguments",
"are",
"point",
"locations",
"not",
"indexes",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L760-L766 | [
"def",
"_projection",
"(",
"self",
",",
"a",
",",
"b",
",",
"c",
")",
":",
"ab",
"=",
"b",
"-",
"a",
"ac",
"=",
"c",
"-",
"a",
"return",
"a",
"+",
"(",
"(",
"ab",
"*",
"ac",
")",
".",
"sum",
"(",
")",
"/",
"(",
"ac",
"*",
"ac",
")",
"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._edges_intersect | Return 1 if edges intersect completely (endpoints excluded) | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _edges_intersect(self, edge1, edge2):
"""
Return 1 if edges intersect completely (endpoints excluded)
"""
h12 = self._intersect_edge_arrays(self.pts[np.array(edge1)],
self.pts[np.array(edge2)])
h21 = self._intersect_edge_arrays(self.... | def _edges_intersect(self, edge1, edge2):
"""
Return 1 if edges intersect completely (endpoints excluded)
"""
h12 = self._intersect_edge_arrays(self.pts[np.array(edge1)],
self.pts[np.array(edge2)])
h21 = self._intersect_edge_arrays(self.... | [
"Return",
"1",
"if",
"edges",
"intersect",
"completely",
"(",
"endpoints",
"excluded",
")"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L809-L823 | [
"def",
"_edges_intersect",
"(",
"self",
",",
"edge1",
",",
"edge2",
")",
":",
"h12",
"=",
"self",
".",
"_intersect_edge_arrays",
"(",
"self",
".",
"pts",
"[",
"np",
".",
"array",
"(",
"edge1",
")",
"]",
",",
"self",
".",
"pts",
"[",
"np",
".",
"arr... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._intersection_matrix | Return a 2D array of intercepts such that
intercepts[i, j] is the intercept of lines[i] onto lines[j].
*lines* must be an array of point locations with shape (N, 2, 2), where
the axes are (lines, points_per_line, xy_per_point).
The intercept is described in intersect_e... | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _intersection_matrix(self, lines):
"""
Return a 2D array of intercepts such that
intercepts[i, j] is the intercept of lines[i] onto lines[j].
*lines* must be an array of point locations with shape (N, 2, 2), where
the axes are (lines, points_per_line, xy_per_point).... | def _intersection_matrix(self, lines):
"""
Return a 2D array of intercepts such that
intercepts[i, j] is the intercept of lines[i] onto lines[j].
*lines* must be an array of point locations with shape (N, 2, 2), where
the axes are (lines, points_per_line, xy_per_point).... | [
"Return",
"a",
"2D",
"array",
"of",
"intercepts",
"such",
"that",
"intercepts",
"[",
"i",
"j",
"]",
"is",
"the",
"intercept",
"of",
"lines",
"[",
"i",
"]",
"onto",
"lines",
"[",
"j",
"]",
".",
"*",
"lines",
"*",
"must",
"be",
"an",
"array",
"of",
... | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L825-L836 | [
"def",
"_intersection_matrix",
"(",
"self",
",",
"lines",
")",
":",
"return",
"self",
".",
"_intersect_edge_arrays",
"(",
"lines",
"[",
":",
",",
"np",
".",
"newaxis",
",",
"...",
"]",
",",
"lines",
"[",
"np",
".",
"newaxis",
",",
"...",
"]",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._intersect_edge_arrays | Return the intercepts of all lines defined in *lines1* as they
intersect all lines in *lines2*.
Arguments are of shape (..., 2, 2), where axes are:
0: number of lines
1: two points per line
2: x,y pair per point
Lines are compared elementwise across t... | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _intersect_edge_arrays(self, lines1, lines2):
"""Return the intercepts of all lines defined in *lines1* as they
intersect all lines in *lines2*.
Arguments are of shape (..., 2, 2), where axes are:
0: number of lines
1: two points per line
2: x,y pa... | def _intersect_edge_arrays(self, lines1, lines2):
"""Return the intercepts of all lines defined in *lines1* as they
intersect all lines in *lines2*.
Arguments are of shape (..., 2, 2), where axes are:
0: number of lines
1: two points per line
2: x,y pa... | [
"Return",
"the",
"intercepts",
"of",
"all",
"lines",
"defined",
"in",
"*",
"lines1",
"*",
"as",
"they",
"intersect",
"all",
"lines",
"in",
"*",
"lines2",
"*",
".",
"Arguments",
"are",
"of",
"shape",
"(",
"...",
"2",
"2",
")",
"where",
"axes",
"are",
... | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L838-L878 | [
"def",
"_intersect_edge_arrays",
"(",
"self",
",",
"lines1",
",",
"lines2",
")",
":",
"# vector for each line in lines1",
"l1",
"=",
"lines1",
"[",
"...",
",",
"1",
",",
":",
"]",
"-",
"lines1",
"[",
"...",
",",
"0",
",",
":",
"]",
"# vector for each line ... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Triangulation._orientation | Returns +1 if edge[0]->point is clockwise from edge[0]->edge[1],
-1 if counterclockwise, and 0 if parallel. | glue_vispy_viewers/extern/vispy/geometry/triangulation.py | def _orientation(self, edge, point):
""" Returns +1 if edge[0]->point is clockwise from edge[0]->edge[1],
-1 if counterclockwise, and 0 if parallel.
"""
v1 = self.pts[point] - self.pts[edge[0]]
v2 = self.pts[edge[1]] - self.pts[edge[0]]
c = np.cross(v1, v2) # positive i... | def _orientation(self, edge, point):
""" Returns +1 if edge[0]->point is clockwise from edge[0]->edge[1],
-1 if counterclockwise, and 0 if parallel.
"""
v1 = self.pts[point] - self.pts[edge[0]]
v2 = self.pts[edge[1]] - self.pts[edge[0]]
c = np.cross(v1, v2) # positive i... | [
"Returns",
"+",
"1",
"if",
"edge",
"[",
"0",
"]",
"-",
">",
"point",
"is",
"clockwise",
"from",
"edge",
"[",
"0",
"]",
"-",
">",
"edge",
"[",
"1",
"]",
"-",
"1",
"if",
"counterclockwise",
"and",
"0",
"if",
"parallel",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/geometry/triangulation.py#L880-L887 | [
"def",
"_orientation",
"(",
"self",
",",
"edge",
",",
"point",
")",
":",
"v1",
"=",
"self",
".",
"pts",
"[",
"point",
"]",
"-",
"self",
".",
"pts",
"[",
"edge",
"[",
"0",
"]",
"]",
"v2",
"=",
"self",
".",
"pts",
"[",
"edge",
"[",
"1",
"]",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | load_ipython_extension | Entry point of the IPython extension
Parameters
----------
IPython : IPython interpreter
An instance of the IPython interpreter that is handed
over to the extension | glue_vispy_viewers/extern/vispy/ipython/ipython.py | def load_ipython_extension(ipython):
""" Entry point of the IPython extension
Parameters
----------
IPython : IPython interpreter
An instance of the IPython interpreter that is handed
over to the extension
"""
import IPython
# don't continue if IPython version is < 3.0
... | def load_ipython_extension(ipython):
""" Entry point of the IPython extension
Parameters
----------
IPython : IPython interpreter
An instance of the IPython interpreter that is handed
over to the extension
"""
import IPython
# don't continue if IPython version is < 3.0
... | [
"Entry",
"point",
"of",
"the",
"IPython",
"extension"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ipython/ipython.py#L9-L30 | [
"def",
"load_ipython_extension",
"(",
"ipython",
")",
":",
"import",
"IPython",
"# don't continue if IPython version is < 3.0",
"ipy_version",
"=",
"LooseVersion",
"(",
"IPython",
".",
"__version__",
")",
"if",
"ipy_version",
"<",
"LooseVersion",
"(",
"\"3.0.0\"",
")",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _load_webgl_backend | Load the webgl backend for the IPython notebook | glue_vispy_viewers/extern/vispy/ipython/ipython.py | def _load_webgl_backend(ipython):
""" Load the webgl backend for the IPython notebook"""
from .. import app
app_instance = app.use_app("ipynb_webgl")
if app_instance.backend_name == "ipynb_webgl":
ipython.write("Vispy IPython module has loaded successfully")
else:
# TODO: Improve t... | def _load_webgl_backend(ipython):
""" Load the webgl backend for the IPython notebook"""
from .. import app
app_instance = app.use_app("ipynb_webgl")
if app_instance.backend_name == "ipynb_webgl":
ipython.write("Vispy IPython module has loaded successfully")
else:
# TODO: Improve t... | [
"Load",
"the",
"webgl",
"backend",
"for",
"the",
"IPython",
"notebook"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ipython/ipython.py#L33-L43 | [
"def",
"_load_webgl_backend",
"(",
"ipython",
")",
":",
"from",
".",
".",
"import",
"app",
"app_instance",
"=",
"app",
".",
"use_app",
"(",
"\"ipynb_webgl\"",
")",
"if",
"app_instance",
".",
"backend_name",
"==",
"\"ipynb_webgl\"",
":",
"ipython",
".",
"write"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Collection.draw | Draw collection | glue_vispy_viewers/extern/vispy/visuals/collections/collection.py | def draw(self, mode=None):
""" Draw collection """
if self._need_update:
self._update()
program = self._programs[0]
mode = mode or self._mode
if self._indices_list is not None:
program.draw(mode, self._indices_buffer)
else:
program.d... | def draw(self, mode=None):
""" Draw collection """
if self._need_update:
self._update()
program = self._programs[0]
mode = mode or self._mode
if self._indices_list is not None:
program.draw(mode, self._indices_buffer)
else:
program.d... | [
"Draw",
"collection"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/collection.py#L197-L209 | [
"def",
"draw",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"if",
"self",
".",
"_need_update",
":",
"self",
".",
"_update",
"(",
")",
"program",
"=",
"self",
".",
"_programs",
"[",
"0",
"]",
"mode",
"=",
"mode",
"or",
"self",
".",
"_mode",
"i... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | gaussian_filter | Drop-in replacement for scipy.ndimage.gaussian_filter.
(note: results are only approximately equal to the output of
gaussian_filter) | glue_vispy_viewers/extern/vispy/util/filter.py | def gaussian_filter(data, sigma):
"""
Drop-in replacement for scipy.ndimage.gaussian_filter.
(note: results are only approximately equal to the output of
gaussian_filter)
"""
if np.isscalar(sigma):
sigma = (sigma,) * data.ndim
baseline = data.mean()
filtered = data - baseline
... | def gaussian_filter(data, sigma):
"""
Drop-in replacement for scipy.ndimage.gaussian_filter.
(note: results are only approximately equal to the output of
gaussian_filter)
"""
if np.isscalar(sigma):
sigma = (sigma,) * data.ndim
baseline = data.mean()
filtered = data - baseline
... | [
"Drop",
"-",
"in",
"replacement",
"for",
"scipy",
".",
"ndimage",
".",
"gaussian_filter",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/filter.py#L8-L44 | [
"def",
"gaussian_filter",
"(",
"data",
",",
"sigma",
")",
":",
"if",
"np",
".",
"isscalar",
"(",
"sigma",
")",
":",
"sigma",
"=",
"(",
"sigma",
",",
")",
"*",
"data",
".",
"ndim",
"baseline",
"=",
"data",
".",
"mean",
"(",
")",
"filtered",
"=",
"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.