<commit_before>import requests
import json
from pprint import pprint
import time
import calendar
import math

API_KEY = "<KEY>"

PLACE_ID_CODES = {
	"edinburgh":"EDI-sky",
	"paris":"PARI-sky",
	"london":"LOND-sky",
	"prague":"PRG-sky",
	"lisbon":"LIS-sky",
	"madrid":"MAD-sky",
	"rome":"ROME-sky",
	"bern":"BRN-sky",
	"zagreb":"ZAG-sky",
	"kiev":"KIEV-sky",
	"berlin":"BERL-sky",
	"munich":"MUC-sky",
	"warsow":"WARS-sky",
	"stockholm":"STOC-sky",
	"moscow":"MOSC-sky",
	"dubai":"DXBA-sky",
	"beijing":"BJSA-sky",
	"new york":"NYCA-sky",
	"nyc":"NYCA-sky",
	"boston":"BOS-sky",
	"dublin":"DUB-sky"
}


def get_place_id(city):

	url = "http://partners.api.skyscanner.net/apiservices/autosuggest/v1.0/GB/EUR/en-GB"
	headers = {
		"Accept":"application/json"
	}
	params = {
		"query":city,
		"apiKey":API_KEY
	}

	r = requests.get(url, headers=headers, params=params)

	return r


def create_session():

	url = "http://partners.api.skyscanner.net/apiservices/pricing/v1.0"
	headers = {
		"Content-Type":"application/x-www-form-urlencoded",
		"Accept":"application/json"
	}
	data = {
		"apiKey":API_KEY,
		"country":"GB",
		"currency":"GBP",
		"locale":"en",
		"originplace":"EDI-sky",
		"destinationplace":"PARI-sky",
		"outbounddate":"2015-10-10"
	}

	r = requests.post(url, headers=headers, data=data)

	return r

def poll_session(session_url):

	url = session_url
	headers = {
		"Accept":"application/json"
	}
	params = {
		"apiKey":API_KEY
	}

	r = requests.get(url, headers=headers, params=params)

	return r

class Optimizer:
	def __init__(self, trips):
		self.trips = [trip.summary for trip in trips]
		self.state = [0]*len(self.trips)

	def get_price_measure(self, state):
		return sum([100.0*float(trip[s]["Price"])/trip[0]["Price"] for s, trip in zip(state, self.trips)])

	def get_time_measure(self, state):
		times = [calendar.timegm(time.strptime(trip[s]["Arrival"],"%Y-%m-%dT%H:%M:%S"))/60.0 for s,trip in zip(state,self.trips)]

		average = sum(times)/len(times)
		variance = math.pow(sum([(t-average)**2 for t in times]),0.5)

		return variance

	def cost(self, state):
		return self.get_price_measure(state) + self.get_time_measure(state)

	def optimize(self):
		best_cost = self.cost(self.state)
		best_state = list(self.state)

		p=True
		while p:
			p=False
			for i in range(len(self.state)):
				new_state = list(best_state)

				if self.state[i] == 0:
					new_state[i] += 1
					new_cost = self.cost(new_state)

					if new_cost < best_cost:
						best_cost = new_cost
						best_state = list(new_state)
						p=True

				elif self.state[i] == len(self.trips[i])-1:<commit_msg>Bug fixed.<commit_after>import requests
import json
from pprint import pprint
import time
import calendar
import math

API_KEY = "<KEY>"

PLACE_ID_CODES = {
	"edinburgh":"EDI-sky",
	"paris":"PARI-sky",
	"london":"LOND-sky",
	"prague":"PRG-sky",
	"lisbon":"LIS-sky",
	"madrid":"MAD-sky",
	"rome":"ROME-sky",
	"bern":"BRN-sky",
	"zagreb":"ZAG-sky",
	"kiev":"KIEV-sky",
	"berlin":"BERL-sky",
	"munich":"MUC-sky",
	"warsow":"WARS-sky",
	"stockholm":"STOC-sky",
	"moscow":"MOSC-sky",
	"dubai":"DXBA-sky",
	"beijing":"BJSA-sky",
	"new york":"NYCA-sky",
	"nyc":"NYCA-sky",
	"boston":"BOS-sky",
	"dublin":"DUB-sky"
}


def get_place_id(city):

	url = "http://partners.api.skyscanner.net/apiservices/autosuggest/v1.0/GB/EUR/en-GB"
	headers = {
		"Accept":"application/json"
	}
	params = {
		"query":city,
		"apiKey":API_KEY
	}

	r = requests.get(url, headers=headers, params=params)

	return r


def create_session():

	url = "http://partners.api.skyscanner.net/apiservices/pricing/v1.0"
	headers = {
		"Content-Type":"application/x-www-form-urlencoded",
		"Accept":"application/json"
	}
	data = {
		"apiKey":API_KEY,
		"country":"GB",
		"currency":"GBP",
		"locale":"en",
		"originplace":"EDI-sky",
		"destinationplace":"PARI-sky",
		"outbounddate":"2015-10-10"
	}

	r = requests.post(url, headers=headers, data=data)

	return r

def poll_session(session_url):

	url = session_url
	headers = {
		"Accept":"application/json"
	}
	params = {
		"apiKey":API_KEY
	}

	r = requests.get(url, headers=headers, params=params)

	return r

class Optimizer:
	def __init__(self, trips):
		self.trips = [trip.summary for trip in trips]
		self.state = [0]*len(self.trips)

	def get_price_measure(self, state):
		return sum([100.0*float(trip[s]["Price"])/trip[0]["Price"] for s, trip in zip(state, self.trips)])

	def get_time_measure(self, state):
		times = [calendar.timegm(time.strptime(trip[s]["Arrival"],"%Y-%m-%dT%H:%M:%S"))/60.0 for s,trip in zip(state,self.trips)]

		average = sum(times)/len(times)
		variance = math.pow(sum([(t-average)**2 for t in times]),0.5)

		return variance

	def cost(self, state):
		return self.get_price_measure(state) + self.get_time_measure(state)

	def optimize(self):
		best_cost = self.cost(self.state)
		best_state = list(self.state)

		p=True
		while p:
			p=False
			for i in range(len(self.state)):
				new_state = list(best_state)

				if new_state[i] == 0:
					new_state[i] += 1
					new_cost = self.cost(new_state)

					if new_cost < best_cost:
						best_cost = new_cost
						best_state = list(new_state)
						p=True

				elif new_state[i] == len(self.trips[i])-1:
{'fraction_non_alphanumeric': 0.19129262184550183, 'fraction_numerical': 0.010402619919090734, 'mean_word_length': 4.413972888425443, 'pattern_counts': {'":': 70, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3036824', 'n_tokens_mistral': 2339, 'n_tokens_neox': 2123, 'n_words': 344}