code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
try: j = self.resolver.getMetadata(objectId=objectId).export(Mimetypes.JSON.DTS.Std) j = jsonify(j) j.status_code = 200 except NautilusError as E: return self.dts_error(error_name=E.__class__.__name__, message=E.__doc__) return j
def r_dts_collection(self, objectId=None)
DTS Collection Metadata reply for given objectId :param objectId: Collection Identifier :return: JSON Format of DTS Collection
11.979778
12.680517
0.944739
from benchbuild.utils import schema as s session = s.Session() run = s.Run( command=str(cmd), project_name=project.name, project_group=project.group, experiment_name=exp, run_group=str(grp), experiment_group=project.experiment.id) session.add(run) ...
def create_run(cmd, project, exp, grp)
Create a new 'run' in the database. This creates a new transaction in the database and creates a new run in this transaction. Afterwards we return both the transaction as well as the run itself. The user is responsible for committing it when the time comes. Args: cmd: The command that has ...
4.024012
3.524102
1.141854
from benchbuild.utils import schema as s session = s.Session() experiment = prj.experiment group = s.RunGroup(id=prj.run_uuid, experiment=experiment.id) session.add(group) session.commit() return (group, session)
def create_run_group(prj)
Create a new 'run_group' in the database. This creates a new transaction in the database and creates a new run_group within this transaction. Afterwards we return both the transaction as well as the run_group itself. The user is responsible for committing it when the time comes. Args: prj ...
5.048748
4.320441
1.168572
from benchbuild.utils.schema import Project, Session session = Session() projects = session.query(Project) \ .filter(Project.name == project.name) \ .filter(Project.group_name == project.group) name = project.name desc = project.__doc__ domain = project.domain group_nam...
def persist_project(project)
Persist this project in the benchbuild database. Args: project: The project we want to persist.
2.389607
2.37326
1.006888
from benchbuild.utils.schema import Experiment, Session session = Session() cfg_exp = experiment.id LOG.debug("Using experiment ID stored in config: %s", cfg_exp) exps = session.query(Experiment).filter(Experiment.id == cfg_exp) desc = str(CFG["experiment_description"]) name = experim...
def persist_experiment(experiment)
Persist this experiment in the benchbuild database. Args: experiment: The experiment we want to persist.
3.348803
3.192066
1.049102
from benchbuild.utils import schema as s for timing in timings: session.add( s.Metric(name="time.user_s", value=timing[0], run_id=run.id)) session.add( s.Metric(name="time.system_s", value=timing[1], run_id=run.id)) session.add( s.Metric(name="ti...
def persist_time(run, session, timings)
Persist the run results in the database. Args: run: The run we attach this timing results to. session: The db transaction we belong to. timings: The timing measurements we want to store.
2.303293
2.271953
1.013794
from benchbuild.utils import schema as s with open(svg_path, 'r') as svg_file: svg_data = svg_file.read() session.add( s.Metadata(name="perf.flamegraph", value=svg_data, run_id=run.id))
def persist_perf(run, session, svg_path)
Persist the flamegraph in the database. The flamegraph exists as a SVG image on disk until we persist it in the database. Args: run: The run we attach these perf measurements to. session: The db transaction we belong to. svg_path: The path to the SVG file we want to store.
3.90094
3.544499
1.100562
for stat in stats: stat.run_id = run.id session.add(stat)
def persist_compilestats(run, session, stats)
Persist the run results in the database. Args: run: The run we attach the compilestats to. session: The db transaction we belong to. stats: The stats we want to store in the database.
3.166096
4.28627
0.73866
from benchbuild.utils import schema as s for cfg_elem in cfg: session.add( s.Config(name=cfg_elem, value=cfg[cfg_elem], run_id=run.id))
def persist_config(run, session, cfg)
Persist the configuration in as key-value pairs. Args: run: The run we attach the config to. session: The db transaction we belong to. cfg: The configuration we want to persist.
4.605994
4.276551
1.077035
header = IORMetricsExtractor.RE_MULTIPLE_SPACES.sub(' ', header) header = header.split(' ') return header
def parse_results_header(cls, header)
Extract columns from the line under "Summary of all tests:" :param header: content of the results header line :return: list of string providing columns
16.89274
19.449224
0.868556
line = IORMetricsExtractor.RE_MULTIPLE_SPACES.sub(' ', line) line = line.split(' ') operation = line[0] assert len(line) == len(columns) for i, col in enumerate(line): col = columns[i] if col in cls.METAS_IGNORED: continue ...
def parse_result_line(cls, columns, line, metrics)
Extract metrics from a result line :param columns: list of columns specified under line "Summary of all tests:" :param line: string of results below the columns line :param metrics: output dict where metrics are written
4.868559
5.394444
0.902514
value = self.attributes['apis'] if isinstance(value, six.string_types): value = shlex.split(value) return value
def apis(self)
List of API to test
4.837997
4.775538
1.013079
path = self._fspath if path: path = path.format( benchmark=context.benchmark, api=execution['category'], **execution.get('metas', {}) ) if self.clean_path: shutil.rmtree(path, ignore_errors=True)...
def pre_execute(self, execution, context)
Make sure the named directory is created if possible
5.526766
5.26097
1.050522
if self.attributes.get('sizes'): for settings in self.attributes.get('sizes'): for pair in itertools.product( shlex.split(settings['block']), shlex.split(settings['transfer']) ): yield pair else: for...
def sizes(self)
Provides block_size and transfer_size through a list of dict, for instance: [{'transfer': '1M 4M', 'block': '8M'}]
4.93883
3.236473
1.525992
options = self.attributes['options'] if isinstance(options, six.string_types): options = shlex.split(options) options = [str(e) for e in options] return options
def options(self)
Additional options appended to the ior command type: either string or a list of string
3.784264
3.180311
1.189904
fms = self.attributes['file_mode'] eax = set() if isinstance(fms, six.string_types): fms = shlex.split(fms) for fm in fms: if fm == 'both': eax.add('fpp') eax.add('onefile') elif fm in ['fpp', 'onefile']: ...
def file_mode(self)
onefile, fpp, or both
4.286304
3.034594
1.41248
bs = self.attributes['block_size'] if isinstance(bs, six.string_types): bs = shlex.split(bs) bs = [str(e) for e in bs] return bs
def block_size(self)
Contiguous bytes to write per task (e.g.: 8, 4k, 2m, 1g)
4.100223
3.707767
1.105847
ts = self.attributes['transfer_size'] if isinstance(ts, six.string_types): ts = shlex.split(ts) ts = [str(e) for e in ts] return ts
def transfer_size(self)
Size of transfer in bytes (e.g.: 8, 4k, 2m, 1g)
4.339734
3.90005
1.112738
if self in {type(self).DEVICE_ADDED, type(self).DEVICE_REMOVED}: return True else: return False
def is_device(self)
Macro to check if this event is a :class:`~libinput.event.DeviceNotifyEvent`.
6.924546
4.417482
1.567532
if self in {type(self).POINTER_MOTION, type(self).POINTER_BUTTON, type(self).POINTER_MOTION_ABSOLUTE, type(self).POINTER_AXIS}: return True else: return False
def is_pointer(self)
Macro to check if this event is a :class:`~libinput.event.PointerEvent`.
5.293278
3.64097
1.45381
if self in {type(self).TOUCH_DOWN, type(self).TOUCH_UP, type(self).TOUCH_MOTION, type(self).TOUCH_CANCEL, type(self).TOUCH_FRAME}: return True else: return False
def is_touch(self)
Macro to check if this event is a :class:`~libinput.event.TouchEvent`.
3.564829
2.823676
1.262478
if self in {type(self).TABLET_TOOL_AXIS, type(self).TABLET_TOOL_BUTTON, type(self).TABLET_TOOL_PROXIMITY, type(self).TABLET_TOOL_TIP}: return True else: return False
def is_tablet_tool(self)
Macro to check if this event is a :class:`~libinput.event.TabletToolEvent`.
4.420645
3.725848
1.18648
if self in {type(self).TABLET_PAD_BUTTON, type(self).TABLET_PAD_RING, type(self).TABLET_PAD_STRIP}: return True else: return False
def is_tablet_pad(self)
Macro to check if this event is a :class:`~libinput.event.TabletPadEvent`.
5.123607
4.45749
1.149438
if self in {type(self).GESTURE_SWIPE_BEGIN, type(self).GESTURE_SWIPE_END, type(self).GESTURE_SWIPE_UPDATE, type(self).GESTURE_PINCH_BEGIN, type(self).GESTURE_PINCH_UPDATE, type(self).GESTURE_PINCH_END}: return True else: return False
def is_gesture(self)
Macro to check if this event is a :class:`~libinput.event.GestureEvent`.
2.500445
2.226319
1.12313
hdevice = self._libinput.libinput_event_get_device(self._hevent) return Device(hdevice, self._libinput)
def device(self)
The device associated with this event. For device added/removed events this is the device added or removed. For all other device events, this is the device that generated the event. Returns: ~libinput.define.Device: Device object.
8.12175
5.204079
1.560651
if self.type != EventType.POINTER_MOTION: raise AttributeError(_wrong_prop.format(self.type)) delta_x = self._libinput.libinput_event_pointer_get_dx(self._handle) delta_y = self._libinput.libinput_event_pointer_get_dy(self._handle) return delta_x, delta_y
def delta(self)
The delta between the last event and the current event. For pointer events that are not of type :attr:`~libinput.constant.EventType.POINTER_MOTION`, this property raises :exc:`AttributeError`. If a device employs pointer acceleration, the delta returned by this method is the accelerated delta. Relative m...
4.304927
3.093693
1.391517
if self.type != EventType.POINTER_MOTION: raise AttributeError(_wrong_prop.format(self.type)) delta_x = self._libinput.libinput_event_pointer_get_dx_unaccelerated( self._handle) delta_y = self._libinput.libinput_event_pointer_get_dy_unaccelerated( self._handle) return delta_x, delta_y
def delta_unaccelerated(self)
The relative delta of the unaccelerated motion vector of the current event. For pointer events that are not of type :attr:`~libinput.constant.EventType.POINTER_MOTION`, this property raises :exc:`AttributeError`. Relative unaccelerated motion deltas are raw device coordinates. Note that these coordinates ...
3.970896
3.024414
1.312947
if self.type != EventType.POINTER_MOTION_ABSOLUTE: raise AttributeError(_wrong_prop.format(self.type)) abs_x = self._libinput.libinput_event_pointer_get_absolute_x( self._handle) abs_y = self._libinput.libinput_event_pointer_get_absolute_y( self._handle) return abs_x, abs_y
def absolute_coords(self)
The current absolute coordinates of the pointer event, in mm from the top left corner of the device. To get the corresponding output screen coordinate, use :meth:`transform_absolute_coords`. For pointer events that are not of type :attr:`~libinput.constant.EventType.POINTER_MOTION_ABSOLUTE`, this property...
3.851545
2.66903
1.44305
if self.type != EventType.POINTER_MOTION_ABSOLUTE: raise AttributeError(_wrong_meth.format(self.type)) abs_x = self._libinput \ .libinput_event_pointer_get_absolute_x_transformed( self._handle, width) abs_y = self._libinput \ .libinput_event_pointer_get_absolute_y_transformed( self._handle, h...
def transform_absolute_coords(self, width, height)
Return the current absolute coordinates of the pointer event, transformed to screen coordinates. For pointer events that are not of type :attr:`~libinput.constant.EventType.POINTER_MOTION_ABSOLUTE`, this method raises :exc:`AttributeError`. Args: width (int): The current output screen width. height (i...
4.120171
3.029043
1.360222
if self.type != EventType.POINTER_BUTTON: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_pointer_get_button(self._handle)
def button(self)
The button that triggered this event. For pointer events that are not of type :attr:`~libinput.constant.EventType.POINTER_BUTTON`, this property raises :exc:`AttributeError`. Returns: int: The button triggering this event. Raises: AttributeError
9.432859
5.788237
1.62966
if self.type != EventType.POINTER_BUTTON: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_pointer_get_button_state( self._handle)
def button_state(self)
The button state that triggered this event. For pointer events that are not of type :attr:`~libinput.constant.EventType.POINTER_BUTTON`, this property raises :exc:`AttributeError`. Returns: ~libinput.constant.ButtonState: The button state triggering this event. Raises: AttributeError
9.083302
5.604014
1.620856
if self.type != EventType.POINTER_BUTTON: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_pointer_get_seat_button_count( self._handle)
def seat_button_count(self)
The total number of buttons pressed on all devices on the associated seat after the event was triggered. For pointer events that are not of type :attr:`~libinput.constant.EventType.POINTER_BUTTON`, this property raises :exc:`AssertionError`. Returns: int: The seat wide pressed button count for the key of...
8.571003
5.556767
1.542444
if self.type != EventType.POINTER_AXIS: raise AttributeError(_wrong_meth.format(self.type)) return self._libinput.libinput_event_pointer_has_axis( self._handle, axis)
def has_axis(self, axis)
Check if the event has a valid value for the given axis. If this method returns True for an axis and :meth:`get_axis_value` returns a value of 0, the event is a scroll stop event. For pointer events that are not of type :attr:`~libinput.constant.EventType.POINTER_AXIS`, this method raises :exc:`AttributeErr...
10.04432
5.412966
1.855604
if self.type != EventType.POINTER_AXIS: raise AttributeError(_wrong_meth.format(self.type)) return self._libinput.libinput_event_pointer_get_axis_value( self._handle, axis)
def get_axis_value(self, axis)
Return the axis value of the given axis. The interpretation of the value depends on the axis. For the two scrolling axes :attr:`~libinput.constant.PointerAxis.SCROLL_VERTICAL` and :attr:`~libinput.constant.PointerAxis.SCROLL_HORIZONTAL`, the value of the event is in relative scroll units, with the positive dir...
8.852687
6.210456
1.425449
if self.type != EventType.POINTER_AXIS: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_pointer_get_axis_source( self._handle)
def axis_source(self)
The source for a given axis event. Axis events (scroll events) can be caused by a hardware item such as a scroll wheel or emulated from other input sources, such as two-finger or edge scrolling on a touchpad. If the source is :attr:`~libinput.constant.PointerAxisSource.FINGER`, libinput guarantees that a sc...
9.835416
5.891725
1.669361
if self.type != EventType.POINTER_AXIS: raise AttributeError(_wrong_meth.format(self.type)) return self._libinput.libinput_event_pointer_get_axis_value_discrete( self._handle, axis)
def get_axis_value_discrete(self, axis)
Return the axis value in discrete steps for a given axis event. How a value translates into a discrete step depends on the source. If the source is :attr:`~libinput.constant.PointerAxisSource.WHEEL`, the discrete value correspond to the number of physical mouse wheel clicks. If the source is :attr:`~libinpu...
8.46562
6.012147
1.408086
if self.type == EventType.TOUCH_FRAME: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_touch_get_slot(self._handle)
def slot(self)
The slot of this touch event. See the kernel's multitouch protocol B documentation for more information. If the touch event has no assigned slot, for example if it is from a single touch device, this property returns -1. For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`, :attr:`~libi...
10.72692
6.900661
1.554477
if self.type == EventType.TOUCH_FRAME: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_touch_get_seat_slot(self._handle)
def seat_slot(self)
The seat slot of the touch event. A seat slot is a non-negative seat wide unique identifier of an active touch point. Events from single touch devices will be represented as one individual touch point per device. For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`, :attr:`~libinput.con...
10.043025
7.103726
1.413769
if self.type not in {EventType.TOUCH_DOWN, EventType.TOUCH_MOTION}: raise AttributeError(_wrong_prop.format(self.type)) x = self._libinput.libinput_event_touch_get_x(self._handle) y = self._libinput.libinput_event_touch_get_y(self._handle) return x, y
def coords(self)
The current absolute coordinates of the touch event, in mm from the top left corner of the device. To get the corresponding output screen coordinates, use :meth:`transform_coords`. For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`, :attr:`~libinput.constant.EventType.TOUCH_MOTION`, this...
4.134281
2.90705
1.422157
if self.type not in {EventType.TOUCH_DOWN, EventType.TOUCH_MOTION}: raise AttributeError(_wrong_meth.format(self.type)) x = self._libinput.libinput_event_touch_get_x_transformed( self._handle, width) y = self._libinput.libinput_event_touch_get_y_transformed( self._handle, height) return x, y
def transform_coords(self, width, height)
Return the current absolute coordinates of the touch event, transformed to screen coordinates. For events not of type :attr:`~libinput.constant.EventType.TOUCH_DOWN`, :attr:`~libinput.constant.EventType.TOUCH_MOTION`, this method raises :exc:`AttributeError`. Args: width (int): The current output screen ...
4.28749
3.075406
1.394122
if self.type not in {EventType.GESTURE_SWIPE_END, EventType.GESTURE_PINCH_END}: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_gesture_get_cancelled(self._handle)
def cancelled(self)
Return if the gesture ended normally, or if it was cancelled. For gesture events that are not of type :attr:`~libinput.constant.EventType.GESTURE_SWIPE_END` or :attr:`~libinput.constant.EventType.GESTURE_PINCH_END`, this property raises :exc:`AttributeError`. Returns: bool: :obj:`True` indicating that th...
6.966886
3.858423
1.80563
if self.type not in {EventType.GESTURE_SWIPE_UPDATE, EventType.GESTURE_PINCH_UPDATE}: raise AttributeError(_wrong_prop.format(self.type)) delta_x = self._libinput.libinput_event_gesture_get_dx(self._handle) delta_y = self._libinput.libinput_event_gesture_get_dy(self._handle) return delta_x, delta_y
def delta(self)
The delta between the last event and the current event. For gesture events that are not of type :attr:`~libinput.constant.EventType.GESTURE_SWIPE_UPDATE` or :attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this property raises :exc:`AttributeError`. If a device employs pointer acceleration, the de...
4.15119
2.593981
1.600317
if self.type not in {EventType.GESTURE_SWIPE_UPDATE, EventType.GESTURE_PINCH_UPDATE}: raise AttributeError(_wrong_prop.format(self.type)) delta_x = self._libinput.libinput_event_gesture_get_dx_unaccelerated( self._handle) delta_y = self._libinput.libinput_event_gesture_get_dy_unaccelerated( self....
def delta_unaccelerated(self)
The relative delta of the unaccelerated motion vector of the current event. For gesture events that are not of type :attr:`~libinput.constant.EventType.GESTURE_SWIPE_UPDATE` or :attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this property raises :exc:`AttributeError`. Relative unaccelerated mot...
3.746998
2.552698
1.467858
if self.type not in {EventType.GESTURE_PINCH_BEGIN, EventType.GESTURE_PINCH_UPDATE, EventType.GESTURE_PINCH_END}: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_gesture_get_scale(self._handle)
def scale(self)
The absolute scale of a pinch gesture, the scale is the division of the current distance between the fingers and the distance at the start of the gesture. The scale begins at 1.0, and if e.g. the fingers moved together by 50% then the scale will become 0.5, if they move twice as far apart as initially the sc...
5.424027
3.251548
1.668137
if self.type != EventType.GESTURE_PINCH_UPDATE: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_gesture_get_angle_delta( self._handle)
def angle_delta(self)
The angle delta in degrees between the last and the current :attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE` event. For gesture events that are not of type :attr:`~libinput.constant.EventType.GESTURE_PINCH_UPDATE`, this property raises :exc:`AttributeError`. The angle delta is defined as the change...
9.242323
4.690212
1.970556
x_changed = self._libinput.libinput_event_tablet_tool_x_has_changed( self._handle) y_changed = self._libinput.libinput_event_tablet_tool_y_has_changed( self._handle) x = self._libinput.libinput_event_tablet_tool_get_x(self._handle) y = self._libinput.libinput_event_tablet_tool_get_y(self._handle) re...
def coords(self)
The (X, Y) coordinates of the tablet tool, in mm from the top left corner of the tablet in its current logical orientation and whether they have changed in this event. Use :meth:`transform_coords` for transforming the axes values into a different coordinate space. Note: On some devices, returned value ma...
2.525979
1.882143
1.342076
delta_x = self._libinput.libinput_event_tablet_tool_get_dx(self._handle) delta_y = self._libinput.libinput_event_tablet_tool_get_dy(self._handle) return delta_x, delta_y
def delta(self)
The delta between the last event and the current event. If the tool employs pointer acceleration, the delta contained in this property is the accelerated delta. This value is in screen coordinate space, the delta is to be interpreted like the value of :attr:`.PointerEvent.delta`. See `Relative motion for ta...
4.143579
3.267403
1.268156
pressure = self._libinput.libinput_event_tablet_tool_get_pressure( self._handle) changed = self._libinput. \ libinput_event_tablet_tool_pressure_has_changed(self._handle) return pressure, changed
def pressure(self)
The current pressure being applied on the tool in use, normalized to the range [0, 1] and whether it has changed in this event. If this axis does not exist on the current tool, this property is (0, :obj:`False`). Returns: (float, bool): The current value of the the axis and whether it has changed.
6.376613
5.476043
1.164456
distance = self._libinput.libinput_event_tablet_tool_get_distance( self._handle) changed = self._libinput. \ libinput_event_tablet_tool_distance_has_changed(self._handle) return distance, changed
def distance(self)
The current distance from the tablet's sensor, normalized to the range [0, 1] and whether it has changed in this event. If this axis does not exist on the current tool, this property is (0, :obj:`False`). Returns: (float, bool): The current value of the the axis.
6.109129
4.598778
1.328424
tilt_x = self._libinput.libinput_event_tablet_tool_get_tilt_x( self._handle) tilt_y = self._libinput.libinput_event_tablet_tool_get_tilt_y( self._handle) x_changed = self._libinput. \ libinput_event_tablet_tool_tilt_x_has_changed(self._handle) y_changed = self._libinput. \ libinput_event_tablet_...
def tilt_axes(self)
The current tilt along the (X, Y) axes of the tablet's current logical orientation, in degrees off the tablet's Z axis and whether they have changed in this event. That is, if the tool is perfectly orthogonal to the tablet, the tilt angle is 0. When the top tilts towards the logical top/left of the tablet, t...
2.358712
1.921915
1.227272
rotation = self._libinput.libinput_event_tablet_tool_get_rotation( self._handle) changed = self._libinput. \ libinput_event_tablet_tool_rotation_has_changed(self._handle) return rotation, changed
def rotation(self)
The current Z rotation of the tool in degrees, clockwise from the tool's logical neutral position and whether it has changed in this event. For tools of type :attr:`~libinput.constant.TabletToolType.MOUSE` and :attr:`~libinput.constant.TabletToolType.LENS` the logical neutral position is pointing to the curr...
6.023962
4.184802
1.439485
position = self._libinput. \ libinput_event_tablet_tool_get_slider_position(self._handle) changed = self._libinput.libinput_event_tablet_tool_slider_has_changed( self._handle) return position, changed
def slider_position(self)
The current position of the slider on the tool, normalized to the range [-1, 1] and whether it has changed in this event. The logical zero is the neutral position of the slider, or the logical center of the axis. This axis is available on e.g. the Wacom Airbrush. If this axis does not exist on the current...
5.48321
5.050164
1.085749
delta = self._libinput.libinput_event_tablet_tool_get_wheel_delta( self._handle) changed = self._libinput.libinput_event_tablet_tool_wheel_has_changed( self._handle) return delta, changed
def wheel_delta(self)
The delta for the wheel in degrees and whether it has changed in this event. Returns: (float, bool): The delta of the wheel, in degrees, compared to the last event and whether it has changed.
4.876201
4.066526
1.199107
delta = self._libinput. \ libinput_event_tablet_tool_get_wheel_delta_discrete(self._handle) changed = self._libinput.libinput_event_tablet_tool_wheel_has_changed( self._handle) return delta, changed
def wheel_delta_discrete(self)
The delta for the wheel in discrete steps (e.g. wheel clicks) and whether it has changed in this event. Returns: (int, bool): The delta of the wheel, in discrete steps, compared to the last event and whether it has changed.
6.124044
5.538343
1.105754
x = self._libinput.libinput_event_tablet_tool_get_x_transformed( self._handle, width) y = self._libinput.libinput_event_tablet_tool_get_y_transformed( self._handle, height) x_changed = self._libinput.libinput_event_tablet_tool_x_has_changed( self._handle) y_changed = self._libinput.libinput_event_t...
def transform_coords(self, width, height)
Return the current absolute (x, y) coordinates of the tablet tool event, transformed to screen coordinates and whether they have changed in this event. Note: On some devices, returned value may be negative or larger than the width of the device. See `Out-of-bounds motion events`_ for more details. Arg...
2.402472
1.921516
1.2503
htablettool = self._libinput.libinput_event_tablet_tool_get_tool( self._handle) return TabletTool(htablettool, self._libinput)
def tool(self)
The tool that was in use during this event. If the caller keeps a reference to a tool, the tool object will compare equal to the previously obtained tool object. Note: Physical tool tracking requires hardware support. If unavailable, libinput creates one tool per type per tablet. See `Tracking unique t...
10.838032
6.785959
1.597126
if self.type != EventType.TABLET_TOOL_BUTTON: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_tool_get_button( self._handle)
def button(self)
The button that triggered this event. For events that are not of type :attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property raises :exc:`AttributeError`. Returns: int: The button triggering this event.
9.651066
4.838148
1.994785
if self.type != EventType.TABLET_TOOL_BUTTON: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_tool_get_button_state( self._handle)
def button_state(self)
The button state of the event. For events that are not of type :attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property raises :exc:`AttributeError`. Returns: ~libinput.constant.ButtonState: The button state triggering this event.
9.135274
4.565931
2.000747
if self.type != EventType.TABLET_TOOL_BUTTON: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_tool_get_seat_button_count( self._handle)
def seat_button_count(self)
The total number of buttons pressed on all devices on the associated seat after the the event was triggered. For events that are not of type :attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property raises :exc:`AttributeError`. Returns: int: The seat wide pressed button count for the key of...
8.734871
4.326487
2.018929
if self.type != EventType.TABLET_PAD_RING: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_ring_position( self._handle)
def ring_position(self)
The current position of the ring, in degrees counterclockwise from the northern-most point of the ring in the tablet's current logical orientation. If the source is :attr:`~libinput.constant.TabletPadRingAxisSource.FINGER`, libinput sends a terminating event with a ring value of -1 when the finger is lifte...
9.21743
4.66265
1.976865
if self.type != EventType.TABLET_PAD_RING: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_ring_number( self._handle)
def ring_number(self)
The number of the ring that has changed state, with 0 being the first ring. On tablets with only one ring, this method always returns 0. For events not of type :attr:`~libinput.constant.EventType.TABLET_PAD_RING`, this property raises :exc:`AssertionError`. Returns: int: The index of the ring that cha...
9.544039
5.096854
1.872535
if self.type != EventType.TABLET_PAD_RING: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_ring_source( self._handle)
def ring_source(self)
The source of the interaction with the ring. If the source is :attr:`~libinput.constant.TabletPadRingAxisSource.FINGER`, libinput sends a ring position value of -1 to terminate the current interaction. For events not of type :attr:`~libinput.constant.EventType.TABLET_PAD_RING`, this property raises :exc...
9.85093
4.505239
2.18655
if self.type != EventType.TABLET_PAD_STRIP: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_strip_position( self._handle)
def strip_position(self)
The current position of the strip, normalized to the range [0, 1], with 0 being the top/left-most point in the tablet's current logical orientation. If the source is :attr:`~libinput.constant.TabletPadStripAxisSource.FINGER`, libinput sends a terminating event with a value of -1 when the finger is lifted f...
9.722452
4.644281
2.093424
if self.type != EventType.TABLET_PAD_STRIP: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_strip_number( self._handle)
def strip_number(self)
The number of the strip that has changed state, with 0 being the first strip. On tablets with only one strip, this method always returns 0. For events not of type :attr:`~libinput.constant.EventType.TABLET_PAD_STRIP`, this property raises :exc:`AttributeError`. Returns: int: The index of the strip tha...
10.188625
4.707727
2.164234
if self.type != EventType.TABLET_PAD_STRIP: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_strip_source( self._handle)
def strip_source(self)
The source of the interaction with the strip. If the source is :attr:`~libinput.constant.TabletPadStripAxisSource.FINGER`, libinput sends a strip position value of -1 to terminate the current interaction. For events not of type :attr:`~libinput.constant.EventType.TABLET_PAD_STRIP`, this property raises :e...
10.728204
4.657517
2.303417
if self.type != EventType.TABLET_PAD_BUTTON: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_button_number( self._handle)
def button_number(self)
The button number that triggered this event, starting at 0. For events that are not of type :attr:`~libinput.constant.Event.TABLET_PAD_BUTTON`, this property raises :exc:`AttributeError`. Note that the number returned is a generic sequential button number and not a semantic button code as defined in ``linux...
8.658204
5.068621
1.708197
if self.type != EventType.TABLET_PAD_BUTTON: raise AttributeError(_wrong_prop.format(self.type)) return self._libinput.libinput_event_tablet_pad_get_button_state( self._handle)
def button_state(self)
The button state of the event. For events not of type :attr:`~libinput.constant.EventType.TABLET_PAD_BUTTON`, this property raises :exc:`AttributeError`. Returns: ~libinput.constant.ButtonState: The button state triggering this event. Raises: AttributeError
8.772446
4.6748
1.876539
hmodegroup = self._libinput.libinput_event_tablet_pad_get_mode_group( self._handle) return TabletPadModeGroup(hmodegroup, self._libinput)
def mode_group(self)
The mode group that the button, ring, or strip that triggered this event is considered in. The mode is a virtual grouping of functionality, usually based on some visual feedback like LEDs on the pad. See `Tablet pad modes`_ for details. Returns: ~libinput.define.TabletPadModeGroup: The mode group of the ...
8.472257
4.452009
1.903019
from argparse import ArgumentParser if args is None: args = sys.argv parser = ArgumentParser(description=''' Attempt to automatically find "adjacent" shapes in a SVG layer, and on a second SVG layer, draw each detected connection between the center points of the corresponding shapes.'''.strip...
def parse_args(args=None)
Parses arguments, returns (options, args).
4.389669
4.389831
0.999963
description = [] with open("README.rst") as file: for line in file: if ".. code:: python" in line and len(description) >= 2: blockLine = description[-2] if re.search(r":$", blockLine) and not re.search(r"::$", blockLine): description[...
def get_long_description()
Returns the Package long description. :return: Package long description. :rtype: unicode
4.467248
4.361409
1.024267
for current_path, dirs, files in ftp_walk(ftpconn, root): yield from (os.path.join(current_path, file) for file in files)
def ftp_listing_paths(ftpconn: FTP, root: str) -> Iterable[str]
Generate the full file paths from a root path.
2.83741
2.524311
1.124034
current_directory = rootpath try: directories, files = directory_listing(ftpconn, current_directory) except ftplib.error_perm: return # Yield before recursion yield current_directory, directories, files # Recurse into sub-directories for name in directories: ...
def ftp_walk(ftpconn: FTP, rootpath='')
Recursively traverse an ftp directory to discovery directory listing.
3.006819
2.867738
1.048499
entries = deque() conn.dir(path, entries.append) entries = map(parse_line, entries) grouped_entries = defaultdict(list) for key, value in entries: grouped_entries[key].append(value) directories = grouped_entries[ListingType.directory] files = grouped_entries[ListingType.file]...
def directory_listing(conn: FTP, path: str) -> Tuple[List, List]
Return the directories and files for single FTP listing.
3.64146
3.495371
1.041795
entry_name = str.rpartition(line, ' ')[-1] entry_type = LISTING_FLAG_MAP.get(line[char_index], ListingType.other) return entry_type, entry_name
def parse_line(line: str, char_index=0) -> Tuple[ListingType, str]
Parse FTP directory listing into (type, filename).
5.218561
4.642344
1.124122
ensure_file_directory(target_uri) with urllib.request.urlopen(source_url) as source_file: with open(target_uri, 'wb') as target_file: shutil.copyfileobj(source_file, target_file, buffer_size)
def download_ftp_url(source_url, target_uri, buffer_size=8192)
Uses urllib. thread safe?
2.077712
1.998109
1.039839
eax = self.attributes.get('devices') if eax is None: eax = self._all_devices if not isinstance(eax, list): eax = [eax] return [str(dev) for dev in eax]
def devices(self)
List of devices to test
5.536688
5.298306
1.044992
def exception_decorator(func): nonlocal error_messages @functools.wraps(func) def exc_wrapper(*args, **kwargs): nonlocal error_messages try: result = func(*args, **kwargs) except sa.exc.SQLAlchemyError as err: result ...
def exceptions(error_is_fatal=True, error_messages=None)
Handle SQLAlchemy exceptions in a sane way. Args: func: An arbitrary function to wrap. error_is_fatal: Should we exit the program on exception? reraise: Should we reraise the exception, after logging? Only makes sense if error_is_fatal is False. error_messages: A diction...
3.682035
3.537685
1.040804
connect_str = str(settings.CFG["db"]["connect_string"]) repo_url = path.template_path("../db/") return (connect_str, repo_url)
def get_version_data()
Retreive migration information.
17.575495
16.241791
1.082116
connect_str, repo_url = get_version_data() LOG.warning("Your database uses an unversioned benchbuild schema.") if not force and not ui.ask( "Should I enforce version control on your schema?"): LOG.error("User declined schema versioning.") return None repo_version = migra...
def enforce_versioning(force=False)
Install versioning on the db.
8.556133
7.77256
1.100813
if settings.CFG["db"]["create_functions"]: print("Refreshing SQL functions...") for file in path.template_files("../sql/", exts=[".sql"]): func = sa.DDL(path.template_str(file)) LOG.info("Loading: '%s' into database", file) connection.execute(func) ...
def init_functions(connection)
Initialize all SQL functions in the database.
9.394247
8.469688
1.109161
try: self.connection = self.engine.connect() return True except sa.exc.OperationalError as opex: LOG.fatal("Could not connect to the database. The error was: '%s'", str(opex)) return False
def connect_engine(self)
Establish a connection to the database. Provides simple error handling for fatal errors. Returns: True, if we could establish a connection, else False.
4.165362
4.028986
1.033849
try: self.connection.execution_options(isolation_level="SERIALIZABLE") except sa.exc.ArgumentError: LOG.debug("Unable to set isolation level to SERIALIZABLE") return True
def configure_engine(self)
Configure the databse connection. Sets appropriate transaction isolation levels and handle errors. Returns: True, if we did not encounter any unrecoverable errors, else False.
4.393367
4.468416
0.983205
groups = re.match(pattern, date_str) return dt.date(*_date_to_tuple(groups.groupdict()))
def parse_date(date_str: str, pattern=_RE_DATE) -> dt.date
Parse datetime.date from YYYY-MM-DD format.
5.914422
4.764723
1.241294
year, month, day = _date_to_tuple(dt_dict) hour, minute, second, microsecond = _time_to_tuple(dt_dict) return year, month, day, hour, minute, second, microsecond
def _datetime_to_tuple(dt_dict)
datetime.datetime components from dictionary to tuple. Example ------- dt_dict = {'year': '2014','month': '07','day': '23', 'hour': '13','minute': '12','second': '45','microsecond': '321'} _datetime_to_tuple(dt_dict) -> (2014, 7, 23, 13, 12, 45, 321)
2.042124
1.99281
1.024746
datetime_ = self.tz_mapper[timezone].localize(datetime_) return datetime_.astimezone(pytz.UTC)
def convert_2_utc(self, datetime_, timezone)
convert to datetime to UTC offset.
5.025556
4.419638
1.137097
cleaned_query = urllib.parse.quote_plus(query, safe='/+') url = BASE_URL + f'esearch.fcgi?db={database}&term={cleaned_query}&retmode=json' url = check_userhistory(userhistory, url) url = check_webenv(webenv, url) url = check_query_key(query_key, url) url = check_retstart(retstart, url) ...
def esearch(database, query, userhistory=True, webenv=False, query_key=False, retstart=False, retmax=False, api_key=False, email=False, **kwargs) -> Optional[EsearchResult]
Search for a query using the Entrez ESearch API. Parameters ---------- database : str Entez database to search. query : str Query string userhistory : bool Tells API to return a WebEnV and query_key. webenv : str An Entrez WebEnv to use saved history. query_k...
2.249195
2.301153
0.977421
url = BASE_URL + f'epost.fcgi' id = ','.join(ids) url_params = f'db={database}&id={id}' url_params = check_webenv(webenv, url_params) url_params = check_api_key(api_key, url_params) url_params = check_email(email, url_params) resp = entrez_try_put_multiple_times(url, url_params, num_tri...
def epost(database, ids: List[str], webenv=False, api_key=False, email=False, **kwargs) -> Optional[EpostResult]
Post IDs using the Entrez ESearch API. Parameters ---------- database : str Entez database to search. ids : list List of IDs to submit to the server. webenv : str An Entrez WebEnv to post ids to. api_key : str A users API key which allows more requests per second...
3.333326
3.777221
0.882481
url = BASE_URL + f'elink.fcgi?dbfrom={dbfrom}&db={db}&retmode=json&cmd=neighbor_history' url = check_webenv(webenv, url) url = check_query_key(query_key, url) url = check_api_key(api_key, url) url = check_email(email, url) if ids: if isinstance(ids, str): id = ids ...
def elink(db: str, dbfrom: str, ids=False, webenv=False, query_key=False, api_key=False, email=False, **kwargs) -> Optional[ElinkResult]
Get document summaries using the Entrez ESearch API. Parameters ---------- db : str Entez database to get ids from. dbfrom : str Entez database the provided ids are from. ids : list or str List of IDs to submit to the server. webenv : str An Entrez WebEnv to use ...
2.486081
2.476802
1.003747
url = BASE_URL + f'esummary.fcgi?db={database}' url = check_webenv(webenv, url) url = check_query_key(query_key, url) url = check_api_key(api_key, url) url = check_email(email, url) if ids: if isinstance(ids, str): id = ids else: id = ','.join(ids) ...
def esummary(database: str, ids=False, webenv=False, query_key=False, count=False, retstart=False, retmax=False, api_key=False, email=False, **kwargs) -> Optional[List[EsummaryResult]]
Get document summaries using the Entrez ESearch API. Parameters ---------- database : str Entez database to search. ids : list or str List of IDs to submit to the server. webenv : str An Entrez WebEnv to use saved history. query_key : str An Entrez query_key to u...
2.86464
2.88241
0.993835
url = BASE_URL + f'efetch.fcgi?db={database}&retmode={retmode}&rettype={rettype}' url = check_webenv(webenv, url) url = check_query_key(query_key, url) url = check_api_key(api_key, url) url = check_email(email, url) if ids: if isinstance(ids, str): id = ids else...
def efetch(database, ids=False, webenv=False, query_key=False, count=False, retstart=False, retmax=False, rettype='full', retmode='xml', api_key=False, email=False, **kwargs) -> str
Get documents using the Entrez ESearch API.gg Parameters ---------- database : str Entez database to search. ids : list or str List of IDs to submit to the server. webenv : str An Entrez WebEnv to use saved history. query_key : str An Entrez query_key to use save...
2.674454
2.785301
0.960203
if not retstart: retstart = 0 if not retmax: retmax = 500 if not count: count = retmax retmax = 500 # Entrez can return a max of 500 while retstart < count: diff = count - retstart if diff < 500: retmax = diff _url = url + f'&rets...
def entrez_sets_of_results(url, retstart=False, retmax=False, count=False) -> Optional[List[requests.Response]]
Gets sets of results back from Entrez. Entrez can only return 500 results at a time. This creates a generator that gets results by incrementing retstart and retmax. Parameters ---------- url : str The Entrez API url to use. retstart : int Return values starting at this index. ...
3.160644
3.364053
0.939535
if query is None: return for tup in query: print(("{0} @ {1} - {2} id: {3} group: {4}".format( tup.end, tup.experiment_name, tup.project_name, tup.experiment_group, tup.run_group)))
def print_runs(query)
Print all rows in this result query.
5.78681
5.943603
0.97362
if query is None: return for run, log in query: print(("{0} @ {1} - {2} id: {3} group: {4} status: {5}".format( run.end, run.experiment_name, run.project_name, run.experiment_group, run.run_group, log.status))) print(("command: {0}".format(run.command))) ...
def print_logs(query, types=None)
Print status logs.
3.925796
3.840205
1.022288
''' Collect layers from input svg sources. Args: svg_sources (list) : A list of file-like objects, each containing one or more XML layers. Returns ------- (width, height), layers : (int, int), list The first item in the tuple is the shape of the largest layer, and ...
def get_svg_layers(svg_sources)
Collect layers from input svg sources. Args: svg_sources (list) : A list of file-like objects, each containing one or more XML layers. Returns ------- (width, height), layers : (int, int), list The first item in the tuple is the shape of the largest layer, and the ...
3.534472
2.222394
1.590389
''' Merge layers from input svg sources into a single XML document. Args: svg_sources (list) : A list of file-like objects, each containing one or more XML layers. share_transform (bool) : If exactly one layer has a transform, apply it to *all* other layers as well....
def merge_svg_layers(svg_sources, share_transform=True)
Merge layers from input svg sources into a single XML document. Args: svg_sources (list) : A list of file-like objects, each containing one or more XML layers. share_transform (bool) : If exactly one layer has a transform, apply it to *all* other layers as well. Return...
3.519027
2.439778
1.442356
arguments = cli_common(__doc__, argv=argv) campaign_file = arguments['CAMPAIGN_FILE'] if arguments['-g']: if osp.exists(campaign_file): raise Exception('Campaign file already exists') with open(campaign_file, 'w') as ostr: Generator().write(ostr) else: ...
def main(argv=None)
ben-sh entry point
4.592025
4.472215
1.02679
arguments = cli_common(__doc__, argv=argv) driver = CampaignDriver(arguments['CAMPAIGN-DIR'], expandcampvars=False) driver(no_exec=True) if argv is not None: return driver
def main(argv=None)
ben-umb entry point
23.461472
20.572006
1.140456
counter = defaultdict(int) for record in records: name = record[field_name] counter[name] += 1 return counter
def count_by(records: Sequence[Dict], field_name: str) -> defaultdict
Frequency each value occurs in a record sequence for a given field name.
3.036967
2.468265
1.230405
exp_name = self.exp_name() fname = os.path.basename(self.out_path) fname = "{exp}_{prefix}_{name}{ending}".format( exp=exp_name, prefix=os.path.splitext(fname)[0], ending=os.path.splitext(fname)[-1], name="full") first = True ...
def generate(self)
Fetch all rows associated with this experiment. This will generate a huge .csv.
4.495816
4.139785
1.086002
from metatab import MetatabDoc t = self.get_resource().get_target() return MetatabDoc(t.inner)
def doc(self)
Return the metatab document for the URL
18.180817
9.295308
1.955913