<commit_before>import matplotlib
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np

class Polygon:
	matplotlib_obj = None
	def __init__(self, vertices, figure=None):
		self.vertices = np.matrix(vertices)
		# Define the polygon
		self.matplotlib_obj = plt.Polygon(vertices, fill=False, linewidth=2)
		self.figure = figure
		# Create and add polygon

	def labelSides(self, labelList, triangle=False):
		if triangle:
			temp1 = labelList[1]
			temp2 = labelList[2]
			temp3 = labelList[0]
			labelList[2] = temp1
			labelList[0] = temp2
			labelList[1] = temp3
		self.sideLabels = labelList
		vertices_pairs = sorted(self.vertices.tolist(), key=lambda element: (element[0], element[1]))
		vertices_pairs=self.vertices.tolist() + [self.vertices.tolist()[0]]
		midpoint_vertices=[]
		for i, vertex in enumerate(vertices_pairs[:-1]):
			x = (vertex[0] + vertices_pairs[i+1][0])/2
			y = (vertex[1] + vertices_pairs[i+1][1])/2
			midpoint_vertices.append([x,y])
		midpoint_vertices = np.matrix(midpoint_vertices)

		centroid = np.mean(midpoint_vertices, axis=0)

		for i, label in enumerate(labelList):
			ac = self.vertices[(i+1) % self.vertices.shape[0], :] - self.vertices[i, :]
			d = np.matrix([ac[0,1], -ac[0,0]])
			# TODO: We need to figure out a better amount of padding to use
			p = 0.1
			v = midpoint_vertices[i, :] + p*d

			dx, dy = d[0, 0], d[0, 1]
			vx, vy = v[0, 0], v[0, 1]<commit_msg>Added opposite side labelling function<commit_after>import matplotlib
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np

class Polygon:
	matplotlib_obj = None
	def __init__(self, vertices, figure=None):
		self.vertices = np.matrix(vertices)
		# Define the polygon
		self.matplotlib_obj = plt.Polygon(vertices, fill=False, linewidth=2)
		self.figure = figure
		# Create and add polygon


	def labelOppositeSides(self, labelList):
		# Number of sides - 1/2  + current index mod number of sides = new index
		numSides = len(self.vertices.tolist())
		const = (numSides-1)/2
		newLabels = range(numSides)
		for i, label in enumerate(labelList):
			idx = (const + i) % numSides
			newLabels[idx] = label
		self.labelSides(newLabels)

	def labelSides(self, labelList):

		self.sideLabels = labelList
		vertices_pairs = sorted(self.vertices.tolist(), key=lambda element: (element[0], element[1]))
		vertices_pairs=self.vertices.tolist() + [self.vertices.tolist()[0]]
		midpoint_vertices=[]
		for i, vertex in enumerate(vertices_pairs[:-1]):
			x = (vertex[0] + vertices_pairs[i+1][0])/2
			y = (vertex[1] + vertices_pairs[i+1][1])/2
			midpoint_vertices.append([x,y])
		midpoint_vertices = np.matrix(midpoint_vertices)

		centroid = np.mean(midpoint_vertices, axis=0)

		for i, label in enumerate(labelList):
			ac = self.vertices[(i+1) % self.vertices.shape[0], :] - self.vertices[i, :]
			d = np.matrix([ac[0,1], -ac[0,0]])
			# TODO: We need to figure out a better amount of padding to use
			p = 0.1
			v = midpoint_vertices[i, :] + p*d

			dx, dy = d[0, 0], d[0, 1]
			vx, vy = v[0, 0], v[0, 1]
{'fraction_non_alphanumeric': 0.14094616639477978, 'fraction_numerical': 0.024796084828711255, 'mean_word_length': 4.304498269896194, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3577655', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1153, 'n_words': 271}