repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
robotpy/pyfrc
lib/pyfrc/physics/drivetrains.py
mecanum_drivetrain
def mecanum_drivetrain( lr_motor, rr_motor, lf_motor, rf_motor, x_wheelbase=2, y_wheelbase=3, speed=5, deadzone=None, ): """ .. deprecated:: 2018.2.0 Use :class:`MecanumDrivetrain` instead """ return MecanumDrivetrain(x_wheelbase, y_wheelbase, speed, deadzo...
python
def mecanum_drivetrain( lr_motor, rr_motor, lf_motor, rf_motor, x_wheelbase=2, y_wheelbase=3, speed=5, deadzone=None, ): """ .. deprecated:: 2018.2.0 Use :class:`MecanumDrivetrain` instead """ return MecanumDrivetrain(x_wheelbase, y_wheelbase, speed, deadzo...
[ "def", "mecanum_drivetrain", "(", "lr_motor", ",", "rr_motor", ",", "lf_motor", ",", "rf_motor", ",", "x_wheelbase", "=", "2", ",", "y_wheelbase", "=", "3", ",", "speed", "=", "5", ",", "deadzone", "=", "None", ",", ")", ":", "return", "MecanumDrivetrain",...
.. deprecated:: 2018.2.0 Use :class:`MecanumDrivetrain` instead
[ "..", "deprecated", "::", "2018", ".", "2", ".", "0", "Use", ":", "class", ":", "MecanumDrivetrain", "instead" ]
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/drivetrains.py#L326-L342
robotpy/pyfrc
lib/pyfrc/physics/drivetrains.py
four_motor_swerve_drivetrain
def four_motor_swerve_drivetrain( lr_motor, rr_motor, lf_motor, rf_motor, lr_angle, rr_angle, lf_angle, rf_angle, x_wheelbase=2, y_wheelbase=2, speed=5, deadzone=None, ): """ Four motors that can be rotated in any direction If any motors are i...
python
def four_motor_swerve_drivetrain( lr_motor, rr_motor, lf_motor, rf_motor, lr_angle, rr_angle, lf_angle, rf_angle, x_wheelbase=2, y_wheelbase=2, speed=5, deadzone=None, ): """ Four motors that can be rotated in any direction If any motors are i...
[ "def", "four_motor_swerve_drivetrain", "(", "lr_motor", ",", "rr_motor", ",", "lf_motor", ",", "rf_motor", ",", "lr_angle", ",", "rr_angle", ",", "lf_angle", ",", "rf_angle", ",", "x_wheelbase", "=", "2", ",", "y_wheelbase", "=", "2", ",", "speed", "=", "5",...
Four motors that can be rotated in any direction If any motors are inverted, then you will need to multiply that motor's value by -1. :param lr_motor: Left rear motor value (-1 to 1); 1 is forward :param rr_motor: Right rear motor value (-1 to 1); 1 is forward ...
[ "Four", "motors", "that", "can", "be", "rotated", "in", "any", "direction", "If", "any", "motors", "are", "inverted", "then", "you", "will", "need", "to", "multiply", "that", "motor", "s", "value", "by", "-", "1", ".", ":", "param", "lr_motor", ":", "L...
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/drivetrains.py#L345-L438
robotpy/pyfrc
lib/pyfrc/physics/drivetrains.py
TwoMotorDrivetrain.get_vector
def get_vector(self, l_motor: float, r_motor: float) -> typing.Tuple[float, float]: """ Given motor values, retrieves the vector of (distance, speed) for your robot :param l_motor: Left motor value (-1 to 1); -1 is forward :param r_motor: Right motor value (-1 ...
python
def get_vector(self, l_motor: float, r_motor: float) -> typing.Tuple[float, float]: """ Given motor values, retrieves the vector of (distance, speed) for your robot :param l_motor: Left motor value (-1 to 1); -1 is forward :param r_motor: Right motor value (-1 ...
[ "def", "get_vector", "(", "self", ",", "l_motor", ":", "float", ",", "r_motor", ":", "float", ")", "->", "typing", ".", "Tuple", "[", "float", ",", "float", "]", ":", "if", "self", ".", "deadzone", ":", "l_motor", "=", "self", ".", "deadzone", "(", ...
Given motor values, retrieves the vector of (distance, speed) for your robot :param l_motor: Left motor value (-1 to 1); -1 is forward :param r_motor: Right motor value (-1 to 1); 1 is forward :returns: speed of robot (ft/s), clockwise rotation of robot (radians/s)
[ "Given", "motor", "values", "retrieves", "the", "vector", "of", "(", "distance", "speed", ")", "for", "your", "robot", ":", "param", "l_motor", ":", "Left", "motor", "value", "(", "-", "1", "to", "1", ")", ";", "-", "1", "is", "forward", ":", "param"...
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/drivetrains.py#L121-L143
robotpy/pyfrc
lib/pyfrc/physics/drivetrains.py
FourMotorDrivetrain.get_vector
def get_vector( self, lr_motor: float, rr_motor: float, lf_motor: float, rf_motor: float ) -> typing.Tuple[float, float]: """ :param lr_motor: Left rear motor value (-1 to 1); -1 is forward :param rr_motor: Right rear motor value (-1 to 1); 1 is forward :param...
python
def get_vector( self, lr_motor: float, rr_motor: float, lf_motor: float, rf_motor: float ) -> typing.Tuple[float, float]: """ :param lr_motor: Left rear motor value (-1 to 1); -1 is forward :param rr_motor: Right rear motor value (-1 to 1); 1 is forward :param...
[ "def", "get_vector", "(", "self", ",", "lr_motor", ":", "float", ",", "rr_motor", ":", "float", ",", "lf_motor", ":", "float", ",", "rf_motor", ":", "float", ")", "->", "typing", ".", "Tuple", "[", "float", ",", "float", "]", ":", "if", "self", ".", ...
:param lr_motor: Left rear motor value (-1 to 1); -1 is forward :param rr_motor: Right rear motor value (-1 to 1); 1 is forward :param lf_motor: Left front motor value (-1 to 1); -1 is forward :param rf_motor: Right front motor value (-1 to 1); 1 is forward ...
[ ":", "param", "lr_motor", ":", "Left", "rear", "motor", "value", "(", "-", "1", "to", "1", ")", ";", "-", "1", "is", "forward", ":", "param", "rr_motor", ":", "Right", "rear", "motor", "value", "(", "-", "1", "to", "1", ")", ";", "1", "is", "fo...
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/drivetrains.py#L194-L221
robotpy/pyfrc
lib/pyfrc/physics/drivetrains.py
MecanumDrivetrain.get_vector
def get_vector( self, lr_motor: float, rr_motor: float, lf_motor: float, rf_motor: float ) -> typing.Tuple[float, float, float]: """ Given motor values, retrieves the vector of (distance, speed) for your robot :param lr_motor: Left rear motor value (-1 to 1); 1 is ...
python
def get_vector( self, lr_motor: float, rr_motor: float, lf_motor: float, rf_motor: float ) -> typing.Tuple[float, float, float]: """ Given motor values, retrieves the vector of (distance, speed) for your robot :param lr_motor: Left rear motor value (-1 to 1); 1 is ...
[ "def", "get_vector", "(", "self", ",", "lr_motor", ":", "float", ",", "rr_motor", ":", "float", ",", "lf_motor", ":", "float", ",", "rf_motor", ":", "float", ")", "->", "typing", ".", "Tuple", "[", "float", ",", "float", ",", "float", "]", ":", "#", ...
Given motor values, retrieves the vector of (distance, speed) for your robot :param lr_motor: Left rear motor value (-1 to 1); 1 is forward :param rr_motor: Right rear motor value (-1 to 1); 1 is forward :param lf_motor: Left front motor value (-1 to 1); 1 is forward ...
[ "Given", "motor", "values", "retrieves", "the", "vector", "of", "(", "distance", "speed", ")", "for", "your", "robot", ":", "param", "lr_motor", ":", "Left", "rear", "motor", "value", "(", "-", "1", "to", "1", ")", ";", "1", "is", "forward", ":", "pa...
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/drivetrains.py#L273-L323
openstack/monasca-common
docker/mysql_check.py
connect_mysql
def connect_mysql(host, port, user, password, database): """Connect to MySQL with retries.""" return pymysql.connect( host=host, port=port, user=user, passwd=password, db=database )
python
def connect_mysql(host, port, user, password, database): """Connect to MySQL with retries.""" return pymysql.connect( host=host, port=port, user=user, passwd=password, db=database )
[ "def", "connect_mysql", "(", "host", ",", "port", ",", "user", ",", "password", ",", "database", ")", ":", "return", "pymysql", ".", "connect", "(", "host", "=", "host", ",", "port", "=", "port", ",", "user", "=", "user", ",", "passwd", "=", "passwor...
Connect to MySQL with retries.
[ "Connect", "to", "MySQL", "with", "retries", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/docker/mysql_check.py#L109-L115
openstack/monasca-common
docker/mysql_check.py
main
def main(): """Start main part of the wait script.""" logger.info('Waiting for database: `%s`', MYSQL_DB) connect_mysql( host=MYSQL_HOST, port=MYSQL_PORT, user=MYSQL_USER, password=MYSQL_PASSWORD, database=MYSQL_DB ) logger.info('Database `%s` found', MYSQL_DB)
python
def main(): """Start main part of the wait script.""" logger.info('Waiting for database: `%s`', MYSQL_DB) connect_mysql( host=MYSQL_HOST, port=MYSQL_PORT, user=MYSQL_USER, password=MYSQL_PASSWORD, database=MYSQL_DB ) logger.info('Database `%s` found', MYSQL_DB)
[ "def", "main", "(", ")", ":", "logger", ".", "info", "(", "'Waiting for database: `%s`'", ",", "MYSQL_DB", ")", "connect_mysql", "(", "host", "=", "MYSQL_HOST", ",", "port", "=", "MYSQL_PORT", ",", "user", "=", "MYSQL_USER", ",", "password", "=", "MYSQL_PASS...
Start main part of the wait script.
[ "Start", "main", "part", "of", "the", "wait", "script", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/docker/mysql_check.py#L118-L128
partofthething/ace
ace/ace.py
unsort_vector
def unsort_vector(data, indices_of_increasing): """Upermutate 1-D data that is sorted by indices_of_increasing.""" return numpy.array([data[indices_of_increasing.index(i)] for i in range(len(data))])
python
def unsort_vector(data, indices_of_increasing): """Upermutate 1-D data that is sorted by indices_of_increasing.""" return numpy.array([data[indices_of_increasing.index(i)] for i in range(len(data))])
[ "def", "unsort_vector", "(", "data", ",", "indices_of_increasing", ")", ":", "return", "numpy", ".", "array", "(", "[", "data", "[", "indices_of_increasing", ".", "index", "(", "i", ")", "]", "for", "i", "in", "range", "(", "len", "(", "data", ")", ")"...
Upermutate 1-D data that is sorted by indices_of_increasing.
[ "Upermutate", "1", "-", "D", "data", "that", "is", "sorted", "by", "indices_of_increasing", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L213-L215
partofthething/ace
ace/ace.py
plot_transforms
def plot_transforms(ace_model, fname='ace_transforms.png'): """Plot the transforms.""" if not plt: raise ImportError('Cannot plot without the matplotlib package') plt.rcParams.update({'font.size': 8}) plt.figure() num_cols = len(ace_model.x) / 2 + 1 for i in range(len(ace_model.x)): ...
python
def plot_transforms(ace_model, fname='ace_transforms.png'): """Plot the transforms.""" if not plt: raise ImportError('Cannot plot without the matplotlib package') plt.rcParams.update({'font.size': 8}) plt.figure() num_cols = len(ace_model.x) / 2 + 1 for i in range(len(ace_model.x)): ...
[ "def", "plot_transforms", "(", "ace_model", ",", "fname", "=", "'ace_transforms.png'", ")", ":", "if", "not", "plt", ":", "raise", "ImportError", "(", "'Cannot plot without the matplotlib package'", ")", "plt", ".", "rcParams", ".", "update", "(", "{", "'font.size...
Plot the transforms.
[ "Plot", "the", "transforms", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L218-L239
partofthething/ace
ace/ace.py
plot_input
def plot_input(ace_model, fname='ace_input.png'): """Plot the transforms.""" if not plt: raise ImportError('Cannot plot without the matplotlib package') plt.rcParams.update({'font.size': 8}) plt.figure() num_cols = len(ace_model.x) / 2 + 1 for i in range(len(ace_model.x)): plt.su...
python
def plot_input(ace_model, fname='ace_input.png'): """Plot the transforms.""" if not plt: raise ImportError('Cannot plot without the matplotlib package') plt.rcParams.update({'font.size': 8}) plt.figure() num_cols = len(ace_model.x) / 2 + 1 for i in range(len(ace_model.x)): plt.su...
[ "def", "plot_input", "(", "ace_model", ",", "fname", "=", "'ace_input.png'", ")", ":", "if", "not", "plt", ":", "raise", "ImportError", "(", "'Cannot plot without the matplotlib package'", ")", "plt", ".", "rcParams", ".", "update", "(", "{", "'font.size'", ":",...
Plot the transforms.
[ "Plot", "the", "transforms", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L241-L259
partofthething/ace
ace/ace.py
ACESolver.specify_data_set
def specify_data_set(self, x_input, y_input): """ Define input to ACE. Parameters ---------- x_input : list list of iterables, one for each independent variable y_input : array the dependent observations """ self.x = x_input ...
python
def specify_data_set(self, x_input, y_input): """ Define input to ACE. Parameters ---------- x_input : list list of iterables, one for each independent variable y_input : array the dependent observations """ self.x = x_input ...
[ "def", "specify_data_set", "(", "self", ",", "x_input", ",", "y_input", ")", ":", "self", ".", "x", "=", "x_input", "self", ".", "y", "=", "y_input" ]
Define input to ACE. Parameters ---------- x_input : list list of iterables, one for each independent variable y_input : array the dependent observations
[ "Define", "input", "to", "ACE", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L50-L62
partofthething/ace
ace/ace.py
ACESolver.solve
def solve(self): """Run the ACE calculational loop.""" self._initialize() while self._outer_error_is_decreasing() and self._outer_iters < MAX_OUTERS: print('* Starting outer iteration {0:03d}. Current err = {1:12.5E}' ''.format(self._outer_iters, self._last_outer_er...
python
def solve(self): """Run the ACE calculational loop.""" self._initialize() while self._outer_error_is_decreasing() and self._outer_iters < MAX_OUTERS: print('* Starting outer iteration {0:03d}. Current err = {1:12.5E}' ''.format(self._outer_iters, self._last_outer_er...
[ "def", "solve", "(", "self", ")", ":", "self", ".", "_initialize", "(", ")", "while", "self", ".", "_outer_error_is_decreasing", "(", ")", "and", "self", ".", "_outer_iters", "<", "MAX_OUTERS", ":", "print", "(", "'* Starting outer iteration {0:03d}. Current err =...
Run the ACE calculational loop.
[ "Run", "the", "ACE", "calculational", "loop", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L64-L72
partofthething/ace
ace/ace.py
ACESolver._initialize
def _initialize(self): """Set up and normalize initial data once input data is specified.""" self.y_transform = self.y - numpy.mean(self.y) self.y_transform /= numpy.std(self.y_transform) self.x_transforms = [numpy.zeros(len(self.y)) for _xi in self.x] self._compute_sorted_indice...
python
def _initialize(self): """Set up and normalize initial data once input data is specified.""" self.y_transform = self.y - numpy.mean(self.y) self.y_transform /= numpy.std(self.y_transform) self.x_transforms = [numpy.zeros(len(self.y)) for _xi in self.x] self._compute_sorted_indice...
[ "def", "_initialize", "(", "self", ")", ":", "self", ".", "y_transform", "=", "self", ".", "y", "-", "numpy", ".", "mean", "(", "self", ".", "y", ")", "self", ".", "y_transform", "/=", "numpy", ".", "std", "(", "self", ".", "y_transform", ")", "sel...
Set up and normalize initial data once input data is specified.
[ "Set", "up", "and", "normalize", "initial", "data", "once", "input", "data", "is", "specified", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L74-L79
partofthething/ace
ace/ace.py
ACESolver._compute_sorted_indices
def _compute_sorted_indices(self): """ The smoothers need sorted data. This sorts it from the perspective of each column. if self._x[0][3] is the 9th-smallest value in self._x[0], then _xi_sorted[3] = 8 We only have to sort the data once. """ sorted_indices = [] ...
python
def _compute_sorted_indices(self): """ The smoothers need sorted data. This sorts it from the perspective of each column. if self._x[0][3] is the 9th-smallest value in self._x[0], then _xi_sorted[3] = 8 We only have to sort the data once. """ sorted_indices = [] ...
[ "def", "_compute_sorted_indices", "(", "self", ")", ":", "sorted_indices", "=", "[", "]", "for", "to_sort", "in", "[", "self", ".", "y", "]", "+", "self", ".", "x", ":", "data_w_indices", "=", "[", "(", "val", ",", "i", ")", "for", "(", "i", ",", ...
The smoothers need sorted data. This sorts it from the perspective of each column. if self._x[0][3] is the 9th-smallest value in self._x[0], then _xi_sorted[3] = 8 We only have to sort the data once.
[ "The", "smoothers", "need", "sorted", "data", ".", "This", "sorts", "it", "from", "the", "perspective", "of", "each", "column", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L81-L96
partofthething/ace
ace/ace.py
ACESolver._outer_error_is_decreasing
def _outer_error_is_decreasing(self): """True if outer iteration error is decreasing.""" is_decreasing, self._last_outer_error = self._error_is_decreasing(self._last_outer_error) return is_decreasing
python
def _outer_error_is_decreasing(self): """True if outer iteration error is decreasing.""" is_decreasing, self._last_outer_error = self._error_is_decreasing(self._last_outer_error) return is_decreasing
[ "def", "_outer_error_is_decreasing", "(", "self", ")", ":", "is_decreasing", ",", "self", ".", "_last_outer_error", "=", "self", ".", "_error_is_decreasing", "(", "self", ".", "_last_outer_error", ")", "return", "is_decreasing" ]
True if outer iteration error is decreasing.
[ "True", "if", "outer", "iteration", "error", "is", "decreasing", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L98-L101
partofthething/ace
ace/ace.py
ACESolver._error_is_decreasing
def _error_is_decreasing(self, last_error): """True if current error is less than last_error.""" current_error = self._compute_error() is_decreasing = current_error < last_error return is_decreasing, current_error
python
def _error_is_decreasing(self, last_error): """True if current error is less than last_error.""" current_error = self._compute_error() is_decreasing = current_error < last_error return is_decreasing, current_error
[ "def", "_error_is_decreasing", "(", "self", ",", "last_error", ")", ":", "current_error", "=", "self", ".", "_compute_error", "(", ")", "is_decreasing", "=", "current_error", "<", "last_error", "return", "is_decreasing", ",", "current_error" ]
True if current error is less than last_error.
[ "True", "if", "current", "error", "is", "less", "than", "last_error", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L103-L107
partofthething/ace
ace/ace.py
ACESolver._compute_error
def _compute_error(self): """Compute unexplained error.""" sum_x = sum(self.x_transforms) err = sum((self.y_transform - sum_x) ** 2) / len(sum_x) return err
python
def _compute_error(self): """Compute unexplained error.""" sum_x = sum(self.x_transforms) err = sum((self.y_transform - sum_x) ** 2) / len(sum_x) return err
[ "def", "_compute_error", "(", "self", ")", ":", "sum_x", "=", "sum", "(", "self", ".", "x_transforms", ")", "err", "=", "sum", "(", "(", "self", ".", "y_transform", "-", "sum_x", ")", "**", "2", ")", "/", "len", "(", "sum_x", ")", "return", "err" ]
Compute unexplained error.
[ "Compute", "unexplained", "error", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L109-L113
partofthething/ace
ace/ace.py
ACESolver._iterate_to_update_x_transforms
def _iterate_to_update_x_transforms(self): """Perform the inner iteration.""" self._inner_iters = 0 self._last_inner_error = float('inf') while self._inner_error_is_decreasing(): print(' Starting inner iteration {0:03d}. Current err = {1:12.5E}' ''.format(s...
python
def _iterate_to_update_x_transforms(self): """Perform the inner iteration.""" self._inner_iters = 0 self._last_inner_error = float('inf') while self._inner_error_is_decreasing(): print(' Starting inner iteration {0:03d}. Current err = {1:12.5E}' ''.format(s...
[ "def", "_iterate_to_update_x_transforms", "(", "self", ")", ":", "self", ".", "_inner_iters", "=", "0", "self", ".", "_last_inner_error", "=", "float", "(", "'inf'", ")", "while", "self", ".", "_inner_error_is_decreasing", "(", ")", ":", "print", "(", "' Star...
Perform the inner iteration.
[ "Perform", "the", "inner", "iteration", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L115-L123
partofthething/ace
ace/ace.py
ACESolver._update_x_transforms
def _update_x_transforms(self): """ Compute a new set of x-transform functions phik. phik(xk) = theta(y) - sum of phii(xi) over i!=k This is the first of the eponymous conditional expectations. The conditional expectations are computed using the SuperSmoother. """ ...
python
def _update_x_transforms(self): """ Compute a new set of x-transform functions phik. phik(xk) = theta(y) - sum of phii(xi) over i!=k This is the first of the eponymous conditional expectations. The conditional expectations are computed using the SuperSmoother. """ ...
[ "def", "_update_x_transforms", "(", "self", ")", ":", "# start by subtracting all transforms", "theta_minus_phis", "=", "self", ".", "y_transform", "-", "numpy", ".", "sum", "(", "self", ".", "x_transforms", ",", "axis", "=", "0", ")", "# add one transform at a time...
Compute a new set of x-transform functions phik. phik(xk) = theta(y) - sum of phii(xi) over i!=k This is the first of the eponymous conditional expectations. The conditional expectations are computed using the SuperSmoother.
[ "Compute", "a", "new", "set", "of", "x", "-", "transform", "functions", "phik", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L129-L162
partofthething/ace
ace/ace.py
ACESolver._update_y_transform
def _update_y_transform(self): """ Update the y-transform (theta). y-transform theta is forced to have mean = 0 and stddev = 1. This is the second conditional expectation """ # sort all phis wrt increasing y. sorted_data_indices = self._yi_sorted sorted_...
python
def _update_y_transform(self): """ Update the y-transform (theta). y-transform theta is forced to have mean = 0 and stddev = 1. This is the second conditional expectation """ # sort all phis wrt increasing y. sorted_data_indices = self._yi_sorted sorted_...
[ "def", "_update_y_transform", "(", "self", ")", ":", "# sort all phis wrt increasing y.", "sorted_data_indices", "=", "self", ".", "_yi_sorted", "sorted_xtransforms", "=", "[", "]", "for", "xt", "in", "self", ".", "x_transforms", ":", "sorted_xt", "=", "sort_vector"...
Update the y-transform (theta). y-transform theta is forced to have mean = 0 and stddev = 1. This is the second conditional expectation
[ "Update", "the", "y", "-", "transform", "(", "theta", ")", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L164-L189
partofthething/ace
ace/ace.py
ACESolver.write_input_to_file
def write_input_to_file(self, fname='ace_input.txt'): """Write y and x values used in this run to a space-delimited txt file.""" self._write_columns(fname, self.x, self.y)
python
def write_input_to_file(self, fname='ace_input.txt'): """Write y and x values used in this run to a space-delimited txt file.""" self._write_columns(fname, self.x, self.y)
[ "def", "write_input_to_file", "(", "self", ",", "fname", "=", "'ace_input.txt'", ")", ":", "self", ".", "_write_columns", "(", "fname", ",", "self", ".", "x", ",", "self", ".", "y", ")" ]
Write y and x values used in this run to a space-delimited txt file.
[ "Write", "y", "and", "x", "values", "used", "in", "this", "run", "to", "a", "space", "-", "delimited", "txt", "file", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L191-L193
partofthething/ace
ace/ace.py
ACESolver.write_transforms_to_file
def write_transforms_to_file(self, fname='ace_transforms.txt'): """Write y and x transforms used in this run to a space-delimited txt file.""" self._write_columns(fname, self.x_transforms, self.y_transform)
python
def write_transforms_to_file(self, fname='ace_transforms.txt'): """Write y and x transforms used in this run to a space-delimited txt file.""" self._write_columns(fname, self.x_transforms, self.y_transform)
[ "def", "write_transforms_to_file", "(", "self", ",", "fname", "=", "'ace_transforms.txt'", ")", ":", "self", ".", "_write_columns", "(", "fname", ",", "self", ".", "x_transforms", ",", "self", ".", "y_transform", ")" ]
Write y and x transforms used in this run to a space-delimited txt file.
[ "Write", "y", "and", "x", "transforms", "used", "in", "this", "run", "to", "a", "space", "-", "delimited", "txt", "file", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/ace.py#L195-L197
partofthething/ace
ace/samples/smoother_friedman82.py
build_sample_smoother_problem_friedman82
def build_sample_smoother_problem_friedman82(N=200): """Sample problem from supersmoother publication.""" x = numpy.random.uniform(size=N) err = numpy.random.standard_normal(N) y = numpy.sin(2 * math.pi * (1 - x) ** 2) + x * err return x, y
python
def build_sample_smoother_problem_friedman82(N=200): """Sample problem from supersmoother publication.""" x = numpy.random.uniform(size=N) err = numpy.random.standard_normal(N) y = numpy.sin(2 * math.pi * (1 - x) ** 2) + x * err return x, y
[ "def", "build_sample_smoother_problem_friedman82", "(", "N", "=", "200", ")", ":", "x", "=", "numpy", ".", "random", ".", "uniform", "(", "size", "=", "N", ")", "err", "=", "numpy", ".", "random", ".", "standard_normal", "(", "N", ")", "y", "=", "numpy...
Sample problem from supersmoother publication.
[ "Sample", "problem", "from", "supersmoother", "publication", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/samples/smoother_friedman82.py#L11-L16
partofthething/ace
ace/samples/smoother_friedman82.py
run_friedman82_basic
def run_friedman82_basic(): """Run Friedman's test of fixed-span smoothers from Figure 2b.""" x, y = build_sample_smoother_problem_friedman82() plt.figure() # plt.plot(x, y, '.', label='Data') for span in smoother.DEFAULT_SPANS: smooth = smoother.BasicFixedSpanSmoother() smooth.speci...
python
def run_friedman82_basic(): """Run Friedman's test of fixed-span smoothers from Figure 2b.""" x, y = build_sample_smoother_problem_friedman82() plt.figure() # plt.plot(x, y, '.', label='Data') for span in smoother.DEFAULT_SPANS: smooth = smoother.BasicFixedSpanSmoother() smooth.speci...
[ "def", "run_friedman82_basic", "(", ")", ":", "x", ",", "y", "=", "build_sample_smoother_problem_friedman82", "(", ")", "plt", ".", "figure", "(", ")", "# plt.plot(x, y, '.', label='Data')", "for", "span", "in", "smoother", ".", "DEFAULT_SPANS", ":", "smooth", "="...
Run Friedman's test of fixed-span smoothers from Figure 2b.
[ "Run", "Friedman", "s", "test", "of", "fixed", "-", "span", "smoothers", "from", "Figure", "2b", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/samples/smoother_friedman82.py#L18-L36
robotpy/pyfrc
lib/pyfrc/sim/field/field.py
RobotField.add_moving_element
def add_moving_element(self, element): """Add elements to the board""" element.initialize(self.canvas) self.elements.append(element)
python
def add_moving_element(self, element): """Add elements to the board""" element.initialize(self.canvas) self.elements.append(element)
[ "def", "add_moving_element", "(", "self", ",", "element", ")", ":", "element", ".", "initialize", "(", "self", ".", "canvas", ")", "self", ".", "elements", ".", "append", "(", "element", ")" ]
Add elements to the board
[ "Add", "elements", "to", "the", "board" ]
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/sim/field/field.py#L84-L88
robotpy/pyfrc
lib/pyfrc/sim/field/field.py
RobotField.on_key_pressed
def on_key_pressed(self, event): """ likely to take in a set of parameters to treat as up, down, left, right, likely to actually be based on a joystick event... not sure yet """ return # TODO if event.keysym == "Up": self.manager...
python
def on_key_pressed(self, event): """ likely to take in a set of parameters to treat as up, down, left, right, likely to actually be based on a joystick event... not sure yet """ return # TODO if event.keysym == "Up": self.manager...
[ "def", "on_key_pressed", "(", "self", ",", "event", ")", ":", "return", "# TODO", "if", "event", ".", "keysym", "==", "\"Up\"", ":", "self", ".", "manager", ".", "set_joystick", "(", "0.0", ",", "-", "1.0", ",", "0", ")", "elif", "event", ".", "keysy...
likely to take in a set of parameters to treat as up, down, left, right, likely to actually be based on a joystick event... not sure yet
[ "likely", "to", "take", "in", "a", "set", "of", "parameters", "to", "treat", "as", "up", "down", "left", "right", "likely", "to", "actually", "be", "based", "on", "a", "joystick", "event", "...", "not", "sure", "yet" ]
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/sim/field/field.py#L93-L118
robotpy/pyfrc
lib/pyfrc/configloader.py
_load_config
def _load_config(robot_path): """ Used internally by pyfrc, don't call this directly. Loads a json file from sim/config.json and makes the information available to simulation/testing code. """ from . import config config_obj = config.config_obj s...
python
def _load_config(robot_path): """ Used internally by pyfrc, don't call this directly. Loads a json file from sim/config.json and makes the information available to simulation/testing code. """ from . import config config_obj = config.config_obj s...
[ "def", "_load_config", "(", "robot_path", ")", ":", "from", ".", "import", "config", "config_obj", "=", "config", ".", "config_obj", "sim_path", "=", "join", "(", "robot_path", ",", "\"sim\"", ")", "config_file", "=", "join", "(", "sim_path", ",", "\"config....
Used internally by pyfrc, don't call this directly. Loads a json file from sim/config.json and makes the information available to simulation/testing code.
[ "Used", "internally", "by", "pyfrc", "don", "t", "call", "this", "directly", ".", "Loads", "a", "json", "file", "from", "sim", "/", "config", ".", "json", "and", "makes", "the", "information", "available", "to", "simulation", "/", "testing", "code", "." ]
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/configloader.py#L43-L144
partofthething/ace
ace/smoother.py
perform_smooth
def perform_smooth(x_values, y_values, span=None, smoother_cls=None): """ Convenience function to run the basic smoother. Parameters ---------- x_values : iterable List of x value observations y_ values : iterable list of y value observations span : float, optional F...
python
def perform_smooth(x_values, y_values, span=None, smoother_cls=None): """ Convenience function to run the basic smoother. Parameters ---------- x_values : iterable List of x value observations y_ values : iterable list of y value observations span : float, optional F...
[ "def", "perform_smooth", "(", "x_values", ",", "y_values", ",", "span", "=", "None", ",", "smoother_cls", "=", "None", ")", ":", "if", "smoother_cls", "is", "None", ":", "smoother_cls", "=", "DEFAULT_BASIC_SMOOTHER", "smoother", "=", "smoother_cls", "(", ")", ...
Convenience function to run the basic smoother. Parameters ---------- x_values : iterable List of x value observations y_ values : iterable list of y value observations span : float, optional Fraction of data to use as the window smoother_cls : Class The class of...
[ "Convenience", "function", "to", "run", "the", "basic", "smoother", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L323-L349
partofthething/ace
ace/smoother.py
Smoother.add_data_point_xy
def add_data_point_xy(self, x, y): """Add a new data point to the data set to be smoothed.""" self.x.append(x) self.y.append(y)
python
def add_data_point_xy(self, x, y): """Add a new data point to the data set to be smoothed.""" self.x.append(x) self.y.append(y)
[ "def", "add_data_point_xy", "(", "self", ",", "x", ",", "y", ")", ":", "self", ".", "x", ".", "append", "(", "x", ")", "self", ".", "y", ".", "append", "(", "y", ")" ]
Add a new data point to the data set to be smoothed.
[ "Add", "a", "new", "data", "point", "to", "the", "data", "set", "to", "be", "smoothed", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L54-L57
partofthething/ace
ace/smoother.py
Smoother.specify_data_set
def specify_data_set(self, x_input, y_input, sort_data=False): """ Fully define data by lists of x values and y values. This will sort them by increasing x but remember how to unsort them for providing results. Parameters ---------- x_input : iterable list o...
python
def specify_data_set(self, x_input, y_input, sort_data=False): """ Fully define data by lists of x values and y values. This will sort them by increasing x but remember how to unsort them for providing results. Parameters ---------- x_input : iterable list o...
[ "def", "specify_data_set", "(", "self", ",", "x_input", ",", "y_input", ",", "sort_data", "=", "False", ")", ":", "if", "sort_data", ":", "xy", "=", "sorted", "(", "zip", "(", "x_input", ",", "y_input", ")", ")", "x", ",", "y", "=", "zip", "(", "*"...
Fully define data by lists of x values and y values. This will sort them by increasing x but remember how to unsort them for providing results. Parameters ---------- x_input : iterable list of floats that represent x y_input : iterable list of floats tha...
[ "Fully", "define", "data", "by", "lists", "of", "x", "values", "and", "y", "values", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L59-L85
partofthething/ace
ace/smoother.py
Smoother.plot
def plot(self, fname=None): """ Plot the input data and resulting smooth. Parameters ---------- fname : str, optional name of file to produce. If none, will show interactively. """ plt.figure() xy = sorted(zip(self.x, self.smooth_result)) ...
python
def plot(self, fname=None): """ Plot the input data and resulting smooth. Parameters ---------- fname : str, optional name of file to produce. If none, will show interactively. """ plt.figure() xy = sorted(zip(self.x, self.smooth_result)) ...
[ "def", "plot", "(", "self", ",", "fname", "=", "None", ")", ":", "plt", ".", "figure", "(", ")", "xy", "=", "sorted", "(", "zip", "(", "self", ".", "x", ",", "self", ".", "smooth_result", ")", ")", "x", ",", "y", "=", "zip", "(", "*", "xy", ...
Plot the input data and resulting smooth. Parameters ---------- fname : str, optional name of file to produce. If none, will show interactively.
[ "Plot", "the", "input", "data", "and", "resulting", "smooth", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L102-L120
partofthething/ace
ace/smoother.py
Smoother._store_unsorted_results
def _store_unsorted_results(self, smooth, residual): """Convert sorted smooth/residual back to as-input order.""" if self._original_index_of_xvalue: # data was sorted. Unsort it here. self.smooth_result = numpy.zeros(len(self.y)) self.cross_validated_residual = numpy....
python
def _store_unsorted_results(self, smooth, residual): """Convert sorted smooth/residual back to as-input order.""" if self._original_index_of_xvalue: # data was sorted. Unsort it here. self.smooth_result = numpy.zeros(len(self.y)) self.cross_validated_residual = numpy....
[ "def", "_store_unsorted_results", "(", "self", ",", "smooth", ",", "residual", ")", ":", "if", "self", ".", "_original_index_of_xvalue", ":", "# data was sorted. Unsort it here.", "self", ".", "smooth_result", "=", "numpy", ".", "zeros", "(", "len", "(", "self", ...
Convert sorted smooth/residual back to as-input order.
[ "Convert", "sorted", "smooth", "/", "residual", "back", "to", "as", "-", "input", "order", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L122-L138
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother.compute
def compute(self): """Perform the smoothing operations.""" self._compute_window_size() smooth = [] residual = [] x, y = self.x, self.y # step through x and y data with a window window_size wide. self._update_values_in_window() self._update_mean_in_window...
python
def compute(self): """Perform the smoothing operations.""" self._compute_window_size() smooth = [] residual = [] x, y = self.x, self.y # step through x and y data with a window window_size wide. self._update_values_in_window() self._update_mean_in_window...
[ "def", "compute", "(", "self", ")", ":", "self", ".", "_compute_window_size", "(", ")", "smooth", "=", "[", "]", "residual", "=", "[", "]", "x", ",", "y", "=", "self", ".", "x", ",", "self", ".", "y", "# step through x and y data with a window window_size ...
Perform the smoothing operations.
[ "Perform", "the", "smoothing", "operations", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L151-L172
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._compute_window_size
def _compute_window_size(self): """Determine characteristics of symmetric neighborhood with J/2 values on each side.""" self._neighbors_on_each_side = int(len(self.x) * self._span) // 2 self.window_size = self._neighbors_on_each_side * 2 + 1 if self.window_size <= 1: # cannot...
python
def _compute_window_size(self): """Determine characteristics of symmetric neighborhood with J/2 values on each side.""" self._neighbors_on_each_side = int(len(self.x) * self._span) // 2 self.window_size = self._neighbors_on_each_side * 2 + 1 if self.window_size <= 1: # cannot...
[ "def", "_compute_window_size", "(", "self", ")", ":", "self", ".", "_neighbors_on_each_side", "=", "int", "(", "len", "(", "self", ".", "x", ")", "*", "self", ".", "_span", ")", "//", "2", "self", ".", "window_size", "=", "self", ".", "_neighbors_on_each...
Determine characteristics of symmetric neighborhood with J/2 values on each side.
[ "Determine", "characteristics", "of", "symmetric", "neighborhood", "with", "J", "/", "2", "values", "on", "each", "side", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L174-L180
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._update_values_in_window
def _update_values_in_window(self): """Update which values are in the current window.""" window_bound_upper = self._window_bound_lower + self.window_size self._x_in_window = self.x[self._window_bound_lower:window_bound_upper] self._y_in_window = self.y[self._window_bound_lower:window_bou...
python
def _update_values_in_window(self): """Update which values are in the current window.""" window_bound_upper = self._window_bound_lower + self.window_size self._x_in_window = self.x[self._window_bound_lower:window_bound_upper] self._y_in_window = self.y[self._window_bound_lower:window_bou...
[ "def", "_update_values_in_window", "(", "self", ")", ":", "window_bound_upper", "=", "self", ".", "_window_bound_lower", "+", "self", ".", "window_size", "self", ".", "_x_in_window", "=", "self", ".", "x", "[", "self", ".", "_window_bound_lower", ":", "window_bo...
Update which values are in the current window.
[ "Update", "which", "values", "are", "in", "the", "current", "window", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L182-L186
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._update_mean_in_window
def _update_mean_in_window(self): """ Compute mean in window the slow way. useful for first step. Considers all values in window See Also -------- _add_observation_to_means : fast update of mean for single observation addition _remove_observation_from_means : fa...
python
def _update_mean_in_window(self): """ Compute mean in window the slow way. useful for first step. Considers all values in window See Also -------- _add_observation_to_means : fast update of mean for single observation addition _remove_observation_from_means : fa...
[ "def", "_update_mean_in_window", "(", "self", ")", ":", "self", ".", "_mean_x_in_window", "=", "numpy", ".", "mean", "(", "self", ".", "_x_in_window", ")", "self", ".", "_mean_y_in_window", "=", "numpy", ".", "mean", "(", "self", ".", "_y_in_window", ")" ]
Compute mean in window the slow way. useful for first step. Considers all values in window See Also -------- _add_observation_to_means : fast update of mean for single observation addition _remove_observation_from_means : fast update of mean for single observation removal
[ "Compute", "mean", "in", "window", "the", "slow", "way", ".", "useful", "for", "first", "step", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L188-L201
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._update_variance_in_window
def _update_variance_in_window(self): """ Compute variance and covariance in window using all values in window (slow). See Also -------- _add_observation_to_variances : fast update for single observation addition _remove_observation_from_variances : fast update for singl...
python
def _update_variance_in_window(self): """ Compute variance and covariance in window using all values in window (slow). See Also -------- _add_observation_to_variances : fast update for single observation addition _remove_observation_from_variances : fast update for singl...
[ "def", "_update_variance_in_window", "(", "self", ")", ":", "self", ".", "_covariance_in_window", "=", "sum", "(", "[", "(", "xj", "-", "self", ".", "_mean_x_in_window", ")", "*", "(", "yj", "-", "self", ".", "_mean_y_in_window", ")", "for", "xj", ",", "...
Compute variance and covariance in window using all values in window (slow). See Also -------- _add_observation_to_variances : fast update for single observation addition _remove_observation_from_variances : fast update for single observation removal
[ "Compute", "variance", "and", "covariance", "in", "window", "using", "all", "values", "in", "window", "(", "slow", ")", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L203-L217
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._advance_window
def _advance_window(self): """Update values in current window and the current window means and variances.""" x_to_remove, y_to_remove = self._x_in_window[0], self._y_in_window[0] self._window_bound_lower += 1 self._update_values_in_window() x_to_add, y_to_add = self._x_in_window...
python
def _advance_window(self): """Update values in current window and the current window means and variances.""" x_to_remove, y_to_remove = self._x_in_window[0], self._y_in_window[0] self._window_bound_lower += 1 self._update_values_in_window() x_to_add, y_to_add = self._x_in_window...
[ "def", "_advance_window", "(", "self", ")", ":", "x_to_remove", ",", "y_to_remove", "=", "self", ".", "_x_in_window", "[", "0", "]", ",", "self", ".", "_y_in_window", "[", "0", "]", "self", ".", "_window_bound_lower", "+=", "1", "self", ".", "_update_value...
Update values in current window and the current window means and variances.
[ "Update", "values", "in", "current", "window", "and", "the", "current", "window", "means", "and", "variances", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L219-L228
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._remove_observation
def _remove_observation(self, x_to_remove, y_to_remove): """Remove observation from window, updating means/variance efficiently.""" self._remove_observation_from_variances(x_to_remove, y_to_remove) self._remove_observation_from_means(x_to_remove, y_to_remove) self.window_size -= 1
python
def _remove_observation(self, x_to_remove, y_to_remove): """Remove observation from window, updating means/variance efficiently.""" self._remove_observation_from_variances(x_to_remove, y_to_remove) self._remove_observation_from_means(x_to_remove, y_to_remove) self.window_size -= 1
[ "def", "_remove_observation", "(", "self", ",", "x_to_remove", ",", "y_to_remove", ")", ":", "self", ".", "_remove_observation_from_variances", "(", "x_to_remove", ",", "y_to_remove", ")", "self", ".", "_remove_observation_from_means", "(", "x_to_remove", ",", "y_to_r...
Remove observation from window, updating means/variance efficiently.
[ "Remove", "observation", "from", "window", "updating", "means", "/", "variance", "efficiently", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L230-L234
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._add_observation
def _add_observation(self, x_to_add, y_to_add): """Add observation to window, updating means/variance efficiently.""" self._add_observation_to_means(x_to_add, y_to_add) self._add_observation_to_variances(x_to_add, y_to_add) self.window_size += 1
python
def _add_observation(self, x_to_add, y_to_add): """Add observation to window, updating means/variance efficiently.""" self._add_observation_to_means(x_to_add, y_to_add) self._add_observation_to_variances(x_to_add, y_to_add) self.window_size += 1
[ "def", "_add_observation", "(", "self", ",", "x_to_add", ",", "y_to_add", ")", ":", "self", ".", "_add_observation_to_means", "(", "x_to_add", ",", "y_to_add", ")", "self", ".", "_add_observation_to_variances", "(", "x_to_add", ",", "y_to_add", ")", "self", ".",...
Add observation to window, updating means/variance efficiently.
[ "Add", "observation", "to", "window", "updating", "means", "/", "variance", "efficiently", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L236-L240
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._add_observation_to_means
def _add_observation_to_means(self, xj, yj): """Update the means without recalculating for the addition of one observation.""" self._mean_x_in_window = ((self.window_size * self._mean_x_in_window + xj) / (self.window_size + 1.0)) self._mean_y_in_window = ((self....
python
def _add_observation_to_means(self, xj, yj): """Update the means without recalculating for the addition of one observation.""" self._mean_x_in_window = ((self.window_size * self._mean_x_in_window + xj) / (self.window_size + 1.0)) self._mean_y_in_window = ((self....
[ "def", "_add_observation_to_means", "(", "self", ",", "xj", ",", "yj", ")", ":", "self", ".", "_mean_x_in_window", "=", "(", "(", "self", ".", "window_size", "*", "self", ".", "_mean_x_in_window", "+", "xj", ")", "/", "(", "self", ".", "window_size", "+"...
Update the means without recalculating for the addition of one observation.
[ "Update", "the", "means", "without", "recalculating", "for", "the", "addition", "of", "one", "observation", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L242-L247
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._remove_observation_from_means
def _remove_observation_from_means(self, xj, yj): """Update the means without recalculating for the deletion of one observation.""" self._mean_x_in_window = ((self.window_size * self._mean_x_in_window - xj) / (self.window_size - 1.0)) self._mean_y_in_window = ((...
python
def _remove_observation_from_means(self, xj, yj): """Update the means without recalculating for the deletion of one observation.""" self._mean_x_in_window = ((self.window_size * self._mean_x_in_window - xj) / (self.window_size - 1.0)) self._mean_y_in_window = ((...
[ "def", "_remove_observation_from_means", "(", "self", ",", "xj", ",", "yj", ")", ":", "self", ".", "_mean_x_in_window", "=", "(", "(", "self", ".", "window_size", "*", "self", ".", "_mean_x_in_window", "-", "xj", ")", "/", "(", "self", ".", "window_size", ...
Update the means without recalculating for the deletion of one observation.
[ "Update", "the", "means", "without", "recalculating", "for", "the", "deletion", "of", "one", "observation", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L249-L254
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._add_observation_to_variances
def _add_observation_to_variances(self, xj, yj): """ Quickly update the variance and co-variance for the addition of one observation. See Also -------- _update_variance_in_window : compute variance considering full window """ term1 = (self.window_size + 1.0) / se...
python
def _add_observation_to_variances(self, xj, yj): """ Quickly update the variance and co-variance for the addition of one observation. See Also -------- _update_variance_in_window : compute variance considering full window """ term1 = (self.window_size + 1.0) / se...
[ "def", "_add_observation_to_variances", "(", "self", ",", "xj", ",", "yj", ")", ":", "term1", "=", "(", "self", ".", "window_size", "+", "1.0", ")", "/", "self", ".", "window_size", "*", "(", "xj", "-", "self", ".", "_mean_x_in_window", ")", "self", "....
Quickly update the variance and co-variance for the addition of one observation. See Also -------- _update_variance_in_window : compute variance considering full window
[ "Quickly", "update", "the", "variance", "and", "co", "-", "variance", "for", "the", "addition", "of", "one", "observation", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L256-L266
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._compute_smooth_during_construction
def _compute_smooth_during_construction(self, xi): """ Evaluate value of smooth at x-value xi. Parameters ---------- xi : float Value of x where smooth value is desired Returns ------- smooth_here : float Value of smooth s(xi) ...
python
def _compute_smooth_during_construction(self, xi): """ Evaluate value of smooth at x-value xi. Parameters ---------- xi : float Value of x where smooth value is desired Returns ------- smooth_here : float Value of smooth s(xi) ...
[ "def", "_compute_smooth_during_construction", "(", "self", ",", "xi", ")", ":", "if", "self", ".", "_variance_in_window", ":", "beta", "=", "self", ".", "_covariance_in_window", "/", "self", ".", "_variance_in_window", "alpha", "=", "self", ".", "_mean_y_in_window...
Evaluate value of smooth at x-value xi. Parameters ---------- xi : float Value of x where smooth value is desired Returns ------- smooth_here : float Value of smooth s(xi)
[ "Evaluate", "value", "of", "smooth", "at", "x", "-", "value", "xi", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L274-L294
partofthething/ace
ace/smoother.py
BasicFixedSpanSmoother._compute_cross_validated_residual_here
def _compute_cross_validated_residual_here(self, xi, yi, smooth_here): """ Compute cross validated residual. This is the absolute residual from Eq. 9. in [1] """ denom = (1.0 - 1.0 / self.window_size - (xi - self._mean_x_in_window) ** 2 / self._...
python
def _compute_cross_validated_residual_here(self, xi, yi, smooth_here): """ Compute cross validated residual. This is the absolute residual from Eq. 9. in [1] """ denom = (1.0 - 1.0 / self.window_size - (xi - self._mean_x_in_window) ** 2 / self._...
[ "def", "_compute_cross_validated_residual_here", "(", "self", ",", "xi", ",", "yi", ",", "smooth_here", ")", ":", "denom", "=", "(", "1.0", "-", "1.0", "/", "self", ".", "window_size", "-", "(", "xi", "-", "self", ".", "_mean_x_in_window", ")", "**", "2"...
Compute cross validated residual. This is the absolute residual from Eq. 9. in [1]
[ "Compute", "cross", "validated", "residual", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/smoother.py#L296-L308
partofthething/ace
ace/samples/breiman85.py
build_sample_ace_problem_breiman85
def build_sample_ace_problem_breiman85(N=200): """Sample problem from Breiman 1985.""" x_cubed = numpy.random.standard_normal(N) x = scipy.special.cbrt(x_cubed) noise = numpy.random.standard_normal(N) y = numpy.exp((x ** 3.0) + noise) return [x], y
python
def build_sample_ace_problem_breiman85(N=200): """Sample problem from Breiman 1985.""" x_cubed = numpy.random.standard_normal(N) x = scipy.special.cbrt(x_cubed) noise = numpy.random.standard_normal(N) y = numpy.exp((x ** 3.0) + noise) return [x], y
[ "def", "build_sample_ace_problem_breiman85", "(", "N", "=", "200", ")", ":", "x_cubed", "=", "numpy", ".", "random", ".", "standard_normal", "(", "N", ")", "x", "=", "scipy", ".", "special", ".", "cbrt", "(", "x_cubed", ")", "noise", "=", "numpy", ".", ...
Sample problem from Breiman 1985.
[ "Sample", "problem", "from", "Breiman", "1985", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/samples/breiman85.py#L9-L15
partofthething/ace
ace/samples/breiman85.py
build_sample_ace_problem_breiman2
def build_sample_ace_problem_breiman2(N=500): """Build sample problem y(x) = exp(sin(x)).""" x = numpy.linspace(0, 1, N) # x = numpy.random.uniform(0, 1, size=N) noise = numpy.random.standard_normal(N) y = numpy.exp(numpy.sin(2 * numpy.pi * x)) + 0.0 * noise return [x], y
python
def build_sample_ace_problem_breiman2(N=500): """Build sample problem y(x) = exp(sin(x)).""" x = numpy.linspace(0, 1, N) # x = numpy.random.uniform(0, 1, size=N) noise = numpy.random.standard_normal(N) y = numpy.exp(numpy.sin(2 * numpy.pi * x)) + 0.0 * noise return [x], y
[ "def", "build_sample_ace_problem_breiman2", "(", "N", "=", "500", ")", ":", "x", "=", "numpy", ".", "linspace", "(", "0", ",", "1", ",", "N", ")", "# x = numpy.random.uniform(0, 1, size=N)", "noise", "=", "numpy", ".", "random", ".", "standard_normal", "(", ...
Build sample problem y(x) = exp(sin(x)).
[ "Build", "sample", "problem", "y", "(", "x", ")", "=", "exp", "(", "sin", "(", "x", "))", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/samples/breiman85.py#L18-L24
partofthething/ace
ace/samples/breiman85.py
run_breiman85
def run_breiman85(): """Run Breiman 85 sample.""" x, y = build_sample_ace_problem_breiman85(200) ace_solver = ace.ACESolver() ace_solver.specify_data_set(x, y) ace_solver.solve() try: ace.plot_transforms(ace_solver, 'sample_ace_breiman85.png') except ImportError: pass ret...
python
def run_breiman85(): """Run Breiman 85 sample.""" x, y = build_sample_ace_problem_breiman85(200) ace_solver = ace.ACESolver() ace_solver.specify_data_set(x, y) ace_solver.solve() try: ace.plot_transforms(ace_solver, 'sample_ace_breiman85.png') except ImportError: pass ret...
[ "def", "run_breiman85", "(", ")", ":", "x", ",", "y", "=", "build_sample_ace_problem_breiman85", "(", "200", ")", "ace_solver", "=", "ace", ".", "ACESolver", "(", ")", "ace_solver", ".", "specify_data_set", "(", "x", ",", "y", ")", "ace_solver", ".", "solv...
Run Breiman 85 sample.
[ "Run", "Breiman", "85", "sample", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/samples/breiman85.py#L27-L37
partofthething/ace
ace/samples/breiman85.py
run_breiman2
def run_breiman2(): """Run Breiman's other sample problem.""" x, y = build_sample_ace_problem_breiman2(500) ace_solver = ace.ACESolver() ace_solver.specify_data_set(x, y) ace_solver.solve() try: plt = ace.plot_transforms(ace_solver, None) except ImportError: pass plt.sub...
python
def run_breiman2(): """Run Breiman's other sample problem.""" x, y = build_sample_ace_problem_breiman2(500) ace_solver = ace.ACESolver() ace_solver.specify_data_set(x, y) ace_solver.solve() try: plt = ace.plot_transforms(ace_solver, None) except ImportError: pass plt.sub...
[ "def", "run_breiman2", "(", ")", ":", "x", ",", "y", "=", "build_sample_ace_problem_breiman2", "(", "500", ")", "ace_solver", "=", "ace", ".", "ACESolver", "(", ")", "ace_solver", ".", "specify_data_set", "(", "x", ",", "y", ")", "ace_solver", ".", "solve"...
Run Breiman's other sample problem.
[ "Run", "Breiman", "s", "other", "sample", "problem", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/samples/breiman85.py#L39-L61
openstack/monasca-common
monasca_common/kafka/producer.py
KafkaProducer.publish
def publish(self, topic, messages, key=None): """Takes messages and puts them on the supplied kafka topic """ if not isinstance(messages, list): messages = [messages] first = True success = False if key is None: key = int(time.time() * 1000) ...
python
def publish(self, topic, messages, key=None): """Takes messages and puts them on the supplied kafka topic """ if not isinstance(messages, list): messages = [messages] first = True success = False if key is None: key = int(time.time() * 1000) ...
[ "def", "publish", "(", "self", ",", "topic", ",", "messages", ",", "key", "=", "None", ")", ":", "if", "not", "isinstance", "(", "messages", ",", "list", ")", ":", "messages", "=", "[", "messages", "]", "first", "=", "True", "success", "=", "False", ...
Takes messages and puts them on the supplied kafka topic
[ "Takes", "messages", "and", "puts", "them", "on", "the", "supplied", "kafka", "topic" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka/producer.py#L45-L83
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
create_gzip_message
def create_gzip_message(payloads, key=None, compresslevel=None): """ Construct a Gzipped Message containing multiple Messages The given payloads will be encoded, compressed, and sent as a single atomic message to Kafka. Arguments: payloads: list(bytes), a list of payload to send be sent to...
python
def create_gzip_message(payloads, key=None, compresslevel=None): """ Construct a Gzipped Message containing multiple Messages The given payloads will be encoded, compressed, and sent as a single atomic message to Kafka. Arguments: payloads: list(bytes), a list of payload to send be sent to...
[ "def", "create_gzip_message", "(", "payloads", ",", "key", "=", "None", ",", "compresslevel", "=", "None", ")", ":", "message_set", "=", "KafkaProtocol", ".", "_encode_message_set", "(", "[", "create_message", "(", "payload", ",", "pl_key", ")", "for", "payloa...
Construct a Gzipped Message containing multiple Messages The given payloads will be encoded, compressed, and sent as a single atomic message to Kafka. Arguments: payloads: list(bytes), a list of payload to send be sent to Kafka key: bytes, a key used for partition routing (optional)
[ "Construct", "a", "Gzipped", "Message", "containing", "multiple", "Messages" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L601-L619
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol._encode_message
def _encode_message(cls, message): """ Encode a single message. The magic number of a message is a format version number. The only supported magic number right now is zero Format ====== Message => Crc MagicByte Attributes Key Value Crc => int32 ...
python
def _encode_message(cls, message): """ Encode a single message. The magic number of a message is a format version number. The only supported magic number right now is zero Format ====== Message => Crc MagicByte Attributes Key Value Crc => int32 ...
[ "def", "_encode_message", "(", "cls", ",", "message", ")", ":", "if", "message", ".", "magic", "==", "0", ":", "msg", "=", "b''", ".", "join", "(", "[", "struct", ".", "pack", "(", "'>BB'", ",", "message", ".", "magic", ",", "message", ".", "attrib...
Encode a single message. The magic number of a message is a format version number. The only supported magic number right now is zero Format ====== Message => Crc MagicByte Attributes Key Value Crc => int32 MagicByte => int8 Attributes => int8 ...
[ "Encode", "a", "single", "message", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L97-L123
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol._decode_message_set_iter
def _decode_message_set_iter(cls, data): """ Iteratively decode a MessageSet Reads repeated elements of (offset, message), calling decode_message to decode a single message. Since compressed messages contain futher MessageSets, these two methods have been decoupled so that they ...
python
def _decode_message_set_iter(cls, data): """ Iteratively decode a MessageSet Reads repeated elements of (offset, message), calling decode_message to decode a single message. Since compressed messages contain futher MessageSets, these two methods have been decoupled so that they ...
[ "def", "_decode_message_set_iter", "(", "cls", ",", "data", ")", ":", "cur", "=", "0", "read_message", "=", "False", "while", "cur", "<", "len", "(", "data", ")", ":", "try", ":", "(", "(", "offset", ",", ")", ",", "cur", ")", "=", "relative_unpack",...
Iteratively decode a MessageSet Reads repeated elements of (offset, message), calling decode_message to decode a single message. Since compressed messages contain futher MessageSets, these two methods have been decoupled so that they may recurse easily.
[ "Iteratively", "decode", "a", "MessageSet" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L126-L158
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol._decode_message
def _decode_message(cls, data, offset): """ Decode a single Message The only caller of this method is decode_message_set_iter. They are decoupled to support nested messages (compressed MessageSets). The offset is actually read from decode_message_set_iter (it is part of ...
python
def _decode_message(cls, data, offset): """ Decode a single Message The only caller of this method is decode_message_set_iter. They are decoupled to support nested messages (compressed MessageSets). The offset is actually read from decode_message_set_iter (it is part of ...
[ "def", "_decode_message", "(", "cls", ",", "data", ",", "offset", ")", ":", "(", "(", "crc", ",", "magic", ",", "att", ")", ",", "cur", ")", "=", "relative_unpack", "(", "'>IBB'", ",", "data", ",", "0", ")", "if", "crc", "!=", "crc32", "(", "data...
Decode a single Message The only caller of this method is decode_message_set_iter. They are decoupled to support nested messages (compressed MessageSets). The offset is actually read from decode_message_set_iter (it is part of the MessageSet payload).
[ "Decode", "a", "single", "Message" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L161-L190
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol.encode_produce_request
def encode_produce_request(cls, client_id, correlation_id, payloads=None, acks=1, timeout=1000): """ Encode some ProduceRequest structs Arguments: client_id: string correlation_id: int payloads: list of ProduceRequest ...
python
def encode_produce_request(cls, client_id, correlation_id, payloads=None, acks=1, timeout=1000): """ Encode some ProduceRequest structs Arguments: client_id: string correlation_id: int payloads: list of ProduceRequest ...
[ "def", "encode_produce_request", "(", "cls", ",", "client_id", ",", "correlation_id", ",", "payloads", "=", "None", ",", "acks", "=", "1", ",", "timeout", "=", "1000", ")", ":", "payloads", "=", "[", "]", "if", "payloads", "is", "None", "else", "payloads...
Encode some ProduceRequest structs Arguments: client_id: string correlation_id: int payloads: list of ProduceRequest acks: How "acky" you want the request to be 0: immediate response 1: written to disk by the leader ...
[ "Encode", "some", "ProduceRequest", "structs" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L197-L235
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol.decode_produce_response
def decode_produce_response(cls, data): """ Decode bytes to a ProduceResponse Arguments: data: bytes to decode """ ((correlation_id, num_topics), cur) = relative_unpack('>ii', data, 0) for _ in range(num_topics): ((strlen,), cur) = relative_unpa...
python
def decode_produce_response(cls, data): """ Decode bytes to a ProduceResponse Arguments: data: bytes to decode """ ((correlation_id, num_topics), cur) = relative_unpack('>ii', data, 0) for _ in range(num_topics): ((strlen,), cur) = relative_unpa...
[ "def", "decode_produce_response", "(", "cls", ",", "data", ")", ":", "(", "(", "correlation_id", ",", "num_topics", ")", ",", "cur", ")", "=", "relative_unpack", "(", "'>ii'", ",", "data", ",", "0", ")", "for", "_", "in", "range", "(", "num_topics", ")...
Decode bytes to a ProduceResponse Arguments: data: bytes to decode
[ "Decode", "bytes", "to", "a", "ProduceResponse" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L238-L257
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol.encode_fetch_request
def encode_fetch_request(cls, client_id, correlation_id, payloads=None, max_wait_time=100, min_bytes=4096): """ Encodes some FetchRequest structs Arguments: client_id: string correlation_id: int payloads: list of FetchRequest ...
python
def encode_fetch_request(cls, client_id, correlation_id, payloads=None, max_wait_time=100, min_bytes=4096): """ Encodes some FetchRequest structs Arguments: client_id: string correlation_id: int payloads: list of FetchRequest ...
[ "def", "encode_fetch_request", "(", "cls", ",", "client_id", ",", "correlation_id", ",", "payloads", "=", "None", ",", "max_wait_time", "=", "100", ",", "min_bytes", "=", "4096", ")", ":", "payloads", "=", "[", "]", "if", "payloads", "is", "None", "else", ...
Encodes some FetchRequest structs Arguments: client_id: string correlation_id: int payloads: list of FetchRequest max_wait_time: int, how long to block waiting on min_bytes of data min_bytes: int, the minimum number of bytes to accumulate before ...
[ "Encodes", "some", "FetchRequest", "structs" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L260-L293
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol.decode_fetch_response
def decode_fetch_response(cls, data): """ Decode bytes to a FetchResponse Arguments: data: bytes to decode """ ((correlation_id, num_topics), cur) = relative_unpack('>ii', data, 0) for _ in range(num_topics): (topic, cur) = read_short_string(data...
python
def decode_fetch_response(cls, data): """ Decode bytes to a FetchResponse Arguments: data: bytes to decode """ ((correlation_id, num_topics), cur) = relative_unpack('>ii', data, 0) for _ in range(num_topics): (topic, cur) = read_short_string(data...
[ "def", "decode_fetch_response", "(", "cls", ",", "data", ")", ":", "(", "(", "correlation_id", ",", "num_topics", ")", ",", "cur", ")", "=", "relative_unpack", "(", "'>ii'", ",", "data", ",", "0", ")", "for", "_", "in", "range", "(", "num_topics", ")",...
Decode bytes to a FetchResponse Arguments: data: bytes to decode
[ "Decode", "bytes", "to", "a", "FetchResponse" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L296-L318
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol.decode_offset_response
def decode_offset_response(cls, data): """ Decode bytes to an OffsetResponse Arguments: data: bytes to decode """ ((correlation_id, num_topics), cur) = relative_unpack('>ii', data, 0) for _ in range(num_topics): (topic, cur) = read_short_string(d...
python
def decode_offset_response(cls, data): """ Decode bytes to an OffsetResponse Arguments: data: bytes to decode """ ((correlation_id, num_topics), cur) = relative_unpack('>ii', data, 0) for _ in range(num_topics): (topic, cur) = read_short_string(d...
[ "def", "decode_offset_response", "(", "cls", ",", "data", ")", ":", "(", "(", "correlation_id", ",", "num_topics", ")", ",", "cur", ")", "=", "relative_unpack", "(", "'>ii'", ",", "data", ",", "0", ")", "for", "_", "in", "range", "(", "num_topics", ")"...
Decode bytes to an OffsetResponse Arguments: data: bytes to decode
[ "Decode", "bytes", "to", "an", "OffsetResponse" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L344-L366
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol.encode_metadata_request
def encode_metadata_request(cls, client_id, correlation_id, topics=None, payloads=None): """ Encode a MetadataRequest Arguments: client_id: string correlation_id: int topics: list of strings """ if payloads is N...
python
def encode_metadata_request(cls, client_id, correlation_id, topics=None, payloads=None): """ Encode a MetadataRequest Arguments: client_id: string correlation_id: int topics: list of strings """ if payloads is N...
[ "def", "encode_metadata_request", "(", "cls", ",", "client_id", ",", "correlation_id", ",", "topics", "=", "None", ",", "payloads", "=", "None", ")", ":", "if", "payloads", "is", "None", ":", "topics", "=", "[", "]", "if", "topics", "is", "None", "else",...
Encode a MetadataRequest Arguments: client_id: string correlation_id: int topics: list of strings
[ "Encode", "a", "MetadataRequest" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L369-L394
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol.decode_metadata_response
def decode_metadata_response(cls, data): """ Decode bytes to a MetadataResponse Arguments: data: bytes to decode """ ((correlation_id, numbrokers), cur) = relative_unpack('>ii', data, 0) # Broker info brokers = [] for _ in range(numbrokers): ...
python
def decode_metadata_response(cls, data): """ Decode bytes to a MetadataResponse Arguments: data: bytes to decode """ ((correlation_id, numbrokers), cur) = relative_unpack('>ii', data, 0) # Broker info brokers = [] for _ in range(numbrokers): ...
[ "def", "decode_metadata_response", "(", "cls", ",", "data", ")", ":", "(", "(", "correlation_id", ",", "numbrokers", ")", ",", "cur", ")", "=", "relative_unpack", "(", "'>ii'", ",", "data", ",", "0", ")", "# Broker info", "brokers", "=", "[", "]", "for",...
Decode bytes to a MetadataResponse Arguments: data: bytes to decode
[ "Decode", "bytes", "to", "a", "MetadataResponse" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L397-L443
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol.encode_offset_commit_request
def encode_offset_commit_request(cls, client_id, correlation_id, group, payloads): """ Encode some OffsetCommitRequest structs Arguments: client_id: string correlation_id: int group: string, the consumer group you are comm...
python
def encode_offset_commit_request(cls, client_id, correlation_id, group, payloads): """ Encode some OffsetCommitRequest structs Arguments: client_id: string correlation_id: int group: string, the consumer group you are comm...
[ "def", "encode_offset_commit_request", "(", "cls", ",", "client_id", ",", "correlation_id", ",", "group", ",", "payloads", ")", ":", "grouped_payloads", "=", "group_by_topic_and_partition", "(", "payloads", ")", "message", "=", "[", "]", "message", ".", "append", ...
Encode some OffsetCommitRequest structs Arguments: client_id: string correlation_id: int group: string, the consumer group you are committing offsets for payloads: list of OffsetCommitRequest
[ "Encode", "some", "OffsetCommitRequest", "structs" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L478-L506
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol.decode_offset_commit_response
def decode_offset_commit_response(cls, data): """ Decode bytes to an OffsetCommitResponse Arguments: data: bytes to decode """ ((correlation_id,), cur) = relative_unpack('>i', data, 0) ((num_topics,), cur) = relative_unpack('>i', data, cur) for _ in ...
python
def decode_offset_commit_response(cls, data): """ Decode bytes to an OffsetCommitResponse Arguments: data: bytes to decode """ ((correlation_id,), cur) = relative_unpack('>i', data, 0) ((num_topics,), cur) = relative_unpack('>i', data, cur) for _ in ...
[ "def", "decode_offset_commit_response", "(", "cls", ",", "data", ")", ":", "(", "(", "correlation_id", ",", ")", ",", "cur", ")", "=", "relative_unpack", "(", "'>i'", ",", "data", ",", "0", ")", "(", "(", "num_topics", ",", ")", ",", "cur", ")", "=",...
Decode bytes to an OffsetCommitResponse Arguments: data: bytes to decode
[ "Decode", "bytes", "to", "an", "OffsetCommitResponse" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L509-L525
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol.encode_offset_fetch_request
def encode_offset_fetch_request(cls, client_id, correlation_id, group, payloads, from_kafka=False): """ Encode some OffsetFetchRequest structs. The request is encoded using version 0 if from_kafka is false, indicating a request for Zookeeper offsets. I...
python
def encode_offset_fetch_request(cls, client_id, correlation_id, group, payloads, from_kafka=False): """ Encode some OffsetFetchRequest structs. The request is encoded using version 0 if from_kafka is false, indicating a request for Zookeeper offsets. I...
[ "def", "encode_offset_fetch_request", "(", "cls", ",", "client_id", ",", "correlation_id", ",", "group", ",", "payloads", ",", "from_kafka", "=", "False", ")", ":", "grouped_payloads", "=", "group_by_topic_and_partition", "(", "payloads", ")", "message", "=", "[",...
Encode some OffsetFetchRequest structs. The request is encoded using version 0 if from_kafka is false, indicating a request for Zookeeper offsets. It is encoded using version 1 otherwise, indicating a request for Kafka offsets. Arguments: client_id: string correl...
[ "Encode", "some", "OffsetFetchRequest", "structs", ".", "The", "request", "is", "encoded", "using", "version", "0", "if", "from_kafka", "is", "false", "indicating", "a", "request", "for", "Zookeeper", "offsets", ".", "It", "is", "encoded", "using", "version", ...
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L528-L562
openstack/monasca-common
monasca_common/kafka_lib/protocol.py
KafkaProtocol.decode_offset_fetch_response
def decode_offset_fetch_response(cls, data): """ Decode bytes to an OffsetFetchResponse Arguments: data: bytes to decode """ ((correlation_id,), cur) = relative_unpack('>i', data, 0) ((num_topics,), cur) = relative_unpack('>i', data, cur) for _ in r...
python
def decode_offset_fetch_response(cls, data): """ Decode bytes to an OffsetFetchResponse Arguments: data: bytes to decode """ ((correlation_id,), cur) = relative_unpack('>i', data, 0) ((num_topics,), cur) = relative_unpack('>i', data, cur) for _ in r...
[ "def", "decode_offset_fetch_response", "(", "cls", ",", "data", ")", ":", "(", "(", "correlation_id", ",", ")", ",", "cur", ")", "=", "relative_unpack", "(", "'>i'", ",", "data", ",", "0", ")", "(", "(", "num_topics", ",", ")", ",", "cur", ")", "=", ...
Decode bytes to an OffsetFetchResponse Arguments: data: bytes to decode
[ "Decode", "bytes", "to", "an", "OffsetFetchResponse" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L565-L586
openstack/monasca-common
monasca_common/simport/simport.py
_get_module
def _get_module(target): """Import a named class, module, method or function. Accepts these formats: ".../file/path|module_name:Class.method" ".../file/path|module_name:Class" ".../file/path|module_name:function" "module_name:Class" "module_name:function" "module...
python
def _get_module(target): """Import a named class, module, method or function. Accepts these formats: ".../file/path|module_name:Class.method" ".../file/path|module_name:Class" ".../file/path|module_name:function" "module_name:Class" "module_name:function" "module...
[ "def", "_get_module", "(", "target", ")", ":", "filepath", ",", "sep", ",", "namespace", "=", "target", ".", "rpartition", "(", "'|'", ")", "if", "sep", "and", "not", "filepath", ":", "raise", "BadDirectory", "(", "\"Path to file not supplied.\"", ")", "modu...
Import a named class, module, method or function. Accepts these formats: ".../file/path|module_name:Class.method" ".../file/path|module_name:Class" ".../file/path|module_name:function" "module_name:Class" "module_name:function" "module_name:Class.function" If a ...
[ "Import", "a", "named", "class", "module", "method", "or", "function", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/simport/simport.py#L37-L85
openstack/monasca-common
monasca_common/simport/simport.py
load
def load(target, source_module=None): """Get the actual implementation of the target.""" module, klass, function = _get_module(target) if not module and source_module: module = source_module if not module: raise MissingModule( "No module name supplied or source_module provide...
python
def load(target, source_module=None): """Get the actual implementation of the target.""" module, klass, function = _get_module(target) if not module and source_module: module = source_module if not module: raise MissingModule( "No module name supplied or source_module provide...
[ "def", "load", "(", "target", ",", "source_module", "=", "None", ")", ":", "module", ",", "klass", ",", "function", "=", "_get_module", "(", "target", ")", "if", "not", "module", "and", "source_module", ":", "module", "=", "source_module", "if", "not", "...
Get the actual implementation of the target.
[ "Get", "the", "actual", "implementation", "of", "the", "target", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/simport/simport.py#L88-L103
robotpy/pyfrc
docs/conf.py
process_child
def process_child(node): """This function changes class references to not have the intermediate module name by hacking at the doctree""" # Edit descriptions to be nicer if isinstance(node, sphinx.addnodes.desc_addname): if len(node.children) == 1: child = node.children[0] ...
python
def process_child(node): """This function changes class references to not have the intermediate module name by hacking at the doctree""" # Edit descriptions to be nicer if isinstance(node, sphinx.addnodes.desc_addname): if len(node.children) == 1: child = node.children[0] ...
[ "def", "process_child", "(", "node", ")", ":", "# Edit descriptions to be nicer", "if", "isinstance", "(", "node", ",", "sphinx", ".", "addnodes", ".", "desc_addname", ")", ":", "if", "len", "(", "node", ".", "children", ")", "==", "1", ":", "child", "=", ...
This function changes class references to not have the intermediate module name by hacking at the doctree
[ "This", "function", "changes", "class", "references", "to", "not", "have", "the", "intermediate", "module", "name", "by", "hacking", "at", "the", "doctree" ]
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/docs/conf.py#L146-L172
openstack/monasca-common
monasca_common/kafka_lib/consumer/base.py
Consumer.commit
def commit(self, partitions=None): """Commit stored offsets to Kafka via OffsetCommitRequest (v0) Keyword Arguments: partitions (list): list of partitions to commit, default is to commit all of them Returns: True on success, False on failure """ # s...
python
def commit(self, partitions=None): """Commit stored offsets to Kafka via OffsetCommitRequest (v0) Keyword Arguments: partitions (list): list of partitions to commit, default is to commit all of them Returns: True on success, False on failure """ # s...
[ "def", "commit", "(", "self", ",", "partitions", "=", "None", ")", ":", "# short circuit if nothing happened. This check is kept outside", "# to prevent un-necessarily acquiring a lock for checking the state", "if", "self", ".", "count_since_commit", "==", "0", ":", "return", ...
Commit stored offsets to Kafka via OffsetCommitRequest (v0) Keyword Arguments: partitions (list): list of partitions to commit, default is to commit all of them Returns: True on success, False on failure
[ "Commit", "stored", "offsets", "to", "Kafka", "via", "OffsetCommitRequest", "(", "v0", ")" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/consumer/base.py#L137-L180
partofthething/ace
ace/model.py
read_column_data_from_txt
def read_column_data_from_txt(fname): """ Read data from a simple text file. Format should be just numbers. First column is the dependent variable. others are independent. Whitespace delimited. Returns ------- x_values : list List of x columns y_values : list list o...
python
def read_column_data_from_txt(fname): """ Read data from a simple text file. Format should be just numbers. First column is the dependent variable. others are independent. Whitespace delimited. Returns ------- x_values : list List of x columns y_values : list list o...
[ "def", "read_column_data_from_txt", "(", "fname", ")", ":", "datafile", "=", "open", "(", "fname", ")", "datarows", "=", "[", "]", "for", "line", "in", "datafile", ":", "datarows", ".", "append", "(", "[", "float", "(", "li", ")", "for", "li", "in", ...
Read data from a simple text file. Format should be just numbers. First column is the dependent variable. others are independent. Whitespace delimited. Returns ------- x_values : list List of x columns y_values : list list of y values
[ "Read", "data", "from", "a", "simple", "text", "file", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/model.py#L18-L41
partofthething/ace
ace/model.py
Model.build_model_from_txt
def build_model_from_txt(self, fname): """ Construct the model and perform regressions based on data in a txt file. Parameters ---------- fname : str The name of the file to load. """ x_values, y_values = read_column_data_from_txt(fname) self....
python
def build_model_from_txt(self, fname): """ Construct the model and perform regressions based on data in a txt file. Parameters ---------- fname : str The name of the file to load. """ x_values, y_values = read_column_data_from_txt(fname) self....
[ "def", "build_model_from_txt", "(", "self", ",", "fname", ")", ":", "x_values", ",", "y_values", "=", "read_column_data_from_txt", "(", "fname", ")", "self", ".", "build_model_from_xy", "(", "x_values", ",", "y_values", ")" ]
Construct the model and perform regressions based on data in a txt file. Parameters ---------- fname : str The name of the file to load.
[ "Construct", "the", "model", "and", "perform", "regressions", "based", "on", "data", "in", "a", "txt", "file", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/model.py#L53-L63
partofthething/ace
ace/model.py
Model.build_model_from_xy
def build_model_from_xy(self, x_values, y_values): """Construct the model and perform regressions based on x, y data.""" self.init_ace(x_values, y_values) self.run_ace() self.build_interpolators()
python
def build_model_from_xy(self, x_values, y_values): """Construct the model and perform regressions based on x, y data.""" self.init_ace(x_values, y_values) self.run_ace() self.build_interpolators()
[ "def", "build_model_from_xy", "(", "self", ",", "x_values", ",", "y_values", ")", ":", "self", ".", "init_ace", "(", "x_values", ",", "y_values", ")", "self", ".", "run_ace", "(", ")", "self", ".", "build_interpolators", "(", ")" ]
Construct the model and perform regressions based on x, y data.
[ "Construct", "the", "model", "and", "perform", "regressions", "based", "on", "x", "y", "data", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/model.py#L65-L69
partofthething/ace
ace/model.py
Model.build_interpolators
def build_interpolators(self): """Compute 1-D interpolation functions for all the transforms so they're continuous..""" self.phi_continuous = [] for xi, phii in zip(self.ace.x, self.ace.x_transforms): self.phi_continuous.append(interp1d(xi, phii)) self.inverse_theta_continuou...
python
def build_interpolators(self): """Compute 1-D interpolation functions for all the transforms so they're continuous..""" self.phi_continuous = [] for xi, phii in zip(self.ace.x, self.ace.x_transforms): self.phi_continuous.append(interp1d(xi, phii)) self.inverse_theta_continuou...
[ "def", "build_interpolators", "(", "self", ")", ":", "self", ".", "phi_continuous", "=", "[", "]", "for", "xi", ",", "phii", "in", "zip", "(", "self", ".", "ace", ".", "x", ",", "self", ".", "ace", ".", "x_transforms", ")", ":", "self", ".", "phi_c...
Compute 1-D interpolation functions for all the transforms so they're continuous..
[ "Compute", "1", "-", "D", "interpolation", "functions", "for", "all", "the", "transforms", "so", "they", "re", "continuous", ".." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/model.py#L79-L84
partofthething/ace
ace/model.py
Model.eval
def eval(self, x_values): """ Evaluate the ACE regression at any combination of independent variable values. Parameters ---------- x_values : iterable a float x-value for each independent variable, e.g. (1.5, 2.5) """ if len(x_values) != len(self.phi_...
python
def eval(self, x_values): """ Evaluate the ACE regression at any combination of independent variable values. Parameters ---------- x_values : iterable a float x-value for each independent variable, e.g. (1.5, 2.5) """ if len(x_values) != len(self.phi_...
[ "def", "eval", "(", "self", ",", "x_values", ")", ":", "if", "len", "(", "x_values", ")", "!=", "len", "(", "self", ".", "phi_continuous", ")", ":", "raise", "ValueError", "(", "'x_values must have length equal to the number of independent variables '", "'({0}) rath...
Evaluate the ACE regression at any combination of independent variable values. Parameters ---------- x_values : iterable a float x-value for each independent variable, e.g. (1.5, 2.5)
[ "Evaluate", "the", "ACE", "regression", "at", "any", "combination", "of", "independent", "variable", "values", "." ]
train
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/model.py#L86-L101
robotpy/pyfrc
lib/pyfrc/util.py
yesno
def yesno(prompt): """Returns True if user answers 'y' """ prompt += " [y/n]" a = "" while a not in ["y", "n"]: a = input(prompt).lower() return a == "y"
python
def yesno(prompt): """Returns True if user answers 'y' """ prompt += " [y/n]" a = "" while a not in ["y", "n"]: a = input(prompt).lower() return a == "y"
[ "def", "yesno", "(", "prompt", ")", ":", "prompt", "+=", "\" [y/n]\"", "a", "=", "\"\"", "while", "a", "not", "in", "[", "\"y\"", ",", "\"n\"", "]", ":", "a", "=", "input", "(", "prompt", ")", ".", "lower", "(", ")", "return", "a", "==", "\"y\"" ...
Returns True if user answers 'y'
[ "Returns", "True", "if", "user", "answers", "y" ]
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/util.py#L8-L15
openstack/monasca-common
docker/kafka_wait_for_topics.py
retry
def retry(retries=KAFKA_WAIT_RETRIES, delay=KAFKA_WAIT_INTERVAL, check_exceptions=()): """Retry decorator.""" def decorator(func): """Decorator.""" def f_retry(*args, **kwargs): """Retry running function on exception after delay.""" for i in range(1, retries + 1...
python
def retry(retries=KAFKA_WAIT_RETRIES, delay=KAFKA_WAIT_INTERVAL, check_exceptions=()): """Retry decorator.""" def decorator(func): """Decorator.""" def f_retry(*args, **kwargs): """Retry running function on exception after delay.""" for i in range(1, retries + 1...
[ "def", "retry", "(", "retries", "=", "KAFKA_WAIT_RETRIES", ",", "delay", "=", "KAFKA_WAIT_INTERVAL", ",", "check_exceptions", "=", "(", ")", ")", ":", "def", "decorator", "(", "func", ")", ":", "\"\"\"Decorator.\"\"\"", "def", "f_retry", "(", "*", "args", ",...
Retry decorator.
[ "Retry", "decorator", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/docker/kafka_wait_for_topics.py#L74-L106
openstack/monasca-common
docker/kafka_wait_for_topics.py
check_topics
def check_topics(client, req_topics): """Check for existence of provided topics in Kafka.""" client.update_cluster() logger.debug('Found topics: %r', client.topics.keys()) for req_topic in req_topics: if req_topic not in client.topics.keys(): err_topic_not_found = 'Topic not found: ...
python
def check_topics(client, req_topics): """Check for existence of provided topics in Kafka.""" client.update_cluster() logger.debug('Found topics: %r', client.topics.keys()) for req_topic in req_topics: if req_topic not in client.topics.keys(): err_topic_not_found = 'Topic not found: ...
[ "def", "check_topics", "(", "client", ",", "req_topics", ")", ":", "client", ".", "update_cluster", "(", ")", "logger", ".", "debug", "(", "'Found topics: %r'", ",", "client", ".", "topics", ".", "keys", "(", ")", ")", "for", "req_topic", "in", "req_topics...
Check for existence of provided topics in Kafka.
[ "Check", "for", "existence", "of", "provided", "topics", "in", "Kafka", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/docker/kafka_wait_for_topics.py#L110-L127
openstack/monasca-common
docker/kafka_wait_for_topics.py
main
def main(): """Start main part of the wait script.""" logger.info('Checking for available topics: %r', repr(REQUIRED_TOPICS)) client = connect_kafka(hosts=KAFKA_HOSTS) check_topics(client, REQUIRED_TOPICS)
python
def main(): """Start main part of the wait script.""" logger.info('Checking for available topics: %r', repr(REQUIRED_TOPICS)) client = connect_kafka(hosts=KAFKA_HOSTS) check_topics(client, REQUIRED_TOPICS)
[ "def", "main", "(", ")", ":", "logger", ".", "info", "(", "'Checking for available topics: %r'", ",", "repr", "(", "REQUIRED_TOPICS", ")", ")", "client", "=", "connect_kafka", "(", "hosts", "=", "KAFKA_HOSTS", ")", "check_topics", "(", "client", ",", "REQUIRED...
Start main part of the wait script.
[ "Start", "main", "part", "of", "the", "wait", "script", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/docker/kafka_wait_for_topics.py#L136-L141
openstack/monasca-common
monasca_common/kafka_lib/conn.py
collect_hosts
def collect_hosts(hosts, randomize=True): """ Collects a comma-separated set of hosts (host:port) and optionally randomize the returned list. """ if isinstance(hosts, six.string_types): hosts = hosts.strip().split(',') result = [] for host_port in hosts: res = host_port.sp...
python
def collect_hosts(hosts, randomize=True): """ Collects a comma-separated set of hosts (host:port) and optionally randomize the returned list. """ if isinstance(hosts, six.string_types): hosts = hosts.strip().split(',') result = [] for host_port in hosts: res = host_port.sp...
[ "def", "collect_hosts", "(", "hosts", ",", "randomize", "=", "True", ")", ":", "if", "isinstance", "(", "hosts", ",", "six", ".", "string_types", ")", ":", "hosts", "=", "hosts", ".", "strip", "(", ")", ".", "split", "(", "','", ")", "result", "=", ...
Collects a comma-separated set of hosts (host:port) and optionally randomize the returned list.
[ "Collects", "a", "comma", "-", "separated", "set", "of", "hosts", "(", "host", ":", "port", ")", "and", "optionally", "randomize", "the", "returned", "list", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/conn.py#L31-L51
openstack/monasca-common
monasca_common/kafka_lib/conn.py
KafkaConnection.send
def send(self, request_id, payload): """ Send a request to Kafka Arguments:: request_id (int): can be any int (used only for debug logging...) payload: an encoded kafka packet (see KafkaProtocol) """ log.debug("About to send %d bytes to Kafka, request %d...
python
def send(self, request_id, payload): """ Send a request to Kafka Arguments:: request_id (int): can be any int (used only for debug logging...) payload: an encoded kafka packet (see KafkaProtocol) """ log.debug("About to send %d bytes to Kafka, request %d...
[ "def", "send", "(", "self", ",", "request_id", ",", "payload", ")", ":", "log", ".", "debug", "(", "\"About to send %d bytes to Kafka, request %d\"", "%", "(", "len", "(", "payload", ")", ",", "request_id", ")", ")", "# Make sure we have a connection", "if", "no...
Send a request to Kafka Arguments:: request_id (int): can be any int (used only for debug logging...) payload: an encoded kafka packet (see KafkaProtocol)
[ "Send", "a", "request", "to", "Kafka" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/conn.py#L138-L157
openstack/monasca-common
monasca_common/kafka_lib/conn.py
KafkaConnection.recv
def recv(self, request_id): """ Get a response packet from Kafka Arguments: request_id: can be any int (only used for debug logging...) Returns: str: Encoded kafka packet response from server """ log.debug("Reading response %d from Kafka" % reque...
python
def recv(self, request_id): """ Get a response packet from Kafka Arguments: request_id: can be any int (only used for debug logging...) Returns: str: Encoded kafka packet response from server """ log.debug("Reading response %d from Kafka" % reque...
[ "def", "recv", "(", "self", ",", "request_id", ")", ":", "log", ".", "debug", "(", "\"Reading response %d from Kafka\"", "%", "request_id", ")", "# Make sure we have a connection", "if", "not", "self", ".", "_sock", ":", "self", ".", "reinit", "(", ")", "# Rea...
Get a response packet from Kafka Arguments: request_id: can be any int (only used for debug logging...) Returns: str: Encoded kafka packet response from server
[ "Get", "a", "response", "packet", "from", "Kafka" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/conn.py#L159-L181
openstack/monasca-common
monasca_common/kafka_lib/conn.py
KafkaConnection.copy
def copy(self): """ Create an inactive copy of the connection object, suitable for passing to a background thread. The returned copy is not connected; you must call reinit() before using. """ c = copy.deepcopy(self) # Python 3 doesn't copy custom attribut...
python
def copy(self): """ Create an inactive copy of the connection object, suitable for passing to a background thread. The returned copy is not connected; you must call reinit() before using. """ c = copy.deepcopy(self) # Python 3 doesn't copy custom attribut...
[ "def", "copy", "(", "self", ")", ":", "c", "=", "copy", ".", "deepcopy", "(", "self", ")", "# Python 3 doesn't copy custom attributes of the threadlocal subclass", "c", ".", "host", "=", "copy", ".", "copy", "(", "self", ".", "host", ")", "c", ".", "port", ...
Create an inactive copy of the connection object, suitable for passing to a background thread. The returned copy is not connected; you must call reinit() before using.
[ "Create", "an", "inactive", "copy", "of", "the", "connection", "object", "suitable", "for", "passing", "to", "a", "background", "thread", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/conn.py#L183-L197
openstack/monasca-common
monasca_common/kafka_lib/conn.py
KafkaConnection.close
def close(self): """ Shutdown and close the connection socket """ log.debug("Closing socket connection for %s:%d" % (self.host, self.port)) if self._sock: # Call shutdown to be a good TCP client # But expect an error if the socket has already been ...
python
def close(self): """ Shutdown and close the connection socket """ log.debug("Closing socket connection for %s:%d" % (self.host, self.port)) if self._sock: # Call shutdown to be a good TCP client # But expect an error if the socket has already been ...
[ "def", "close", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Closing socket connection for %s:%d\"", "%", "(", "self", ".", "host", ",", "self", ".", "port", ")", ")", "if", "self", ".", "_sock", ":", "# Call shutdown to be a good TCP client", "# But ex...
Shutdown and close the connection socket
[ "Shutdown", "and", "close", "the", "connection", "socket" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/conn.py#L199-L217
openstack/monasca-common
monasca_common/kafka_lib/conn.py
KafkaConnection.reinit
def reinit(self): """ Re-initialize the socket connection close current socket (if open) and start a fresh connection raise ConnectionError on error """ log.debug("Reinitializing socket connection for %s:%d" % (self.host, self.port)) if self._sock: ...
python
def reinit(self): """ Re-initialize the socket connection close current socket (if open) and start a fresh connection raise ConnectionError on error """ log.debug("Reinitializing socket connection for %s:%d" % (self.host, self.port)) if self._sock: ...
[ "def", "reinit", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Reinitializing socket connection for %s:%d\"", "%", "(", "self", ".", "host", ",", "self", ".", "port", ")", ")", "if", "self", ".", "_sock", ":", "self", ".", "close", "(", ")", "try...
Re-initialize the socket connection close current socket (if open) and start a fresh connection raise ConnectionError on error
[ "Re", "-", "initialize", "the", "socket", "connection", "close", "current", "socket", "(", "if", "open", ")", "and", "start", "a", "fresh", "connection", "raise", "ConnectionError", "on", "error" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/conn.py#L219-L235
openstack/monasca-common
monasca_common/kafka_lib/consumer/kafka.py
KafkaConsumer.configure
def configure(self, **configs): """Configure the consumer instance Configuration settings can be passed to constructor, otherwise defaults will be used: Keyword Arguments: bootstrap_servers (list): List of initial broker nodes the consumer should contact to ...
python
def configure(self, **configs): """Configure the consumer instance Configuration settings can be passed to constructor, otherwise defaults will be used: Keyword Arguments: bootstrap_servers (list): List of initial broker nodes the consumer should contact to ...
[ "def", "configure", "(", "self", ",", "*", "*", "configs", ")", ":", "configs", "=", "self", ".", "_deprecate_configs", "(", "*", "*", "configs", ")", "self", ".", "_config", "=", "{", "}", "for", "key", "in", "self", ".", "DEFAULT_CONFIG", ":", "sel...
Configure the consumer instance Configuration settings can be passed to constructor, otherwise defaults will be used: Keyword Arguments: bootstrap_servers (list): List of initial broker nodes the consumer should contact to bootstrap initial cluster metadata. This d...
[ "Configure", "the", "consumer", "instance" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/consumer/kafka.py#L75-L156
openstack/monasca-common
monasca_common/kafka_lib/consumer/kafka.py
KafkaConsumer.set_topic_partitions
def set_topic_partitions(self, *topics): """ Set the topic/partitions to consume Optionally specify offsets to start from Accepts types: * str (utf-8): topic name (will consume all available partitions) * tuple: (topic, partition) * dict: - { topic: ...
python
def set_topic_partitions(self, *topics): """ Set the topic/partitions to consume Optionally specify offsets to start from Accepts types: * str (utf-8): topic name (will consume all available partitions) * tuple: (topic, partition) * dict: - { topic: ...
[ "def", "set_topic_partitions", "(", "self", ",", "*", "topics", ")", ":", "self", ".", "_topics", "=", "[", "]", "self", ".", "_client", ".", "load_metadata_for_topics", "(", ")", "# Setup offsets", "self", ".", "_offsets", "=", "OffsetsStruct", "(", "fetch"...
Set the topic/partitions to consume Optionally specify offsets to start from Accepts types: * str (utf-8): topic name (will consume all available partitions) * tuple: (topic, partition) * dict: - { topic: partition } - { topic: [partition list] } ...
[ "Set", "the", "topic", "/", "partitions", "to", "consume", "Optionally", "specify", "offsets", "to", "start", "from" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/consumer/kafka.py#L158-L284
openstack/monasca-common
monasca_common/kafka_lib/consumer/kafka.py
KafkaConsumer.next
def next(self): """Return the next available message Blocks indefinitely unless consumer_timeout_ms > 0 Returns: a single KafkaMessage from the message iterator Raises: ConsumerTimeout after consumer_timeout_ms and no message Note: This is ...
python
def next(self): """Return the next available message Blocks indefinitely unless consumer_timeout_ms > 0 Returns: a single KafkaMessage from the message iterator Raises: ConsumerTimeout after consumer_timeout_ms and no message Note: This is ...
[ "def", "next", "(", "self", ")", ":", "self", ".", "_set_consumer_timeout_start", "(", ")", "while", "True", ":", "try", ":", "return", "six", ".", "next", "(", "self", ".", "_get_message_iterator", "(", ")", ")", "# Handle batch completion", "except", "Stop...
Return the next available message Blocks indefinitely unless consumer_timeout_ms > 0 Returns: a single KafkaMessage from the message iterator Raises: ConsumerTimeout after consumer_timeout_ms and no message Note: This is also the method called inte...
[ "Return", "the", "next", "available", "message" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/consumer/kafka.py#L290-L315
openstack/monasca-common
monasca_common/kafka_lib/consumer/kafka.py
KafkaConsumer.fetch_messages
def fetch_messages(self): """Sends FetchRequests for all topic/partitions set for consumption Returns: Generator that yields KafkaMessage structs after deserializing with the configured `deserializer_class` Note: Refreshes metadata on errors, and resets fetc...
python
def fetch_messages(self): """Sends FetchRequests for all topic/partitions set for consumption Returns: Generator that yields KafkaMessage structs after deserializing with the configured `deserializer_class` Note: Refreshes metadata on errors, and resets fetc...
[ "def", "fetch_messages", "(", "self", ")", ":", "max_bytes", "=", "self", ".", "_config", "[", "'fetch_message_max_bytes'", "]", "max_wait_time", "=", "self", ".", "_config", "[", "'fetch_wait_max_ms'", "]", "min_bytes", "=", "self", ".", "_config", "[", "'fet...
Sends FetchRequests for all topic/partitions set for consumption Returns: Generator that yields KafkaMessage structs after deserializing with the configured `deserializer_class` Note: Refreshes metadata on errors, and resets fetch offset on OffsetOutOfRa...
[ "Sends", "FetchRequests", "for", "all", "topic", "/", "partitions", "set", "for", "consumption" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/consumer/kafka.py#L317-L420
openstack/monasca-common
monasca_common/kafka_lib/consumer/kafka.py
KafkaConsumer.get_partition_offsets
def get_partition_offsets(self, topic, partition, request_time_ms, max_num_offsets): """Request available fetch offsets for a single topic/partition Keyword Arguments: topic (str): topic for offset request partition (int): partition for offset request request_time_ms...
python
def get_partition_offsets(self, topic, partition, request_time_ms, max_num_offsets): """Request available fetch offsets for a single topic/partition Keyword Arguments: topic (str): topic for offset request partition (int): partition for offset request request_time_ms...
[ "def", "get_partition_offsets", "(", "self", ",", "topic", ",", "partition", ",", "request_time_ms", ",", "max_num_offsets", ")", ":", "reqs", "=", "[", "OffsetRequest", "(", "topic", ",", "partition", ",", "request_time_ms", ",", "max_num_offsets", ")", "]", ...
Request available fetch offsets for a single topic/partition Keyword Arguments: topic (str): topic for offset request partition (int): partition for offset request request_time_ms (int): Used to ask for all messages before a certain time (ms). There are two s...
[ "Request", "available", "fetch", "offsets", "for", "a", "single", "topic", "/", "partition" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/consumer/kafka.py#L422-L453
openstack/monasca-common
monasca_common/kafka_lib/consumer/kafka.py
KafkaConsumer.offsets
def offsets(self, group=None): """Get internal consumer offset values Keyword Arguments: group: Either "fetch", "commit", "task_done", or "highwater". If no group specified, returns all groups. Returns: A copy of internal offsets struct """ ...
python
def offsets(self, group=None): """Get internal consumer offset values Keyword Arguments: group: Either "fetch", "commit", "task_done", or "highwater". If no group specified, returns all groups. Returns: A copy of internal offsets struct """ ...
[ "def", "offsets", "(", "self", ",", "group", "=", "None", ")", ":", "if", "not", "group", ":", "return", "{", "'fetch'", ":", "self", ".", "offsets", "(", "'fetch'", ")", ",", "'commit'", ":", "self", ".", "offsets", "(", "'commit'", ")", ",", "'ta...
Get internal consumer offset values Keyword Arguments: group: Either "fetch", "commit", "task_done", or "highwater". If no group specified, returns all groups. Returns: A copy of internal offsets struct
[ "Get", "internal", "consumer", "offset", "values" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/consumer/kafka.py#L455-L473
openstack/monasca-common
monasca_common/kafka_lib/consumer/kafka.py
KafkaConsumer.task_done
def task_done(self, message): """Mark a fetched message as consumed. Offsets for messages marked as "task_done" will be stored back to the kafka cluster for this consumer group on commit() Arguments: message (KafkaMessage): the message to mark as complete Returns: ...
python
def task_done(self, message): """Mark a fetched message as consumed. Offsets for messages marked as "task_done" will be stored back to the kafka cluster for this consumer group on commit() Arguments: message (KafkaMessage): the message to mark as complete Returns: ...
[ "def", "task_done", "(", "self", ",", "message", ")", ":", "topic_partition", "=", "(", "message", ".", "topic", ",", "message", ".", "partition", ")", "if", "topic_partition", "not", "in", "self", ".", "_topics", ":", "logger", ".", "warning", "(", "'Un...
Mark a fetched message as consumed. Offsets for messages marked as "task_done" will be stored back to the kafka cluster for this consumer group on commit() Arguments: message (KafkaMessage): the message to mark as complete Returns: True, unless the topic-partit...
[ "Mark", "a", "fetched", "message", "as", "consumed", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/consumer/kafka.py#L475-L519
openstack/monasca-common
monasca_common/kafka_lib/consumer/kafka.py
KafkaConsumer.commit
def commit(self): """Store consumed message offsets (marked via task_done()) to kafka cluster for this consumer_group. Returns: True on success, or False if no offsets were found for commit Note: this functionality requires server version >=0.8.1.1 h...
python
def commit(self): """Store consumed message offsets (marked via task_done()) to kafka cluster for this consumer_group. Returns: True on success, or False if no offsets were found for commit Note: this functionality requires server version >=0.8.1.1 h...
[ "def", "commit", "(", "self", ")", ":", "if", "not", "self", ".", "_config", "[", "'group_id'", "]", ":", "logger", ".", "warning", "(", "'Cannot commit without a group_id!'", ")", "raise", "KafkaConfigurationError", "(", "'Attempted to commit offsets '", "'without ...
Store consumed message offsets (marked via task_done()) to kafka cluster for this consumer_group. Returns: True on success, or False if no offsets were found for commit Note: this functionality requires server version >=0.8.1.1 https://cwiki.apache.org/confl...
[ "Store", "consumed", "message", "offsets", "(", "marked", "via", "task_done", "()", ")", "to", "kafka", "cluster", "for", "this", "consumer_group", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/consumer/kafka.py#L521-L586
openstack/monasca-common
monasca_common/rest/utils.py
as_json
def as_json(data, **kwargs): """Writes data as json. :param dict data: data to convert to json :param kwargs kwargs: kwargs for json dumps :return: json string :rtype: str """ if 'sort_keys' not in kwargs: kwargs['sort_keys'] = False if 'ensure_ascii' not in kwargs: kwa...
python
def as_json(data, **kwargs): """Writes data as json. :param dict data: data to convert to json :param kwargs kwargs: kwargs for json dumps :return: json string :rtype: str """ if 'sort_keys' not in kwargs: kwargs['sort_keys'] = False if 'ensure_ascii' not in kwargs: kwa...
[ "def", "as_json", "(", "data", ",", "*", "*", "kwargs", ")", ":", "if", "'sort_keys'", "not", "in", "kwargs", ":", "kwargs", "[", "'sort_keys'", "]", "=", "False", "if", "'ensure_ascii'", "not", "in", "kwargs", ":", "kwargs", "[", "'ensure_ascii'", "]", ...
Writes data as json. :param dict data: data to convert to json :param kwargs kwargs: kwargs for json dumps :return: json string :rtype: str
[ "Writes", "data", "as", "json", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/rest/utils.py#L39-L55
openstack/monasca-common
monasca_common/rest/utils.py
read_body
def read_body(payload, content_type=JSON_CONTENT_TYPE): """Reads HTTP payload according to given content_type. Function is capable of reading from payload stream. Read data is then processed according to content_type. Note: Content-Type is validated. It means that if read_body body is ...
python
def read_body(payload, content_type=JSON_CONTENT_TYPE): """Reads HTTP payload according to given content_type. Function is capable of reading from payload stream. Read data is then processed according to content_type. Note: Content-Type is validated. It means that if read_body body is ...
[ "def", "read_body", "(", "payload", ",", "content_type", "=", "JSON_CONTENT_TYPE", ")", ":", "if", "content_type", "not", "in", "_READABLE_CONTENT_TYPES", ":", "msg", "=", "(", "'Cannot read %s, not in %s'", "%", "(", "content_type", ",", "_READABLE_CONTENT_TYPES", ...
Reads HTTP payload according to given content_type. Function is capable of reading from payload stream. Read data is then processed according to content_type. Note: Content-Type is validated. It means that if read_body body is not capable of reading data in requested type, it will ...
[ "Reads", "HTTP", "payload", "according", "to", "given", "content_type", "." ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/rest/utils.py#L76-L115
robotpy/pyfrc
lib/pyfrc/sim/ui.py
SimUI.__process_idle_events
def __process_idle_events(self): """This should never be called directly, it is called via an event, and should always be on the GUI thread""" while True: try: callable, args = self.queue.get(block=False) except queue.Empty: break ...
python
def __process_idle_events(self): """This should never be called directly, it is called via an event, and should always be on the GUI thread""" while True: try: callable, args = self.queue.get(block=False) except queue.Empty: break ...
[ "def", "__process_idle_events", "(", "self", ")", ":", "while", "True", ":", "try", ":", "callable", ",", "args", "=", "self", ".", "queue", ".", "get", "(", "block", "=", "False", ")", "except", "queue", ".", "Empty", ":", "break", "callable", "(", ...
This should never be called directly, it is called via an event, and should always be on the GUI thread
[ "This", "should", "never", "be", "called", "directly", "it", "is", "called", "via", "an", "event", "and", "should", "always", "be", "on", "the", "GUI", "thread" ]
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/sim/ui.py#L568-L576
robotpy/pyfrc
lib/pyfrc/sim/ui.py
SimUI.timer_fired
def timer_fired(self): """Polling loop for events from other threads""" self.__process_idle_events() # grab the simulation lock, gather all of the # wpilib objects, and display them on the screen self.update_widgets() # call next timer_fired (or we'll never call timer_f...
python
def timer_fired(self): """Polling loop for events from other threads""" self.__process_idle_events() # grab the simulation lock, gather all of the # wpilib objects, and display them on the screen self.update_widgets() # call next timer_fired (or we'll never call timer_f...
[ "def", "timer_fired", "(", "self", ")", ":", "self", ".", "__process_idle_events", "(", ")", "# grab the simulation lock, gather all of the", "# wpilib objects, and display them on the screen", "self", ".", "update_widgets", "(", ")", "# call next timer_fired (or we'll never call...
Polling loop for events from other threads
[ "Polling", "loop", "for", "events", "from", "other", "threads" ]
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/sim/ui.py#L582-L592
openstack/monasca-common
monasca_common/kafka_lib/codec.py
snappy_encode
def snappy_encode(payload, xerial_compatible=False, xerial_blocksize=32 * 1024): """Encodes the given data with snappy if xerial_compatible is set then the stream is encoded in a fashion compatible with the xerial snappy library The block size (xerial_blocksize) controls how frequent the blocking ...
python
def snappy_encode(payload, xerial_compatible=False, xerial_blocksize=32 * 1024): """Encodes the given data with snappy if xerial_compatible is set then the stream is encoded in a fashion compatible with the xerial snappy library The block size (xerial_blocksize) controls how frequent the blocking ...
[ "def", "snappy_encode", "(", "payload", ",", "xerial_compatible", "=", "False", ",", "xerial_blocksize", "=", "32", "*", "1024", ")", ":", "if", "not", "has_snappy", "(", ")", ":", "raise", "NotImplementedError", "(", "\"Snappy codec is not available\"", ")", "i...
Encodes the given data with snappy if xerial_compatible is set then the stream is encoded in a fashion compatible with the xerial snappy library The block size (xerial_blocksize) controls how frequent the blocking occurs 32k is the default in the xerial library. The format winds up being ...
[ "Encodes", "the", "given", "data", "with", "snappy", "if", "xerial_compatible", "is", "set", "then", "the", "stream", "is", "encoded", "in", "a", "fashion", "compatible", "with", "the", "xerial", "snappy", "library" ]
train
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/codec.py#L70-L114
robotpy/pyfrc
lib/pyfrc/mains/cli_deploy.py
relpath
def relpath(path): """Path helper, gives you a path relative to this file""" return os.path.normpath( os.path.join(os.path.abspath(os.path.dirname(__file__)), path) )
python
def relpath(path): """Path helper, gives you a path relative to this file""" return os.path.normpath( os.path.join(os.path.abspath(os.path.dirname(__file__)), path) )
[ "def", "relpath", "(", "path", ")", ":", "return", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", ",", "path", ...
Path helper, gives you a path relative to this file
[ "Path", "helper", "gives", "you", "a", "path", "relative", "to", "this", "file" ]
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/mains/cli_deploy.py#L22-L26
robotpy/pyfrc
lib/pyfrc/sim/field/user_renderer.py
UserRenderer.draw_pathfinder_trajectory
def draw_pathfinder_trajectory( self, trajectory, color="#ff0000", offset=None, scale=(1, 1), show_dt=False, dt_offset=0.0, **kwargs ): """ Special helper function for drawing trajectories generated by robotpy-pathfinder...
python
def draw_pathfinder_trajectory( self, trajectory, color="#ff0000", offset=None, scale=(1, 1), show_dt=False, dt_offset=0.0, **kwargs ): """ Special helper function for drawing trajectories generated by robotpy-pathfinder...
[ "def", "draw_pathfinder_trajectory", "(", "self", ",", "trajectory", ",", "color", "=", "\"#ff0000\"", ",", "offset", "=", "None", ",", "scale", "=", "(", "1", ",", "1", ")", ",", "show_dt", "=", "False", ",", "dt_offset", "=", "0.0", ",", "*", "*", ...
Special helper function for drawing trajectories generated by robotpy-pathfinder :param trajectory: A list of pathfinder segment objects :param offset: If specified, should be x/y tuple to add to the path relative to the robot coordinates ...
[ "Special", "helper", "function", "for", "drawing", "trajectories", "generated", "by", "robotpy", "-", "pathfinder", ":", "param", "trajectory", ":", "A", "list", "of", "pathfinder", "segment", "objects", ":", "param", "offset", ":", "If", "specified", "should", ...
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/sim/field/user_renderer.py#L41-L91
robotpy/pyfrc
lib/pyfrc/sim/field/user_renderer.py
UserRenderer.draw_line
def draw_line( self, line_pts, color="#ff0000", robot_coordinates=False, relative_to_first=False, arrow=True, scale=(1, 1), **kwargs ): """ :param line_pts: A list of (x,y) pairs to draw. (x,y) are in field units ...
python
def draw_line( self, line_pts, color="#ff0000", robot_coordinates=False, relative_to_first=False, arrow=True, scale=(1, 1), **kwargs ): """ :param line_pts: A list of (x,y) pairs to draw. (x,y) are in field units ...
[ "def", "draw_line", "(", "self", ",", "line_pts", ",", "color", "=", "\"#ff0000\"", ",", "robot_coordinates", "=", "False", ",", "relative_to_first", "=", "False", ",", "arrow", "=", "True", ",", "scale", "=", "(", "1", ",", "1", ")", ",", "*", "*", ...
:param line_pts: A list of (x,y) pairs to draw. (x,y) are in field units which are measured in feet :param color: The color of the line, expressed as a 6-digit hex color :param robot_coordinates: If True, the pts will be adjusted such that ...
[ ":", "param", "line_pts", ":", "A", "list", "of", "(", "x", "y", ")", "pairs", "to", "draw", ".", "(", "x", "y", ")", "are", "in", "field", "units", "which", "are", "measured", "in", "feet", ":", "param", "color", ":", "The", "color", "of", "the"...
train
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/sim/field/user_renderer.py#L93-L144