_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q230400
CourseTaskFiles.action_download
train
def action_download(self, courseid, taskid, path): """ Download a file or a directory """ wanted_path = self.verify_path(courseid, taskid, path) if wanted_path is None: raise web.notfound() task_fs = self.task_factory.get_task_fs(courseid, taskid) (method, mimetype_...
python
{ "resource": "" }
q230401
write_json_or_yaml
train
def write_json_or_yaml(file_path, content): """ Write JSON or YAML depending on the file extension. """ with codecs.open(file_path, "w", "utf-8") as f: f.write(get_json_or_yaml(file_path, content))
python
{ "resource": "" }
q230402
get_json_or_yaml
train
def get_json_or_yaml(file_path, content): """ Generate JSON or YAML depending on the file extension. """ if os.path.splitext(file_path)[1] == ".json": return json.dumps(content, sort_keys=False, indent=4, separators=(',', ': ')) else: return inginious.common.custom_yaml.dump(content)
python
{ "resource": "" }
q230403
UserManager._set_session
train
def _set_session(self, username, realname, email, language): """ Init the session. Preserves potential LTI information. """ self._session.loggedin = True self._session.email = email self._session.username = username self._session.realname = realname self._session.language...
python
{ "resource": "" }
q230404
UserManager._destroy_session
train
def _destroy_session(self): """ Destroy the session """ self._session.loggedin = False self._session.email = None self._session.username = None self._session.realname = None self._session.token = None self._session.lti = None
python
{ "resource": "" }
q230405
UserManager.create_lti_session
train
def create_lti_session(self, user_id, roles, realname, email, course_id, task_id, consumer_key, outcome_service_url, outcome_result_id, tool_name, tool_desc, tool_url, context_title, context_label): """ Creates an LTI cookieless session. Returns the new session id""" self._de...
python
{ "resource": "" }
q230406
UserManager.user_saw_task
train
def user_saw_task(self, username, courseid, taskid): """ Set in the database that the user has viewed this task """ self._database.user_tasks.update({"username": username, "courseid": courseid, "taskid": taskid}, {"$setOnInsert": {"username": username, "courseid"...
python
{ "resource": "" }
q230407
UserManager.update_user_stats
train
def update_user_stats(self, username, task, submission, result_str, grade, state, newsub): """ Update stats with a new submission """ self.user_saw_task(username, submission["courseid"], submission["taskid"]) if newsub: old_submission = self._database.user_tasks.find_one_and_update(...
python
{ "resource": "" }
q230408
UserManager.get_course_aggregations
train
def get_course_aggregations(self, course): """ Returns a list of the course aggregations""" return natsorted(list(self._database.aggregations.find({"courseid": course.get_id()})), key=lambda x: x["description"])
python
{ "resource": "" }
q230409
WebAppTask.get_accessible_time
train
def get_accessible_time(self, plugin_override=True): """ Get the accessible time of this task """ vals = self._hook_manager.call_hook('task_accessibility', course=self.get_course(), task=self, default=self._accessible) return vals[0] if len(vals) and plugin_override else self._accessible
python
{ "resource": "" }
q230410
WebAppTask.get_deadline
train
def get_deadline(self): """ Returns a string containing the deadline for this task """ if self.get_accessible_time().is_always_accessible(): return _("No deadline") elif self.get_accessible_time().is_never_accessible(): return _("It's too late") else: ...
python
{ "resource": "" }
q230411
WebAppTask.get_authors
train
def get_authors(self, language): """ Return the list of this task's authors """ return self.gettext(language, self._author) if self._author else ""
python
{ "resource": "" }
q230412
WebAppTask.adapt_input_for_backend
train
def adapt_input_for_backend(self, input_data): """ Adapt the input from web.py for the inginious.backend """ for problem in self._problems: input_data = problem.adapt_input_for_backend(input_data) return input_data
python
{ "resource": "" }
q230413
CourseSubmissionsPage.get_users
train
def get_users(self, course): """ Returns a sorted list of users """ users = OrderedDict(sorted(list(self.user_manager.get_users_info(self.user_manager.get_course_registered_users(course)).items()), key=lambda k: k[1][0] if k[1] is not None else "")) return users
python
{ "resource": "" }
q230414
CoursePage.get_course
train
def get_course(self, courseid): """ Return the course """ try: course = self.course_factory.get_course(courseid) except: raise web.notfound() return course
python
{ "resource": "" }
q230415
CoursePage.show_page
train
def show_page(self, course): """ Prepares and shows the course page """ username = self.user_manager.session_username() if not self.user_manager.course_is_open_to_user(course, lti=False): return self.template_helper.get_renderer().course_unavailable() else: tasks ...
python
{ "resource": "" }
q230416
mavparms
train
def mavparms(logfile): '''extract mavlink parameters''' mlog = mavutil.mavlink_connection(filename) while True: try: m = mlog.recv_match(type=['PARAM_VALUE', 'PARM']) if m is None: return except Exception: return if m.get_type() ==...
python
{ "resource": "" }
q230417
MAVLink.send
train
def send(self, mavmsg, force_mavlink1=False): '''send a MAVLink message''' buf = mavmsg.pack(self, force_mavlink1=force_mavlink1) self.file.write(buf) self.seq = (self.seq + 1) % 256 self.total_packets_sent += 1 self.total_b...
python
{ "resource": "" }
q230418
MAVLink.bytes_needed
train
def bytes_needed(self): '''return number of bytes needed for next parsing stage''' if self.native: ret = self.native.expected_length - self.buf_len() else: ret = self.expected_length - self.buf_len() if ret <= 0: ...
python
{ "resource": "" }
q230419
MAVLink.__callbacks
train
def __callbacks(self, msg): '''this method exists only to make profiling results easier to read''' if self.callback: self.callback(msg, *self.callback_args, **self.callback_kwargs)
python
{ "resource": "" }
q230420
MAVLink.parse_char
train
def parse_char(self, c): '''input some data bytes, possibly returning a new message''' self.buf.extend(c) self.total_bytes_received += len(c) if self.native: if native_testing: self.test_buf.extend(c) m = self.__pa...
python
{ "resource": "" }
q230421
MAVLink.parse_buffer
train
def parse_buffer(self, s): '''input some data bytes, possibly returning a list of new messages''' m = self.parse_char(s) if m is None: return None ret = [m] while True: m = self.parse_char("") if m is None: ...
python
{ "resource": "" }
q230422
MAVLink.check_signature
train
def check_signature(self, msgbuf, srcSystem, srcComponent): '''check signature on incoming message''' if isinstance(msgbuf, array.array): msgbuf = msgbuf.tostring() timestamp_buf = msgbuf[-12:-6] link_id = msgbuf[-13] (tlow, thigh) = struct.unp...
python
{ "resource": "" }
q230423
MAVLink.flexifunction_set_send
train
def flexifunction_set_send(self, target_system, target_component, force_mavlink1=False): ''' Depreciated but used as a compiler flag. Do not remove target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ...
python
{ "resource": "" }
q230424
MAVLink.system_time_send
train
def system_time_send(self, time_unix_usec, time_boot_ms, force_mavlink1=False): ''' The system time is the time of the master clock, typically the computer clock of the main onboard computer. time_unix_usec : Timestamp of the master clock in mi...
python
{ "resource": "" }
q230425
MAVLink.set_mode_send
train
def set_mode_send(self, target_system, base_mode, custom_mode, force_mavlink1=False): ''' THIS INTERFACE IS DEPRECATED. USE COMMAND_LONG with MAV_CMD_DO_SET_MODE INSTEAD. Set the system mode, as defined by enum MAV_MODE. There is no target component ...
python
{ "resource": "" }
q230426
MAVLink.param_request_list_send
train
def param_request_list_send(self, target_system, target_component, force_mavlink1=False): ''' Request all parameters of this component. After this request, all parameters are emitted. target_system : System ID (uint8_t) target_...
python
{ "resource": "" }
q230427
MAVLink.mission_current_send
train
def mission_current_send(self, seq, force_mavlink1=False): ''' Message that announces the sequence number of the current active mission item. The MAV will fly towards this mission item. seq : Sequence (uint16_t) ...
python
{ "resource": "" }
q230428
MAVLink.mission_count_send
train
def mission_count_send(self, target_system, target_component, count, force_mavlink1=False): ''' This message is emitted as response to MISSION_REQUEST_LIST by the MAV and to initiate a write transaction. The GCS can then request the individual mission item...
python
{ "resource": "" }
q230429
MAVLink.mission_clear_all_send
train
def mission_clear_all_send(self, target_system, target_component, force_mavlink1=False): ''' Delete all mission items at once. target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' ...
python
{ "resource": "" }
q230430
MAVLink.data_stream_send
train
def data_stream_send(self, stream_id, message_rate, on_off, force_mavlink1=False): ''' THIS INTERFACE IS DEPRECATED. USE MESSAGE_INTERVAL INSTEAD. stream_id : The ID of the requested data stream (uint8_t) message_rate : The me...
python
{ "resource": "" }
q230431
MAVLink.command_ack_send
train
def command_ack_send(self, command, result, force_mavlink1=False): ''' Report status of a command. Includes feedback wether the command was executed. command : Command ID, as defined by MAV_CMD enum. (uint16_t) result ...
python
{ "resource": "" }
q230432
MAVLink.timesync_send
train
def timesync_send(self, tc1, ts1, force_mavlink1=False): ''' Time synchronization message. tc1 : Time sync timestamp 1 (int64_t) ts1 : Time sync timestamp 2 (int64_t) ''' return ...
python
{ "resource": "" }
q230433
MAVLink.camera_trigger_send
train
def camera_trigger_send(self, time_usec, seq, force_mavlink1=False): ''' Camera-IMU triggering and synchronisation message. time_usec : Timestamp for the image frame in microseconds (uint64_t) seq : Image frame sequen...
python
{ "resource": "" }
q230434
MAVLink.log_erase_send
train
def log_erase_send(self, target_system, target_component, force_mavlink1=False): ''' Erase all logs target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' return self.send(se...
python
{ "resource": "" }
q230435
MAVLink.log_request_end_send
train
def log_request_end_send(self, target_system, target_component, force_mavlink1=False): ''' Stop log transfer and resume normal logging target_system : System ID (uint8_t) target_component : Component ID (uint8_t) ''' ...
python
{ "resource": "" }
q230436
MAVLink.power_status_send
train
def power_status_send(self, Vcc, Vservo, flags, force_mavlink1=False): ''' Power supply status Vcc : 5V rail voltage in millivolts (uint16_t) Vservo : servo rail voltage in millivolts (uint16_t) fla...
python
{ "resource": "" }
q230437
MAVLink.terrain_check_send
train
def terrain_check_send(self, lat, lon, force_mavlink1=False): ''' Request that the vehicle report terrain height at the given location. Used by GCS to check if vehicle has all terrain data needed for a mission. lat : ...
python
{ "resource": "" }
q230438
MAVLink.gps_input_encode
train
def gps_input_encode(self, time_usec, gps_id, ignore_flags, time_week_ms, time_week, fix_type, lat, lon, alt, hdop, vdop, vn, ve, vd, speed_accuracy, horiz_accuracy, vert_accuracy, satellites_visible): ''' GPS sensor input message. This is a raw sensor value sent by the GPS. ...
python
{ "resource": "" }
q230439
MAVLink.message_interval_send
train
def message_interval_send(self, message_id, interval_us, force_mavlink1=False): ''' This interface replaces DATA_STREAM message_id : The ID of the requested MAVLink message. v1.0 is limited to 254 messages. (uint16_t) interval_us ...
python
{ "resource": "" }
q230440
MAVLink.extended_sys_state_send
train
def extended_sys_state_send(self, vtol_state, landed_state, force_mavlink1=False): ''' Provides state for additional features vtol_state : The VTOL state if applicable. Is set to MAV_VTOL_STATE_UNDEFINED if UAV is not in VTOL configuration. (uint8_t) ...
python
{ "resource": "" }
q230441
MAVLink.named_value_float_send
train
def named_value_float_send(self, time_boot_ms, name, value, force_mavlink1=False): ''' Send a key-value pair as float. The use of this message is discouraged for normal packets, but a quite efficient way for testing new messages and getting experimental de...
python
{ "resource": "" }
q230442
MAVLink.named_value_int_send
train
def named_value_int_send(self, time_boot_ms, name, value, force_mavlink1=False): ''' Send a key-value pair as integer. The use of this message is discouraged for normal packets, but a quite efficient way for testing new messages and getting experimental ...
python
{ "resource": "" }
q230443
MAVLink.debug_send
train
def debug_send(self, time_boot_ms, ind, value, force_mavlink1=False): ''' Send a debug value. The index is used to discriminate between values. These values show up in the plot of QGroundControl as DEBUG N. time_boot_ms : Time...
python
{ "resource": "" }
q230444
PublisherMotors.sendVX
train
def sendVX(self, vx): ''' Sends VX velocity. @param vx: VX velocity @type vx: float ''' self.lock.acquire() self.data.vx = vx self.lock.release()
python
{ "resource": "" }
q230445
PublisherMotors.sendVY
train
def sendVY(self, vy): ''' Sends VY velocity. @param vy: VY velocity @type vy: float ''' self.lock.acquire() self.data.vy = vy self.lock.release()
python
{ "resource": "" }
q230446
PublisherMotors.sendAZ
train
def sendAZ(self, az): ''' Sends AZ velocity. @param az: AZ velocity @type az: float ''' self.lock.acquire() self.data.az = az self.lock.release()
python
{ "resource": "" }
q230447
bumperEvent2BumperData
train
def bumperEvent2BumperData(event): ''' Translates from ROS BumperScan to JderobotTypes BumperData. @param event: ROS BumperScan to translate @type event: BumperScan @return a BumperData translated from event # bumper LEFT = 0 CENTER = 1 RIGHT = 2 # state RELEASED = ...
python
{ "resource": "" }
q230448
ListenerBumper.__callback
train
def __callback (self, event): ''' Callback function to receive and save Bumper Scans. @param event: ROS BumperScan received @type event: BumperScan ''' bump = bumperEvent2BumperData(event) if bump.state == 1: self.lock.acquire() ...
python
{ "resource": "" }
q230449
ListenerBumper.getBumperData
train
def getBumperData(self): ''' Returns last BumperData. @return last JdeRobotTypes BumperData saved ''' self.lock.acquire() t = current_milli_time() if (t - self.time) > 500: self.data.state = 0 bump = self.data self.lock.release() ...
python
{ "resource": "" }
q230450
BatteryModule.cmd_bat
train
def cmd_bat(self, args): '''show battery levels''' print("Flight battery: %u%%" % self.battery_level) if self.settings.numcells != 0: print("%.2f V/cell for %u cells - approx %u%%" % (self.per_cell, self.settings.numcell...
python
{ "resource": "" }
q230451
BatteryModule.battery_update
train
def battery_update(self, SYS_STATUS): '''update battery level''' # main flight battery self.battery_level = SYS_STATUS.battery_remaining self.voltage_level = SYS_STATUS.voltage_battery self.current_battery = SYS_STATUS.current_battery if self.settings.numcells != 0: ...
python
{ "resource": "" }
q230452
CalibrationModule.cmd_accelcal
train
def cmd_accelcal(self, args): '''do a full 3D accel calibration''' mav = self.master # ack the APM to begin 3D calibration of accelerometers mav.mav.command_long_send(mav.target_system, mav.target_component, mavutil.mavlink.MAV_CMD_PREFLIGHT_CALIBRATION,...
python
{ "resource": "" }
q230453
CalibrationModule.cmd_gyrocal
train
def cmd_gyrocal(self, args): '''do a full gyro calibration''' mav = self.master mav.mav.command_long_send(mav.target_system, mav.target_component, mavutil.mavlink.MAV_CMD_PREFLIGHT_CALIBRATION, 0, 1, 0, 0, 0, 0, 0, 0)
python
{ "resource": "" }
q230454
CalibrationModule.cmd_magcal
train
def cmd_magcal(self, args): '''control magnetometer calibration''' if len(args) < 1: print("Usage: magcal <start|accept|cancel>") return if args[0] == 'start': self.master.mav.command_long_send( self.settings.target_system, # target_system ...
python
{ "resource": "" }
q230455
FenceModule.set_fence_enabled
train
def set_fence_enabled(self, do_enable): '''Enable or disable fence''' self.master.mav.command_long_send( self.target_system, self.target_component, mavutil.mavlink.MAV_CMD_DO_FENCE_ENABLE, 0, do_enable, 0, 0, 0, 0, 0, 0)
python
{ "resource": "" }
q230456
FenceModule.cmd_fence_move
train
def cmd_fence_move(self, args): '''handle fencepoint move''' if len(args) < 1: print("Usage: fence move FENCEPOINTNUM") return if not self.have_list: print("Please list fence points first") return idx = int(args[0]) if idx <= 0 or ...
python
{ "resource": "" }
q230457
FenceModule.cmd_fence_remove
train
def cmd_fence_remove(self, args): '''handle fencepoint remove''' if len(args) < 1: print("Usage: fence remove FENCEPOINTNUM") return if not self.have_list: print("Please list fence points first") return idx = int(args[0]) if idx <=...
python
{ "resource": "" }
q230458
FenceModule.send_fence
train
def send_fence(self): '''send fence points from fenceloader''' # must disable geo-fencing when loading self.fenceloader.target_system = self.target_system self.fenceloader.target_component = self.target_component self.fenceloader.reindex() action = self.get_mav_param('FEN...
python
{ "resource": "" }
q230459
FenceModule.fetch_fence_point
train
def fetch_fence_point(self ,i): '''fetch one fence point''' self.master.mav.fence_fetch_point_send(self.target_system, self.target_component, i) tstart = time.time() p = None while time.time() - tstart < 3: p = self....
python
{ "resource": "" }
q230460
FenceModule.fence_draw_callback
train
def fence_draw_callback(self, points): '''callback from drawing a fence''' self.fenceloader.clear() if len(points) < 3: return self.fenceloader.target_system = self.target_system self.fenceloader.target_component = self.target_component bounds = mp_util.polygo...
python
{ "resource": "" }
q230461
ConsoleModule.add_menu
train
def add_menu(self, menu): '''add a new menu''' self.menu.add(menu) self.mpstate.console.set_menu(self.menu, self.menu_callback)
python
{ "resource": "" }
q230462
ConsoleModule.estimated_time_remaining
train
def estimated_time_remaining(self, lat, lon, wpnum, speed): '''estimate time remaining in mission in seconds''' idx = wpnum if wpnum >= self.module('wp').wploader.count(): return 0 distance = 0 done = set() while idx < self.module('wp').wploader.count(): ...
python
{ "resource": "" }
q230463
Vector3.angle
train
def angle(self, v): '''return the angle between this vector and another vector''' return acos((self * v) / (self.length() * v.length()))
python
{ "resource": "" }
q230464
Matrix3.from_euler
train
def from_euler(self, roll, pitch, yaw): '''fill the matrix from Euler angles in radians''' cp = cos(pitch) sp = sin(pitch) sr = sin(roll) cr = cos(roll) sy = sin(yaw) cy = cos(yaw) self.a.x = cp * cy self.a.y = (sr * sp * cy) - (cr * sy) s...
python
{ "resource": "" }
q230465
Matrix3.from_euler312
train
def from_euler312(self, roll, pitch, yaw): '''fill the matrix from Euler angles in radians in 312 convention''' c3 = cos(pitch) s3 = sin(pitch) s2 = sin(roll) c2 = cos(roll) s1 = sin(yaw) c1 = cos(yaw) self.a.x = c1 * c3 - s1 * s2 * s3 self.b.y = ...
python
{ "resource": "" }
q230466
Matrix3.rotate
train
def rotate(self, g): '''rotate the matrix by a given amount on 3 axes''' temp_matrix = Matrix3() a = self.a b = self.b c = self.c temp_matrix.a.x = a.y * g.z - a.z * g.y temp_matrix.a.y = a.z * g.x - a.x * g.z temp_matrix.a.z = a.x * g.y - a.y * g.x ...
python
{ "resource": "" }
q230467
Matrix3.normalize
train
def normalize(self): '''re-normalise a rotation matrix''' error = self.a * self.b t0 = self.a - (self.b * (0.5 * error)) t1 = self.b - (self.a * (0.5 * error)) t2 = t0 % t1 self.a = t0 * (1.0 / t0.length()) self.b = t1 * (1.0 / t1.length()) self.c = t2 * (...
python
{ "resource": "" }
q230468
Matrix3.trace
train
def trace(self): '''the trace of the matrix''' return self.a.x + self.b.y + self.c.z
python
{ "resource": "" }
q230469
Matrix3.from_axis_angle
train
def from_axis_angle(self, axis, angle): '''create a rotation matrix from axis and angle''' ux = axis.x uy = axis.y uz = axis.z ct = cos(angle) st = sin(angle) self.a.x = ct + (1-ct) * ux**2 self.a.y = ux*uy*(1-ct) - uz*st self.a.z = ux*uz*(1-ct) + ...
python
{ "resource": "" }
q230470
Matrix3.from_two_vectors
train
def from_two_vectors(self, vec1, vec2): '''get a rotation matrix from two vectors. This returns a rotation matrix which when applied to vec1 will produce a vector pointing in the same direction as vec2''' angle = vec1.angle(vec2) cross = vec1 % vec2 if cross.length(...
python
{ "resource": "" }
q230471
Line.plane_intersection
train
def plane_intersection(self, plane, forward_only=False): '''return point where line intersects with a plane''' l_dot_n = self.vector * plane.normal if l_dot_n == 0.0: # line is parallel to the plane return None d = ((plane.point - self.point) * plane.normal) / l_d...
python
{ "resource": "" }
q230472
RgbdCamera.getRgbd
train
def getRgbd(self): ''' Returns last Rgbd. @return last JdeRobotTypes Rgbd saved ''' img = Rgb() if self.hasproxy(): self.lock.acquire() img = self.image self.lock.release() return img
python
{ "resource": "" }
q230473
Graph.add_mavlink_packet
train
def add_mavlink_packet(self, msg): '''add data to the graph''' mtype = msg.get_type() if mtype not in self.msg_types: return for i in range(len(self.fields)): if mtype not in self.field_types[i]: continue f = self.fields[i] ...
python
{ "resource": "" }
q230474
generate
train
def generate(basename, xml): '''generate complete javascript implementation''' if basename.endswith('.js'): filename = basename else: filename = basename + '.js' msgs = [] enums = [] filelist = [] for x in xml: msgs.extend(x.message) enums.extend(x.enum) ...
python
{ "resource": "" }
q230475
flight_modes
train
def flight_modes(logfile): '''show flight modes for a log file''' print("Processing log %s" % filename) mlog = mavutil.mavlink_connection(filename) mode = "" previous_mode = "" mode_start_timestamp = -1 time_in_mode = {} previous_percent = -1 seconds_per_percent = -1 filesize =...
python
{ "resource": "" }
q230476
have_graph
train
def have_graph(name): '''return true if we have a graph of the given name''' for g in mestate.graphs: if g.name == name: return True return False
python
{ "resource": "" }
q230477
expression_ok
train
def expression_ok(expression): '''return True if an expression is OK with current messages''' expression_ok = True fields = expression.split() for f in fields: try: if f.endswith(':2'): f = f[:-2] if mavutil.evaluate_expression(f, mestate.status.msgs) is N...
python
{ "resource": "" }
q230478
load_graph_xml
train
def load_graph_xml(xml, filename, load_all=False): '''load a graph from one xml string''' ret = [] try: root = objectify.fromstring(xml) except Exception: return [] if root.tag != 'graphs': return [] if not hasattr(root, 'graph'): return [] for g in root.graph...
python
{ "resource": "" }
q230479
cmd_condition
train
def cmd_condition(args): '''control MAVExporer conditions''' if len(args) == 0: print("condition is: %s" % mestate.settings.condition) return mestate.settings.condition = ' '.join(args) if len(mestate.settings.condition) == 0 or mestate.settings.condition == 'clear': mestate.sett...
python
{ "resource": "" }
q230480
MAVLink.ualberta_sys_status_send
train
def ualberta_sys_status_send(self, mode, nav_mode, pilot, force_mavlink1=False): ''' System status specific to ualberta uav mode : System mode, see UALBERTA_AUTOPILOT_MODE ENUM (uint8_t) nav_mode : Navigation mode, se...
python
{ "resource": "" }
q230481
MAVLink.button_change_send
train
def button_change_send(self, time_boot_ms, last_change_ms, state, force_mavlink1=False): ''' Report button state change time_boot_ms : Timestamp (milliseconds since system boot) (uint32_t) last_change_ms : Time of last change of bu...
python
{ "resource": "" }
q230482
convert_from_latlon_to_utm
train
def convert_from_latlon_to_utm(points=None, latitudes=None, longitudes=None, false_easting=None, false_northing=None): """Convert latitude and longitude data to UTM as a list of coordinates. ...
python
{ "resource": "" }
q230483
QuaternionBase.dcm
train
def dcm(self): """ Get the DCM :returns: 3x3 array """ if self._dcm is None: if self._q is not None: # try to get dcm from q self._dcm = self._q_to_dcm(self.q) elif self._euler is not None: # try to get get ...
python
{ "resource": "" }
q230484
lock_time
train
def lock_time(logfile): '''work out gps lock times for a log file''' print("Processing log %s" % filename) mlog = mavutil.mavlink_connection(filename) locked = False start_time = 0.0 total_time = 0.0 t = None m = mlog.recv_match(type=['GPS_RAW_INT','GPS_RAW'], condition=args.condition) ...
python
{ "resource": "" }
q230485
MPSlipMapFrame.on_menu
train
def on_menu(self, event): '''handle menu selection''' state = self.state # see if it is a popup menu if state.popup_object is not None: obj = state.popup_object ret = obj.popup_menu.find_selected(event) if ret is not None: ret.call_hand...
python
{ "resource": "" }
q230486
MPSlipMapFrame.follow
train
def follow(self, object): '''follow an object on the map''' state = self.state (px,py) = state.panel.pixmapper(object.latlon) ratio = 0.25 if (px > ratio*state.width and px < (1.0-ratio)*state.width and py > ratio*state.height and py < (1.0-rat...
python
{ "resource": "" }
q230487
MPSlipMapFrame.add_object
train
def add_object(self, obj): '''add an object to a later''' state = self.state if not obj.layer in state.layers: # its a new layer state.layers[obj.layer] = {} state.layers[obj.layer][obj.key] = obj state.need_redraw = True
python
{ "resource": "" }
q230488
MPSlipMapFrame.remove_object
train
def remove_object(self, key): '''remove an object by key from all layers''' state = self.state for layer in state.layers: state.layers[layer].pop(key, None) state.need_redraw = True
python
{ "resource": "" }
q230489
MPSlipMapPanel.current_view
train
def current_view(self): '''return a tuple representing the current view''' state = self.state return (state.lat, state.lon, state.width, state.height, state.ground_width, state.mt.tiles_pending())
python
{ "resource": "" }
q230490
MPSlipMapPanel.coordinates
train
def coordinates(self, x, y): '''return coordinates of a pixel in the map''' state = self.state return state.mt.coord_from_area(x, y, state.lat, state.lon, state.width, state.ground_width)
python
{ "resource": "" }
q230491
MPSlipMapPanel.re_center
train
def re_center(self, x, y, lat, lon): '''re-center view for pixel x,y''' state = self.state if lat is None or lon is None: return (lat2,lon2) = self.coordinates(x, y) distance = mp_util.gps_distance(lat2, lon2, lat, lon) bearing = mp_util.gps_bearing(lat2, lon...
python
{ "resource": "" }
q230492
MPSlipMapPanel.change_zoom
train
def change_zoom(self, zoom): '''zoom in or out by zoom factor, keeping centered''' state = self.state if self.mouse_pos: (x,y) = (self.mouse_pos.x, self.mouse_pos.y) else: (x,y) = (state.width/2, state.height/2) (lat,lon) = self.coordinates(x, y) s...
python
{ "resource": "" }
q230493
MPSlipMapPanel.enter_position
train
def enter_position(self): '''enter new position''' state = self.state dlg = wx.TextEntryDialog(self, 'Enter new position', 'Position') dlg.SetValue("%f %f" % (state.lat, state.lon)) if dlg.ShowModal() == wx.ID_OK: latlon = dlg.GetValue().split() dlg.Destro...
python
{ "resource": "" }
q230494
MPSlipMapPanel.update_position
train
def update_position(self): '''update position text''' state = self.state pos = self.mouse_pos newtext = '' alt = 0 if pos is not None: (lat,lon) = self.coordinates(pos.x, pos.y) newtext += 'Cursor: %f %f (%s)' % (lat, lon, mp_util.latlon_to_grid((l...
python
{ "resource": "" }
q230495
MPSlipMapPanel.selected_objects
train
def selected_objects(self, pos): '''return a list of matching objects for a position''' state = self.state selected = [] (px, py) = pos for layer in state.layers: for key in state.layers[layer]: obj = state.layers[layer][key] distance =...
python
{ "resource": "" }
q230496
MPSlipMapPanel.show_default_popup
train
def show_default_popup(self, pos): '''show default popup menu''' state = self.state if state.default_popup.popup is not None: wx_menu = state.default_popup.popup.wx_menu() state.frame.PopupMenu(wx_menu, pos)
python
{ "resource": "" }
q230497
MPSlipMapPanel.clear_thumbnails
train
def clear_thumbnails(self): '''clear all thumbnails from the map''' state = self.state for l in state.layers: keys = state.layers[l].keys()[:] for key in keys: if (isinstance(state.layers[l][key], SlipThumbnail) and not isinstance(state...
python
{ "resource": "" }
q230498
MPSlipMapPanel.on_key_down
train
def on_key_down(self, event): '''handle keyboard input''' state = self.state # send all key events to the parent if self.mouse_pos: latlon = self.coordinates(self.mouse_pos.x, self.mouse_pos.y) selected = self.selected_objects(self.mouse_pos) state.ev...
python
{ "resource": "" }
q230499
evaluate_expression
train
def evaluate_expression(expression, vars): '''evaluation an expression''' try: v = eval(expression, globals(), vars) except NameError: return None except ZeroDivisionError: return None return v
python
{ "resource": "" }