Return a numpy array mapping events to events

    - Rows corresponds to events
    - Columns correspond to events

    Array has value 0 if event cannot be scheduled at same time as other event
    (1 otherwise)
168400
def event_availability_array(events):
    
    array = np.ones((len(events), len(events)))
    for row, event in enumerate(events):
        for col, other_event in enumerate(events):
            if row != col:
                tags = set(event.tags)
                events_share_tag = len(tags.intersection(other_event.tags)) > 0
                if (other_event in event.unavailability) or events_share_tag:
                    array[row, col] = 0
                    array[col, row] = 0
    return array
296036
def events(self):
        
        if self._events is None:
            self._events = EventList(self._version, workspace_sid=self._solution['sid'], )
        return self._events
1283764
def _get_events(self):
        
        self.last_update = datetime.datetime.now()
        time_min = datetime.datetime.utcnow()
        time_max = time_min + datetime.timedelta(hours=self.events_within_hours)
        events = []

        try:
            eventsResult = (
                self.service.events()
                .list(
                    calendarId="primary",
                    timeMax=time_max.isoformat() + "Z",  # 'Z' indicates UTC time
                    timeMin=time_min.isoformat() + "Z",  # 'Z' indicates UTC time
                    singleEvents=True,
                    orderBy="startTime",
                )
                .execute(num_retries=5)
            )
        except Exception:
            return self.events or events
        else:
            for event in eventsResult.get("items", []):
                # filter out events that we did not accept (default)
                # unless we organized them with no attendees
                i_organized = event.get("organizer", {}).get("self", False)
                has_attendees = event.get("attendees", [])
                for attendee in event.get("attendees", []):
                    if attendee.get("self") is True:
                        if attendee["responseStatus"] in self.response:
                            break
                else:
                    # we did not organize the event or we did not accept it
                    if not i_organized or has_attendees:
                        continue

                # strip and lower case output if needed
                for key in ["description", "location", "summary"]:
                    event[key] = event.get(key, "").strip()
                    if self.force_lowercase is True:
                        event[key] = event[key].lower()

                # ignore all day events if configured
                if event["start"].get("date") is not None:
                    if self.ignore_all_day_events:
                        continue

                # filter out blacklisted event names
                if event["summary"] is not None:
                    if event["summary"].lower() in map(
                        lambda e: e.lower(), self.blacklist_events
                    ):
                        continue

                events.append(event)

        return events[: self.num_events]
410729
def element_from_neighbourhood(X):
    

    m, n = X.shape
    new_X = np.copy(X)

    event_to_move = np.random.randint(m)
    current_event_slot = np.where(new_X[event_to_move, :] == 1)[0][0]

    slot_to_move_to = np.random.randint(n - 1)
    if slot_to_move_to >= current_event_slot:
        slot_to_move_to += 1
    scheduled_events_in_slot = np.where(new_X[:, slot_to_move_to] == 1)[0]

    if len(scheduled_events_in_slot) == 0:  # No event in that slot
        new_X[event_to_move] = np.zeros(n)
        new_X[event_to_move, slot_to_move_to] = 1

    else: # There is an event in that slot
        swap_rows = [event_to_move, scheduled_events_in_slot[0]]
        new_X[swap_rows] = new_X[swap_rows[::-1]]

    return new_X
1209454
def tag_array(events):
    
    all_tags = sorted(set(tag for event in events for tag in event.tags))
    array = np.zeros((len(events), len(all_tags)))
    for row, event in enumerate(events):
        for tag in event.tags:
            array[row, all_tags.index(tag)] = 1
    return array
236832
def main():
    
    credentials = get_credentials()
    http = credentials.authorize(httplib2.Http())
    service = discovery.build('calendar', 'v3', http=http)

    now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
    print('Getting the upcoming 10 events')
    eventsResult = service.events().list(
        calendarId='primary', timeMin=now, maxResults=10, singleEvents=True,
        orderBy='startTime').execute()
    events = eventsResult.get('items', [])

    if not events:
        print('No upcoming events found.')
    for event in events:
        start = event['start'].get('dateTime', event['start'].get('date'))
        print(start, event['summary'])
188174
def add_template_network_events(self, columns, vectors):
        
        # initialize with zeros - since vectors can be None, look for the
        # longest one that isn't
        new_events = None
        new_events = numpy.zeros(
            max([len(v) for v in vectors if v is not None]),
            dtype=self.network_event_dtype
        )
        # they shouldn't all be None
        assert new_events is not None
        new_events['template_id'] = self.template_index
        for c, v in zip(columns, vectors):
            if v is not None:
                if isinstance(v, Array):
                    new_events[c] = v.numpy()
                else:
                    new_events[c] = v
        self.template_events = numpy.append(self.template_events, new_events)
686334
def map_cluster(events, cluster):
    
    cluster = np.ascontiguousarray(cluster)
    events = np.ascontiguousarray(events)
    mapped_cluster = np.zeros((events.shape[0], ), dtype=dtype_from_descr(data_struct.ClusterInfoTable))
    mapped_cluster = np.ascontiguousarray(mapped_cluster)
    analysis_functions.map_cluster(events, cluster, mapped_cluster)
    return mapped_cluster
1235352
def get_events_in_both_arrays(events_one, events_two):
    
    events_one = np.ascontiguousarray(events_one)  # change memory alignement for c++ library
    events_two = np.ascontiguousarray(events_two)  # change memory alignement for c++ library
    event_result = np.empty_like(events_one)
    count = analysis_functions.get_events_in_both_arrays(events_one, events_two, event_result)
    return event_result[:count]
687968
def events_list(self):
        
        evt = []
        evt.extend(events.NEPALI_EVENTS[self.month, self.day])
        evt.extend(events.ENGLISH_EVENTS[self.en_date.month, self.en_date.day])
        return evt
1023756
public Object[] toArray() {
		XEvent array[] = new XEvent[events.size()];
		for (int i = 0; i < events.size(); i++) {
			try {
				array[i] = events.get(i);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return array;
	}
207102
def events(self, *events):
        
        return self.send_events(self.create_event(e) for e in events)
1280869
def get_events(self):
        
        res = self.con.get('_events', wait=False)
        logger.debug("Got events from %s: %s", self.name, res)
        return unserialize(res, True)
99715
def event_return(events):
    '''
    
    '''
    conn, mdb = _get_conn(ret=None)

    if isinstance(events, list):
        events = events[0]

    if isinstance(events, dict):
        log.debug(events)

        if PYMONGO_VERSION > _LooseVersion('2.3'):
            mdb.events.insert_one(events.copy())
        else:
            mdb.events.insert(events.copy())
1327116
def _get_events_data(object_key: str) -> List[dict]:
    
    events_data = []
    key = _keys.events_data(object_key)
    for event_id in _get_events_list(object_key):
        event_dict = literal_eval(DB.get_hash_value(key, event_id))
        events_data.append(event_dict)
    return events_data
979395
def events(self, **kwargs):
        
        events_result = self.service.events().list(**kwargs).execute()
        return [Event(event) for event in events_result.get("items", [])]
858490
def events(self):
        
        events = [self.acknowledge_event] + self.verification_events
        return [x for x in events if x]