code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def getfile(object):
"""Work out which source or compiled file an object was defined in."""
if ismodule(object):
if hasattr(object, '__file__'):
return object.__file__
raise TypeError('{!r} is a built-in module'.format(object))
if isclass(object):
if hasattr(object, '__mo... | Work out which source or compiled file an object was defined in. | getfile | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getmodulename(path):
"""Return the module name for a given file, or None."""
fname = os.path.basename(path)
# Check for paths that look like an actual module file
suffixes = [(-len(suffix), suffix)
for suffix in importlib.machinery.all_suffixes()]
suffixes.sort() # try longes... | Return the module name for a given file, or None. | getmodulename | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getsourcefile(object):
"""Return the filename that can be used to locate an object's source.
Return None if no way can be identified to get the source.
"""
filename = getfile(object)
all_bytecode_suffixes = importlib.machinery.DEBUG_BYTECODE_SUFFIXES[:]
all_bytecode_suffixes += importlib.mac... | Return the filename that can be used to locate an object's source.
Return None if no way can be identified to get the source.
| getsourcefile | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getabsfile(object, _filename=None):
"""Return an absolute path to the source or compiled file for an object.
The idea is for each object to have a unique origin, so this routine
normalizes the result as much as possible."""
if _filename is None:
_filename = getsourcefile(object) or getfile(... | Return an absolute path to the source or compiled file for an object.
The idea is for each object to have a unique origin, so this routine
normalizes the result as much as possible. | getabsfile | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getmodule(object, _filename=None):
"""Return the module an object was defined in, or None if not found."""
if ismodule(object):
return object
if hasattr(object, '__module__'):
return sys.modules.get(object.__module__)
# Try the filename to modulename cache
if _filename is not Non... | Return the module an object was defined in, or None if not found. | getmodule | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def findsource(object):
"""Return the entire source file and starting line number for an object.
The argument may be a module, class, method, function, traceback, frame,
or code object. The source code is returned as a list of all the lines
in the file and the line number indexes a line in that list. ... | Return the entire source file and starting line number for an object.
The argument may be a module, class, method, function, traceback, frame,
or code object. The source code is returned as a list of all the lines
in the file and the line number indexes a line in that list. An OSError
is raised if th... | findsource | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getcomments(object):
"""Get lines of comments immediately preceding an object's source code.
Returns None when source can't be found.
"""
try:
lines, lnum = findsource(object)
except (OSError, TypeError):
return None
if ismodule(object):
# Look for a comment block a... | Get lines of comments immediately preceding an object's source code.
Returns None when source can't be found.
| getcomments | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getblock(lines):
"""Extract the block of code at the top of the given list of lines."""
blockfinder = BlockFinder()
try:
tokens = tokenize.generate_tokens(iter(lines).__next__)
for _token in tokens:
blockfinder.tokeneater(*_token)
except (EndOfBlock, IndentationError):
... | Extract the block of code at the top of the given list of lines. | getblock | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getsourcelines(object):
"""Return a list of source lines and starting line number for an object.
The argument may be a module, class, method, function, traceback, frame,
or code object. The source code is returned as a list of the lines
corresponding to the object and the line number indicates whe... | Return a list of source lines and starting line number for an object.
The argument may be a module, class, method, function, traceback, frame,
or code object. The source code is returned as a list of the lines
corresponding to the object and the line number indicates where in the
original source file ... | getsourcelines | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getclasstree(classes, unique=False):
"""Arrange the given list of classes into a hierarchy of nested lists.
Where a nested list appears, it contains classes derived from the class
whose entry immediately precedes the list. Each entry is a 2-tuple
containing a class and a tuple of its base classes.... | Arrange the given list of classes into a hierarchy of nested lists.
Where a nested list appears, it contains classes derived from the class
whose entry immediately precedes the list. Each entry is a 2-tuple
containing a class and a tuple of its base classes. If the 'unique'
argument is true, exactly ... | getclasstree | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getargs(co):
"""Get information about the arguments accepted by a code object.
Three things are returned: (args, varargs, varkw), where
'args' is the list of argument names. Keyword-only arguments are
appended. 'varargs' and 'varkw' are the names of the * and **
arguments or None."""
args, ... | Get information about the arguments accepted by a code object.
Three things are returned: (args, varargs, varkw), where
'args' is the list of argument names. Keyword-only arguments are
appended. 'varargs' and 'varkw' are the names of the * and **
arguments or None. | getargs | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def _getfullargs(co):
"""Get information about the arguments accepted by a code object.
Four things are returned: (args, varargs, kwonlyargs, varkw), where
'args' and 'kwonlyargs' are lists of argument names, and 'varargs'
and 'varkw' are the names of the * and ** arguments or None."""
if not isco... | Get information about the arguments accepted by a code object.
Four things are returned: (args, varargs, kwonlyargs, varkw), where
'args' and 'kwonlyargs' are lists of argument names, and 'varargs'
and 'varkw' are the names of the * and ** arguments or None. | _getfullargs | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getargspec(func):
"""Get the names and default values of a function's arguments.
A tuple of four things is returned: (args, varargs, varkw, defaults).
'args' is a list of the argument names.
'args' will include keyword-only argument names.
'varargs' and 'varkw' are the names of the * and ** arg... | Get the names and default values of a function's arguments.
A tuple of four things is returned: (args, varargs, varkw, defaults).
'args' is a list of the argument names.
'args' will include keyword-only argument names.
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'defaults... | getargspec | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getfullargspec(func):
"""Get the names and default values of a callable object's arguments.
A tuple of seven things is returned:
(args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults annotations).
'args' is a list of the argument names.
'varargs' and 'varkw' are the names of the * and ** ... | Get the names and default values of a callable object's arguments.
A tuple of seven things is returned:
(args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults annotations).
'args' is a list of the argument names.
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'defaults'... | getfullargspec | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getargvalues(frame):
"""Get information about arguments passed into a particular frame.
A tuple of four things is returned: (args, varargs, varkw, locals).
'args' is a list of the argument names.
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'locals' is the locals dicti... | Get information about arguments passed into a particular frame.
A tuple of four things is returned: (args, varargs, varkw, locals).
'args' is a list of the argument names.
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'locals' is the locals dictionary of the given frame. | getargvalues | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def formatargspec(args, varargs=None, varkw=None, defaults=None,
kwonlyargs=(), kwonlydefaults={}, annotations={},
formatarg=str,
formatvarargs=lambda name: '*' + name,
formatvarkw=lambda name: '**' + name,
formatvalue=lambda valu... | Format an argument spec from the values returned by getargspec
or getfullargspec.
The first seven arguments are (args, varargs, varkw, defaults,
kwonlyargs, kwonlydefaults, annotations). The other five arguments
are the corresponding optional formatting functions that are called to
turn names and ... | formatargspec | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def formatargvalues(args, varargs, varkw, locals,
formatarg=str,
formatvarargs=lambda name: '*' + name,
formatvarkw=lambda name: '**' + name,
formatvalue=lambda value: '=' + repr(value)):
"""Format an argument spec from the 4 values ret... | Format an argument spec from the 4 values returned by getargvalues.
The first four arguments are (args, varargs, varkw, locals). The
next four arguments are the corresponding optional formatting functions
that are called to turn names and values into strings. The ninth
argument is an optional functio... | formatargvalues | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getcallargs(*func_and_positional, **named):
"""Get the mapping of arguments to values.
A dict is returned, with keys the function argument names (including the
names of the * and ** arguments, if any), and values the respective bound
values from 'positional' and 'named'."""
func = func_and_posi... | Get the mapping of arguments to values.
A dict is returned, with keys the function argument names (including the
names of the * and ** arguments, if any), and values the respective bound
values from 'positional' and 'named'. | getcallargs | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getclosurevars(func):
"""
Get the mapping of free variables to their current values.
Returns a named tuple of dicts mapping the current nonlocal, global
and builtin references as seen by the body of the function. A final
set of unbound names that could not be resolved is also provided.
"""
... |
Get the mapping of free variables to their current values.
Returns a named tuple of dicts mapping the current nonlocal, global
and builtin references as seen by the body of the function. A final
set of unbound names that could not be resolved is also provided.
| getclosurevars | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getframeinfo(frame, context=1):
"""Get information about a frame or traceback object.
A tuple of five things is returned: the filename, the line number of
the current line, the function name, a list of lines of context from
the source code, and the index of the current line within that list.
Th... | Get information about a frame or traceback object.
A tuple of five things is returned: the filename, the line number of
the current line, the function name, a list of lines of context from
the source code, and the index of the current line within that list.
The optional second argument specifies the nu... | getframeinfo | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getouterframes(frame, context=1):
"""Get a list of records for a frame and all higher (calling) frames.
Each record contains a frame object, filename, line number, function
name, a list of lines of context, and index within the context."""
framelist = []
while frame:
framelist.append((f... | Get a list of records for a frame and all higher (calling) frames.
Each record contains a frame object, filename, line number, function
name, a list of lines of context, and index within the context. | getouterframes | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getinnerframes(tb, context=1):
"""Get a list of records for a traceback's frame and all lower frames.
Each record contains a frame object, filename, line number, function
name, a list of lines of context, and index within the context."""
framelist = []
while tb:
framelist.append((tb.tb_... | Get a list of records for a traceback's frame and all lower frames.
Each record contains a frame object, filename, line number, function
name, a list of lines of context, and index within the context. | getinnerframes | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getattr_static(obj, attr, default=_sentinel):
"""Retrieve attributes without triggering dynamic lookup via the
descriptor protocol, __getattr__ or __getattribute__.
Note: this function may not be able to retrieve all attributes
that getattr can fetch (like dynamically created attributes)
... | Retrieve attributes without triggering dynamic lookup via the
descriptor protocol, __getattr__ or __getattribute__.
Note: this function may not be able to retrieve all attributes
that getattr can fetch (like dynamically created attributes)
and may find attributes that getattr can't (like d... | getattr_static | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getgeneratorstate(generator):
"""Get current state of a generator-iterator.
Possible states are:
GEN_CREATED: Waiting to start execution.
GEN_RUNNING: Currently being executed by the interpreter.
GEN_SUSPENDED: Currently suspended at a yield expression.
GEN_CLOSED: Execution has com... | Get current state of a generator-iterator.
Possible states are:
GEN_CREATED: Waiting to start execution.
GEN_RUNNING: Currently being executed by the interpreter.
GEN_SUSPENDED: Currently suspended at a yield expression.
GEN_CLOSED: Execution has completed.
| getgeneratorstate | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def getgeneratorlocals(generator):
"""
Get the mapping of generator local variables to their current values.
A dict is returned, with the keys the local variable names and values the
bound values."""
if not isgenerator(generator):
raise TypeError("'{!r}' is not a Python generator".format(g... |
Get the mapping of generator local variables to their current values.
A dict is returned, with the keys the local variable names and values the
bound values. | getgeneratorlocals | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def _signature_strip_non_python_syntax(signature):
"""
Takes a signature in Argument Clinic's extended signature format.
Returns a tuple of three things:
* that signature re-rendered in standard Python syntax,
* the index of the "self" parameter (generally 0), or None if
the function doe... |
Takes a signature in Argument Clinic's extended signature format.
Returns a tuple of three things:
* that signature re-rendered in standard Python syntax,
* the index of the "self" parameter (generally 0), or None if
the function does not have a "self" parameter, and
* the index of th... | _signature_strip_non_python_syntax | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def replace(self, *, name=_void, kind=_void,
annotation=_void, default=_void):
'''Creates a customized copy of the Parameter.'''
if name is _void:
name = self._name
if kind is _void:
kind = self._kind
if annotation is _void:
annotati... | Creates a customized copy of the Parameter. | replace | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def __init__(self, parameters=None, *, return_annotation=_empty,
__validate_parameters__=True):
'''Constructs Signature from the given list of Parameter
objects and 'return_annotation'. All arguments are optional.
'''
if parameters is None:
params = Ordered... | Constructs Signature from the given list of Parameter
objects and 'return_annotation'. All arguments are optional.
| __init__ | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def from_function(cls, func):
'''Constructs Signature for the given python function'''
is_duck_function = False
if not isfunction(func):
if _signature_is_functionlike(func):
is_duck_function = True
else:
# If it's not a pure Python functio... | Constructs Signature for the given python function | from_function | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def replace(self, *, parameters=_void, return_annotation=_void):
'''Creates a customized copy of the Signature.
Pass 'parameters' and/or 'return_annotation' arguments
to override them in the new copy.
'''
if parameters is _void:
parameters = self.parameters.values()
... | Creates a customized copy of the Signature.
Pass 'parameters' and/or 'return_annotation' arguments
to override them in the new copy.
| replace | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def _main():
""" Logic for inspecting an object given at command line """
import argparse
import importlib
parser = argparse.ArgumentParser()
parser.add_argument(
'object',
help="The object to be analysed. "
"It supports the 'module:qualname' syntax")
parser.add_a... | Logic for inspecting an object given at command line | _main | python | hhatto/autopep8 | test/inspect_example.py | https://github.com/hhatto/autopep8/blob/master/test/inspect_example.py | MIT |
def test_readlines_from_file_with_bad_encoding(self):
"""Bad encoding should not cause an exception."""
self.assertEqual(
['# -*- coding: zlatin-1 -*-\n'],
autopep8.readlines_from_file(
os.path.join(ROOT_DIR, 'test', 'bad_encoding.py'))) | Bad encoding should not cause an exception. | test_readlines_from_file_with_bad_encoding | python | hhatto/autopep8 | test/test_autopep8.py | https://github.com/hhatto/autopep8/blob/master/test/test_autopep8.py | MIT |
def test_readlines_from_file_with_bad_encoding2(self):
"""Bad encoding should not cause an exception."""
# This causes a warning on Python 3.
with warnings.catch_warnings(record=True):
self.assertTrue(autopep8.readlines_from_file(
os.path.join(ROOT_DIR, 'test', 'bad_e... | Bad encoding should not cause an exception. | test_readlines_from_file_with_bad_encoding2 | python | hhatto/autopep8 | test/test_autopep8.py | https://github.com/hhatto/autopep8/blob/master/test/test_autopep8.py | MIT |
def test_fix_code_byte_string(self):
"""This feature is here for friendliness to Python 2."""
self.assertEqual(
'print(123)\n',
autopep8.fix_code(b'print( 123 )\n')) | This feature is here for friendliness to Python 2. | test_fix_code_byte_string | python | hhatto/autopep8 | test/test_autopep8.py | https://github.com/hhatto/autopep8/blob/master/test/test_autopep8.py | MIT |
def test_e231_should_only_do_ws_comma_once(self):
"""If we don't check appropriately, we end up doing ws_comma multiple
times and skipping all other fixes."""
line = """\
print( 1 )
foo[0,:]
bar[zap[0][0]:zig[0][0],:]
"""
fixed = """\
print(1)
foo[0, :]
bar[zap[0][0]:zig[0][0], :]
"""
... | If we don't check appropriately, we end up doing ws_comma multiple
times and skipping all other fixes. | test_e231_should_only_do_ws_comma_once | python | hhatto/autopep8 | test/test_autopep8.py | https://github.com/hhatto/autopep8/blob/master/test/test_autopep8.py | MIT |
def test_e501_with_aggressive_and_massive_number_of_logical_lines(self):
"""We do not care about results here.
We just want to know that it doesn't take a ridiculous amount of
time. Caching is currently required to avoid repeately trying
the same line.
"""
line = """\
#... | We do not care about results here.
We just want to know that it doesn't take a ridiculous amount of
time. Caching is currently required to avoid repeately trying
the same line.
| test_e501_with_aggressive_and_massive_number_of_logical_lines | python | hhatto/autopep8 | test/test_autopep8.py | https://github.com/hhatto/autopep8/blob/master/test/test_autopep8.py | MIT |
def test_e501_avoid_breaking_at_opening_slice(self):
"""Prevents line break on slice notation, dict access in this example:
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw[
'abc'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
"""
... | Prevents line break on slice notation, dict access in this example:
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw[
'abc'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
| test_e501_avoid_breaking_at_opening_slice | python | hhatto/autopep8 | test/test_autopep8.py | https://github.com/hhatto/autopep8/blob/master/test/test_autopep8.py | MIT |
def test_e501_avoid_breaking_at_multi_level_slice(self):
"""Prevents line break on slice notation, dict access in this example:
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw['abc'][
'def'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
"""
... | Prevents line break on slice notation, dict access in this example:
GYakymOSMc=GYakymOSMW(GYakymOSMJ,GYakymOSMA,GYakymOSMr,GYakymOSMw['abc'][
'def'],GYakymOSMU,GYakymOSMq,GYakymOSMH,GYakymOSMl,svygreNveyvarf=GYakymOSME)
| test_e501_avoid_breaking_at_multi_level_slice | python | hhatto/autopep8 | test/test_autopep8.py | https://github.com/hhatto/autopep8/blob/master/test/test_autopep8.py | MIT |
def test_execfile_in_lambda_should_not_be_modified(self):
"""Modifying this to the exec() form is invalid in Python 2."""
line = 'lambda: execfile("foo.py")\n'
with autopep8_context(line, options=['--aggressive']) as result:
self.assertEqual(line, result) | Modifying this to the exec() form is invalid in Python 2. | test_execfile_in_lambda_should_not_be_modified | python | hhatto/autopep8 | test/test_autopep8.py | https://github.com/hhatto/autopep8/blob/master/test/test_autopep8.py | MIT |
def check(expected_filename, input_filename, aggressive):
"""Test and compare output.
Return True on success.
"""
got = autopep8.fix_file(
input_filename,
options=autopep8.parse_args([''] + aggressive * ['--aggressive']))
try:
with autopep8.open_with_encoding(expected_file... | Test and compare output.
Return True on success.
| check | python | hhatto/autopep8 | test/test_suite.py | https://github.com/hhatto/autopep8/blob/master/test/test_suite.py | MIT |
def run(filename, aggressive):
"""Test against a specific file.
Return True on success.
Expected output should have the same base filename, but live in an "out"
directory:
foo/bar.py
foo/out/bar.py
Failed output will go to:
foo/out/bar.py.err
"""
return check(
... | Test against a specific file.
Return True on success.
Expected output should have the same base filename, but live in an "out"
directory:
foo/bar.py
foo/out/bar.py
Failed output will go to:
foo/out/bar.py.err
| run | python | hhatto/autopep8 | test/test_suite.py | https://github.com/hhatto/autopep8/blob/master/test/test_suite.py | MIT |
def __eq__(self, other):
'''Vectors can be checked for equality.
Uses epsilon floating comparison; tiny differences are still equal.
'''
for i in range(len(self._v)):
if not equal(self._v[i], other._v[i]):
return False
return True | Vectors can be checked for equality.
Uses epsilon floating comparison; tiny differences are still equal.
| __eq__ | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def __cmp__(self, other):
'''Vectors can be compared, returning -1,0,+1.
Elements are compared in order, using epsilon floating comparison.
'''
for i in range(len(self._v)):
if not equal(self._v[i], other._v[i]):
if self._v[i] > other._v[i]: return 1
... | Vectors can be compared, returning -1,0,+1.
Elements are compared in order, using epsilon floating comparison.
| __cmp__ | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def __neg__(self):
'''The inverse of a vector is a negative in all elements.'''
v = V(self)
for i in range(len(v._v)):
v[i] = -v[i]
v._l = self._l
return v | The inverse of a vector is a negative in all elements. | __neg__ | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def __nonzero__(self):
'''A vector is nonzero if any of its elements are nonzero.'''
for i in range(len(self._v)):
if self._v[i]: return True
return False | A vector is nonzero if any of its elements are nonzero. | __nonzero__ | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def random(cls, order=3):
'''Returns a unit vector in a random direction.'''
# distribution is not without bias, need to use polar coords?
v = V(range(order))
v._l = None
short = True
while short:
for i in range(order):
v._v[i] = 2.0*random.ran... | Returns a unit vector in a random direction. | random | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def __iadd__(self, other):
'''Vectors can be added to each other, or a scalar added to them.'''
if isinstance(other, V):
if len(other._v) != len(self._v):
raise ValueError, 'mismatched dimensions'
for i in range(len(self._v)):
self._v[i] += other._... | Vectors can be added to each other, or a scalar added to them. | __iadd__ | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def __isub__(self, other):
'''Vectors can be subtracted, or a scalar subtracted from them.'''
if isinstance(other, V):
if len(other._v) != len(self._v):
raise ValueError, 'mismatched dimensions'
for i in range(len(self._v)):
self._v[i] -= other._v[... | Vectors can be subtracted, or a scalar subtracted from them. | __isub__ | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def __imul__(self, other):
'''Vectors can be multipled by a scalar. Two 3d vectors can cross.'''
if isinstance(other, V):
self._v = self.cross(other)._v
else:
for i in range(len(self._v)):
self._v[i] *= other
self._l = None
return self | Vectors can be multipled by a scalar. Two 3d vectors can cross. | __imul__ | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def __idiv__(self, other):
'''Vectors can be divided by scalars; each element is divided.'''
other = 1.0 / other
for i in range(len(self._v)):
self._v[i] *= other
self._l = None
return self | Vectors can be divided by scalars; each element is divided. | __idiv__ | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def cross(self, other):
'''Find the vector cross product between two 3d vectors.'''
if len(self._v) != 3 or len(other._v) != 3:
raise ValueError, 'cross multiplication only for 3d vectors'
p, q = self._v, other._v
r = [ p[1] * q[2] - p[2] * q[1],
p[2] * q[0] - p... | Find the vector cross product between two 3d vectors. | cross | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def dot(self, other):
'''Find the scalar dot product between this vector and another.'''
s = 0
for i in range(len(self._v)):
s += self._v[i] * other._v[i]
return s | Find the scalar dot product between this vector and another. | dot | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def magnitude(self, value=None):
'''Find the magnitude (spatial length) of this vector.
With a value, return a vector with same direction but of given length.
'''
mag = self.__mag()
if value is None: return mag
if zero(mag):
raise ValueError, 'Zero-magnitude v... | Find the magnitude (spatial length) of this vector.
With a value, return a vector with same direction but of given length.
| magnitude | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def order(self, order):
'''Remove elements from the end, or extend with new elements.'''
order = int(order)
if order < 1:
raise ValueError, 'cannot reduce a vector to zero elements'
v = V(self)
while order < len(v._v):
v._v.pop()
while order > len(... | Remove elements from the end, or extend with new elements. | order | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def conjugate(self):
'''The conjugate of a quaternion has its X, Y and Z negated.'''
twin = Q(self)
for i in range(3):
twin._v[i] = -twin._v[i]
twin._l = twin._l
return twin | The conjugate of a quaternion has its X, Y and Z negated. | conjugate | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def inverse(self):
'''The quaternion inverse is the conjugate with reciprocal W.'''
twin = self.conjugate()
if twin._v[3] != 1.0:
twin._v[3] = 1.0 / twin._v[3]
twin._l = None
return twin | The quaternion inverse is the conjugate with reciprocal W. | inverse | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def rotate(cls, axis, theta):
'''Prepare a quaternion that represents a rotation on a given axis.'''
if isinstance(axis, str):
if axis in ('x','X'): axis = V.X
elif axis in ('y','Y'): axis = V.Y
elif axis in ('z','Z'): axis = V.Z
axis = axis.normalize()
... | Prepare a quaternion that represents a rotation on a given axis. | rotate | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def __init__(self, *args):
'''Constructs a new 4x4 matrix.
If no arguments are given, an identity matrix is constructed.
Any combination of V vectors, tuples, lists or scalars may be given,
but taken together in order, they must have 16 number values total.
'''
# no args ... | Constructs a new 4x4 matrix.
If no arguments are given, an identity matrix is constructed.
Any combination of V vectors, tuples, lists or scalars may be given,
but taken together in order, they must have 16 number values total.
| __init__ | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def __str__(self):
'''Returns a multiple-line string representation of the matrix.'''
# prettier on multiple lines
n = self.__class__.__name__
ns = ' '*len(n)
t = n+'('+', '.join([ repr(self._v[i]) for i in 0,1,2,3 ])+',\n'
t += ns+' '+', '.join([ repr(self._v[i]) for i i... | Returns a multiple-line string representation of the matrix. | __str__ | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def __setitem__(self, rc, value):
'''Injects a single element into the matrix.
May index 0-15, or with tuples of (row,column) 0-3 each.
Indexing goes across first, so m[3] is m[0,3] and m[7] is m[1,3].
'''
if not isinstance(rc, tuple): return V.__getitem__(self, rc)
self.... | Injects a single element into the matrix.
May index 0-15, or with tuples of (row,column) 0-3 each.
Indexing goes across first, so m[3] is m[0,3] and m[7] is m[1,3].
| __setitem__ | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def row(self, r, v=None):
'''Returns or replaces a vector representing a row of the matrix.
Rows are counted 0-3. If given, new vector must be four numbers.
'''
if r < 0 or r > 3: raise IndexError, 'row index out of range'
if v is None: return V(self._v[r*4:(r+1)*4])
e = ... | Returns or replaces a vector representing a row of the matrix.
Rows are counted 0-3. If given, new vector must be four numbers.
| row | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def col(self, c, v=None):
'''Returns or replaces a vector representing a column of the matrix.
Columns are counted 0-3. If given, new vector must be four numbers.
'''
if c < 0 or c > 3: raise IndexError, 'column index out of range'
if v is None: return V([ self._v[c+4*i] for i in... | Returns or replaces a vector representing a column of the matrix.
Columns are counted 0-3. If given, new vector must be four numbers.
| col | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def translation(self):
'''Extracts the translation component from this matrix.'''
(a,b,c,d,
e,f,g,h,
i,j,k,l,
m,n,o,p) = self._v
return V(m,n,o) | Extracts the translation component from this matrix. | translation | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def rotation(self):
'''Extracts Euler angles of rotation from this matrix.
This attempts to find alternate rotations in case of gimbal lock,
but all of the usual problems with Euler angles apply here.
All Euler angles are in radians.
'''
(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) ... | Extracts Euler angles of rotation from this matrix.
This attempts to find alternate rotations in case of gimbal lock,
but all of the usual problems with Euler angles apply here.
All Euler angles are in radians.
| rotation | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def angle(a, b):
'''Find the angle (scalar value in radians) between two 3d vectors.'''
a = a.normalize()
b = b.normalize()
if a == b: return 0.0
return math.acos(a.dot(b)) | Find the angle (scalar value in radians) between two 3d vectors. | angle | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def track(v):
'''Find the track (direction in positive radians) of a 2d vector.
E.g., track(V(1,0)) == 0 radians; track(V(0,1) == math.pi/2 radians;
track(V(-1,0)) == math.pi radians; and track(V(0,-1) is math.pi*3/2.
'''
t = math.atan2(v[1], v[0])
if t < 0:
return t + 2.*math.pi
return t | Find the track (direction in positive radians) of a 2d vector.
E.g., track(V(1,0)) == 0 radians; track(V(0,1) == math.pi/2 radians;
track(V(-1,0)) == math.pi radians; and track(V(0,-1) is math.pi*3/2.
| track | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def quangle(a, b):
'''Find a quaternion that rotates one 3d vector to parallel another.'''
x = a.cross(b)
w = a.magnitude() * b.magnitude() + a.dot(b)
return Q(x[0], x[1], x[2], w) | Find a quaternion that rotates one 3d vector to parallel another. | quangle | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def dsquared(one, two):
'''Find the square of the distance between two points.'''
# working with squared distances is common to avoid slow sqrt() calls
m = 0
for i in range(len(one._v)):
d = one._v[i] - two._v[i]
m += d * d
return m | Find the square of the distance between two points. | dsquared | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def nearest(point, neighbors):
'''Find the nearest neighbor point to a given point.'''
best = None
for other in neighbors:
d = dsquared(point, other)
if best is None or d < best[1]:
best = (other, d)
return best[0] | Find the nearest neighbor point to a given point. | nearest | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def farthest(point, neighbors):
'''Find the farthest neighbor point to a given point.'''
best = None
for other in neighbors:
d = dsquared(point, other)
if best is None or d > best[1]:
best = (other, d)
return best[0] | Find the farthest neighbor point to a given point. | farthest | python | hhatto/autopep8 | test/vectors_example.py | https://github.com/hhatto/autopep8/blob/master/test/vectors_example.py | MIT |
def test_keys(self):
"""areas.json - All regions are accounted for."""
expected = set([
u'Norrbotten',
u'V\xe4sterbotten',
]) | areas.json - All regions are accounted for. | test_keys | python | hhatto/autopep8 | test/suite/E10.py | https://github.com/hhatto/autopep8/blob/master/test/suite/E10.py | MIT |
def qualify_by_address(
self, cr, uid, ids, context=None,
params_to_check=frozenset(QUALIF_BY_ADDRESS_PARAM)):
""" This gets called by the web server """ | This gets called by the web server | qualify_by_address | python | hhatto/autopep8 | test/suite/E12.py | https://github.com/hhatto/autopep8/blob/master/test/suite/E12.py | MIT |
def qualify_by_address(self, cr, uid, ids, context=None,
params_to_check=frozenset(QUALIF_BY_ADDRESS_PARAM)):
""" This gets called by the web server """ | This gets called by the web server | qualify_by_address | python | hhatto/autopep8 | test/suite/E12.py | https://github.com/hhatto/autopep8/blob/master/test/suite/E12.py | MIT |
def test_keys(self):
"""areas.json - All regions are accounted for."""
expected = set([
u'Norrbotten',
u'V\xe4sterbotten',
]) | areas.json - All regions are accounted for. | test_keys | python | hhatto/autopep8 | test/suite/W19.py | https://github.com/hhatto/autopep8/blob/master/test/suite/W19.py | MIT |
def test_keys(self):
"""areas.json - All regions are accounted for."""
expected = set([
u'Norrbotten',
u'V\xe4sterbotten',
]) | areas.json - All regions are accounted for. | test_keys | python | hhatto/autopep8 | test/suite/out/E10.py | https://github.com/hhatto/autopep8/blob/master/test/suite/out/E10.py | MIT |
def qualify_by_address(
self, cr, uid, ids, context=None,
params_to_check=frozenset(QUALIF_BY_ADDRESS_PARAM)):
""" This gets called by the web server """ | This gets called by the web server | qualify_by_address | python | hhatto/autopep8 | test/suite/out/E12.py | https://github.com/hhatto/autopep8/blob/master/test/suite/out/E12.py | MIT |
def qualify_by_address(self, cr, uid, ids, context=None,
params_to_check=frozenset(QUALIF_BY_ADDRESS_PARAM)):
""" This gets called by the web server """ | This gets called by the web server | qualify_by_address | python | hhatto/autopep8 | test/suite/out/E12.py | https://github.com/hhatto/autopep8/blob/master/test/suite/out/E12.py | MIT |
def test_keys(self):
"""areas.json - All regions are accounted for."""
expected = set([
u'Norrbotten',
u'V\xe4sterbotten',
]) | areas.json - All regions are accounted for. | test_keys | python | hhatto/autopep8 | test/suite/out/W19.py | https://github.com/hhatto/autopep8/blob/master/test/suite/out/W19.py | MIT |
def return_random_from_word(word):
"""
This function receives a TextMobject,
obtains its length:
len(TextMobject("Some text"))
and returns a random list, example:
INPUT: word = TextMobjecT("Hello")
length = len(word) # 4
rango = list(range(length)) # [0,1,2,3]
OUTPUT: [3,0,2,1]... |
This function receives a TextMobject,
obtains its length:
len(TextMobject("Some text"))
and returns a random list, example:
INPUT: word = TextMobjecT("Hello")
length = len(word) # 4
rango = list(range(length)) # [0,1,2,3]
OUTPUT: [3,0,2,1] # Random list
| return_random_from_word | python | manim-kindergarten/manim_sandbox | utils/animations/RandomScene.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/animations/RandomScene.py | MIT |
def get_random_coord(r_x, r_y, step_x, step_y):
"""
Given two ranges (a, b) and (c, d), this function returns an
intermediate array (x, y) such that "x" belongs to (a, c)
and "y" belongs to (b, d).
"""
range_x = list(range(r_x[0], r_x[1], step_x))
range_y = list(range(r_y[0], r_y[1], step_... |
Given two ranges (a, b) and (c, d), this function returns an
intermediate array (x, y) such that "x" belongs to (a, c)
and "y" belongs to (b, d).
| get_random_coord | python | manim-kindergarten/manim_sandbox | utils/animations/RandomScene.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/animations/RandomScene.py | MIT |
def return_random_coords(word, r_x, r_y, step_x, step_y):
"""
This function returns a random coordinate array,
given the length of a TextMobject
"""
rango = range(len(word))
return [word.get_center() + get_random_coord(r_x, r_y, step_x, step_y) for _ in rango] |
This function returns a random coordinate array,
given the length of a TextMobject
| return_random_coords | python | manim-kindergarten/manim_sandbox | utils/animations/RandomScene.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/animations/RandomScene.py | MIT |
def get_formatter(self, **kwargs):
"""
Configuration is based first off instance attributes,
but overwritten by any kew word argument. Relevant
key words:
- include_sign
- group_with_commas
- num_decimal_places
- field_name (e.g. 0 or 0.real)
"""
... |
Configuration is based first off instance attributes,
but overwritten by any kew word argument. Relevant
key words:
- include_sign
- group_with_commas
- num_decimal_places
- field_name (e.g. 0 or 0.real)
| get_formatter | python | manim-kindergarten/manim_sandbox | utils/mobjects/ColorText.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/mobjects/ColorText.py | MIT |
def apply_edge(self):
'''
(private)
Finally apply the edge.
Appies the edge
'''
for (u,v) in self.edgeQ:
if u==v:
continue
self.adde(u,v) |
(private)
Finally apply the edge.
Appies the edge
| apply_edge | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def adde(self, u, v):
'''
(private)
Add an edge applied on arraies inside.
'''
if self.verbose:
print("Added edge from and to"+str(u)+" "+str(v))
self.hasone[u] = True
self.hasone[v] = True
self.out[u]=self.out[u]+1
self.cnt = self.cn... |
(private)
Add an edge applied on arraies inside.
| adde | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def dfs(self, x,layer,fat):
'''
(private)
Get the basic arguments of the tree.
'''
self.dfsord.append(x)
self.dep[x] = layer
self.fa[x] = fat
i = self.head[x]
if i==0:
self.size[x]=1
while i != int(0):
v = self.edg[... |
(private)
Get the basic arguments of the tree.
| dfs | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def getpos(self,v):
'''
(private)
Get the x-y crood position between of a tree.
'''
if v!= self.treeroot:
u=self.fa[v]
self.pos[v] = self.pos[u]+2*np.array([math.cos(self.tau[v]+self.omega[v]/2),math.sin(self.tau[v]+self.omega[v]/2),0])
yita = se... |
(private)
Get the x-y crood position between of a tree.
| getpos | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def getxy(self):
'''
(private)
Get the position between of a tree.
'''
self.getpos(self.treeroot)
for i in range(1,self.edgnum):
if self.hasone[i]:
p=Circle(fill_color=GREEN,radius=0.25,fill_opacity=0.8,color=GREEN)
p.move_to(se... |
(private)
Get the position between of a tree.
| getxy | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def get_id(self):
'''
(private)
Get the id between of a tree.
'''
for i in range(1,self.edgnum):
if self.hasone[i]==True:
ics=TextMobject(str(i))
ics.move_to(self.pos[i]).shift((self.radius+0.1)*DOWN).scale(0.6)
self.ids... |
(private)
Get the id between of a tree.
| get_id | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def get_connection(self,x,fa):
'''
(private)
Get the lines between of a tree.
'''
ln = Line(self.pos[self.fa[x]],self.pos[self.fa[x]],color=BLUE)
ln = Line(self.pos[self.fa[x]],self.pos[x],color=BLUE)
self.lines.add(ln)
txt=TextMobject(str(len(self.lines)-... |
(private)
Get the lines between of a tree.
| get_connection | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def highlight_edge(self,frm,to):
"""
Focuses on an edge to stress
"""
for i in range(0,len(self.sidecnt)):
u = self.sidecnt[i][0]
v = self.sidecnt[i][1]
if u!=0 and v!=0:
if frm==u and to==v:
self.play(FocusOn(self.... |
Focuses on an edge to stress
| highlight_edge | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def get_instance_of_edge(self,x):
'''
Returns a instance of edge which you can apply methods on.
'''
for i in range(0,len(self.sidecnt)):
u = self.sidecnt[i][0]
v = self.sidecnt[i][1]
if u!=0 and v!=0:
if frm==u and to==v:
... |
Returns a instance of edge which you can apply methods on.
| get_instance_of_edge | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def get_arguments(self):
'''
(private)
Get the datas of a tree.
'''
self.apply_edge()
self.dfs(self.treeroot,self.treeroot,0)
self.treeMobject.add(self.getxy())
self.treeMobject.add(self.get_nodes())
self.treeMobject.add(self.get_id())
self... |
(private)
Get the datas of a tree.
| get_arguments | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def restart(self):
'''
(private)
Restart the tree. Clear all the mobjects and datas.
'''
self.cnt = 0
self.edg = [Edge(0,0)]
self.head = [0]*self.edgnum
self.dep = [0]*self.edgnum
self.sidecnt = [(0,0)]
self.fa = [0]*self.edgnum
sel... |
(private)
Restart the tree. Clear all the mobjects and datas.
| restart | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def draw_tree(self):
'''
Show up the tree onto the screen.
'''
self.apply_edge()
self.dfs(self.treeroot,self.treeroot,0)
self.treeMobject.add(self.getxy())
self.treeMobject.add(self.get_nodes())
self.treeMobject.add(self.get_id())
self.treeMobject.... |
Show up the tree onto the screen.
| draw_tree | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def update_transform(self):
'''
Update the tree on the screen, which uses the latest data to
reposition and rebuild the tree.
'''
utter = self.treeMobject.copy()
self.remove(self.treeMobject)
self.restart()
self.get_arguments()
self.play(Transfo... |
Update the tree on the screen, which uses the latest data to
reposition and rebuild the tree.
| update_transform | python | manim-kindergarten/manim_sandbox | utils/scenes/OITree.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/utils/scenes/OITree.py | MIT |
def get_formatter(self, **kwargs):
"""
Configuration is based first off instance attributes,
but overwritten by any kew word argument. Relevant
key words:
- include_sign
- group_with_commas
- num_decimal_places
- field_name (e.g. 0 or 0.real)
"""
... |
Configuration is based first off instance attributes,
but overwritten by any kew word argument. Relevant
key words:
- include_sign
- group_with_commas
- num_decimal_places
- field_name (e.g. 0 or 0.real)
| get_formatter | python | manim-kindergarten/manim_sandbox | videos/manimTutorial/part3_Color.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/videos/manimTutorial/part3_Color.py | MIT |
def capture(self, mobjects, write_current_frame=True):
"""
Capture mobjects on the current frame, write to movie if possible.
:param mobjects: instance of Mobject to be captured.
:param write_current_frame: boolean value, whether to write current frame to movie.
"""
self... |
Capture mobjects on the current frame, write to movie if possible.
:param mobjects: instance of Mobject to be captured.
:param write_current_frame: boolean value, whether to write current frame to movie.
| capture | python | manim-kindergarten/manim_sandbox | videos/Solitaire/raw_frame_scene.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/videos/Solitaire/raw_frame_scene.py | MIT |
def tear_down(self):
"""
Finish method for RawFrameScene. A must call after using this scene.
"""
self.file_writer.close_movie_pipe()
setattr(self, "msg_flag", False)
self.msg_thread.join()
self.print_frame_message(msg_end="\n")
self.num_plays += 1 |
Finish method for RawFrameScene. A must call after using this scene.
| tear_down | python | manim-kindergarten/manim_sandbox | videos/Solitaire/raw_frame_scene.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/videos/Solitaire/raw_frame_scene.py | MIT |
def play(*args, **kwargs):
"""
'self.play' method fails in this scene. Do not use it.
"""
raise Exception("""
'self.play' method is not allowed to use in this scene
Use 'self.capture(...)' instead
""") |
'self.play' method fails in this scene. Do not use it.
| play | python | manim-kindergarten/manim_sandbox | videos/Solitaire/raw_frame_scene.py | https://github.com/manim-kindergarten/manim_sandbox/blob/master/videos/Solitaire/raw_frame_scene.py | MIT |
async def async_update_worker(worker_id, q, notification_q, app, datastore):
"""
Async worker function that processes watch check jobs from the queue.
Args:
worker_id: Unique identifier for this worker
q: AsyncSignalPriorityQueue containing jobs to process
notification_q: Standa... |
Async worker function that processes watch check jobs from the queue.
Args:
worker_id: Unique identifier for this worker
q: AsyncSignalPriorityQueue containing jobs to process
notification_q: Standard queue for notifications
app: Flask application instance
datastore... | async_update_worker | python | dgtlmoon/changedetection.io | changedetectionio/async_update_worker.py | https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/async_update_worker.py | Apache-2.0 |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves Python code examples from Django repository that contain 'django' in the code, which helps identify Django-specific code snippets but provides limited analytical insights beyond basic filtering.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.