<commit_before>#-*-coding:utf8*-
import sys
import bisect

class Clique:
	def __init__(self, c):
		(X,(tb,te)) = c
		self._X = X
		self._tb = tb
		self._te = te
                self._candidates = set()
	
	def __eq__(self, other):
		if self._X == other._X and self._tb == other._tb and self._te == other._te:
			return True
		else:
			return False

	def __hash__(self):
		return hash((self._X, self._tb, self._te))

	def __str__(self):
		return ','.join(map(str, list(self._X)))  + " " + str(self._tb) + "," + str(self._te)
	
	def getAdjacentNodes(self, times, nodes, delta):
            if self._te - self._tb <= delta:
                self._candidates = set()

                for u in self._X:
                    neighbors = nodes[u]
                    for n in neighbors:
                        # On regarde si le lien est apparu entre tb et te
                        is_present = False
                        if self._tb in times[frozenset([u,n])]:
				self._candidates.add(n)

                        if self._te in times[frozenset([u,n])]:
                        	self._candidates.add(n)


                    self._candidates = self._candidates.difference(self._X)
	    return self._candidates

	def getFirstTInInterval(self, times, nodes, td, delta):
		# Plus petit t entre te et td + delta impliquant (u,v) ?
		t =  None
		# Bien extraire tous les noeuds de la clique et du voisinage de chaque noeud de la clique (c'est ici qu'on fait grossir le temps pour pouvoir ajouter des noeuds)
		# Get all links implying at least one of X's nodes.
		candidates = set()
		for u in self._X:
			for n_u in nodes[u]:
				link = frozenset([u,n_u])

				if link in times:
					candidates.add(link)

		# Get the intercontact times in [te;td+delta]
		for candidate in candidates:
			sys.stderr.write("c is " + str(candidate) + "\n")              
			sys.stderr.write("tt is " + str(times[candidate]) + "\n")              
			index = bisect.bisect_right(times[candidate], self._te)
			sys.stderr.write(str(index) + "/" + str(len(times[candidate]))+ "\n")

			if len(times[candidate]) == 1 and index == 1 and times[candidate][index-1] <= td + delta:
				if times[candidate][index - 1] > self._te:
					if t>times[candidate][index-1] or t==None: 
						t = times[candidate][index-1]
			elif index < len(times[candidate]) and times[candidate][index] <= td + delta:
				if times[candidate][index - 1] > self._te:
					if t>times[candidate][index] or t==None:
						t = times[candidate][index]

		sys.stderr.write("    new_t = %s\n" % (str(t)))
		return t

	def isClique(self, times, node, delta):
		""" returns True if X(c) union node is a clique over tb;te, False otherwise"""

		for i in self._X:
			if frozenset([i, node]) not in times.keys():
				# Verifier que le lien existe
				sys.stderr.write("(%d, %d) does not exist\n" % (i, node))<commit_msg>Fixed index issues<commit_after>#-*-coding:utf8*-
import sys
import bisect

class Clique:
	def __init__(self, c):
		(X,(tb,te)) = c
		self._X = X
		self._tb = tb
		self._te = te
                self._candidates = set()
	
	def __eq__(self, other):
		if self._X == other._X and self._tb == other._tb and self._te == other._te:
			return True
		else:
			return False

	def __hash__(self):
		return hash((self._X, self._tb, self._te))

	def __str__(self):
		return ','.join(map(str, list(self._X)))  + " " + str(self._tb) + "," + str(self._te)
	
	def getAdjacentNodes(self, times, nodes, delta):
            if self._te - self._tb <= delta:
                self._candidates = set()

                for u in self._X:
                    neighbors = nodes[u]
                    for n in neighbors:
                        # On regarde si le lien est apparu entre tb et te
                        is_present = False
                        if self._tb in times[frozenset([u,n])]:
				self._candidates.add(n)

                        if self._te in times[frozenset([u,n])]:
                        	self._candidates.add(n)


                    self._candidates = self._candidates.difference(self._X)
	    return self._candidates

	def getFirstTInInterval(self, times, nodes, td, delta):
		# Plus petit t entre te et td + delta impliquant (u,v) ?
		t =  None
		# Bien extraire tous les noeuds de la clique et du voisinage de chaque noeud de la clique (c'est ici qu'on fait grossir le temps pour pouvoir ajouter des noeuds)
		# Get all links implying at least one of X's nodes.
		candidates = set()
		for u in self._X:
			for n_u in nodes[u]:
				link = frozenset([u,n_u])

				if link in times:
					candidates.add(link)

		# Get the intercontact times in [te;td+delta]
		for candidate in candidates:
			sys.stderr.write("c is " + str(candidate) + "\n")              
			sys.stderr.write("tt is " + str(times[candidate]) + "\n")              
			index = bisect.bisect_right(times[candidate], self._te)
			sys.stderr.write(str(index) + "/" + str(len(times[candidate]))+ "\n")

			if len(times[candidate]) == 1 and index == 1 and times[candidate][index-1] <= td + delta:
				if times[candidate][index - 1] > self._te:
					if t>times[candidate][index-1] or t==None: 
						t = times[candidate][index-1]
			elif index < len(times[candidate]) and times[candidate][index] <= td + delta:
				if times[candidate][index] > self._te:
					if t>times[candidate][index] or t==None:
						t = times[candidate][index]

		sys.stderr.write("    new_t = %s\n" % (str(t)))
		return t

	def isClique(self, times, node, delta):
		""" returns True if X(c) union node is a clique over tb;te, False otherwise"""

		for i in self._X:
			if frozenset([i, node]) not in times.keys():
				# Verifier que le lien existe
				sys.stderr.write("(%d, %d) does not exist\n" % (i, node))
{'fraction_non_alphanumeric': 0.1350307287093942, 'fraction_numerical': 0.0026338893766461808, 'mean_word_length': 2.418967587034814, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3557137', 'n_tokens_mistral': 2152, 'n_tokens_neox': 1886, 'n_words': 558}