_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q264500 | BaseBackend.get_formatted_messages | validation | def get_formatted_messages(self, formats, label, context):
"""
Returns a dictionary with the format identifier as the key. The values are
are fully rendered templates with the given context.
"""
format_templates = {}
for fmt in formats:
# conditionally turn of... | python | {
"resource": ""
} |
q264501 | copy_attributes | validation | def copy_attributes(source, destination, ignore_patterns=[]):
"""
Copy the attributes from a source object to a destination object.
"""
for attr in _wildcard_filter(dir(source), *ignore_patterns):
setattr(destination, attr, getattr(source, attr)) | python | {
"resource": ""
} |
q264502 | DataFrameColumnSet.row | validation | def row(self, idx):
"""
Returns DataFrameRow of the DataFrame given its index.
:param idx: the index of the row in the DataFrame.
:return: returns a DataFrameRow
"""
return DataFrameRow(idx, [x[idx] for x in self], self.colnames) | python | {
"resource": ""
} |
q264503 | notice_settings | validation | def notice_settings(request):
"""
The notice settings view.
Template: :template:`notification/notice_settings.html`
Context:
notice_types
A list of all :model:`notification.NoticeType` objects.
notice_settings
A dictionary containing ``column_headers`` for eac... | python | {
"resource": ""
} |
q264504 | Tungsten.query | validation | def query(self, input = '', params = {}):
"""Query Wolfram Alpha and return a Result object"""
# Get and construct query parameters
# Default parameters
payload = {'input': input,
'appid': self.appid}
# Additional parameters (from params), formatted for url
... | python | {
"resource": ""
} |
q264505 | Result.pods | validation | def pods(self):
"""Return list of all Pod objects in result"""
# Return empty list if xml_tree is not defined (error Result object)
if not self.xml_tree:
return []
# Create a Pod object for every pod group in xml
return [Pod(elem) for elem in self.xml_tree.findall('p... | python | {
"resource": ""
} |
q264506 | SearchTree.find | validation | def find(self, *args):
"""
Find a node in the tree. If the node is not found it is added first and then returned.
:param args: a tuple
:return: returns the node
"""
curr_node = self.__root
return self.__traverse(curr_node, 0, *args) | python | {
"resource": ""
} |
q264507 | get_notification_language | validation | def get_notification_language(user):
"""
Returns site-specific notification language for this user. Raises
LanguageStoreNotAvailable if this site does not use translated
notifications.
"""
if getattr(settings, "NOTIFICATION_LANGUAGE_MODULE", False):
try:
app_label, model_name... | python | {
"resource": ""
} |
q264508 | send_now | validation | def send_now(users, label, extra_context=None, sender=None):
"""
Creates a new notice.
This is intended to be how other apps create new notices.
notification.send(user, "friends_invite_sent", {
"spam": "eggs",
"foo": "bar",
)
"""
sent = False
if extra_context is None:
... | python | {
"resource": ""
} |
q264509 | send | validation | def send(*args, **kwargs):
"""
A basic interface around both queue and send_now. This honors a global
flag NOTIFICATION_QUEUE_ALL that helps determine whether all calls should
be queued or not. A per call ``queue`` or ``now`` keyword argument can be
used to always override the default global behavio... | python | {
"resource": ""
} |
q264510 | queue | validation | def queue(users, label, extra_context=None, sender=None):
"""
Queue the notification in NoticeQueueBatch. This allows for large amounts
of user notifications to be deferred to a seperate process running outside
the webserver.
"""
if extra_context is None:
extra_context = {}
if isinst... | python | {
"resource": ""
} |
q264511 | write_table_pair_potential | validation | def write_table_pair_potential(func, dfunc=None, bounds=(1.0, 10.0), samples=1000, tollerance=1e-6, keyword='PAIR'):
"""A helper function to write lammps pair potentials to string. Assumes that
functions are vectorized.
Parameters
----------
func: function
A function that will be evaluated f... | python | {
"resource": ""
} |
q264512 | write_tersoff_potential | validation | def write_tersoff_potential(parameters):
"""Write tersoff potential file from parameters to string
Parameters
----------
parameters: dict
keys are tuple of elements with the values being the parameters length 14
"""
lines = []
for (e1, e2, e3), params in parameters.items():
i... | python | {
"resource": ""
} |
q264513 | GroupedDataFrame.aggregate | validation | def aggregate(self, clazz, new_col, *args):
"""
Aggregate the rows of each group into a single value.
:param clazz: name of a class that extends class Callable
:type clazz: class
:param new_col: name of the new column
:type new_col: str
:param args: list of colum... | python | {
"resource": ""
} |
q264514 | is_disjoint | validation | def is_disjoint(set1, set2, warn):
"""
Checks if elements of set2 are in set1.
:param set1: a set of values
:param set2: a set of values
:param warn: the error message that should be thrown
when the sets are NOT disjoint
:return: returns true no elements of set2 are in set1
"""
for... | python | {
"resource": ""
} |
q264515 | contains_all | validation | def contains_all(set1, set2, warn):
"""
Checks if all elements from set2 are in set1.
:param set1: a set of values
:param set2: a set of values
:param warn: the error message that should be thrown
when the sets are not containd
:return: returns true if all values of set2 are in set1
... | python | {
"resource": ""
} |
q264516 | MARCXMLSerializer.to_XML | validation | def to_XML(self):
"""
Serialize object back to XML string.
Returns:
str: String which should be same as original input, if everything\
works as expected.
"""
marcxml_template = """<record xmlns="http://www.loc.gov/MARC21/slim/"
xmlns:xsi="http://www.... | python | {
"resource": ""
} |
q264517 | MARCXMLParser._parse_string | validation | def _parse_string(self, xml):
"""
Parse MARC XML document to dicts, which are contained in
self.controlfields and self.datafields.
Args:
xml (str or HTMLElement): input data
Also detect if this is oai marc format or not (see elf.oai_marc).
"""
if not... | python | {
"resource": ""
} |
q264518 | MARCXMLParser._parse_control_fields | validation | def _parse_control_fields(self, fields, tag_id="tag"):
"""
Parse control fields.
Args:
fields (list): list of HTMLElements
tag_id (str): parameter name, which holds the information, about
field name this is normally "tag", but in case of
... | python | {
"resource": ""
} |
q264519 | MARCXMLParser._parse_data_fields | validation | def _parse_data_fields(self, fields, tag_id="tag", sub_id="code"):
"""
Parse data fields.
Args:
fields (list): of HTMLElements
tag_id (str): parameter name, which holds the information, about
field name this is normally "tag", but in case of
... | python | {
"resource": ""
} |
q264520 | MARCXMLParser.get_i_name | validation | def get_i_name(self, num, is_oai=None):
"""
This method is used mainly internally, but it can be handy if you work
with with raw MARC XML object and not using getters.
Args:
num (int): Which indicator you need (1/2).
is_oai (bool/None): If None, :attr:`.oai_marc`... | python | {
"resource": ""
} |
q264521 | MARCXMLParser.get_subfields | validation | def get_subfields(self, datafield, subfield, i1=None, i2=None,
exception=False):
"""
Return content of given `subfield` in `datafield`.
Args:
datafield (str): Section name (for example "001", "100", "700").
subfield (str): Subfield name (for exampl... | python | {
"resource": ""
} |
q264522 | _get_params | validation | def _get_params(target, param, dof):
'''Get the given param from each of the DOFs for a joint.'''
return [target.getParam(getattr(ode, 'Param{}{}'.format(param, s)))
for s in ['', '2', '3'][:dof]] | python | {
"resource": ""
} |
q264523 | _set_params | validation | def _set_params(target, param, values, dof):
'''Set the given param for each of the DOFs for a joint.'''
if not isinstance(values, (list, tuple, np.ndarray)):
values = [values] * dof
assert dof == len(values)
for s, value in zip(['', '2', '3'][:dof], values):
target.setParam(getattr(ode,... | python | {
"resource": ""
} |
q264524 | make_quaternion | validation | def make_quaternion(theta, *axis):
'''Given an angle and an axis, create a quaternion.'''
x, y, z = axis
r = np.sqrt(x * x + y * y + z * z)
st = np.sin(theta / 2.)
ct = np.cos(theta / 2.)
return [x * st / r, y * st / r, z * st / r, ct] | python | {
"resource": ""
} |
q264525 | center_of_mass | validation | def center_of_mass(bodies):
'''Given a set of bodies, compute their center of mass in world coordinates.
'''
x = np.zeros(3.)
t = 0.
for b in bodies:
m = b.mass
x += b.body_to_world(m.c) * m.mass
t += m.mass
return x / t | python | {
"resource": ""
} |
q264526 | Body.state | validation | def state(self, state):
'''Set the state of this body.
Parameters
----------
state : BodyState tuple
The desired state of the body.
'''
assert self.name == state.name, \
'state name "{}" != body name "{}"'.format(state.name, self.name)
sel... | python | {
"resource": ""
} |
q264527 | Body.rotation | validation | def rotation(self, rotation):
'''Set the rotation of this body using a rotation matrix.
Parameters
----------
rotation : sequence of 9 floats
The desired rotation matrix for this body.
'''
if isinstance(rotation, np.ndarray):
rotation = rotation.r... | python | {
"resource": ""
} |
q264528 | Body.body_to_world | validation | def body_to_world(self, position):
'''Convert a body-relative offset to world coordinates.
Parameters
----------
position : 3-tuple of float
A tuple giving body-relative offsets.
Returns
-------
position : 3-tuple of float
A tuple giving ... | python | {
"resource": ""
} |
q264529 | Body.world_to_body | validation | def world_to_body(self, position):
'''Convert a point in world coordinates to a body-relative offset.
Parameters
----------
position : 3-tuple of float
A world coordinates position.
Returns
-------
offset : 3-tuple of float
A tuple giving... | python | {
"resource": ""
} |
q264530 | Body.relative_offset_to_world | validation | def relative_offset_to_world(self, offset):
'''Convert a relative body offset to world coordinates.
Parameters
----------
offset : 3-tuple of float
The offset of the desired point, given as a relative fraction of the
size of this body. For example, offset (0, 0, ... | python | {
"resource": ""
} |
q264531 | Body.add_force | validation | def add_force(self, force, relative=False, position=None, relative_position=None):
'''Add a force to this body.
Parameters
----------
force : 3-tuple of float
A vector giving the forces along each world or body coordinate axis.
relative : bool, optional
I... | python | {
"resource": ""
} |
q264532 | Body.add_torque | validation | def add_torque(self, torque, relative=False):
'''Add a torque to this body.
Parameters
----------
force : 3-tuple of float
A vector giving the torque along each world or body coordinate axis.
relative : bool, optional
If False, the torque values are assum... | python | {
"resource": ""
} |
q264533 | Body.join_to | validation | def join_to(self, joint, other_body=None, **kwargs):
'''Connect this body to another one using a joint.
This method creates a joint to fasten this body to the other one. See
:func:`World.join`.
Parameters
----------
joint : str
The type of joint to use when ... | python | {
"resource": ""
} |
q264534 | Body.connect_to | validation | def connect_to(self, joint, other_body, offset=(0, 0, 0), other_offset=(0, 0, 0),
**kwargs):
'''Move another body next to this one and join them together.
This method will move the ``other_body`` so that the anchor points for
the joint coincide. It then creates a joint to fas... | python | {
"resource": ""
} |
q264535 | Joint.positions | validation | def positions(self):
'''List of positions for linear degrees of freedom.'''
return [self.ode_obj.getPosition(i) for i in range(self.LDOF)] | python | {
"resource": ""
} |
q264536 | Joint.position_rates | validation | def position_rates(self):
'''List of position rates for linear degrees of freedom.'''
return [self.ode_obj.getPositionRate(i) for i in range(self.LDOF)] | python | {
"resource": ""
} |
q264537 | Joint.angles | validation | def angles(self):
'''List of angles for rotational degrees of freedom.'''
return [self.ode_obj.getAngle(i) for i in range(self.ADOF)] | python | {
"resource": ""
} |
q264538 | Joint.angle_rates | validation | def angle_rates(self):
'''List of angle rates for rotational degrees of freedom.'''
return [self.ode_obj.getAngleRate(i) for i in range(self.ADOF)] | python | {
"resource": ""
} |
q264539 | Joint.axes | validation | def axes(self):
'''List of axes for this object's degrees of freedom.'''
return [np.array(self.ode_obj.getAxis(i))
for i in range(self.ADOF or self.LDOF)] | python | {
"resource": ""
} |
q264540 | Joint.lo_stops | validation | def lo_stops(self, lo_stops):
'''Set the lo stop values for this object's degrees of freedom.
Parameters
----------
lo_stops : float or sequence of float
A lo stop value to set on all degrees of freedom, or a list
containing one such value for each degree of free... | python | {
"resource": ""
} |
q264541 | Joint.hi_stops | validation | def hi_stops(self, hi_stops):
'''Set the hi stop values for this object's degrees of freedom.
Parameters
----------
hi_stops : float or sequence of float
A hi stop value to set on all degrees of freedom, or a list
containing one such value for each degree of free... | python | {
"resource": ""
} |
q264542 | Joint.velocities | validation | def velocities(self, velocities):
'''Set the target velocities for this object's degrees of freedom.
Parameters
----------
velocities : float or sequence of float
A target velocity value to set on all degrees of freedom, or a list
containing one such value for ea... | python | {
"resource": ""
} |
q264543 | Joint.max_forces | validation | def max_forces(self, max_forces):
'''Set the maximum forces for this object's degrees of freedom.
Parameters
----------
max_forces : float or sequence of float
A maximum force value to set on all degrees of freedom, or a list
containing one such value for each de... | python | {
"resource": ""
} |
q264544 | Joint.erps | validation | def erps(self, erps):
'''Set the ERP values for this object's degrees of freedom.
Parameters
----------
erps : float or sequence of float
An ERP value to set on all degrees of freedom, or a list
containing one such value for each degree of freedom.
'''
... | python | {
"resource": ""
} |
q264545 | Joint.cfms | validation | def cfms(self, cfms):
'''Set the CFM values for this object's degrees of freedom.
Parameters
----------
cfms : float or sequence of float
A CFM value to set on all degrees of freedom, or a list
containing one such value for each degree of freedom.
'''
... | python | {
"resource": ""
} |
q264546 | Joint.stop_cfms | validation | def stop_cfms(self, stop_cfms):
'''Set the CFM values for this object's DOF limits.
Parameters
----------
stop_cfms : float or sequence of float
A CFM value to set on all degrees of freedom limits, or a list
containing one such value for each degree of freedom li... | python | {
"resource": ""
} |
q264547 | Joint.stop_erps | validation | def stop_erps(self, stop_erps):
'''Set the ERP values for this object's DOF limits.
Parameters
----------
stop_erps : float or sequence of float
An ERP value to set on all degrees of freedom limits, or a list
containing one such value for each degree of freedom l... | python | {
"resource": ""
} |
q264548 | Slider.axes | validation | def axes(self, axes):
'''Set the linear axis of displacement for this joint.
Parameters
----------
axes : list containing one 3-tuple of floats
A list of the axes for this joint. For a slider joint, which has one
degree of freedom, this must contain one 3-tuple s... | python | {
"resource": ""
} |
q264549 | Hinge.axes | validation | def axes(self, axes):
'''Set the angular axis of rotation for this joint.
Parameters
----------
axes : list containing one 3-tuple of floats
A list of the axes for this joint. For a hinge joint, which has one
degree of freedom, this must contain one 3-tuple speci... | python | {
"resource": ""
} |
q264550 | Universal.axes | validation | def axes(self):
'''A list of axes of rotation for this joint.'''
return [np.array(self.ode_obj.getAxis1()),
np.array(self.ode_obj.getAxis2())] | python | {
"resource": ""
} |
q264551 | World.create_body | validation | def create_body(self, shape, name=None, **kwargs):
'''Create a new body.
Parameters
----------
shape : str
The "shape" of the body to be created. This should name a type of
body object, e.g., "box" or "cap".
name : str, optional
The name to us... | python | {
"resource": ""
} |
q264552 | World.join | validation | def join(self, shape, body_a, body_b=None, name=None, **kwargs):
'''Create a new joint that connects two bodies together.
Parameters
----------
shape : str
The "shape" of the joint to use for joining together two bodies.
This should name a type of joint, such as ... | python | {
"resource": ""
} |
q264553 | World.move_next_to | validation | def move_next_to(self, body_a, body_b, offset_a, offset_b):
'''Move one body to be near another one.
After moving, the location described by ``offset_a`` on ``body_a`` will
be coincident with the location described by ``offset_b`` on ``body_b``.
Parameters
----------
bo... | python | {
"resource": ""
} |
q264554 | World.set_body_states | validation | def set_body_states(self, states):
'''Set the states of some bodies in the world.
Parameters
----------
states : sequence of states
A complete state tuple for one or more bodies in the world. See
:func:`get_body_states`.
'''
for state in states:
... | python | {
"resource": ""
} |
q264555 | World.step | validation | def step(self, substeps=2):
'''Step the world forward by one frame.
Parameters
----------
substeps : int, optional
Split the step into this many sub-steps. This helps to prevent the
time delta for an update from being too large.
'''
self.frame_no ... | python | {
"resource": ""
} |
q264556 | World.are_connected | validation | def are_connected(self, body_a, body_b):
'''Determine whether the given bodies are currently connected.
Parameters
----------
body_a : str or :class:`Body`
One body to test for connectedness. If this is a string, it is
treated as the name of a body to look up.
... | python | {
"resource": ""
} |
q264557 | parse_amc | validation | def parse_amc(source):
'''Parse an AMC motion capture data file.
Parameters
----------
source : file
A file-like object that contains AMC motion capture text.
Yields
------
frame : dict
Yields a series of motion capture frames. Each frame is a dictionary
that maps a... | python | {
"resource": ""
} |
q264558 | AsfVisitor.create_bodies | validation | def create_bodies(self, translate=(0, 1, 0), size=0.1):
'''Traverse the bone hierarchy and create physics bodies.'''
stack = [('root', 0, self.root['position'] + translate)]
while stack:
name, depth, end = stack.pop()
for child in self.hierarchy.get(name, ()):
... | python | {
"resource": ""
} |
q264559 | AsfVisitor.create_joints | validation | def create_joints(self):
'''Traverse the bone hierarchy and create physics joints.'''
stack = ['root']
while stack:
parent = stack.pop()
for child in self.hierarchy.get(parent, ()):
stack.append(child)
if parent not in self.bones:
... | python | {
"resource": ""
} |
q264560 | MARCXMLQuery._parse_corporations | validation | def _parse_corporations(self, datafield, subfield, roles=["any"]):
"""
Parse informations about corporations from given field identified
by `datafield` parameter.
Args:
datafield (str): MARC field ID ("``110``", "``610``", etc..)
subfield (str): MARC subfield ID... | python | {
"resource": ""
} |
q264561 | MARCXMLQuery._parse_persons | validation | def _parse_persons(self, datafield, subfield, roles=["aut"]):
"""
Parse persons from given datafield.
Args:
datafield (str): code of datafield ("010", "730", etc..)
subfield (char): code of subfield ("a", "z", "4", etc..)
role (list of str): set to ["any"] f... | python | {
"resource": ""
} |
q264562 | MARCXMLQuery.get_ISBNs | validation | def get_ISBNs(self):
"""
Get list of VALID ISBN.
Returns:
list: List with *valid* ISBN strings.
"""
invalid_isbns = set(self.get_invalid_ISBNs())
valid_isbns = [
self._clean_isbn(isbn)
for isbn in self["020a"]
if self._cle... | python | {
"resource": ""
} |
q264563 | MARCXMLQuery.get_urls | validation | def get_urls(self):
"""
Content of field ``856u42``. Typically URL pointing to producers
homepage.
Returns:
list: List of URLs defined by producer.
"""
urls = self.get_subfields("856", "u", i1="4", i2="2")
return map(lambda x: x.replace("&", "&")... | python | {
"resource": ""
} |
q264564 | MARCXMLQuery.get_internal_urls | validation | def get_internal_urls(self):
"""
URL's, which may point to edeposit, aleph, kramerius and so on.
Fields ``856u40``, ``998a`` and ``URLu``.
Returns:
list: List of internal URLs.
"""
internal_urls = self.get_subfields("856", "u", i1="4", i2="0")
inter... | python | {
"resource": ""
} |
q264565 | pid | validation | def pid(kp=0., ki=0., kd=0., smooth=0.1):
r'''Create a callable that implements a PID controller.
A PID controller returns a control signal :math:`u(t)` given a history of
error measurements :math:`e(0) \dots e(t)`, using proportional (P), integral
(I), and derivative (D) terms, according to:
.. m... | python | {
"resource": ""
} |
q264566 | as_flat_array | validation | def as_flat_array(iterables):
'''Given a sequence of sequences, return a flat numpy array.
Parameters
----------
iterables : sequence of sequence of number
A sequence of tuples or lists containing numbers. Typically these come
from something that represents each joint in a skeleton, lik... | python | {
"resource": ""
} |
q264567 | Skeleton.load | validation | def load(self, source, **kwargs):
'''Load a skeleton definition from a file.
Parameters
----------
source : str or file
A filename or file-like object that contains text information
describing a skeleton. See :class:`pagoda.parser.Parser` for more
inf... | python | {
"resource": ""
} |
q264568 | Skeleton.load_skel | validation | def load_skel(self, source, **kwargs):
'''Load a skeleton definition from a text file.
Parameters
----------
source : str or file
A filename or file-like object that contains text information
describing a skeleton. See :class:`pagoda.parser.BodyParser` for
... | python | {
"resource": ""
} |
q264569 | Skeleton.load_asf | validation | def load_asf(self, source, **kwargs):
'''Load a skeleton definition from an ASF text file.
Parameters
----------
source : str or file
A filename or file-like object that contains text information
describing a skeleton, in ASF format.
'''
if hasatt... | python | {
"resource": ""
} |
q264570 | Skeleton.set_pid_params | validation | def set_pid_params(self, *args, **kwargs):
'''Set PID parameters for all joints in the skeleton.
Parameters for this method are passed directly to the `pid` constructor.
'''
for joint in self.joints:
joint.target_angles = [None] * joint.ADOF
joint.controllers = [... | python | {
"resource": ""
} |
q264571 | Skeleton.joint_torques | validation | def joint_torques(self):
'''Get a list of all current joint torques in the skeleton.'''
return as_flat_array(getattr(j, 'amotor', j).feedback[-1][:j.ADOF]
for j in self.joints) | python | {
"resource": ""
} |
q264572 | Skeleton.indices_for_joint | validation | def indices_for_joint(self, name):
'''Get a list of the indices for a specific joint.
Parameters
----------
name : str
The name of the joint to look up.
Returns
-------
list of int :
A list of the index values for quantities related to th... | python | {
"resource": ""
} |
q264573 | Skeleton.indices_for_body | validation | def indices_for_body(self, name, step=3):
'''Get a list of the indices for a specific body.
Parameters
----------
name : str
The name of the body to look up.
step : int, optional
The number of numbers for each body. Defaults to 3, should be set
... | python | {
"resource": ""
} |
q264574 | Skeleton.joint_distances | validation | def joint_distances(self):
'''Get the current joint separations for the skeleton.
Returns
-------
distances : list of float
A list expressing the distance between the two joint anchor points,
for each joint in the skeleton. These quantities describe how
... | python | {
"resource": ""
} |
q264575 | Skeleton.enable_motors | validation | def enable_motors(self, max_force):
'''Enable the joint motors in this skeleton.
This method sets the maximum force that can be applied by each joint to
attain the desired target velocities. It also enables torque feedback
for all joint motors.
Parameters
----------
... | python | {
"resource": ""
} |
q264576 | Skeleton.set_target_angles | validation | def set_target_angles(self, angles):
'''Move each joint toward a target angle.
This method uses a PID controller to set a target angular velocity for
each degree of freedom in the skeleton, based on the difference between
the current and the target angle for the respective DOF.
... | python | {
"resource": ""
} |
q264577 | Skeleton.add_torques | validation | def add_torques(self, torques):
'''Add torques for each degree of freedom in the skeleton.
Parameters
----------
torques : list of float
A list of the torques to add to each degree of freedom in the
skeleton.
'''
j = 0
for joint in self.jo... | python | {
"resource": ""
} |
q264578 | Markers.labels | validation | def labels(self):
'''Return the names of our marker labels in canonical order.'''
return sorted(self.channels, key=lambda c: self.channels[c]) | python | {
"resource": ""
} |
q264579 | Markers.load_csv | validation | def load_csv(self, filename, start_frame=10, max_frames=int(1e300)):
'''Load marker data from a CSV file.
The file will be imported using Pandas, which must be installed to use
this method. (``pip install pandas``)
The first line of the CSV file will be used for header information. The... | python | {
"resource": ""
} |
q264580 | Markers.load_c3d | validation | def load_c3d(self, filename, start_frame=0, max_frames=int(1e300)):
'''Load marker data from a C3D file.
The file will be imported using the c3d module, which must be installed
to use this method. (``pip install c3d``)
Parameters
----------
filename : str
Na... | python | {
"resource": ""
} |
q264581 | Markers.process_data | validation | def process_data(self):
'''Process data to produce velocity and dropout information.'''
self.visibility = self.data[:, :, 3]
self.positions = self.data[:, :, :3]
self.velocities = np.zeros_like(self.positions) + 1000
for frame_no in range(1, len(self.data) - 1):
prev ... | python | {
"resource": ""
} |
q264582 | Markers.create_bodies | validation | def create_bodies(self):
'''Create physics bodies corresponding to each marker in our data.'''
self.bodies = {}
for label in self.channels:
body = self.world.create_body(
'sphere', name='marker:{}'.format(label), radius=0.02)
body.is_kinematic = True
... | python | {
"resource": ""
} |
q264583 | Markers.load_attachments | validation | def load_attachments(self, source, skeleton):
'''Load attachment configuration from the given text source.
The attachment configuration file has a simple format. After discarding
Unix-style comments (any part of a line that starts with the pound (#)
character), each line in the file is ... | python | {
"resource": ""
} |
q264584 | Markers.attach | validation | def attach(self, frame_no):
'''Attach marker bodies to the corresponding skeleton bodies.
Attachments are only made for markers that are not in a dropout state in
the given frame.
Parameters
----------
frame_no : int
The frame of data we will use for attachi... | python | {
"resource": ""
} |
q264585 | Markers.reposition | validation | def reposition(self, frame_no):
'''Reposition markers to a specific frame of data.
Parameters
----------
frame_no : int
The frame of data where we should reposition marker bodies. Markers
will be positioned in the appropriate places in world coordinates.
... | python | {
"resource": ""
} |
q264586 | Markers.distances | validation | def distances(self):
'''Get a list of the distances between markers and their attachments.
Returns
-------
distances : ndarray of shape (num-markers, 3)
Array of distances for each marker joint in our attachment setup. If
a marker does not currently have an assoc... | python | {
"resource": ""
} |
q264587 | Markers.forces | validation | def forces(self, dx_tm1=None):
'''Return an array of the forces exerted by marker springs.
Notes
-----
The forces exerted by the marker springs can be approximated by::
F = kp * dx
where ``dx`` is the current array of marker distances. An even more
accurate ... | python | {
"resource": ""
} |
q264588 | World.load_skeleton | validation | def load_skeleton(self, filename, pid_params=None):
'''Create and configure a skeleton in our model.
Parameters
----------
filename : str
The name of a file containing skeleton configuration data.
pid_params : dict, optional
If given, use this dictionary ... | python | {
"resource": ""
} |
q264589 | World.load_markers | validation | def load_markers(self, filename, attachments, max_frames=1e100):
'''Load marker data and attachment preferences into the model.
Parameters
----------
filename : str
The name of a file containing marker data. This currently needs to
be either a .C3D or a .CSV file... | python | {
"resource": ""
} |
q264590 | World.step | validation | def step(self, substeps=2):
'''Advance the physics world by one step.
Typically this is called as part of a :class:`pagoda.viewer.Viewer`, but
it can also be called manually (or some other stepping mechanism
entirely can be used).
'''
# by default we step by following ou... | python | {
"resource": ""
} |
q264591 | World.settle_to_markers | validation | def settle_to_markers(self, frame_no=0, max_distance=0.05, max_iters=300,
states=None):
'''Settle the skeleton to our marker data at a specific frame.
Parameters
----------
frame_no : int, optional
Settle the skeleton to marker data at this frame. D... | python | {
"resource": ""
} |
q264592 | World.follow_markers | validation | def follow_markers(self, start=0, end=1e100, states=None):
'''Iterate over a set of marker data, dragging its skeleton along.
Parameters
----------
start : int, optional
Start following marker data after this frame. Defaults to 0.
end : int, optional
Stop... | python | {
"resource": ""
} |
q264593 | World._step_to_marker_frame | validation | def _step_to_marker_frame(self, frame_no, dt=None):
'''Update the simulator to a specific frame of marker data.
This method returns a generator of body states for the skeleton! This
generator must be exhausted (e.g., by consuming this call in a for loop)
for the simulator to work proper... | python | {
"resource": ""
} |
q264594 | World.inverse_kinematics | validation | def inverse_kinematics(self, start=0, end=1e100, states=None, max_force=20):
'''Follow a set of marker data, yielding kinematic joint angles.
Parameters
----------
start : int, optional
Start following marker data after this frame. Defaults to 0.
end : int, optional
... | python | {
"resource": ""
} |
q264595 | World.inverse_dynamics | validation | def inverse_dynamics(self, angles, start=0, end=1e100, states=None, max_force=100):
'''Follow a set of angle data, yielding dynamic joint torques.
Parameters
----------
angles : ndarray (num-frames x num-dofs)
Follow angle data provided by this array of angle values.
... | python | {
"resource": ""
} |
q264596 | World.forward_dynamics | validation | def forward_dynamics(self, torques, start=0, states=None):
'''Move the body according to a set of torque data.'''
if states is not None:
self.skeleton.set_body_states(states)
for frame_no, torque in enumerate(torques):
if frame_no < start:
continue
... | python | {
"resource": ""
} |
q264597 | resorted | validation | def resorted(values):
"""
Sort values, but put numbers after alphabetically sorted words.
This function is here to make outputs diff-compatible with Aleph.
Example::
>>> sorted(["b", "1", "a"])
['1', 'a', 'b']
>>> resorted(["b", "1", "a"])
['a', 'b', '1']
Args:
... | python | {
"resource": ""
} |
q264598 | Viewer.render | validation | def render(self, dt):
'''Draw all bodies in the world.'''
for frame in self._frozen:
for body in frame:
self.draw_body(body)
for body in self.world.bodies:
self.draw_body(body)
if hasattr(self.world, 'markers'):
# draw line between anc... | python | {
"resource": ""
} |
q264599 | Room.get_stream | validation | def get_stream(self, error_callback=None, live=True):
""" Get room stream to listen for messages.
Kwargs:
error_callback (func): Callback to call when an error occurred (parameters: exception)
live (bool): If True, issue a live stream, otherwise an offline stream
Return... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.