select_events(event_masks)

    event_masks:
      Sequence of (deviceid, mask) pairs, where deviceid is a numerical device
      ID, or AllDevices or AllMasterDevices, and mask is either an unsigned
      integer or sequence of 32 bits unsigned values
350043
def select_events(self, event_masks):
    '''
    
    '''
    return XISelectEvents(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        window=self,
        masks=event_masks,
    )
291749
def _events(self):
    """"""
    for did, device in sorted(six.iteritems(self._proto.devices)):
      if device.name:
        yield dict(
            ph=_TYPE_METADATA,
            pid=did,
            name='process_name',
            args=dict(name=device.name))
      yield dict(
          ph=_TYPE_METADATA,
          pid=did,
          name='process_sort_index',
          args=dict(sort_index=did))
      for rid, resource in sorted(six.iteritems(device.resources)):
        if resource.name:
          yield dict(
              ph=_TYPE_METADATA,
              pid=did,
              tid=rid,
              name='thread_name',
              args=dict(name=resource.name))
        yield dict(
            ph=_TYPE_METADATA,
            pid=did,
            tid=rid,
            name='thread_sort_index',
            args=dict(sort_index=rid))
    # TODO(sammccall): filtering and downsampling?
    for event in self._proto.trace_events:
      yield self._event(event)
222940
def hidden_events(self, user):
        
        ids = user.events_hidden.all().values_list("event__id")
        return Event.objects.filter(id__in=ids)
505760
def validate_event_and_assign_id(event):
  
  event_time = event.get(TIMESTAMP_FIELD)

  if event_time is None:
    event[TIMESTAMP_FIELD] = event_time = epoch_time_to_kronos_time(time.time())
  elif type(event_time) not in (int, long):
    raise InvalidEventTime(event_time)

  # Generate a uuid1-like sequence from the event time with the non-time bytes
  # set to random values.
  _id = uuid_from_kronos_time(event_time)
  event[ID_FIELD] = str(_id)
  return _id, event
160390
function toBitMask(event) {
    if (!_.has(eventMap, event)) {
        throw new Error('Unkown event: ' + event);
    }
    return eventMap[event];
}
1169648
def _cellMask(self, index):
        
        row = index.row()
        col = index.column()
        if (row < 0 or row >= self.rowCount() or col < 0 or col >= self.columnCount()):
            return None

        # The check above should have returned None if the sliced array is None
        assert self._slicedArray is not None, "Sanity check failed."

        nFields = len(self._fieldNames)
        mask = self._slicedArray.mask
        if is_an_array(mask):
            if self._separateFieldOrientation == Qt.Horizontal:
                maskValue = mask[row, col // nFields][self._fieldNames[col % nFields]]
            elif self._separateFieldOrientation == Qt.Vertical:
                maskValue = mask[row // nFields, col][self._fieldNames[row % nFields]]
            else:
                maskValue = mask[row, col]
        else:
            maskValue = mask

        # Here maskValue can still be a list in case of structured arrays. It can even still be
        # a numpy array in case of a structured array with sub arrays as fields
        if is_an_array(maskValue):
            allMasked = np.all(maskValue)
        else:
            try:
                allMasked = all(maskValue)
            except TypeError as ex:
                allMasked = bool(maskValue)

        return allMasked
876697
function encode(events) {
  if(!Array.isArray(events)) {
    return '00';
  }
  let bitmask = 0;
  for(event in events) {
    let index = events[event];
    bitmask += (1 << index);
  }
  return ('00' + bitmask.toString(16)).substr(-2);
}
307491
function DeviceInfo (deviceIndex, deviceName, deviceType) {
    this.index = deviceIndex;
    this.name = deviceName;
    this.type = deviceType;
}
575655
def _get_events(self, result):
        """""""
        events = []

        for event_data in result:
            event = Event.factory(event_data)

            if event is not None:
                events.append(event)

                if isinstance(event, DeviceStateChangedEvent):
                    # change device state
                    if self.__devices[event.device_url] is None:
                        raise Exception(
                            "Received device change " +
                            "state for unknown device '" +
                            event.device_url + "'")

                    self.__devices[event.device_url].set_active_states(
                        event.states)

        return events
1046951
def _match_mask(mask, ctype):
    

    # Handle the simple cases first
    if '*' not in mask:
        return ctype == mask
    elif mask == '*/*':
        return True
    elif not mask.endswith('/*'):
        return False

    mask_major = mask[:-2]
    ctype_major = ctype.split('/', 1)[0]
    return ctype_major == mask_major
555603
public void setEvents(java.util.Collection<DeviceEvent> events) {
        if (events == null) {
            this.events = null;
            return;
        }

        this.events = new java.util.ArrayList<DeviceEvent>(events);
    }
967924
def select_device_by_load(wproc=0.5, wmem=0.5):
    

    ids = device_by_load(wproc=wproc, wmem=wmem)
    cp.cuda.Device(ids[0]).use()
    return ids[0]
216866
def search_device_by_id(self, deviceID) -> Device:
        
        for d in self.devices:
            if d.id == deviceID:
                return d
        return None
1362176
static void decodeTo(String eventKey, Collection<String> eventIds) {
        int startIdx = 0;
        String prevId = null;
        for (int i = 0; i < eventKey.length(); i++) {
            char ch = eventKey.charAt(i);
            if (ch == DELIM_REGULAR || ch == DELIM_SHARED_PREFIX) {
                String eventId = checkValid(combine(prevId, eventKey.substring(startIdx, i)));
                eventIds.add(eventId);
                prevId = (ch == DELIM_REGULAR) ? null : eventId;
                startIdx = i + 1;
            }
        }
        // Add the final event ID
        eventIds.add(checkValid(combine(prevId, eventKey.substring(startIdx, eventKey.length()))));
    }
1168135
def enumerate(cls):
        
        devices = {}
        for d in hid.enumerate(0, 0):
            vendor_id = d['vendor_id']
            product_id = d['product_id']
            serial_number = d['serial_number']
            interface_number = d['interface_number']
            path = d['path']

            # HIDAPI on Mac cannot detect correct HID interfaces, so device with
            # DebugLink doesn't work on Mac...
            if devices.get(serial_number) != None and devices[serial_number][0] == path:
                raise Exception("Two devices with the same path and S/N found. This is Mac, right? :-/")

            if (vendor_id, product_id) in DEVICE_IDS:
                devices.setdefault(serial_number, [None, None, None])
                if is_normal_link(d):
                    devices[serial_number][0] = path
                elif is_debug_link(d):
                    devices[serial_number][1] = path
                else:
                    raise Exception("Unknown USB interface number: %d" % interface_number)

        # List of two-tuples (path_normal, path_debuglink)
        return list(devices.values())
31974
def set_trigger_group_bit_mask(self, trigger_group_bit_mask):
        """"""
        set_cmd = self._create_set_property_msg("_trigger_group_bit_mask",
                                                0x0c, trigger_group_bit_mask)
        self._send_method(set_cmd, self._property_set)
462245
def event(self, interface_id, address, value_key, value):
        """"""
        LOG.debug("RPCFunctions.event: interface_id = %s, address = %s, value_key = %s, value = %s" % (
            interface_id, address, value_key.upper(), str(value)))
        self.devices_all[interface_id.split(
            '-')[-1]][address].event(interface_id, value_key.upper(), value)
        if self.eventcallback:
            self.eventcallback(interface_id=interface_id, address=address,
                               value_key=value_key.upper(), value=value)
        return True