repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
vatlab/SoS | src/sos/section_analyzer.py | get_step_output | def get_step_output(section, default_output):
'''determine step output'''
step_output: sos_targets = sos_targets()
#
if 'provides' in section.options and default_output:
step_output = default_output
# look for input statement.
output_idx = find_statement(section, 'output')
if output... | python | def get_step_output(section, default_output):
'''determine step output'''
step_output: sos_targets = sos_targets()
#
if 'provides' in section.options and default_output:
step_output = default_output
# look for input statement.
output_idx = find_statement(section, 'output')
if output... | [
"def",
"get_step_output",
"(",
"section",
",",
"default_output",
")",
":",
"step_output",
":",
"sos_targets",
"=",
"sos_targets",
"(",
")",
"if",
"'provides'",
"in",
"section",
".",
"options",
"and",
"default_output",
":",
"step_output",
"=",
"default_output",
"... | determine step output | [
"determine",
"step",
"output"
] | 6b60ed0770916d135e17322e469520d778e9d4e7 | https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/src/sos/section_analyzer.py#L394-L448 | train |
vatlab/SoS | src/sos/section_analyzer.py | analyze_section | def analyze_section(section: SoS_Step,
default_input: Optional[sos_targets] = None,
default_output: Optional[sos_targets] = None,
context={},
vars_and_output_only: bool = False) -> Dict[str, Any]:
'''Analyze a section for how it uses in... | python | def analyze_section(section: SoS_Step,
default_input: Optional[sos_targets] = None,
default_output: Optional[sos_targets] = None,
context={},
vars_and_output_only: bool = False) -> Dict[str, Any]:
'''Analyze a section for how it uses in... | [
"def",
"analyze_section",
"(",
"section",
":",
"SoS_Step",
",",
"default_input",
":",
"Optional",
"[",
"sos_targets",
"]",
"=",
"None",
",",
"default_output",
":",
"Optional",
"[",
"sos_targets",
"]",
"=",
"None",
",",
"context",
"=",
"{",
"}",
",",
"vars_... | Analyze a section for how it uses input and output, what variables
it uses, and input, output, etc. | [
"Analyze",
"a",
"section",
"for",
"how",
"it",
"uses",
"input",
"and",
"output",
"what",
"variables",
"it",
"uses",
"and",
"input",
"output",
"etc",
"."
] | 6b60ed0770916d135e17322e469520d778e9d4e7 | https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/src/sos/section_analyzer.py#L514-L569 | train |
vatlab/SoS | src/sos/converter.py | extract_workflow | def extract_workflow(notebook):
'''Extract workflow from a notebook file or notebook JSON instance'''
if isinstance(notebook, str):
nb = nbformat.read(notebook, nbformat.NO_CONVERT)
else:
nb = notebook
cells = nb.cells
content = '#!/usr/bin/env sos-runner\n#fileformat=SOS1.0\n\n'
... | python | def extract_workflow(notebook):
'''Extract workflow from a notebook file or notebook JSON instance'''
if isinstance(notebook, str):
nb = nbformat.read(notebook, nbformat.NO_CONVERT)
else:
nb = notebook
cells = nb.cells
content = '#!/usr/bin/env sos-runner\n#fileformat=SOS1.0\n\n'
... | [
"def",
"extract_workflow",
"(",
"notebook",
")",
":",
"if",
"isinstance",
"(",
"notebook",
",",
"str",
")",
":",
"nb",
"=",
"nbformat",
".",
"read",
"(",
"notebook",
",",
"nbformat",
".",
"NO_CONVERT",
")",
"else",
":",
"nb",
"=",
"notebook",
"cells",
... | Extract workflow from a notebook file or notebook JSON instance | [
"Extract",
"workflow",
"from",
"a",
"notebook",
"file",
"or",
"notebook",
"JSON",
"instance"
] | 6b60ed0770916d135e17322e469520d778e9d4e7 | https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/src/sos/converter.py#L166-L199 | train |
vatlab/SoS | misc/vim-ipython/vim_ipython.py | vim_ipython_is_open | def vim_ipython_is_open():
"""
Helper function to let us know if the vim-ipython shell is currently
visible
"""
for w in vim.windows:
if w.buffer.name is not None and w.buffer.name.endswith("vim-ipython"):
return True
return False | python | def vim_ipython_is_open():
"""
Helper function to let us know if the vim-ipython shell is currently
visible
"""
for w in vim.windows:
if w.buffer.name is not None and w.buffer.name.endswith("vim-ipython"):
return True
return False | [
"def",
"vim_ipython_is_open",
"(",
")",
":",
"for",
"w",
"in",
"vim",
".",
"windows",
":",
"if",
"w",
".",
"buffer",
".",
"name",
"is",
"not",
"None",
"and",
"w",
".",
"buffer",
".",
"name",
".",
"endswith",
"(",
"\"vim-ipython\"",
")",
":",
"return"... | Helper function to let us know if the vim-ipython shell is currently
visible | [
"Helper",
"function",
"to",
"let",
"us",
"know",
"if",
"the",
"vim",
"-",
"ipython",
"shell",
"is",
"currently",
"visible"
] | 6b60ed0770916d135e17322e469520d778e9d4e7 | https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/misc/vim-ipython/vim_ipython.py#L345-L353 | train |
vatlab/SoS | misc/vim-ipython/vim_ipython.py | with_subchannel | def with_subchannel(f,*args):
"conditionally monitor subchannel"
def f_with_update(*args):
try:
f(*args)
if monitor_subchannel:
update_subchannel_msgs(force=True)
except AttributeError: #if kc is None
echo("not connected to IPython", 'Error')
... | python | def with_subchannel(f,*args):
"conditionally monitor subchannel"
def f_with_update(*args):
try:
f(*args)
if monitor_subchannel:
update_subchannel_msgs(force=True)
except AttributeError: #if kc is None
echo("not connected to IPython", 'Error')
... | [
"def",
"with_subchannel",
"(",
"f",
",",
"*",
"args",
")",
":",
"\"conditionally monitor subchannel\"",
"def",
"f_with_update",
"(",
"*",
"args",
")",
":",
"try",
":",
"f",
"(",
"*",
"args",
")",
"if",
"monitor_subchannel",
":",
"update_subchannel_msgs",
"(",
... | conditionally monitor subchannel | [
"conditionally",
"monitor",
"subchannel"
] | 6b60ed0770916d135e17322e469520d778e9d4e7 | https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/misc/vim-ipython/vim_ipython.py#L570-L579 | train |
vatlab/SoS | misc/vim-ipython/vim_ipython.py | set_pid | def set_pid():
"""
Explicitly ask the ipython kernel for its pid
"""
global pid
lines = '\n'.join(['import os', '_pid = os.getpid()'])
try:
msg_id = send(lines, silent=True, user_variables=['_pid'])
except TypeError: # change in IPython 3.0+
msg_id = send(lines, silent=True,... | python | def set_pid():
"""
Explicitly ask the ipython kernel for its pid
"""
global pid
lines = '\n'.join(['import os', '_pid = os.getpid()'])
try:
msg_id = send(lines, silent=True, user_variables=['_pid'])
except TypeError: # change in IPython 3.0+
msg_id = send(lines, silent=True,... | [
"def",
"set_pid",
"(",
")",
":",
"global",
"pid",
"lines",
"=",
"'\\n'",
".",
"join",
"(",
"[",
"'import os'",
",",
"'_pid = os.getpid()'",
"]",
")",
"try",
":",
"msg_id",
"=",
"send",
"(",
"lines",
",",
"silent",
"=",
"True",
",",
"user_variables",
"=... | Explicitly ask the ipython kernel for its pid | [
"Explicitly",
"ask",
"the",
"ipython",
"kernel",
"for",
"its",
"pid"
] | 6b60ed0770916d135e17322e469520d778e9d4e7 | https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/misc/vim-ipython/vim_ipython.py#L646-L673 | train |
BradRuderman/pyhs2 | pyhs2/cursor.py | Cursor.fetchmany | def fetchmany(self,size=-1):
""" return a sequential set of records. This is guaranteed by locking,
so that no other thread can grab a few records while a set is fetched.
this has the side effect that other threads may have to wait for
an arbitrary long time for the completion of the curre... | python | def fetchmany(self,size=-1):
""" return a sequential set of records. This is guaranteed by locking,
so that no other thread can grab a few records while a set is fetched.
this has the side effect that other threads may have to wait for
an arbitrary long time for the completion of the curre... | [
"def",
"fetchmany",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"self",
".",
"_cursorLock",
".",
"acquire",
"(",
")",
"if",
"size",
"<",
"0",
"or",
"size",
">",
"self",
".",
"MAX_BLOCK_SIZE",
":",
"size",
"=",
"self",
".",
"arraysize",
"recs... | return a sequential set of records. This is guaranteed by locking,
so that no other thread can grab a few records while a set is fetched.
this has the side effect that other threads may have to wait for
an arbitrary long time for the completion of the current request. | [
"return",
"a",
"sequential",
"set",
"of",
"records",
".",
"This",
"is",
"guaranteed",
"by",
"locking",
"so",
"that",
"no",
"other",
"thread",
"can",
"grab",
"a",
"few",
"records",
"while",
"a",
"set",
"is",
"fetched",
".",
"this",
"has",
"the",
"side",
... | 1094d4b3a1e9032ee17eeb41f3381bbbd95862c1 | https://github.com/BradRuderman/pyhs2/blob/1094d4b3a1e9032ee17eeb41f3381bbbd95862c1/pyhs2/cursor.py#L143-L159 | train |
kashifrazzaqui/json-streamer | jsonstreamer/jsonstreamer.py | JSONStreamer.on_number | def on_number(self, ctx, value):
''' Since this is defined both integer and double callbacks are useless '''
value = int(value) if value.isdigit() else float(value)
top = self._stack[-1]
if top is JSONCompositeType.OBJECT:
self.fire(JSONStreamer.VALUE_EVENT, value)
el... | python | def on_number(self, ctx, value):
''' Since this is defined both integer and double callbacks are useless '''
value = int(value) if value.isdigit() else float(value)
top = self._stack[-1]
if top is JSONCompositeType.OBJECT:
self.fire(JSONStreamer.VALUE_EVENT, value)
el... | [
"def",
"on_number",
"(",
"self",
",",
"ctx",
",",
"value",
")",
":",
"value",
"=",
"int",
"(",
"value",
")",
"if",
"value",
".",
"isdigit",
"(",
")",
"else",
"float",
"(",
"value",
")",
"top",
"=",
"self",
".",
"_stack",
"[",
"-",
"1",
"]",
"if... | Since this is defined both integer and double callbacks are useless | [
"Since",
"this",
"is",
"defined",
"both",
"integer",
"and",
"double",
"callbacks",
"are",
"useless"
] | f87527d57557d11682c12727a1a4eeda9cca3c8f | https://github.com/kashifrazzaqui/json-streamer/blob/f87527d57557d11682c12727a1a4eeda9cca3c8f/jsonstreamer/jsonstreamer.py#L147-L156 | train |
kashifrazzaqui/json-streamer | jsonstreamer/jsonstreamer.py | JSONStreamer.close | def close(self):
"""Closes the streamer which causes a `DOC_END_EVENT` to be fired and frees up memory used by yajl"""
self.fire(JSONStreamer.DOC_END_EVENT)
self._stack = None
self._parser.close() | python | def close(self):
"""Closes the streamer which causes a `DOC_END_EVENT` to be fired and frees up memory used by yajl"""
self.fire(JSONStreamer.DOC_END_EVENT)
self._stack = None
self._parser.close() | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"fire",
"(",
"JSONStreamer",
".",
"DOC_END_EVENT",
")",
"self",
".",
"_stack",
"=",
"None",
"self",
".",
"_parser",
".",
"close",
"(",
")"
] | Closes the streamer which causes a `DOC_END_EVENT` to be fired and frees up memory used by yajl | [
"Closes",
"the",
"streamer",
"which",
"causes",
"a",
"DOC_END_EVENT",
"to",
"be",
"fired",
"and",
"frees",
"up",
"memory",
"used",
"by",
"yajl"
] | f87527d57557d11682c12727a1a4eeda9cca3c8f | https://github.com/kashifrazzaqui/json-streamer/blob/f87527d57557d11682c12727a1a4eeda9cca3c8f/jsonstreamer/jsonstreamer.py#L190-L194 | train |
paolodragone/pymzn | pymzn/mzn/aio/minizinc.py | minizinc | async def minizinc(
mzn, *dzn_files, args=None, data=None, include=None, stdlib_dir=None,
globals_dir=None, declare_enums=True, allow_multiple_assignments=False,
keep=False, output_vars=None, output_base=None, output_mode='dict',
solver=None, timeout=None, two_pass=None, pre_passes=None,
output_obje... | python | async def minizinc(
mzn, *dzn_files, args=None, data=None, include=None, stdlib_dir=None,
globals_dir=None, declare_enums=True, allow_multiple_assignments=False,
keep=False, output_vars=None, output_base=None, output_mode='dict',
solver=None, timeout=None, two_pass=None, pre_passes=None,
output_obje... | [
"async",
"def",
"minizinc",
"(",
"mzn",
",",
"*",
"dzn_files",
",",
"args",
"=",
"None",
",",
"data",
"=",
"None",
",",
"include",
"=",
"None",
",",
"stdlib_dir",
"=",
"None",
",",
"globals_dir",
"=",
"None",
",",
"declare_enums",
"=",
"True",
",",
"... | Coroutine version of the ``pymzn.minizinc`` function.
Parameters
----------
max_queue_size : int
Maximum number of solutions in the queue between the solution parser and
the returned solution stream. When the queue is full, the solver
execution will halt untill an item of the queue ... | [
"Coroutine",
"version",
"of",
"the",
"pymzn",
".",
"minizinc",
"function",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/aio/minizinc.py#L35-L101 | train |
paolodragone/pymzn | pymzn/dzn/parse.py | parse_value | def parse_value(val, var_type=None, enums=None, rebase_arrays=True):
"""Parses the value of a dzn statement.
Parameters
----------
val : str
A value in dzn format.
var_type : dict
The dictionary of variable type as returned by the command ``minizinc
--model-types-only``. Def... | python | def parse_value(val, var_type=None, enums=None, rebase_arrays=True):
"""Parses the value of a dzn statement.
Parameters
----------
val : str
A value in dzn format.
var_type : dict
The dictionary of variable type as returned by the command ``minizinc
--model-types-only``. Def... | [
"def",
"parse_value",
"(",
"val",
",",
"var_type",
"=",
"None",
",",
"enums",
"=",
"None",
",",
"rebase_arrays",
"=",
"True",
")",
":",
"if",
"not",
"var_type",
":",
"p_val",
"=",
"_parse_array",
"(",
"val",
",",
"rebase_arrays",
"=",
"rebase_arrays",
",... | Parses the value of a dzn statement.
Parameters
----------
val : str
A value in dzn format.
var_type : dict
The dictionary of variable type as returned by the command ``minizinc
--model-types-only``. Default is ``None``, in which case the type of the
variable is inferred... | [
"Parses",
"the",
"value",
"of",
"a",
"dzn",
"statement",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/dzn/parse.py#L395-L438 | train |
paolodragone/pymzn | pymzn/dzn/parse.py | dzn2dict | def dzn2dict(dzn, *, rebase_arrays=True, types=None, return_enums=False):
"""Parses a dzn string or file into a dictionary of variable assignments.
Parameters
----------
dzn : str
A dzn content string or a path to a dzn file.
rebase_arrays : bool
Whether to return arrays as zero-bas... | python | def dzn2dict(dzn, *, rebase_arrays=True, types=None, return_enums=False):
"""Parses a dzn string or file into a dictionary of variable assignments.
Parameters
----------
dzn : str
A dzn content string or a path to a dzn file.
rebase_arrays : bool
Whether to return arrays as zero-bas... | [
"def",
"dzn2dict",
"(",
"dzn",
",",
"*",
",",
"rebase_arrays",
"=",
"True",
",",
"types",
"=",
"None",
",",
"return_enums",
"=",
"False",
")",
":",
"dzn_ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"dzn",
")",
"[",
"1",
"]",
"if",
"dzn_ext",... | Parses a dzn string or file into a dictionary of variable assignments.
Parameters
----------
dzn : str
A dzn content string or a path to a dzn file.
rebase_arrays : bool
Whether to return arrays as zero-based lists or to return them as
dictionaries, preserving the original index... | [
"Parses",
"a",
"dzn",
"string",
"or",
"file",
"into",
"a",
"dictionary",
"of",
"variable",
"assignments",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/dzn/parse.py#L490-L593 | train |
paolodragone/pymzn | pymzn/mzn/solvers.py | Solver.args | def args(
self, all_solutions=False, num_solutions=None, free_search=False,
parallel=None, seed=None, **kwargs
):
"""Returns a list of command line arguments for the specified options.
If the solver parser is able to parse statistics, this function should
always add options ... | python | def args(
self, all_solutions=False, num_solutions=None, free_search=False,
parallel=None, seed=None, **kwargs
):
"""Returns a list of command line arguments for the specified options.
If the solver parser is able to parse statistics, this function should
always add options ... | [
"def",
"args",
"(",
"self",
",",
"all_solutions",
"=",
"False",
",",
"num_solutions",
"=",
"None",
",",
"free_search",
"=",
"False",
",",
"parallel",
"=",
"None",
",",
"seed",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"args",
"=",
"[",
"'-s'",
",",... | Returns a list of command line arguments for the specified options.
If the solver parser is able to parse statistics, this function should
always add options to display statistics.
Parameters
----------
all_solutions : bool
Whether all the solutions must be returned... | [
"Returns",
"a",
"list",
"of",
"command",
"line",
"arguments",
"for",
"the",
"specified",
"options",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/solvers.py#L96-L130 | train |
paolodragone/pymzn | pymzn/log.py | debug | def debug(dbg=True):
"""Enables or disables debugging messages on the standard output."""
global _debug_handler
if dbg and _debug_handler is None:
_debug_handler = logging.StreamHandler()
logger.addHandler(_debug_handler)
logger.setLevel(logging.DEBUG)
elif not dbg and _debug_han... | python | def debug(dbg=True):
"""Enables or disables debugging messages on the standard output."""
global _debug_handler
if dbg and _debug_handler is None:
_debug_handler = logging.StreamHandler()
logger.addHandler(_debug_handler)
logger.setLevel(logging.DEBUG)
elif not dbg and _debug_han... | [
"def",
"debug",
"(",
"dbg",
"=",
"True",
")",
":",
"global",
"_debug_handler",
"if",
"dbg",
"and",
"_debug_handler",
"is",
"None",
":",
"_debug_handler",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"logger",
".",
"addHandler",
"(",
"_debug_handler",
")",... | Enables or disables debugging messages on the standard output. | [
"Enables",
"or",
"disables",
"debugging",
"messages",
"on",
"the",
"standard",
"output",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/log.py#L15-L25 | train |
paolodragone/pymzn | pymzn/mzn/minizinc.py | minizinc_version | def minizinc_version():
"""Returns the version of the found minizinc executable."""
vs = _run_minizinc('--version')
m = re.findall('version ([\d\.]+)', vs)
if not m:
raise RuntimeError('MiniZinc executable not found.')
return m[0] | python | def minizinc_version():
"""Returns the version of the found minizinc executable."""
vs = _run_minizinc('--version')
m = re.findall('version ([\d\.]+)', vs)
if not m:
raise RuntimeError('MiniZinc executable not found.')
return m[0] | [
"def",
"minizinc_version",
"(",
")",
":",
"vs",
"=",
"_run_minizinc",
"(",
"'--version'",
")",
"m",
"=",
"re",
".",
"findall",
"(",
"'version ([\\d\\.]+)'",
",",
"vs",
")",
"if",
"not",
"m",
":",
"raise",
"RuntimeError",
"(",
"'MiniZinc executable not found.'"... | Returns the version of the found minizinc executable. | [
"Returns",
"the",
"version",
"of",
"the",
"found",
"minizinc",
"executable",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/minizinc.py#L64-L70 | train |
paolodragone/pymzn | pymzn/mzn/minizinc.py | preprocess_model | def preprocess_model(model, rewrap=True, **kwargs):
"""Preprocess a MiniZinc model.
This function takes care of preprocessing the model by resolving the
template using the arguments passed as keyword arguments to this function.
Optionally, this function can also "rewrap" the model, deleting spaces at
... | python | def preprocess_model(model, rewrap=True, **kwargs):
"""Preprocess a MiniZinc model.
This function takes care of preprocessing the model by resolving the
template using the arguments passed as keyword arguments to this function.
Optionally, this function can also "rewrap" the model, deleting spaces at
... | [
"def",
"preprocess_model",
"(",
"model",
",",
"rewrap",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"args",
"=",
"{",
"**",
"kwargs",
",",
"**",
"config",
".",
"get",
"(",
"'args'",
",",
"{",
"}",
")",
"}",
"model",
"=",
"_process_template",
"(",
"... | Preprocess a MiniZinc model.
This function takes care of preprocessing the model by resolving the
template using the arguments passed as keyword arguments to this function.
Optionally, this function can also "rewrap" the model, deleting spaces at
the beginning of the lines while preserving indentation.... | [
"Preprocess",
"a",
"MiniZinc",
"model",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/minizinc.py#L179-L209 | train |
paolodragone/pymzn | pymzn/mzn/minizinc.py | save_model | def save_model(model, output_file=None, output_dir=None, output_prefix='pymzn'):
"""Save a model to file.
Parameters
----------
model : str
The minizinc model (i.e. the content of a ``.mzn`` file).
output_file : str
The path to the output file. If this parameter is ``None`` (default... | python | def save_model(model, output_file=None, output_dir=None, output_prefix='pymzn'):
"""Save a model to file.
Parameters
----------
model : str
The minizinc model (i.e. the content of a ``.mzn`` file).
output_file : str
The path to the output file. If this parameter is ``None`` (default... | [
"def",
"save_model",
"(",
"model",
",",
"output_file",
"=",
"None",
",",
"output_dir",
"=",
"None",
",",
"output_prefix",
"=",
"'pymzn'",
")",
":",
"if",
"output_file",
":",
"mzn_file",
"=",
"output_file",
"output_file",
"=",
"open",
"(",
"output_file",
",",... | Save a model to file.
Parameters
----------
model : str
The minizinc model (i.e. the content of a ``.mzn`` file).
output_file : str
The path to the output file. If this parameter is ``None`` (default), a
temporary file is created with the given model in the specified output
... | [
"Save",
"a",
"model",
"to",
"file",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/minizinc.py#L212-L249 | train |
paolodragone/pymzn | pymzn/mzn/minizinc.py | check_instance | def check_instance(
mzn, *dzn_files, data=None, include=None, stdlib_dir=None, globals_dir=None,
allow_multiple_assignments=False
):
"""Perform instance checking on a model + data.
This function calls the command ``minizinc --instance-check-only`` to check
for consistency of the given model + data.... | python | def check_instance(
mzn, *dzn_files, data=None, include=None, stdlib_dir=None, globals_dir=None,
allow_multiple_assignments=False
):
"""Perform instance checking on a model + data.
This function calls the command ``minizinc --instance-check-only`` to check
for consistency of the given model + data.... | [
"def",
"check_instance",
"(",
"mzn",
",",
"*",
"dzn_files",
",",
"data",
"=",
"None",
",",
"include",
"=",
"None",
",",
"stdlib_dir",
"=",
"None",
",",
"globals_dir",
"=",
"None",
",",
"allow_multiple_assignments",
"=",
"False",
")",
":",
"args",
"=",
"[... | Perform instance checking on a model + data.
This function calls the command ``minizinc --instance-check-only`` to check
for consistency of the given model + data.
Parameters
----------
mzn : str
The minizinc model. This can be either the path to the ``.mzn`` file or
the content of... | [
"Perform",
"instance",
"checking",
"on",
"a",
"model",
"+",
"data",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/minizinc.py#L327-L378 | train |
paolodragone/pymzn | pymzn/mzn/minizinc.py | check_model | def check_model(
mzn, *, include=None, stdlib_dir=None, globals_dir=None
):
"""Perform model checking on a given model.
This function calls the command ``minizinc --model-check-only`` to check
for consistency of the given model.
Parameters
----------
mzn : str
The minizinc model. T... | python | def check_model(
mzn, *, include=None, stdlib_dir=None, globals_dir=None
):
"""Perform model checking on a given model.
This function calls the command ``minizinc --model-check-only`` to check
for consistency of the given model.
Parameters
----------
mzn : str
The minizinc model. T... | [
"def",
"check_model",
"(",
"mzn",
",",
"*",
",",
"include",
"=",
"None",
",",
"stdlib_dir",
"=",
"None",
",",
"globals_dir",
"=",
"None",
")",
":",
"args",
"=",
"[",
"'--model-check-only'",
"]",
"args",
"+=",
"_flattening_args",
"(",
"mzn",
",",
"include... | Perform model checking on a given model.
This function calls the command ``minizinc --model-check-only`` to check
for consistency of the given model.
Parameters
----------
mzn : str
The minizinc model. This can be either the path to the ``.mzn`` file or
the content of the model its... | [
"Perform",
"model",
"checking",
"on",
"a",
"given",
"model",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/minizinc.py#L381-L419 | train |
paolodragone/pymzn | pymzn/mzn/minizinc.py | minizinc | def minizinc(
mzn, *dzn_files, args=None, data=None, include=None, stdlib_dir=None,
globals_dir=None, declare_enums=True, allow_multiple_assignments=False,
keep=False, output_vars=None, output_base=None, output_mode='dict',
solver=None, timeout=None, two_pass=None, pre_passes=None,
output_objective=... | python | def minizinc(
mzn, *dzn_files, args=None, data=None, include=None, stdlib_dir=None,
globals_dir=None, declare_enums=True, allow_multiple_assignments=False,
keep=False, output_vars=None, output_base=None, output_mode='dict',
solver=None, timeout=None, two_pass=None, pre_passes=None,
output_objective=... | [
"def",
"minizinc",
"(",
"mzn",
",",
"*",
"dzn_files",
",",
"args",
"=",
"None",
",",
"data",
"=",
"None",
",",
"include",
"=",
"None",
",",
"stdlib_dir",
"=",
"None",
",",
"globals_dir",
"=",
"None",
",",
"declare_enums",
"=",
"True",
",",
"allow_multi... | Implements the workflow for solving a CSP problem encoded with MiniZinc.
Parameters
----------
mzn : str
The minizinc model. This can be either the path to the ``.mzn`` file or
the content of the model itself.
*dzn_files
A list of paths to dzn files to attach to the minizinc exe... | [
"Implements",
"the",
"workflow",
"for",
"solving",
"a",
"CSP",
"problem",
"encoded",
"with",
"MiniZinc",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/minizinc.py#L502-L658 | train |
paolodragone/pymzn | pymzn/mzn/minizinc.py | solve | def solve(
solver, mzn, *dzn_files, data=None, include=None, stdlib_dir=None,
globals_dir=None, allow_multiple_assignments=False, output_mode='item',
timeout=None, two_pass=None, pre_passes=None, output_objective=False,
non_unique=False, all_solutions=False, num_solutions=None,
free_search=False, pa... | python | def solve(
solver, mzn, *dzn_files, data=None, include=None, stdlib_dir=None,
globals_dir=None, allow_multiple_assignments=False, output_mode='item',
timeout=None, two_pass=None, pre_passes=None, output_objective=False,
non_unique=False, all_solutions=False, num_solutions=None,
free_search=False, pa... | [
"def",
"solve",
"(",
"solver",
",",
"mzn",
",",
"*",
"dzn_files",
",",
"data",
"=",
"None",
",",
"include",
"=",
"None",
",",
"stdlib_dir",
"=",
"None",
",",
"globals_dir",
"=",
"None",
",",
"allow_multiple_assignments",
"=",
"False",
",",
"output_mode",
... | Flatten and solve a MiniZinc program.
Parameters
----------
solver : Solver
The ``Solver`` instance to use.
mzn : str
The path to the minizinc model file.
*dzn_files
A list of paths to dzn files to attach to the minizinc execution,
provided as positional arguments; b... | [
"Flatten",
"and",
"solve",
"a",
"MiniZinc",
"program",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/minizinc.py#L694-L796 | train |
paolodragone/pymzn | pymzn/mzn/minizinc.py | mzn2fzn | def mzn2fzn(
mzn, *dzn_files, args=None, data=None, include=None, stdlib_dir=None,
globals_dir=None, declare_enums=True, allow_multiple_assignments=False,
keep=False, output_vars=None, output_base=None, output_mode='item',
no_ozn=False
):
"""Flatten a MiniZinc model into a FlatZinc one.
This fu... | python | def mzn2fzn(
mzn, *dzn_files, args=None, data=None, include=None, stdlib_dir=None,
globals_dir=None, declare_enums=True, allow_multiple_assignments=False,
keep=False, output_vars=None, output_base=None, output_mode='item',
no_ozn=False
):
"""Flatten a MiniZinc model into a FlatZinc one.
This fu... | [
"def",
"mzn2fzn",
"(",
"mzn",
",",
"*",
"dzn_files",
",",
"args",
"=",
"None",
",",
"data",
"=",
"None",
",",
"include",
"=",
"None",
",",
"stdlib_dir",
"=",
"None",
",",
"globals_dir",
"=",
"None",
",",
"declare_enums",
"=",
"True",
",",
"allow_multip... | Flatten a MiniZinc model into a FlatZinc one.
This function is equivalent to the command ``minizinc --compile``.
Parameters
----------
mzn : str
The minizinc model. This can be either the path to the ``.mzn`` file or
the content of the model itself.
*dzn_files
A list of pat... | [
"Flatten",
"a",
"MiniZinc",
"model",
"into",
"a",
"FlatZinc",
"one",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/minizinc.py#L799-L914 | train |
paolodragone/pymzn | pymzn/mzn/output.py | Solutions.print | def print(self, output_file=sys.stdout, log=False):
"""Print the solution stream"""
for soln in iter(self):
print(soln, file=output_file)
print(SOLN_SEP, file=output_file)
if self.status == 0:
print(SEARCH_COMPLETE, file=output_file)
if (self.status... | python | def print(self, output_file=sys.stdout, log=False):
"""Print the solution stream"""
for soln in iter(self):
print(soln, file=output_file)
print(SOLN_SEP, file=output_file)
if self.status == 0:
print(SEARCH_COMPLETE, file=output_file)
if (self.status... | [
"def",
"print",
"(",
"self",
",",
"output_file",
"=",
"sys",
".",
"stdout",
",",
"log",
"=",
"False",
")",
":",
"for",
"soln",
"in",
"iter",
"(",
"self",
")",
":",
"print",
"(",
"soln",
",",
"file",
"=",
"output_file",
")",
"print",
"(",
"SOLN_SEP"... | Print the solution stream | [
"Print",
"the",
"solution",
"stream"
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/output.py#L143-L167 | train |
paolodragone/pymzn | pymzn/config.py | Config.dump | def dump(self):
"""Writes the changes to the configuration file."""
try:
import yaml
cfg_file = self._cfg_file()
cfg_dir, __ = os.path.split(cfg_file)
os.makedirs(cfg_dir, exist_ok=True)
with open(cfg_file, 'w') as f:
yaml.dump(... | python | def dump(self):
"""Writes the changes to the configuration file."""
try:
import yaml
cfg_file = self._cfg_file()
cfg_dir, __ = os.path.split(cfg_file)
os.makedirs(cfg_dir, exist_ok=True)
with open(cfg_file, 'w') as f:
yaml.dump(... | [
"def",
"dump",
"(",
"self",
")",
":",
"try",
":",
"import",
"yaml",
"cfg_file",
"=",
"self",
".",
"_cfg_file",
"(",
")",
"cfg_dir",
",",
"__",
"=",
"os",
".",
"path",
".",
"split",
"(",
"cfg_file",
")",
"os",
".",
"makedirs",
"(",
"cfg_dir",
",",
... | Writes the changes to the configuration file. | [
"Writes",
"the",
"changes",
"to",
"the",
"configuration",
"file",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/config.py#L102-L115 | train |
paolodragone/pymzn | pymzn/mzn/templates.py | discretize | def discretize(value, factor=100):
"""Discretize the given value, pre-multiplying by the given factor"""
if not isinstance(value, Iterable):
return int(value * factor)
int_value = list(deepcopy(value))
for i in range(len(int_value)):
int_value[i] = int(int_value[i] * factor)
return i... | python | def discretize(value, factor=100):
"""Discretize the given value, pre-multiplying by the given factor"""
if not isinstance(value, Iterable):
return int(value * factor)
int_value = list(deepcopy(value))
for i in range(len(int_value)):
int_value[i] = int(int_value[i] * factor)
return i... | [
"def",
"discretize",
"(",
"value",
",",
"factor",
"=",
"100",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"Iterable",
")",
":",
"return",
"int",
"(",
"value",
"*",
"factor",
")",
"int_value",
"=",
"list",
"(",
"deepcopy",
"(",
"value",
")... | Discretize the given value, pre-multiplying by the given factor | [
"Discretize",
"the",
"given",
"value",
"pre",
"-",
"multiplying",
"by",
"the",
"given",
"factor"
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/templates.py#L87-L94 | train |
paolodragone/pymzn | pymzn/mzn/templates.py | from_string | def from_string(source, args=None):
"""Renders a template string"""
if _has_jinja:
logger.info('Precompiling model with arguments: {}'.format(args))
return _jenv.from_string(source).render(args or {})
if args:
raise RuntimeError(_except_text)
return source | python | def from_string(source, args=None):
"""Renders a template string"""
if _has_jinja:
logger.info('Precompiling model with arguments: {}'.format(args))
return _jenv.from_string(source).render(args or {})
if args:
raise RuntimeError(_except_text)
return source | [
"def",
"from_string",
"(",
"source",
",",
"args",
"=",
"None",
")",
":",
"if",
"_has_jinja",
":",
"logger",
".",
"info",
"(",
"'Precompiling model with arguments: {}'",
".",
"format",
"(",
"args",
")",
")",
"return",
"_jenv",
".",
"from_string",
"(",
"source... | Renders a template string | [
"Renders",
"a",
"template",
"string"
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/templates.py#L146-L153 | train |
paolodragone/pymzn | pymzn/mzn/templates.py | add_package | def add_package(package_name, package_path='templates', encoding='utf-8'):
"""Adds the given package to the template search routine"""
if not _has_jinja:
raise RuntimeError(_except_text)
_jload.add_loader(PackageLoader(package_name, package_path, encoding)) | python | def add_package(package_name, package_path='templates', encoding='utf-8'):
"""Adds the given package to the template search routine"""
if not _has_jinja:
raise RuntimeError(_except_text)
_jload.add_loader(PackageLoader(package_name, package_path, encoding)) | [
"def",
"add_package",
"(",
"package_name",
",",
"package_path",
"=",
"'templates'",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"if",
"not",
"_has_jinja",
":",
"raise",
"RuntimeError",
"(",
"_except_text",
")",
"_jload",
".",
"add_loader",
"(",
"PackageLoader",
... | Adds the given package to the template search routine | [
"Adds",
"the",
"given",
"package",
"to",
"the",
"template",
"search",
"routine"
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/templates.py#L155-L159 | train |
paolodragone/pymzn | pymzn/mzn/templates.py | add_path | def add_path(searchpath, encoding='utf-8', followlinks=False):
"""Adds the given path to the template search routine"""
if not _has_jinja:
raise RuntimeError(_except_text)
_jload.add_loader(FileSystemLoader(searchpath, encoding, followlinks)) | python | def add_path(searchpath, encoding='utf-8', followlinks=False):
"""Adds the given path to the template search routine"""
if not _has_jinja:
raise RuntimeError(_except_text)
_jload.add_loader(FileSystemLoader(searchpath, encoding, followlinks)) | [
"def",
"add_path",
"(",
"searchpath",
",",
"encoding",
"=",
"'utf-8'",
",",
"followlinks",
"=",
"False",
")",
":",
"if",
"not",
"_has_jinja",
":",
"raise",
"RuntimeError",
"(",
"_except_text",
")",
"_jload",
".",
"add_loader",
"(",
"FileSystemLoader",
"(",
"... | Adds the given path to the template search routine | [
"Adds",
"the",
"given",
"path",
"to",
"the",
"template",
"search",
"routine"
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/mzn/templates.py#L162-L166 | train |
paolodragone/pymzn | pymzn/dzn/marsh.py | val2dzn | def val2dzn(val, wrap=True):
"""Serializes a value into its dzn representation.
The supported types are ``bool``, ``int``, ``float``, ``set``, ``array``.
Parameters
----------
val
The value to serialize
wrap : bool
Whether to wrap the serialized value.
Returns
-------
... | python | def val2dzn(val, wrap=True):
"""Serializes a value into its dzn representation.
The supported types are ``bool``, ``int``, ``float``, ``set``, ``array``.
Parameters
----------
val
The value to serialize
wrap : bool
Whether to wrap the serialized value.
Returns
-------
... | [
"def",
"val2dzn",
"(",
"val",
",",
"wrap",
"=",
"True",
")",
":",
"if",
"_is_value",
"(",
"val",
")",
":",
"dzn_val",
"=",
"_dzn_val",
"(",
"val",
")",
"elif",
"_is_set",
"(",
"val",
")",
":",
"dzn_val",
"=",
"_dzn_set",
"(",
"val",
")",
"elif",
... | Serializes a value into its dzn representation.
The supported types are ``bool``, ``int``, ``float``, ``set``, ``array``.
Parameters
----------
val
The value to serialize
wrap : bool
Whether to wrap the serialized value.
Returns
-------
str
The serialized dzn r... | [
"Serializes",
"a",
"value",
"into",
"its",
"dzn",
"representation",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/dzn/marsh.py#L215-L247 | train |
paolodragone/pymzn | pymzn/dzn/marsh.py | stmt2dzn | def stmt2dzn(name, val, declare=True, assign=True, wrap=True):
"""Returns a dzn statement declaring and assigning the given value.
Parameters
----------
val
The value to serialize.
declare : bool
Whether to include the declaration of the variable in the statement or
just the... | python | def stmt2dzn(name, val, declare=True, assign=True, wrap=True):
"""Returns a dzn statement declaring and assigning the given value.
Parameters
----------
val
The value to serialize.
declare : bool
Whether to include the declaration of the variable in the statement or
just the... | [
"def",
"stmt2dzn",
"(",
"name",
",",
"val",
",",
"declare",
"=",
"True",
",",
"assign",
"=",
"True",
",",
"wrap",
"=",
"True",
")",
":",
"if",
"not",
"(",
"declare",
"or",
"assign",
")",
":",
"raise",
"ValueError",
"(",
"'The statement must be a declarat... | Returns a dzn statement declaring and assigning the given value.
Parameters
----------
val
The value to serialize.
declare : bool
Whether to include the declaration of the variable in the statement or
just the assignment.
assign : bool
Wheter to include the assignmen... | [
"Returns",
"a",
"dzn",
"statement",
"declaring",
"and",
"assigning",
"the",
"given",
"value",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/dzn/marsh.py#L250-L285 | train |
paolodragone/pymzn | pymzn/dzn/marsh.py | stmt2enum | def stmt2enum(enum_type, declare=True, assign=True, wrap=True):
"""Returns a dzn enum declaration from an enum type.
Parameters
----------
enum_type : Enum
The enum to serialize.
declare : bool
Whether to include the ``enum`` declatation keyword in the statement or
just the ... | python | def stmt2enum(enum_type, declare=True, assign=True, wrap=True):
"""Returns a dzn enum declaration from an enum type.
Parameters
----------
enum_type : Enum
The enum to serialize.
declare : bool
Whether to include the ``enum`` declatation keyword in the statement or
just the ... | [
"def",
"stmt2enum",
"(",
"enum_type",
",",
"declare",
"=",
"True",
",",
"assign",
"=",
"True",
",",
"wrap",
"=",
"True",
")",
":",
"if",
"not",
"(",
"declare",
"or",
"assign",
")",
":",
"raise",
"ValueError",
"(",
"'The statement must be a declaration or an ... | Returns a dzn enum declaration from an enum type.
Parameters
----------
enum_type : Enum
The enum to serialize.
declare : bool
Whether to include the ``enum`` declatation keyword in the statement or
just the assignment.
assign : bool
Wheter to include the assignment ... | [
"Returns",
"a",
"dzn",
"enum",
"declaration",
"from",
"an",
"enum",
"type",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/dzn/marsh.py#L288-L331 | train |
paolodragone/pymzn | pymzn/dzn/marsh.py | dict2dzn | def dict2dzn(
objs, declare=False, assign=True, declare_enums=True, wrap=True, fout=None
):
"""Serializes the objects in input and produces a list of strings encoding
them into dzn format. Optionally, the produced dzn is written on a file.
Supported types of objects include: ``str``, ``int``, ``float``... | python | def dict2dzn(
objs, declare=False, assign=True, declare_enums=True, wrap=True, fout=None
):
"""Serializes the objects in input and produces a list of strings encoding
them into dzn format. Optionally, the produced dzn is written on a file.
Supported types of objects include: ``str``, ``int``, ``float``... | [
"def",
"dict2dzn",
"(",
"objs",
",",
"declare",
"=",
"False",
",",
"assign",
"=",
"True",
",",
"declare_enums",
"=",
"True",
",",
"wrap",
"=",
"True",
",",
"fout",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
... | Serializes the objects in input and produces a list of strings encoding
them into dzn format. Optionally, the produced dzn is written on a file.
Supported types of objects include: ``str``, ``int``, ``float``, ``set``,
``list`` or ``dict``. List and dict are serialized into dzn
(multi-dimensional) arra... | [
"Serializes",
"the",
"objects",
"in",
"input",
"and",
"produces",
"a",
"list",
"of",
"strings",
"encoding",
"them",
"into",
"dzn",
"format",
".",
"Optionally",
"the",
"produced",
"dzn",
"is",
"written",
"on",
"a",
"file",
"."
] | 35b04cfb244918551649b9bb8a0ab65d37c31fe4 | https://github.com/paolodragone/pymzn/blob/35b04cfb244918551649b9bb8a0ab65d37c31fe4/pymzn/dzn/marsh.py#L334-L391 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask.async_or_eager | def async_or_eager(self, **options):
"""
Attempt to call self.apply_async, or if that fails because of a problem
with the broker, run the task eagerly and return an EagerResult.
"""
args = options.pop("args", None)
kwargs = options.pop("kwargs", None)
possible_bro... | python | def async_or_eager(self, **options):
"""
Attempt to call self.apply_async, or if that fails because of a problem
with the broker, run the task eagerly and return an EagerResult.
"""
args = options.pop("args", None)
kwargs = options.pop("kwargs", None)
possible_bro... | [
"def",
"async_or_eager",
"(",
"self",
",",
"**",
"options",
")",
":",
"args",
"=",
"options",
".",
"pop",
"(",
"\"args\"",
",",
"None",
")",
"kwargs",
"=",
"options",
".",
"pop",
"(",
"\"kwargs\"",
",",
"None",
")",
"possible_broker_errors",
"=",
"self",... | Attempt to call self.apply_async, or if that fails because of a problem
with the broker, run the task eagerly and return an EagerResult. | [
"Attempt",
"to",
"call",
"self",
".",
"apply_async",
"or",
"if",
"that",
"fails",
"because",
"of",
"a",
"problem",
"with",
"the",
"broker",
"run",
"the",
"task",
"eagerly",
"and",
"return",
"an",
"EagerResult",
"."
] | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L90-L101 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask.async_or_fail | def async_or_fail(self, **options):
"""
Attempt to call self.apply_async, but if that fails with an exception,
we fake the task completion using the exception as the result. This
allows us to seamlessly handle errors on task creation the same way we
handle errors when a task runs... | python | def async_or_fail(self, **options):
"""
Attempt to call self.apply_async, but if that fails with an exception,
we fake the task completion using the exception as the result. This
allows us to seamlessly handle errors on task creation the same way we
handle errors when a task runs... | [
"def",
"async_or_fail",
"(",
"self",
",",
"**",
"options",
")",
":",
"args",
"=",
"options",
".",
"pop",
"(",
"\"args\"",
",",
"None",
")",
"kwargs",
"=",
"options",
".",
"pop",
"(",
"\"kwargs\"",
",",
"None",
")",
"possible_broker_errors",
"=",
"self",
... | Attempt to call self.apply_async, but if that fails with an exception,
we fake the task completion using the exception as the result. This
allows us to seamlessly handle errors on task creation the same way we
handle errors when a task runs, simplifying the user interface. | [
"Attempt",
"to",
"call",
"self",
".",
"apply_async",
"but",
"if",
"that",
"fails",
"with",
"an",
"exception",
"we",
"fake",
"the",
"task",
"completion",
"using",
"the",
"exception",
"as",
"the",
"result",
".",
"This",
"allows",
"us",
"to",
"seamlessly",
"h... | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L104-L117 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask.delay_or_eager | def delay_or_eager(self, *args, **kwargs):
"""
Wrap async_or_eager with a convenience signiture like delay
"""
return self.async_or_eager(args=args, kwargs=kwargs) | python | def delay_or_eager(self, *args, **kwargs):
"""
Wrap async_or_eager with a convenience signiture like delay
"""
return self.async_or_eager(args=args, kwargs=kwargs) | [
"def",
"delay_or_eager",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"async_or_eager",
"(",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
")"
] | Wrap async_or_eager with a convenience signiture like delay | [
"Wrap",
"async_or_eager",
"with",
"a",
"convenience",
"signiture",
"like",
"delay"
] | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L120-L124 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask.delay_or_run | def delay_or_run(self, *args, **kwargs):
"""
Attempt to call self.delay, or if that fails, call self.run.
Returns a tuple, (result, required_fallback). ``result`` is the result
of calling delay or run. ``required_fallback`` is True if the broker
failed we had to resort to `self.... | python | def delay_or_run(self, *args, **kwargs):
"""
Attempt to call self.delay, or if that fails, call self.run.
Returns a tuple, (result, required_fallback). ``result`` is the result
of calling delay or run. ``required_fallback`` is True if the broker
failed we had to resort to `self.... | [
"def",
"delay_or_run",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"\"delay_or_run is deprecated. Please use delay_or_eager\"",
",",
"DeprecationWarning",
",",
")",
"possible_broker_errors",
"=",
"self",
".",
"_get_pos... | Attempt to call self.delay, or if that fails, call self.run.
Returns a tuple, (result, required_fallback). ``result`` is the result
of calling delay or run. ``required_fallback`` is True if the broker
failed we had to resort to `self.run`. | [
"Attempt",
"to",
"call",
"self",
".",
"delay",
"or",
"if",
"that",
"fails",
"call",
"self",
".",
"run",
"."
] | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L127-L146 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask.delay_or_fail | def delay_or_fail(self, *args, **kwargs):
"""
Wrap async_or_fail with a convenience signiture like delay
"""
return self.async_or_fail(args=args, kwargs=kwargs) | python | def delay_or_fail(self, *args, **kwargs):
"""
Wrap async_or_fail with a convenience signiture like delay
"""
return self.async_or_fail(args=args, kwargs=kwargs) | [
"def",
"delay_or_fail",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"async_or_fail",
"(",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
")"
] | Wrap async_or_fail with a convenience signiture like delay | [
"Wrap",
"async_or_fail",
"with",
"a",
"convenience",
"signiture",
"like",
"delay"
] | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L149-L153 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask.simulate_async_error | def simulate_async_error(self, exception):
"""
Take this exception and store it as an error in the result backend.
This unifies the handling of broker-connection errors with any other
type of error that might occur when running the task. So the same
error-handling that might retr... | python | def simulate_async_error(self, exception):
"""
Take this exception and store it as an error in the result backend.
This unifies the handling of broker-connection errors with any other
type of error that might occur when running the task. So the same
error-handling that might retr... | [
"def",
"simulate_async_error",
"(",
"self",
",",
"exception",
")",
":",
"task_id",
"=",
"gen_unique_id",
"(",
")",
"async_result",
"=",
"self",
".",
"AsyncResult",
"(",
"task_id",
")",
"einfo",
"=",
"ExceptionInfo",
"(",
"sys",
".",
"exc_info",
"(",
")",
"... | Take this exception and store it as an error in the result backend.
This unifies the handling of broker-connection errors with any other
type of error that might occur when running the task. So the same
error-handling that might retry a task or display a useful message to
the user can al... | [
"Take",
"this",
"exception",
"and",
"store",
"it",
"as",
"an",
"error",
"in",
"the",
"result",
"backend",
".",
"This",
"unifies",
"the",
"handling",
"of",
"broker",
"-",
"connection",
"errors",
"with",
"any",
"other",
"type",
"of",
"error",
"that",
"might"... | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L178-L196 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask.calc_progress | def calc_progress(self, completed_count, total_count):
"""
Calculate the percentage progress and estimated remaining time based on
the current number of items completed of the total.
Returns a tuple of ``(percentage_complete, seconds_remaining)``.
"""
self.logger.debug(
... | python | def calc_progress(self, completed_count, total_count):
"""
Calculate the percentage progress and estimated remaining time based on
the current number of items completed of the total.
Returns a tuple of ``(percentage_complete, seconds_remaining)``.
"""
self.logger.debug(
... | [
"def",
"calc_progress",
"(",
"self",
",",
"completed_count",
",",
"total_count",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"calc_progress(%s, %s)\"",
",",
"completed_count",
",",
"total_count",
",",
")",
"current_time",
"=",
"time",
".",
"time",
"(... | Calculate the percentage progress and estimated remaining time based on
the current number of items completed of the total.
Returns a tuple of ``(percentage_complete, seconds_remaining)``. | [
"Calculate",
"the",
"percentage",
"progress",
"and",
"estimated",
"remaining",
"time",
"based",
"on",
"the",
"current",
"number",
"of",
"items",
"completed",
"of",
"the",
"total",
"."
] | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L246-L278 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask.update_progress | def update_progress(
self,
completed_count,
total_count,
update_frequency=1,
):
"""
Update the task backend with both an estimated percentage complete and
number of seconds remaining until completion.
``completed_count`` Number of task "units" that ha... | python | def update_progress(
self,
completed_count,
total_count,
update_frequency=1,
):
"""
Update the task backend with both an estimated percentage complete and
number of seconds remaining until completion.
``completed_count`` Number of task "units" that ha... | [
"def",
"update_progress",
"(",
"self",
",",
"completed_count",
",",
"total_count",
",",
"update_frequency",
"=",
"1",
",",
")",
":",
"if",
"completed_count",
"-",
"self",
".",
"_last_update_count",
"<",
"update_frequency",
":",
"return",
"progress_percent",
",",
... | Update the task backend with both an estimated percentage complete and
number of seconds remaining until completion.
``completed_count`` Number of task "units" that have been completed out
of ``total_count`` total "units."
``update_frequency`` Only actually store the updated progress in... | [
"Update",
"the",
"task",
"backend",
"with",
"both",
"an",
"estimated",
"percentage",
"complete",
"and",
"number",
"of",
"seconds",
"remaining",
"until",
"completion",
"."
] | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L280-L311 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask._validate_required_class_vars | def _validate_required_class_vars(self):
"""
Ensure that this subclass has defined all of the required class
variables.
"""
required_members = (
'significant_kwargs',
'herd_avoidance_timeout',
)
for required_member in required_members:
... | python | def _validate_required_class_vars(self):
"""
Ensure that this subclass has defined all of the required class
variables.
"""
required_members = (
'significant_kwargs',
'herd_avoidance_timeout',
)
for required_member in required_members:
... | [
"def",
"_validate_required_class_vars",
"(",
"self",
")",
":",
"required_members",
"=",
"(",
"'significant_kwargs'",
",",
"'herd_avoidance_timeout'",
",",
")",
"for",
"required_member",
"in",
"required_members",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"requir... | Ensure that this subclass has defined all of the required class
variables. | [
"Ensure",
"that",
"this",
"subclass",
"has",
"defined",
"all",
"of",
"the",
"required",
"class",
"variables",
"."
] | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L378-L390 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask.on_success | def on_success(self, retval, task_id, args, kwargs):
"""
Store results in the backend even if we're always eager. This ensures
the `delay_or_run` calls always at least have results.
"""
if self.request.is_eager:
# Store the result because celery wouldn't otherwise
... | python | def on_success(self, retval, task_id, args, kwargs):
"""
Store results in the backend even if we're always eager. This ensures
the `delay_or_run` calls always at least have results.
"""
if self.request.is_eager:
# Store the result because celery wouldn't otherwise
... | [
"def",
"on_success",
"(",
"self",
",",
"retval",
",",
"task_id",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"self",
".",
"request",
".",
"is_eager",
":",
"self",
".",
"update_state",
"(",
"task_id",
",",
"SUCCESS",
",",
"retval",
")"
] | Store results in the backend even if we're always eager. This ensures
the `delay_or_run` calls always at least have results. | [
"Store",
"results",
"in",
"the",
"backend",
"even",
"if",
"we",
"re",
"always",
"eager",
".",
"This",
"ensures",
"the",
"delay_or_run",
"calls",
"always",
"at",
"least",
"have",
"results",
"."
] | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L392-L399 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask._get_cache | def _get_cache(self):
"""
Return the cache to use for thundering herd protection, etc.
"""
if not self._cache:
self._cache = get_cache(self.app)
return self._cache | python | def _get_cache(self):
"""
Return the cache to use for thundering herd protection, etc.
"""
if not self._cache:
self._cache = get_cache(self.app)
return self._cache | [
"def",
"_get_cache",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_cache",
":",
"self",
".",
"_cache",
"=",
"get_cache",
"(",
"self",
".",
"app",
")",
"return",
"self",
".",
"_cache"
] | Return the cache to use for thundering herd protection, etc. | [
"Return",
"the",
"cache",
"to",
"use",
"for",
"thundering",
"herd",
"protection",
"etc",
"."
] | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L405-L411 | train |
PolicyStat/jobtastic | jobtastic/task.py | JobtasticTask._get_cache_key | def _get_cache_key(self, **kwargs):
"""
Take this task's configured ``significant_kwargs`` and build a hash
that all equivalent task calls will match.
Takes in kwargs and returns a string.
To change the way the cache key is generated or do more in-depth
processing, over... | python | def _get_cache_key(self, **kwargs):
"""
Take this task's configured ``significant_kwargs`` and build a hash
that all equivalent task calls will match.
Takes in kwargs and returns a string.
To change the way the cache key is generated or do more in-depth
processing, over... | [
"def",
"_get_cache_key",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"m",
"=",
"md5",
"(",
")",
"for",
"significant_kwarg",
"in",
"self",
".",
"significant_kwargs",
":",
"key",
",",
"to_str",
"=",
"significant_kwarg",
"try",
":",
"m",
".",
"update",
"(",... | Take this task's configured ``significant_kwargs`` and build a hash
that all equivalent task calls will match.
Takes in kwargs and returns a string.
To change the way the cache key is generated or do more in-depth
processing, override this method. | [
"Take",
"this",
"task",
"s",
"configured",
"significant_kwargs",
"and",
"build",
"a",
"hash",
"that",
"all",
"equivalent",
"task",
"calls",
"will",
"match",
"."
] | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L426-L450 | train |
PolicyStat/jobtastic | jobtastic/cache/__init__.py | get_cache | def get_cache(app):
"""
Attempt to find a valid cache from the Celery configuration
If the setting is a valid cache, just use it.
Otherwise, if Django is installed, then:
If the setting is a valid Django cache entry, then use that.
If the setting is empty use the default cache
Other... | python | def get_cache(app):
"""
Attempt to find a valid cache from the Celery configuration
If the setting is a valid cache, just use it.
Otherwise, if Django is installed, then:
If the setting is a valid Django cache entry, then use that.
If the setting is empty use the default cache
Other... | [
"def",
"get_cache",
"(",
"app",
")",
":",
"jobtastic_cache_setting",
"=",
"app",
".",
"conf",
".",
"get",
"(",
"'JOBTASTIC_CACHE'",
")",
"if",
"isinstance",
"(",
"jobtastic_cache_setting",
",",
"BaseCache",
")",
":",
"return",
"jobtastic_cache_setting",
"if",
"'... | Attempt to find a valid cache from the Celery configuration
If the setting is a valid cache, just use it.
Otherwise, if Django is installed, then:
If the setting is a valid Django cache entry, then use that.
If the setting is empty use the default cache
Otherwise, if Werkzeug is installed, ... | [
"Attempt",
"to",
"find",
"a",
"valid",
"cache",
"from",
"the",
"Celery",
"configuration"
] | 19cd3137ebf46877cee1ee5155d318bb6261ee1c | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/cache/__init__.py#L29-L70 | train |
dodger487/dplython | dplython/dplython.py | select | def select(*args):
"""Select specific columns from DataFrame.
Output will be DplyFrame type. Order of columns will be the same as input into
select.
>>> diamonds >> select(X.color, X.carat) >> head(3)
Out:
color carat
0 E 0.23
1 E 0.21
2 E 0.23
Grouping variables are implied... | python | def select(*args):
"""Select specific columns from DataFrame.
Output will be DplyFrame type. Order of columns will be the same as input into
select.
>>> diamonds >> select(X.color, X.carat) >> head(3)
Out:
color carat
0 E 0.23
1 E 0.21
2 E 0.23
Grouping variables are implied... | [
"def",
"select",
"(",
"*",
"args",
")",
":",
"def",
"select_columns",
"(",
"df",
",",
"args",
")",
":",
"columns",
"=",
"[",
"column",
".",
"_name",
"for",
"column",
"in",
"args",
"]",
"if",
"df",
".",
"_grouped_on",
":",
"for",
"col",
"in",
"df",
... | Select specific columns from DataFrame.
Output will be DplyFrame type. Order of columns will be the same as input into
select.
>>> diamonds >> select(X.color, X.carat) >> head(3)
Out:
color carat
0 E 0.23
1 E 0.21
2 E 0.23
Grouping variables are implied in selection.
>>> df ... | [
"Select",
"specific",
"columns",
"from",
"DataFrame",
"."
] | 09c2a5f4ca67221b2a59928366ca8274357f7234 | https://github.com/dodger487/dplython/blob/09c2a5f4ca67221b2a59928366ca8274357f7234/dplython/dplython.py#L203-L232 | train |
dodger487/dplython | dplython/dplython.py | arrange | def arrange(*args):
"""Sort DataFrame by the input column arguments.
>>> diamonds >> sample_n(5) >> arrange(X.price) >> select(X.depth, X.price)
Out:
depth price
28547 61.0 675
35132 59.1 889
42526 61.3 1323
3468 61.6 3392
23829 62.0 11903
"""
names = [column._name f... | python | def arrange(*args):
"""Sort DataFrame by the input column arguments.
>>> diamonds >> sample_n(5) >> arrange(X.price) >> select(X.depth, X.price)
Out:
depth price
28547 61.0 675
35132 59.1 889
42526 61.3 1323
3468 61.6 3392
23829 62.0 11903
"""
names = [column._name f... | [
"def",
"arrange",
"(",
"*",
"args",
")",
":",
"names",
"=",
"[",
"column",
".",
"_name",
"for",
"column",
"in",
"args",
"]",
"def",
"f",
"(",
"df",
")",
":",
"sortby_df",
"=",
"df",
">>",
"mutate",
"(",
"*",
"args",
")",
"index",
"=",
"sortby_df"... | Sort DataFrame by the input column arguments.
>>> diamonds >> sample_n(5) >> arrange(X.price) >> select(X.depth, X.price)
Out:
depth price
28547 61.0 675
35132 59.1 889
42526 61.3 1323
3468 61.6 3392
23829 62.0 11903 | [
"Sort",
"DataFrame",
"by",
"the",
"input",
"column",
"arguments",
"."
] | 09c2a5f4ca67221b2a59928366ca8274357f7234 | https://github.com/dodger487/dplython/blob/09c2a5f4ca67221b2a59928366ca8274357f7234/dplython/dplython.py#L377-L394 | train |
dodger487/dplython | dplython/dplython.py | rename | def rename(**kwargs):
"""Rename one or more columns, leaving other columns unchanged
Example usage:
diamonds >> rename(new_name=old_name)
"""
def rename_columns(df):
column_assignments = {old_name_later._name: new_name
for new_name, old_name_later in kwargs.items()}
return... | python | def rename(**kwargs):
"""Rename one or more columns, leaving other columns unchanged
Example usage:
diamonds >> rename(new_name=old_name)
"""
def rename_columns(df):
column_assignments = {old_name_later._name: new_name
for new_name, old_name_later in kwargs.items()}
return... | [
"def",
"rename",
"(",
"**",
"kwargs",
")",
":",
"def",
"rename_columns",
"(",
"df",
")",
":",
"column_assignments",
"=",
"{",
"old_name_later",
".",
"_name",
":",
"new_name",
"for",
"new_name",
",",
"old_name_later",
"in",
"kwargs",
".",
"items",
"(",
")",... | Rename one or more columns, leaving other columns unchanged
Example usage:
diamonds >> rename(new_name=old_name) | [
"Rename",
"one",
"or",
"more",
"columns",
"leaving",
"other",
"columns",
"unchanged"
] | 09c2a5f4ca67221b2a59928366ca8274357f7234 | https://github.com/dodger487/dplython/blob/09c2a5f4ca67221b2a59928366ca8274357f7234/dplython/dplython.py#L453-L463 | train |
dodger487/dplython | dplython/dplython.py | transmute | def transmute(*args, **kwargs):
""" Similar to `select` but allows mutation in column definitions.
In : (diamonds >>
head(3) >>
transmute(new_price=X.price * 2, x_plus_y=X.x + X.y))
Out:
new_price x_plus_y
0 652 7.93
1 652 7.73
2 654 8.... | python | def transmute(*args, **kwargs):
""" Similar to `select` but allows mutation in column definitions.
In : (diamonds >>
head(3) >>
transmute(new_price=X.price * 2, x_plus_y=X.x + X.y))
Out:
new_price x_plus_y
0 652 7.93
1 652 7.73
2 654 8.... | [
"def",
"transmute",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"mutate_dateframe_fn",
"=",
"mutate",
"(",
"*",
"args",
",",
"**",
"dict",
"(",
"kwargs",
")",
")",
"column_names_args",
"=",
"[",
"str",
"(",
"arg",
")",
"for",
"arg",
"in",
"args"... | Similar to `select` but allows mutation in column definitions.
In : (diamonds >>
head(3) >>
transmute(new_price=X.price * 2, x_plus_y=X.x + X.y))
Out:
new_price x_plus_y
0 652 7.93
1 652 7.73
2 654 8.12 | [
"Similar",
"to",
"select",
"but",
"allows",
"mutation",
"in",
"column",
"definitions",
"."
] | 09c2a5f4ca67221b2a59928366ca8274357f7234 | https://github.com/dodger487/dplython/blob/09c2a5f4ca67221b2a59928366ca8274357f7234/dplython/dplython.py#L467-L484 | train |
dodger487/dplython | dplython/dplython.py | get_join_cols | def get_join_cols(by_entry):
""" helper function used for joins
builds left and right join list for join function
"""
left_cols = []
right_cols = []
for col in by_entry:
if isinstance(col, str):
left_cols.append(col)
right_cols.append(col)
else:
left_cols.append(col[0])
right... | python | def get_join_cols(by_entry):
""" helper function used for joins
builds left and right join list for join function
"""
left_cols = []
right_cols = []
for col in by_entry:
if isinstance(col, str):
left_cols.append(col)
right_cols.append(col)
else:
left_cols.append(col[0])
right... | [
"def",
"get_join_cols",
"(",
"by_entry",
")",
":",
"left_cols",
"=",
"[",
"]",
"right_cols",
"=",
"[",
"]",
"for",
"col",
"in",
"by_entry",
":",
"if",
"isinstance",
"(",
"col",
",",
"str",
")",
":",
"left_cols",
".",
"append",
"(",
"col",
")",
"right... | helper function used for joins
builds left and right join list for join function | [
"helper",
"function",
"used",
"for",
"joins",
"builds",
"left",
"and",
"right",
"join",
"list",
"for",
"join",
"function"
] | 09c2a5f4ca67221b2a59928366ca8274357f7234 | https://github.com/dodger487/dplython/blob/09c2a5f4ca67221b2a59928366ca8274357f7234/dplython/dplython.py#L504-L517 | train |
dodger487/dplython | dplython/dplython.py | mutating_join | def mutating_join(*args, **kwargs):
""" generic function for mutating dplyr-style joins
"""
# candidate for improvement
left = args[0]
right = args[1]
if 'by' in kwargs:
left_cols, right_cols = get_join_cols(kwargs['by'])
else:
left_cols, right_cols = None, None
if 'suffixes' in kwargs:
dsuf... | python | def mutating_join(*args, **kwargs):
""" generic function for mutating dplyr-style joins
"""
# candidate for improvement
left = args[0]
right = args[1]
if 'by' in kwargs:
left_cols, right_cols = get_join_cols(kwargs['by'])
else:
left_cols, right_cols = None, None
if 'suffixes' in kwargs:
dsuf... | [
"def",
"mutating_join",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"left",
"=",
"args",
"[",
"0",
"]",
"right",
"=",
"args",
"[",
"1",
"]",
"if",
"'by'",
"in",
"kwargs",
":",
"left_cols",
",",
"right_cols",
"=",
"get_join_cols",
"(",
"kwargs",
... | generic function for mutating dplyr-style joins | [
"generic",
"function",
"for",
"mutating",
"dplyr",
"-",
"style",
"joins"
] | 09c2a5f4ca67221b2a59928366ca8274357f7234 | https://github.com/dodger487/dplython/blob/09c2a5f4ca67221b2a59928366ca8274357f7234/dplython/dplython.py#L520-L542 | train |
mher/chartkick.py | chartkick/ext.py | ChartExtension._chart_support | def _chart_support(self, name, data, caller, **kwargs):
"template chart support function"
id = 'chart-%s' % next(self.id)
name = self._chart_class_name(name)
options = dict(self.environment.options)
options.update(name=name, id=id)
# jinja2 prepends 'l_' or 'l_{{ n }}'(v... | python | def _chart_support(self, name, data, caller, **kwargs):
"template chart support function"
id = 'chart-%s' % next(self.id)
name = self._chart_class_name(name)
options = dict(self.environment.options)
options.update(name=name, id=id)
# jinja2 prepends 'l_' or 'l_{{ n }}'(v... | [
"def",
"_chart_support",
"(",
"self",
",",
"name",
",",
"data",
",",
"caller",
",",
"**",
"kwargs",
")",
":",
"\"template chart support function\"",
"id",
"=",
"'chart-%s'",
"%",
"next",
"(",
"self",
".",
"id",
")",
"name",
"=",
"self",
".",
"_chart_class_... | template chart support function | [
"template",
"chart",
"support",
"function"
] | 3411f36a069560fe1ba218e0a35f68c413332f63 | https://github.com/mher/chartkick.py/blob/3411f36a069560fe1ba218e0a35f68c413332f63/chartkick/ext.py#L63-L88 | train |
mher/chartkick.py | chartkick/ext.py | ChartExtension.load_library | def load_library(self):
"loads configuration options"
try:
filename = self.environment.get_template('chartkick.json').filename
except TemplateNotFound:
return {}
else:
options = Options()
options.load(filename)
return options | python | def load_library(self):
"loads configuration options"
try:
filename = self.environment.get_template('chartkick.json').filename
except TemplateNotFound:
return {}
else:
options = Options()
options.load(filename)
return options | [
"def",
"load_library",
"(",
"self",
")",
":",
"\"loads configuration options\"",
"try",
":",
"filename",
"=",
"self",
".",
"environment",
".",
"get_template",
"(",
"'chartkick.json'",
")",
".",
"filename",
"except",
"TemplateNotFound",
":",
"return",
"{",
"}",
"... | loads configuration options | [
"loads",
"configuration",
"options"
] | 3411f36a069560fe1ba218e0a35f68c413332f63 | https://github.com/mher/chartkick.py/blob/3411f36a069560fe1ba218e0a35f68c413332f63/chartkick/ext.py#L94-L103 | train |
mher/chartkick.py | chartkick/__init__.py | js | def js():
"returns home directory of js"
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'js') | python | def js():
"returns home directory of js"
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'js') | [
"def",
"js",
"(",
")",
":",
"\"returns home directory of js\"",
"return",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
",",
"'js'",
")"
] | returns home directory of js | [
"returns",
"home",
"directory",
"of",
"js"
] | 3411f36a069560fe1ba218e0a35f68c413332f63 | https://github.com/mher/chartkick.py/blob/3411f36a069560fe1ba218e0a35f68c413332f63/chartkick/__init__.py#L8-L10 | train |
mher/chartkick.py | chartkick/templatetags/chartkick.py | parse_options | def parse_options(source):
"""parses chart tag options"""
options = {}
tokens = [t.strip() for t in source.split('=')]
name = tokens[0]
for token in tokens[1:-1]:
value, next_name = token.rsplit(' ', 1)
options[name.strip()] = value
name = next_name
options[name.strip()]... | python | def parse_options(source):
"""parses chart tag options"""
options = {}
tokens = [t.strip() for t in source.split('=')]
name = tokens[0]
for token in tokens[1:-1]:
value, next_name = token.rsplit(' ', 1)
options[name.strip()] = value
name = next_name
options[name.strip()]... | [
"def",
"parse_options",
"(",
"source",
")",
":",
"options",
"=",
"{",
"}",
"tokens",
"=",
"[",
"t",
".",
"strip",
"(",
")",
"for",
"t",
"in",
"source",
".",
"split",
"(",
"'='",
")",
"]",
"name",
"=",
"tokens",
"[",
"0",
"]",
"for",
"token",
"i... | parses chart tag options | [
"parses",
"chart",
"tag",
"options"
] | 3411f36a069560fe1ba218e0a35f68c413332f63 | https://github.com/mher/chartkick.py/blob/3411f36a069560fe1ba218e0a35f68c413332f63/chartkick/templatetags/chartkick.py#L91-L102 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.copy | def copy(self):
"""Returns a copy of the RigidTransform.
Returns
-------
:obj:`RigidTransform`
A deep copy of the RigidTransform.
"""
return RigidTransform(np.copy(self.rotation), np.copy(self.translation), self.from_frame, self.to_frame) | python | def copy(self):
"""Returns a copy of the RigidTransform.
Returns
-------
:obj:`RigidTransform`
A deep copy of the RigidTransform.
"""
return RigidTransform(np.copy(self.rotation), np.copy(self.translation), self.from_frame, self.to_frame) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"RigidTransform",
"(",
"np",
".",
"copy",
"(",
"self",
".",
"rotation",
")",
",",
"np",
".",
"copy",
"(",
"self",
".",
"translation",
")",
",",
"self",
".",
"from_frame",
",",
"self",
".",
"to_frame",
... | Returns a copy of the RigidTransform.
Returns
-------
:obj:`RigidTransform`
A deep copy of the RigidTransform. | [
"Returns",
"a",
"copy",
"of",
"the",
"RigidTransform",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L81-L89 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform._check_valid_rotation | def _check_valid_rotation(self, rotation):
"""Checks that the given rotation matrix is valid.
"""
if not isinstance(rotation, np.ndarray) or not np.issubdtype(rotation.dtype, np.number):
raise ValueError('Rotation must be specified as numeric numpy array')
if len(rotation.sh... | python | def _check_valid_rotation(self, rotation):
"""Checks that the given rotation matrix is valid.
"""
if not isinstance(rotation, np.ndarray) or not np.issubdtype(rotation.dtype, np.number):
raise ValueError('Rotation must be specified as numeric numpy array')
if len(rotation.sh... | [
"def",
"_check_valid_rotation",
"(",
"self",
",",
"rotation",
")",
":",
"if",
"not",
"isinstance",
"(",
"rotation",
",",
"np",
".",
"ndarray",
")",
"or",
"not",
"np",
".",
"issubdtype",
"(",
"rotation",
".",
"dtype",
",",
"np",
".",
"number",
")",
":",... | Checks that the given rotation matrix is valid. | [
"Checks",
"that",
"the",
"given",
"rotation",
"matrix",
"is",
"valid",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L91-L101 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform._check_valid_translation | def _check_valid_translation(self, translation):
"""Checks that the translation vector is valid.
"""
if not isinstance(translation, np.ndarray) or not np.issubdtype(translation.dtype, np.number):
raise ValueError('Translation must be specified as numeric numpy array')
t = tr... | python | def _check_valid_translation(self, translation):
"""Checks that the translation vector is valid.
"""
if not isinstance(translation, np.ndarray) or not np.issubdtype(translation.dtype, np.number):
raise ValueError('Translation must be specified as numeric numpy array')
t = tr... | [
"def",
"_check_valid_translation",
"(",
"self",
",",
"translation",
")",
":",
"if",
"not",
"isinstance",
"(",
"translation",
",",
"np",
".",
"ndarray",
")",
"or",
"not",
"np",
".",
"issubdtype",
"(",
"translation",
".",
"dtype",
",",
"np",
".",
"number",
... | Checks that the translation vector is valid. | [
"Checks",
"that",
"the",
"translation",
"vector",
"is",
"valid",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L103-L111 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.interpolate_with | def interpolate_with(self, other_tf, t):
"""Interpolate with another rigid transformation.
Parameters
----------
other_tf : :obj:`RigidTransform`
The transform to interpolate with.
t : float
The interpolation step in [0,1], where 0 favors this RigidTrans... | python | def interpolate_with(self, other_tf, t):
"""Interpolate with another rigid transformation.
Parameters
----------
other_tf : :obj:`RigidTransform`
The transform to interpolate with.
t : float
The interpolation step in [0,1], where 0 favors this RigidTrans... | [
"def",
"interpolate_with",
"(",
"self",
",",
"other_tf",
",",
"t",
")",
":",
"if",
"t",
"<",
"0",
"or",
"t",
">",
"1",
":",
"raise",
"ValueError",
"(",
"'Must interpolate between 0 and 1'",
")",
"interp_translation",
"=",
"(",
"1.0",
"-",
"t",
")",
"*",
... | Interpolate with another rigid transformation.
Parameters
----------
other_tf : :obj:`RigidTransform`
The transform to interpolate with.
t : float
The interpolation step in [0,1], where 0 favors this RigidTransform.
Returns
-------
:obj:... | [
"Interpolate",
"with",
"another",
"rigid",
"transformation",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L288-L316 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.linear_trajectory_to | def linear_trajectory_to(self, target_tf, traj_len):
"""Creates a trajectory of poses linearly interpolated from this tf to a target tf.
Parameters
----------
target_tf : :obj:`RigidTransform`
The RigidTransform to interpolate to.
traj_len : int
The numbe... | python | def linear_trajectory_to(self, target_tf, traj_len):
"""Creates a trajectory of poses linearly interpolated from this tf to a target tf.
Parameters
----------
target_tf : :obj:`RigidTransform`
The RigidTransform to interpolate to.
traj_len : int
The numbe... | [
"def",
"linear_trajectory_to",
"(",
"self",
",",
"target_tf",
",",
"traj_len",
")",
":",
"if",
"traj_len",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'Traj len must at least 0'",
")",
"delta_t",
"=",
"1.0",
"/",
"(",
"traj_len",
"+",
"1",
")",
"t",
"=",
... | Creates a trajectory of poses linearly interpolated from this tf to a target tf.
Parameters
----------
target_tf : :obj:`RigidTransform`
The RigidTransform to interpolate to.
traj_len : int
The number of RigidTransforms in the returned trajectory.
Return... | [
"Creates",
"a",
"trajectory",
"of",
"poses",
"linearly",
"interpolated",
"from",
"this",
"tf",
"to",
"a",
"target",
"tf",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L318-L342 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.apply | def apply(self, points):
"""Applies the rigid transformation to a set of 3D objects.
Parameters
----------
points : :obj:`BagOfPoints`
A set of objects to transform. Could be any subclass of BagOfPoints.
Returns
-------
:obj:`BagOfPoints`
... | python | def apply(self, points):
"""Applies the rigid transformation to a set of 3D objects.
Parameters
----------
points : :obj:`BagOfPoints`
A set of objects to transform. Could be any subclass of BagOfPoints.
Returns
-------
:obj:`BagOfPoints`
... | [
"def",
"apply",
"(",
"self",
",",
"points",
")",
":",
"if",
"not",
"isinstance",
"(",
"points",
",",
"BagOfPoints",
")",
":",
"raise",
"ValueError",
"(",
"'Rigid transformations can only be applied to bags of points'",
")",
"if",
"points",
".",
"dim",
"!=",
"3",... | Applies the rigid transformation to a set of 3D objects.
Parameters
----------
points : :obj:`BagOfPoints`
A set of objects to transform. Could be any subclass of BagOfPoints.
Returns
-------
:obj:`BagOfPoints`
A transformed set of objects of the... | [
"Applies",
"the",
"rigid",
"transformation",
"to",
"a",
"set",
"of",
"3D",
"objects",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L344-L392 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.dot | def dot(self, other_tf):
"""Compose this rigid transform with another.
This transform is on the left-hand side of the composition.
Parameters
----------
other_tf : :obj:`RigidTransform`
The other RigidTransform to compose with this one.
Returns
----... | python | def dot(self, other_tf):
"""Compose this rigid transform with another.
This transform is on the left-hand side of the composition.
Parameters
----------
other_tf : :obj:`RigidTransform`
The other RigidTransform to compose with this one.
Returns
----... | [
"def",
"dot",
"(",
"self",
",",
"other_tf",
")",
":",
"if",
"other_tf",
".",
"to_frame",
"!=",
"self",
".",
"from_frame",
":",
"raise",
"ValueError",
"(",
"'To frame of right hand side ({0}) must match from frame of left hand side ({1})'",
".",
"format",
"(",
"other_t... | Compose this rigid transform with another.
This transform is on the left-hand side of the composition.
Parameters
----------
other_tf : :obj:`RigidTransform`
The other RigidTransform to compose with this one.
Returns
-------
:obj:`RigidTransform`
... | [
"Compose",
"this",
"rigid",
"transform",
"with",
"another",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L394-L427 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.inverse | def inverse(self):
"""Take the inverse of the rigid transform.
Returns
-------
:obj:`RigidTransform`
The inverse of this RigidTransform.
"""
inv_rotation = self.rotation.T
inv_translation = np.dot(-self.rotation.T, self.translation)
return Rig... | python | def inverse(self):
"""Take the inverse of the rigid transform.
Returns
-------
:obj:`RigidTransform`
The inverse of this RigidTransform.
"""
inv_rotation = self.rotation.T
inv_translation = np.dot(-self.rotation.T, self.translation)
return Rig... | [
"def",
"inverse",
"(",
"self",
")",
":",
"inv_rotation",
"=",
"self",
".",
"rotation",
".",
"T",
"inv_translation",
"=",
"np",
".",
"dot",
"(",
"-",
"self",
".",
"rotation",
".",
"T",
",",
"self",
".",
"translation",
")",
"return",
"RigidTransform",
"(... | Take the inverse of the rigid transform.
Returns
-------
:obj:`RigidTransform`
The inverse of this RigidTransform. | [
"Take",
"the",
"inverse",
"of",
"the",
"rigid",
"transform",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L456-L468 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.save | def save(self, filename):
"""Save the RigidTransform to a file.
The file format is:
from_frame
to_frame
translation (space separated)
rotation_row_0 (space separated)
rotation_row_1 (space separated)
rotation_row_2 (space separated)
Parameters
... | python | def save(self, filename):
"""Save the RigidTransform to a file.
The file format is:
from_frame
to_frame
translation (space separated)
rotation_row_0 (space separated)
rotation_row_1 (space separated)
rotation_row_2 (space separated)
Parameters
... | [
"def",
"save",
"(",
"self",
",",
"filename",
")",
":",
"file_root",
",",
"file_ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"if",
"file_ext",
".",
"lower",
"(",
")",
"!=",
"TF_EXTENSION",
":",
"raise",
"ValueError",
"(",
"'Exten... | Save the RigidTransform to a file.
The file format is:
from_frame
to_frame
translation (space separated)
rotation_row_0 (space separated)
rotation_row_1 (space separated)
rotation_row_2 (space separated)
Parameters
----------
filename : :... | [
"Save",
"the",
"RigidTransform",
"to",
"a",
"file",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L470-L502 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.as_frames | def as_frames(self, from_frame, to_frame='world'):
"""Return a shallow copy of this rigid transform with just the frames
changed.
Parameters
----------
from_frame : :obj:`str`
The new from_frame.
to_frame : :obj:`str`
The new to_frame.
R... | python | def as_frames(self, from_frame, to_frame='world'):
"""Return a shallow copy of this rigid transform with just the frames
changed.
Parameters
----------
from_frame : :obj:`str`
The new from_frame.
to_frame : :obj:`str`
The new to_frame.
R... | [
"def",
"as_frames",
"(",
"self",
",",
"from_frame",
",",
"to_frame",
"=",
"'world'",
")",
":",
"return",
"RigidTransform",
"(",
"self",
".",
"rotation",
",",
"self",
".",
"translation",
",",
"from_frame",
",",
"to_frame",
")"
] | Return a shallow copy of this rigid transform with just the frames
changed.
Parameters
----------
from_frame : :obj:`str`
The new from_frame.
to_frame : :obj:`str`
The new to_frame.
Returns
-------
:obj:`RigidTransform`
... | [
"Return",
"a",
"shallow",
"copy",
"of",
"this",
"rigid",
"transform",
"with",
"just",
"the",
"frames",
"changed",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L504-L521 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.rotation_from_quaternion | def rotation_from_quaternion(q_wxyz):
"""Convert quaternion array to rotation matrix.
Parameters
----------
q_wxyz : :obj:`numpy.ndarray` of float
A quaternion in wxyz order.
Returns
-------
:obj:`numpy.ndarray` of float
A 3x3 rotation ma... | python | def rotation_from_quaternion(q_wxyz):
"""Convert quaternion array to rotation matrix.
Parameters
----------
q_wxyz : :obj:`numpy.ndarray` of float
A quaternion in wxyz order.
Returns
-------
:obj:`numpy.ndarray` of float
A 3x3 rotation ma... | [
"def",
"rotation_from_quaternion",
"(",
"q_wxyz",
")",
":",
"q_xyzw",
"=",
"np",
".",
"array",
"(",
"[",
"q_wxyz",
"[",
"1",
"]",
",",
"q_wxyz",
"[",
"2",
"]",
",",
"q_wxyz",
"[",
"3",
"]",
",",
"q_wxyz",
"[",
"0",
"]",
"]",
")",
"R",
"=",
"tra... | Convert quaternion array to rotation matrix.
Parameters
----------
q_wxyz : :obj:`numpy.ndarray` of float
A quaternion in wxyz order.
Returns
-------
:obj:`numpy.ndarray` of float
A 3x3 rotation matrix made from the quaternion. | [
"Convert",
"quaternion",
"array",
"to",
"rotation",
"matrix",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L700-L715 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.quaternion_from_axis_angle | def quaternion_from_axis_angle(v):
"""Convert axis-angle representation to a quaternion vector.
Parameters
----------
v : :obj:`numpy.ndarray` of float
An axis-angle representation.
Returns
-------
:obj:`numpy.ndarray` of float
A quaterni... | python | def quaternion_from_axis_angle(v):
"""Convert axis-angle representation to a quaternion vector.
Parameters
----------
v : :obj:`numpy.ndarray` of float
An axis-angle representation.
Returns
-------
:obj:`numpy.ndarray` of float
A quaterni... | [
"def",
"quaternion_from_axis_angle",
"(",
"v",
")",
":",
"theta",
"=",
"np",
".",
"linalg",
".",
"norm",
"(",
"v",
")",
"if",
"theta",
">",
"0",
":",
"v",
"=",
"v",
"/",
"np",
".",
"linalg",
".",
"norm",
"(",
"v",
")",
"ax",
",",
"ay",
",",
"... | Convert axis-angle representation to a quaternion vector.
Parameters
----------
v : :obj:`numpy.ndarray` of float
An axis-angle representation.
Returns
-------
:obj:`numpy.ndarray` of float
A quaternion vector from the axis-angle vector. | [
"Convert",
"axis",
"-",
"angle",
"representation",
"to",
"a",
"quaternion",
"vector",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L719-L741 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.transform_from_dual_quaternion | def transform_from_dual_quaternion(dq, from_frame='unassigned', to_frame='world'):
"""Create a RigidTransform from a DualQuaternion.
Parameters
----------
dq : :obj:`DualQuaternion`
The DualQuaternion to transform.
from_frame : :obj:`str`
A name for the ... | python | def transform_from_dual_quaternion(dq, from_frame='unassigned', to_frame='world'):
"""Create a RigidTransform from a DualQuaternion.
Parameters
----------
dq : :obj:`DualQuaternion`
The DualQuaternion to transform.
from_frame : :obj:`str`
A name for the ... | [
"def",
"transform_from_dual_quaternion",
"(",
"dq",
",",
"from_frame",
"=",
"'unassigned'",
",",
"to_frame",
"=",
"'world'",
")",
":",
"quaternion",
"=",
"dq",
".",
"qr",
"translation",
"=",
"2",
"*",
"dq",
".",
"qd",
"[",
"1",
":",
"]",
"return",
"Rigid... | Create a RigidTransform from a DualQuaternion.
Parameters
----------
dq : :obj:`DualQuaternion`
The DualQuaternion to transform.
from_frame : :obj:`str`
A name for the frame of reference on which this transform
operates.
to_frame : :obj:`str... | [
"Create",
"a",
"RigidTransform",
"from",
"a",
"DualQuaternion",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L760-L783 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.rotation_and_translation_from_matrix | def rotation_and_translation_from_matrix(matrix):
"""Helper to convert 4x4 matrix to rotation matrix and translation vector.
Parameters
----------
matrix : :obj:`numpy.ndarray` of float
4x4 rigid transformation matrix to be converted.
Returns
-------
... | python | def rotation_and_translation_from_matrix(matrix):
"""Helper to convert 4x4 matrix to rotation matrix and translation vector.
Parameters
----------
matrix : :obj:`numpy.ndarray` of float
4x4 rigid transformation matrix to be converted.
Returns
-------
... | [
"def",
"rotation_and_translation_from_matrix",
"(",
"matrix",
")",
":",
"if",
"not",
"isinstance",
"(",
"matrix",
",",
"np",
".",
"ndarray",
")",
"or",
"matrix",
".",
"shape",
"[",
"0",
"]",
"!=",
"4",
"or",
"matrix",
".",
"shape",
"[",
"1",
"]",
"!=",... | Helper to convert 4x4 matrix to rotation matrix and translation vector.
Parameters
----------
matrix : :obj:`numpy.ndarray` of float
4x4 rigid transformation matrix to be converted.
Returns
-------
:obj:`tuple` of :obj:`numpy.ndarray` of float
A ... | [
"Helper",
"to",
"convert",
"4x4",
"matrix",
"to",
"rotation",
"matrix",
"and",
"translation",
"vector",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L786-L809 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.rotation_from_axis_and_origin | def rotation_from_axis_and_origin(axis, origin, angle, to_frame='world'):
"""
Returns a rotation matrix around some arbitrary axis, about the point origin, using Rodrigues Formula
Parameters
----------
axis : :obj:`numpy.ndarray` of float
3x1 vector representing whic... | python | def rotation_from_axis_and_origin(axis, origin, angle, to_frame='world'):
"""
Returns a rotation matrix around some arbitrary axis, about the point origin, using Rodrigues Formula
Parameters
----------
axis : :obj:`numpy.ndarray` of float
3x1 vector representing whic... | [
"def",
"rotation_from_axis_and_origin",
"(",
"axis",
",",
"origin",
",",
"angle",
",",
"to_frame",
"=",
"'world'",
")",
":",
"axis_hat",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"0",
",",
"-",
"axis",
"[",
"2",
"]",
",",
"axis",
"[",
"1",
"]",
"]",
... | Returns a rotation matrix around some arbitrary axis, about the point origin, using Rodrigues Formula
Parameters
----------
axis : :obj:`numpy.ndarray` of float
3x1 vector representing which axis we should be rotating about
origin : :obj:`numpy.ndarray` of float
... | [
"Returns",
"a",
"rotation",
"matrix",
"around",
"some",
"arbitrary",
"axis",
"about",
"the",
"point",
"origin",
"using",
"Rodrigues",
"Formula"
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L812-L840 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.x_axis_rotation | def x_axis_rotation(theta):
"""Generates a 3x3 rotation matrix for a rotation of angle
theta about the x axis.
Parameters
----------
theta : float
amount to rotate, in radians
Returns
-------
:obj:`numpy.ndarray` of float
A random... | python | def x_axis_rotation(theta):
"""Generates a 3x3 rotation matrix for a rotation of angle
theta about the x axis.
Parameters
----------
theta : float
amount to rotate, in radians
Returns
-------
:obj:`numpy.ndarray` of float
A random... | [
"def",
"x_axis_rotation",
"(",
"theta",
")",
":",
"R",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
",",
"0",
",",
"]",
",",
"[",
"0",
",",
"np",
".",
"cos",
"(",
"theta",
")",
",",
"-",
"np",
".",
"sin",
"(",
"theta",
")",
"]",... | Generates a 3x3 rotation matrix for a rotation of angle
theta about the x axis.
Parameters
----------
theta : float
amount to rotate, in radians
Returns
-------
:obj:`numpy.ndarray` of float
A random 3x3 rotation matrix. | [
"Generates",
"a",
"3x3",
"rotation",
"matrix",
"for",
"a",
"rotation",
"of",
"angle",
"theta",
"about",
"the",
"x",
"axis",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L843-L860 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.y_axis_rotation | def y_axis_rotation(theta):
"""Generates a 3x3 rotation matrix for a rotation of angle
theta about the y axis.
Parameters
----------
theta : float
amount to rotate, in radians
Returns
-------
:obj:`numpy.ndarray` of float
A random... | python | def y_axis_rotation(theta):
"""Generates a 3x3 rotation matrix for a rotation of angle
theta about the y axis.
Parameters
----------
theta : float
amount to rotate, in radians
Returns
-------
:obj:`numpy.ndarray` of float
A random... | [
"def",
"y_axis_rotation",
"(",
"theta",
")",
":",
"R",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"np",
".",
"cos",
"(",
"theta",
")",
",",
"0",
",",
"np",
".",
"sin",
"(",
"theta",
")",
"]",
",",
"[",
"0",
",",
"1",
",",
"0",
"]",
",",
"[",... | Generates a 3x3 rotation matrix for a rotation of angle
theta about the y axis.
Parameters
----------
theta : float
amount to rotate, in radians
Returns
-------
:obj:`numpy.ndarray` of float
A random 3x3 rotation matrix. | [
"Generates",
"a",
"3x3",
"rotation",
"matrix",
"for",
"a",
"rotation",
"of",
"angle",
"theta",
"about",
"the",
"y",
"axis",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L863-L880 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.z_axis_rotation | def z_axis_rotation(theta):
"""Generates a 3x3 rotation matrix for a rotation of angle
theta about the z axis.
Parameters
----------
theta : float
amount to rotate, in radians
Returns
-------
:obj:`numpy.ndarray` of float
A random... | python | def z_axis_rotation(theta):
"""Generates a 3x3 rotation matrix for a rotation of angle
theta about the z axis.
Parameters
----------
theta : float
amount to rotate, in radians
Returns
-------
:obj:`numpy.ndarray` of float
A random... | [
"def",
"z_axis_rotation",
"(",
"theta",
")",
":",
"R",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"np",
".",
"cos",
"(",
"theta",
")",
",",
"-",
"np",
".",
"sin",
"(",
"theta",
")",
",",
"0",
"]",
",",
"[",
"np",
".",
"sin",
"(",
"theta",
")",... | Generates a 3x3 rotation matrix for a rotation of angle
theta about the z axis.
Parameters
----------
theta : float
amount to rotate, in radians
Returns
-------
:obj:`numpy.ndarray` of float
A random 3x3 rotation matrix. | [
"Generates",
"a",
"3x3",
"rotation",
"matrix",
"for",
"a",
"rotation",
"of",
"angle",
"theta",
"about",
"the",
"z",
"axis",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L883-L900 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.random_rotation | def random_rotation():
"""Generates a random 3x3 rotation matrix with SVD.
Returns
-------
:obj:`numpy.ndarray` of float
A random 3x3 rotation matrix.
"""
rand_seed = np.random.rand(3, 3)
U, S, V = np.linalg.svd(rand_seed)
return U | python | def random_rotation():
"""Generates a random 3x3 rotation matrix with SVD.
Returns
-------
:obj:`numpy.ndarray` of float
A random 3x3 rotation matrix.
"""
rand_seed = np.random.rand(3, 3)
U, S, V = np.linalg.svd(rand_seed)
return U | [
"def",
"random_rotation",
"(",
")",
":",
"rand_seed",
"=",
"np",
".",
"random",
".",
"rand",
"(",
"3",
",",
"3",
")",
"U",
",",
"S",
",",
"V",
"=",
"np",
".",
"linalg",
".",
"svd",
"(",
"rand_seed",
")",
"return",
"U"
] | Generates a random 3x3 rotation matrix with SVD.
Returns
-------
:obj:`numpy.ndarray` of float
A random 3x3 rotation matrix. | [
"Generates",
"a",
"random",
"3x3",
"rotation",
"matrix",
"with",
"SVD",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L903-L913 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.rotation_from_axes | def rotation_from_axes(x_axis, y_axis, z_axis):
"""Convert specification of axis in target frame to
a rotation matrix from source to target frame.
Parameters
----------
x_axis : :obj:`numpy.ndarray` of float
A normalized 3-vector for the target frame's x-axis.
... | python | def rotation_from_axes(x_axis, y_axis, z_axis):
"""Convert specification of axis in target frame to
a rotation matrix from source to target frame.
Parameters
----------
x_axis : :obj:`numpy.ndarray` of float
A normalized 3-vector for the target frame's x-axis.
... | [
"def",
"rotation_from_axes",
"(",
"x_axis",
",",
"y_axis",
",",
"z_axis",
")",
":",
"return",
"np",
".",
"hstack",
"(",
"(",
"x_axis",
"[",
":",
",",
"np",
".",
"newaxis",
"]",
",",
"y_axis",
"[",
":",
",",
"np",
".",
"newaxis",
"]",
",",
"z_axis",... | Convert specification of axis in target frame to
a rotation matrix from source to target frame.
Parameters
----------
x_axis : :obj:`numpy.ndarray` of float
A normalized 3-vector for the target frame's x-axis.
y_axis : :obj:`numpy.ndarray` of float
A nor... | [
"Convert",
"specification",
"of",
"axis",
"in",
"target",
"frame",
"to",
"a",
"rotation",
"matrix",
"from",
"source",
"to",
"target",
"frame",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L927-L948 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.interpolate | def interpolate(T0, T1, t):
"""Return an interpolation of two RigidTransforms.
Parameters
----------
T0 : :obj:`RigidTransform`
The first RigidTransform to interpolate.
T1 : :obj:`RigidTransform`
The second RigidTransform to interpolate.
t : flo... | python | def interpolate(T0, T1, t):
"""Return an interpolation of two RigidTransforms.
Parameters
----------
T0 : :obj:`RigidTransform`
The first RigidTransform to interpolate.
T1 : :obj:`RigidTransform`
The second RigidTransform to interpolate.
t : flo... | [
"def",
"interpolate",
"(",
"T0",
",",
"T1",
",",
"t",
")",
":",
"if",
"T0",
".",
"to_frame",
"!=",
"T1",
".",
"to_frame",
":",
"raise",
"ValueError",
"(",
"'Cannot interpolate between 2 transforms with different to frames! Got T1 {0} and T2 {1}'",
".",
"format",
"("... | Return an interpolation of two RigidTransforms.
Parameters
----------
T0 : :obj:`RigidTransform`
The first RigidTransform to interpolate.
T1 : :obj:`RigidTransform`
The second RigidTransform to interpolate.
t : float
The interpolation step i... | [
"Return",
"an",
"interpolation",
"of",
"two",
"RigidTransforms",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L973-L1004 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | RigidTransform.load | def load(filename):
"""Load a RigidTransform from a file.
The file format is:
from_frame
to_frame
translation (space separated)
rotation_row_0 (space separated)
rotation_row_1 (space separated)
rotation_row_2 (space separated)
Parameters
... | python | def load(filename):
"""Load a RigidTransform from a file.
The file format is:
from_frame
to_frame
translation (space separated)
rotation_row_0 (space separated)
rotation_row_1 (space separated)
rotation_row_2 (space separated)
Parameters
... | [
"def",
"load",
"(",
"filename",
")",
":",
"file_root",
",",
"file_ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"if",
"file_ext",
".",
"lower",
"(",
")",
"!=",
"TF_EXTENSION",
":",
"raise",
"ValueError",
"(",
"'Extension %s not suppo... | Load a RigidTransform from a file.
The file format is:
from_frame
to_frame
translation (space separated)
rotation_row_0 (space separated)
rotation_row_1 (space separated)
rotation_row_2 (space separated)
Parameters
----------
filename : :... | [
"Load",
"a",
"RigidTransform",
"from",
"a",
"file",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L1007-L1066 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | SimilarityTransform.dot | def dot(self, other_tf):
"""Compose this simliarity transform with another.
This transform is on the left-hand side of the composition.
Parameters
----------
other_tf : :obj:`SimilarityTransform`
The other SimilarityTransform to compose with this one.
Retur... | python | def dot(self, other_tf):
"""Compose this simliarity transform with another.
This transform is on the left-hand side of the composition.
Parameters
----------
other_tf : :obj:`SimilarityTransform`
The other SimilarityTransform to compose with this one.
Retur... | [
"def",
"dot",
"(",
"self",
",",
"other_tf",
")",
":",
"if",
"other_tf",
".",
"to_frame",
"!=",
"self",
".",
"from_frame",
":",
"raise",
"ValueError",
"(",
"'To frame of right hand side ({0}) must match from frame of left hand side ({1})'",
".",
"format",
"(",
"other_t... | Compose this simliarity transform with another.
This transform is on the left-hand side of the composition.
Parameters
----------
other_tf : :obj:`SimilarityTransform`
The other SimilarityTransform to compose with this one.
Returns
-------
:obj:`Sim... | [
"Compose",
"this",
"simliarity",
"transform",
"with",
"another",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L1187-L1222 | train |
BerkeleyAutomation/autolab_core | autolab_core/rigid_transformations.py | SimilarityTransform.inverse | def inverse(self):
"""Take the inverse of the similarity transform.
Returns
-------
:obj:`SimilarityTransform`
The inverse of this SimilarityTransform.
"""
inv_rot = np.linalg.inv(self.rotation)
inv_scale = 1.0 / self.scale
inv_trans = -inv_sc... | python | def inverse(self):
"""Take the inverse of the similarity transform.
Returns
-------
:obj:`SimilarityTransform`
The inverse of this SimilarityTransform.
"""
inv_rot = np.linalg.inv(self.rotation)
inv_scale = 1.0 / self.scale
inv_trans = -inv_sc... | [
"def",
"inverse",
"(",
"self",
")",
":",
"inv_rot",
"=",
"np",
".",
"linalg",
".",
"inv",
"(",
"self",
".",
"rotation",
")",
"inv_scale",
"=",
"1.0",
"/",
"self",
".",
"scale",
"inv_trans",
"=",
"-",
"inv_scale",
"*",
"inv_rot",
".",
"dot",
"(",
"s... | Take the inverse of the similarity transform.
Returns
-------
:obj:`SimilarityTransform`
The inverse of this SimilarityTransform. | [
"Take",
"the",
"inverse",
"of",
"the",
"similarity",
"transform",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/rigid_transformations.py#L1224-L1237 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | BagOfPoints.save | def save(self, filename):
"""Saves the collection to a file.
Parameters
----------
filename : :obj:`str`
The file to save the collection to.
Raises
------
ValueError
If the file extension is not .npy or .npz.
"""
file_root... | python | def save(self, filename):
"""Saves the collection to a file.
Parameters
----------
filename : :obj:`str`
The file to save the collection to.
Raises
------
ValueError
If the file extension is not .npy or .npz.
"""
file_root... | [
"def",
"save",
"(",
"self",
",",
"filename",
")",
":",
"file_root",
",",
"file_ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"if",
"file_ext",
"==",
"'.npy'",
":",
"np",
".",
"save",
"(",
"filename",
",",
"self",
".",
"_data",
... | Saves the collection to a file.
Parameters
----------
filename : :obj:`str`
The file to save the collection to.
Raises
------
ValueError
If the file extension is not .npy or .npz. | [
"Saves",
"the",
"collection",
"to",
"a",
"file",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L112-L131 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | BagOfPoints.load_data | def load_data(filename):
"""Loads data from a file.
Parameters
----------
filename : :obj:`str`
The file to load the collection from.
Returns
-------
:obj:`numpy.ndarray` of float
The data read from the file.
Raises
-----... | python | def load_data(filename):
"""Loads data from a file.
Parameters
----------
filename : :obj:`str`
The file to load the collection from.
Returns
-------
:obj:`numpy.ndarray` of float
The data read from the file.
Raises
-----... | [
"def",
"load_data",
"(",
"filename",
")",
":",
"file_root",
",",
"file_ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"data",
"=",
"None",
"if",
"file_ext",
"==",
"'.npy'",
":",
"data",
"=",
"np",
".",
"load",
"(",
"filename",
"... | Loads data from a file.
Parameters
----------
filename : :obj:`str`
The file to load the collection from.
Returns
-------
:obj:`numpy.ndarray` of float
The data read from the file.
Raises
------
ValueError
If ... | [
"Loads",
"data",
"from",
"a",
"file",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L133-L159 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | Point.open | def open(filename, frame='unspecified'):
"""Create a Point from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created point.
Returns
-------
... | python | def open(filename, frame='unspecified'):
"""Create a Point from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created point.
Returns
-------
... | [
"def",
"open",
"(",
"filename",
",",
"frame",
"=",
"'unspecified'",
")",
":",
"data",
"=",
"BagOfPoints",
".",
"load_data",
"(",
"filename",
")",
"return",
"Point",
"(",
"data",
",",
"frame",
")"
] | Create a Point from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created point.
Returns
-------
:obj:`Point`
A point created from t... | [
"Create",
"a",
"Point",
"from",
"data",
"saved",
"in",
"a",
"file",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L371-L388 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | Direction._check_valid_data | def _check_valid_data(self, data):
"""Checks that the incoming data is a Nx1 ndarray.
Parameters
----------
data : :obj:`numpy.ndarray`
The data to verify.
Raises
------
ValueError
If the data is not of the correct shape or if the vector ... | python | def _check_valid_data(self, data):
"""Checks that the incoming data is a Nx1 ndarray.
Parameters
----------
data : :obj:`numpy.ndarray`
The data to verify.
Raises
------
ValueError
If the data is not of the correct shape or if the vector ... | [
"def",
"_check_valid_data",
"(",
"self",
",",
"data",
")",
":",
"if",
"len",
"(",
"data",
".",
"shape",
")",
"==",
"2",
"and",
"data",
".",
"shape",
"[",
"1",
"]",
"!=",
"1",
":",
"raise",
"ValueError",
"(",
"'Can only initialize Direction from a single Nx... | Checks that the incoming data is a Nx1 ndarray.
Parameters
----------
data : :obj:`numpy.ndarray`
The data to verify.
Raises
------
ValueError
If the data is not of the correct shape or if the vector is not
normed. | [
"Checks",
"that",
"the",
"incoming",
"data",
"is",
"a",
"Nx1",
"ndarray",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L405-L422 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | Direction.orthogonal_basis | def orthogonal_basis(self):
"""Return an orthogonal basis to this direction.
Note
----
Only implemented in 3D.
Returns
-------
:obj:`tuple` of :obj:`Direction`
The pair of normalized Direction vectors that form a basis of
this directi... | python | def orthogonal_basis(self):
"""Return an orthogonal basis to this direction.
Note
----
Only implemented in 3D.
Returns
-------
:obj:`tuple` of :obj:`Direction`
The pair of normalized Direction vectors that form a basis of
this directi... | [
"def",
"orthogonal_basis",
"(",
"self",
")",
":",
"if",
"self",
".",
"dim",
"==",
"3",
":",
"x_arr",
"=",
"np",
".",
"array",
"(",
"[",
"-",
"self",
".",
"data",
"[",
"1",
"]",
",",
"self",
".",
"data",
"[",
"0",
"]",
",",
"0",
"]",
")",
"i... | Return an orthogonal basis to this direction.
Note
----
Only implemented in 3D.
Returns
-------
:obj:`tuple` of :obj:`Direction`
The pair of normalized Direction vectors that form a basis of
this direction's orthogonal complement.
Ra... | [
"Return",
"an",
"orthogonal",
"basis",
"to",
"this",
"direction",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L424-L449 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | Direction.open | def open(filename, frame='unspecified'):
"""Create a Direction from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created Direction.
Returns
---... | python | def open(filename, frame='unspecified'):
"""Create a Direction from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created Direction.
Returns
---... | [
"def",
"open",
"(",
"filename",
",",
"frame",
"=",
"'unspecified'",
")",
":",
"data",
"=",
"BagOfPoints",
".",
"load_data",
"(",
"filename",
")",
"return",
"Direction",
"(",
"data",
",",
"frame",
")"
] | Create a Direction from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created Direction.
Returns
-------
:obj:`Direction`
A Directio... | [
"Create",
"a",
"Direction",
"from",
"data",
"saved",
"in",
"a",
"file",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L452-L469 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | Plane3D.split_points | def split_points(self, point_cloud):
"""Split a point cloud into two along this plane.
Parameters
----------
point_cloud : :obj:`PointCloud`
The PointCloud to divide in two.
Returns
-------
:obj:`tuple` of :obj:`PointCloud`
Two new PointC... | python | def split_points(self, point_cloud):
"""Split a point cloud into two along this plane.
Parameters
----------
point_cloud : :obj:`PointCloud`
The PointCloud to divide in two.
Returns
-------
:obj:`tuple` of :obj:`PointCloud`
Two new PointC... | [
"def",
"split_points",
"(",
"self",
",",
"point_cloud",
")",
":",
"if",
"not",
"isinstance",
"(",
"point_cloud",
",",
"PointCloud",
")",
":",
"raise",
"ValueError",
"(",
"'Can only split point clouds'",
")",
"above_plane",
"=",
"point_cloud",
".",
"_data",
"-",
... | Split a point cloud into two along this plane.
Parameters
----------
point_cloud : :obj:`PointCloud`
The PointCloud to divide in two.
Returns
-------
:obj:`tuple` of :obj:`PointCloud`
Two new PointCloud objects. The first contains points above th... | [
"Split",
"a",
"point",
"cloud",
"into",
"two",
"along",
"this",
"plane",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L498-L528 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | PointCloud.mean | def mean(self):
"""Returns the average point in the cloud.
Returns
-------
:obj:`Point`
The mean point in the PointCloud.
"""
mean_point_data = np.mean(self._data, axis=1)
return Point(mean_point_data, self._frame) | python | def mean(self):
"""Returns the average point in the cloud.
Returns
-------
:obj:`Point`
The mean point in the PointCloud.
"""
mean_point_data = np.mean(self._data, axis=1)
return Point(mean_point_data, self._frame) | [
"def",
"mean",
"(",
"self",
")",
":",
"mean_point_data",
"=",
"np",
".",
"mean",
"(",
"self",
".",
"_data",
",",
"axis",
"=",
"1",
")",
"return",
"Point",
"(",
"mean_point_data",
",",
"self",
".",
"_frame",
")"
] | Returns the average point in the cloud.
Returns
-------
:obj:`Point`
The mean point in the PointCloud. | [
"Returns",
"the",
"average",
"point",
"in",
"the",
"cloud",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L587-L596 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | PointCloud.subsample | def subsample(self, rate, random=False):
"""Returns a subsampled version of the PointCloud.
Parameters
----------
rate : int
Only every rate-th element of the PointCloud is returned.
Returns
-------
:obj:`PointCloud`
A subsampled point cl... | python | def subsample(self, rate, random=False):
"""Returns a subsampled version of the PointCloud.
Parameters
----------
rate : int
Only every rate-th element of the PointCloud is returned.
Returns
-------
:obj:`PointCloud`
A subsampled point cl... | [
"def",
"subsample",
"(",
"self",
",",
"rate",
",",
"random",
"=",
"False",
")",
":",
"if",
"type",
"(",
"rate",
")",
"!=",
"int",
"and",
"rate",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'Can only subsample with strictly positive integer rate'",
")",
"indi... | Returns a subsampled version of the PointCloud.
Parameters
----------
rate : int
Only every rate-th element of the PointCloud is returned.
Returns
-------
:obj:`PointCloud`
A subsampled point cloud with N / rate total samples.
Raises
... | [
"Returns",
"a",
"subsampled",
"version",
"of",
"the",
"PointCloud",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L598-L623 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | PointCloud.box_mask | def box_mask(self, box):
"""Return a PointCloud containing only points within the given Box.
Parameters
----------
box : :obj:`Box`
A box whose boundaries are used to filter points.
Returns
-------
:obj:`PointCloud`
A filtered PointCloud ... | python | def box_mask(self, box):
"""Return a PointCloud containing only points within the given Box.
Parameters
----------
box : :obj:`Box`
A box whose boundaries are used to filter points.
Returns
-------
:obj:`PointCloud`
A filtered PointCloud ... | [
"def",
"box_mask",
"(",
"self",
",",
"box",
")",
":",
"if",
"not",
"isinstance",
"(",
"box",
",",
"Box",
")",
":",
"raise",
"ValueError",
"(",
"'Must provide Box object'",
")",
"if",
"box",
".",
"frame",
"!=",
"self",
".",
"frame",
":",
"raise",
"Value... | Return a PointCloud containing only points within the given Box.
Parameters
----------
box : :obj:`Box`
A box whose boundaries are used to filter points.
Returns
-------
:obj:`PointCloud`
A filtered PointCloud whose points are all in the given bo... | [
"Return",
"a",
"PointCloud",
"containing",
"only",
"points",
"within",
"the",
"given",
"Box",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L625-L655 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | PointCloud.best_fit_plane | def best_fit_plane(self):
"""Fits a plane to the point cloud using least squares.
Returns
-------
:obj:`tuple` of :obj:`numpy.ndarray` of float
A normal vector to and point in the fitted plane.
"""
X = np.c_[self.x_coords, self.y_coords, np.ones(self.num_poin... | python | def best_fit_plane(self):
"""Fits a plane to the point cloud using least squares.
Returns
-------
:obj:`tuple` of :obj:`numpy.ndarray` of float
A normal vector to and point in the fitted plane.
"""
X = np.c_[self.x_coords, self.y_coords, np.ones(self.num_poin... | [
"def",
"best_fit_plane",
"(",
"self",
")",
":",
"X",
"=",
"np",
".",
"c_",
"[",
"self",
".",
"x_coords",
",",
"self",
".",
"y_coords",
",",
"np",
".",
"ones",
"(",
"self",
".",
"num_points",
")",
"]",
"y",
"=",
"self",
".",
"z_coords",
"A",
"=",
... | Fits a plane to the point cloud using least squares.
Returns
-------
:obj:`tuple` of :obj:`numpy.ndarray` of float
A normal vector to and point in the fitted plane. | [
"Fits",
"a",
"plane",
"to",
"the",
"point",
"cloud",
"using",
"least",
"squares",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L657-L674 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | PointCloud.remove_zero_points | def remove_zero_points(self):
"""Removes points with a zero in the z-axis.
Note
----
This returns nothing and updates the PointCloud in-place.
"""
points_of_interest = np.where(self.z_coords != 0.0)[0]
self._data = self.data[:, points_of_interest] | python | def remove_zero_points(self):
"""Removes points with a zero in the z-axis.
Note
----
This returns nothing and updates the PointCloud in-place.
"""
points_of_interest = np.where(self.z_coords != 0.0)[0]
self._data = self.data[:, points_of_interest] | [
"def",
"remove_zero_points",
"(",
"self",
")",
":",
"points_of_interest",
"=",
"np",
".",
"where",
"(",
"self",
".",
"z_coords",
"!=",
"0.0",
")",
"[",
"0",
"]",
"self",
".",
"_data",
"=",
"self",
".",
"data",
"[",
":",
",",
"points_of_interest",
"]"
] | Removes points with a zero in the z-axis.
Note
----
This returns nothing and updates the PointCloud in-place. | [
"Removes",
"points",
"with",
"a",
"zero",
"in",
"the",
"z",
"-",
"axis",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L687-L695 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | PointCloud.remove_infinite_points | def remove_infinite_points(self):
"""Removes infinite points.
Note
----
This returns nothing and updates the PointCloud in-place.
"""
points_of_interest = np.where(np.all(np.isfinite(self.data), axis=0))[0]
self._data = self.data[:, points_of_interest] | python | def remove_infinite_points(self):
"""Removes infinite points.
Note
----
This returns nothing and updates the PointCloud in-place.
"""
points_of_interest = np.where(np.all(np.isfinite(self.data), axis=0))[0]
self._data = self.data[:, points_of_interest] | [
"def",
"remove_infinite_points",
"(",
"self",
")",
":",
"points_of_interest",
"=",
"np",
".",
"where",
"(",
"np",
".",
"all",
"(",
"np",
".",
"isfinite",
"(",
"self",
".",
"data",
")",
",",
"axis",
"=",
"0",
")",
")",
"[",
"0",
"]",
"self",
".",
... | Removes infinite points.
Note
----
This returns nothing and updates the PointCloud in-place. | [
"Removes",
"infinite",
"points",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L697-L705 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | PointCloud.open | def open(filename, frame='unspecified'):
"""Create a PointCloud from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created PointCloud.
Returns
-... | python | def open(filename, frame='unspecified'):
"""Create a PointCloud from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created PointCloud.
Returns
-... | [
"def",
"open",
"(",
"filename",
",",
"frame",
"=",
"'unspecified'",
")",
":",
"data",
"=",
"BagOfPoints",
".",
"load_data",
"(",
"filename",
")",
"return",
"PointCloud",
"(",
"data",
",",
"frame",
")"
] | Create a PointCloud from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created PointCloud.
Returns
-------
:obj:`PointCloud`
A Point... | [
"Create",
"a",
"PointCloud",
"from",
"data",
"saved",
"in",
"a",
"file",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L817-L834 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | NormalCloud.subsample | def subsample(self, rate):
"""Returns a subsampled version of the NormalCloud.
Parameters
----------
rate : int
Only every rate-th element of the NormalCloud is returned.
Returns
-------
:obj:`RateCloud`
A subsampled point cloud with N / ... | python | def subsample(self, rate):
"""Returns a subsampled version of the NormalCloud.
Parameters
----------
rate : int
Only every rate-th element of the NormalCloud is returned.
Returns
-------
:obj:`RateCloud`
A subsampled point cloud with N / ... | [
"def",
"subsample",
"(",
"self",
",",
"rate",
")",
":",
"if",
"type",
"(",
"rate",
")",
"!=",
"int",
"and",
"rate",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'Can only subsample with strictly positive integer rate'",
")",
"subsample_inds",
"=",
"np",
".",
... | Returns a subsampled version of the NormalCloud.
Parameters
----------
rate : int
Only every rate-th element of the NormalCloud is returned.
Returns
-------
:obj:`RateCloud`
A subsampled point cloud with N / rate total samples.
Raises
... | [
"Returns",
"a",
"subsampled",
"version",
"of",
"the",
"NormalCloud",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L897-L919 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | NormalCloud.remove_zero_normals | def remove_zero_normals(self):
"""Removes normal vectors with a zero magnitude.
Note
----
This returns nothing and updates the NormalCloud in-place.
"""
points_of_interest = np.where(np.linalg.norm(self._data, axis=0) != 0.0)[0]
self._data = self._data[:, points_... | python | def remove_zero_normals(self):
"""Removes normal vectors with a zero magnitude.
Note
----
This returns nothing and updates the NormalCloud in-place.
"""
points_of_interest = np.where(np.linalg.norm(self._data, axis=0) != 0.0)[0]
self._data = self._data[:, points_... | [
"def",
"remove_zero_normals",
"(",
"self",
")",
":",
"points_of_interest",
"=",
"np",
".",
"where",
"(",
"np",
".",
"linalg",
".",
"norm",
"(",
"self",
".",
"_data",
",",
"axis",
"=",
"0",
")",
"!=",
"0.0",
")",
"[",
"0",
"]",
"self",
".",
"_data",... | Removes normal vectors with a zero magnitude.
Note
----
This returns nothing and updates the NormalCloud in-place. | [
"Removes",
"normal",
"vectors",
"with",
"a",
"zero",
"magnitude",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L921-L929 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | NormalCloud.remove_nan_normals | def remove_nan_normals(self):
"""Removes normal vectors with nan magnitude.
Note
----
This returns nothing and updates the NormalCloud in-place.
"""
points_of_interest = np.where(np.isfinite(np.linalg.norm(self._data, axis=0)))[0]
self._data = self._data[:, point... | python | def remove_nan_normals(self):
"""Removes normal vectors with nan magnitude.
Note
----
This returns nothing and updates the NormalCloud in-place.
"""
points_of_interest = np.where(np.isfinite(np.linalg.norm(self._data, axis=0)))[0]
self._data = self._data[:, point... | [
"def",
"remove_nan_normals",
"(",
"self",
")",
":",
"points_of_interest",
"=",
"np",
".",
"where",
"(",
"np",
".",
"isfinite",
"(",
"np",
".",
"linalg",
".",
"norm",
"(",
"self",
".",
"_data",
",",
"axis",
"=",
"0",
")",
")",
")",
"[",
"0",
"]",
... | Removes normal vectors with nan magnitude.
Note
----
This returns nothing and updates the NormalCloud in-place. | [
"Removes",
"normal",
"vectors",
"with",
"nan",
"magnitude",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L931-L939 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | NormalCloud.open | def open(filename, frame='unspecified'):
"""Create a NormalCloud from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created NormalCloud.
Returns
... | python | def open(filename, frame='unspecified'):
"""Create a NormalCloud from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created NormalCloud.
Returns
... | [
"def",
"open",
"(",
"filename",
",",
"frame",
"=",
"'unspecified'",
")",
":",
"data",
"=",
"BagOfPoints",
".",
"load_data",
"(",
"filename",
")",
"return",
"NormalCloud",
"(",
"data",
",",
"frame",
")"
] | Create a NormalCloud from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created NormalCloud.
Returns
-------
:obj:`NormalCloud`
A No... | [
"Create",
"a",
"NormalCloud",
"from",
"data",
"saved",
"in",
"a",
"file",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L942-L959 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | ImageCoords.open | def open(filename, frame='unspecified'):
"""Create an ImageCoords from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created ImageCoords.
Returns
... | python | def open(filename, frame='unspecified'):
"""Create an ImageCoords from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created ImageCoords.
Returns
... | [
"def",
"open",
"(",
"filename",
",",
"frame",
"=",
"'unspecified'",
")",
":",
"data",
"=",
"BagOfPoints",
".",
"load_data",
"(",
"filename",
")",
"return",
"ImageCoords",
"(",
"data",
",",
"frame",
")"
] | Create an ImageCoords from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created ImageCoords.
Returns
-------
:obj:`ImageCoords`
An ... | [
"Create",
"an",
"ImageCoords",
"from",
"data",
"saved",
"in",
"a",
"file",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L1015-L1032 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | RgbCloud.open | def open(filename, frame='unspecified'):
"""Create a RgbCloud from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created RgbCloud.
Returns
-----... | python | def open(filename, frame='unspecified'):
"""Create a RgbCloud from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created RgbCloud.
Returns
-----... | [
"def",
"open",
"(",
"filename",
",",
"frame",
"=",
"'unspecified'",
")",
":",
"data",
"=",
"BagOfPoints",
".",
"load_data",
"(",
"filename",
")",
"return",
"RgbCloud",
"(",
"data",
",",
"frame",
")"
] | Create a RgbCloud from data saved in a file.
Parameters
----------
filename : :obj:`str`
The file to load data from.
frame : :obj:`str`
The frame to apply to the created RgbCloud.
Returns
-------
:obj:`RgbCloud`
A RgdCloud cr... | [
"Create",
"a",
"RgbCloud",
"from",
"data",
"saved",
"in",
"a",
"file",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L1093-L1110 | train |
BerkeleyAutomation/autolab_core | autolab_core/points.py | PointNormalCloud.remove_zero_points | def remove_zero_points(self):
"""Remove all elements where the norms and points are zero.
Note
----
This returns nothing and updates the NormalCloud in-place.
"""
points_of_interest = np.where((np.linalg.norm(self.point_cloud.data, axis=0) != 0.0) &
... | python | def remove_zero_points(self):
"""Remove all elements where the norms and points are zero.
Note
----
This returns nothing and updates the NormalCloud in-place.
"""
points_of_interest = np.where((np.linalg.norm(self.point_cloud.data, axis=0) != 0.0) &
... | [
"def",
"remove_zero_points",
"(",
"self",
")",
":",
"points_of_interest",
"=",
"np",
".",
"where",
"(",
"(",
"np",
".",
"linalg",
".",
"norm",
"(",
"self",
".",
"point_cloud",
".",
"data",
",",
"axis",
"=",
"0",
")",
"!=",
"0.0",
")",
"&",
"(",
"np... | Remove all elements where the norms and points are zero.
Note
----
This returns nothing and updates the NormalCloud in-place. | [
"Remove",
"all",
"elements",
"where",
"the",
"norms",
"and",
"points",
"are",
"zero",
"."
] | 8f3813f6401972868cc5e3981ba1b4382d4418d5 | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/points.py#L1201-L1212 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.