text:
database[1].weights[database[1].efeatures[1]]=5
database[1].weights[database[1].efeatures[2]]=6
database[1].weights[database[1].efeatures[3]]=4
database[1].weights[database[1].efeatures[4]]=5
database[1].weights[database[1].efeatures[5]]=6
database[1].weights[database[1].efeatures[6]]=8
database[1].weights[database[1].efeatures[7]]=8
database[1].weights[database[1].efeatures[8]]=5
database[1].weights[database[1].efeatures[9]]=1
database[1].weights[database[1].efeatures[10]]=5
database[1].weights[database[1].efeatures[11]]=6
database[1].weights[database[1].sfeatures[1]]=5
database[1].weights[database[1].sfeatures[2]]=6
database[1].weights[database[1].sfeatures[3]]=4
database[1].weights[database[1].sfeatures[4]]=5
database[1].weights[database[1].sfeatures[5]]=6
database[1].weights[database[1].sfeatures[6]]=4
database[1].weights[database[1].sfeatures[7]]=5
database[1].weights[database[1].sfeatures[8]]=8
database[1].weights[database[1].sfeatures[9]]=3
database[1].weights[database[1].sfeatures[10]]=4
database[1].weights[database[1].sfeatures[11]]=4
database[1].weights[database[1].sfeatures[12]]=3
database[1].weights[database[1].sfeatures[13]]=3
database[1].weights[database[1].sfeatures[14]]=5
database[2].weights[database[2].efeatures[1]]=5
database[2].weights[database[2].efeatures[2]]=8
database[2].weights[database[2].efeatures[3]]=4
database[2].weights[database[2].efeatures[4]]=4
database[2].weights[database[2].efeatures[5]]=6
database[2].weights[database[2].efeatures[6]]=10
database[2].weights[database[2].efeatures[7]]=3
database[2].weights[database[2].efeatures[8]]=5
database[2].weights[database[2].efeatures[9]]=7
database[2].weights[database[2].efeatures[10]]=6
database[2].weights[database[2].sfeatures[1]]=5
database[2].weights[database[2].sfeatures[2]]=8
database[2].weights[database[2].sfeatures[3]]=4
database[2].weights[database[2].sfeatures[4]]=4
database[2].weights[database[2].sfeatures[5]]=6
database[2].weights[database[2].sfeatures[6]]=7
database[2].weights[database[2].sfeatures[7]]=7
database[2].weights[database[2].sfeatures[8]]=10
database[2].weights[database[2].sfeatures[9]]=5
database[2].weights[database[2].sfeatures[10]]=6
database[3].weights[database[3].efeatures[1]]=0
database[3].weights[database[3].efeatures[2]]=3
database[3].weights[database[3].efeatures[3]]=8
database[3].weights[database[3].efeatures[4]]=4
database[3].weights[database[3].efeatures[5]]=4
database[3].weights[database[3].efeatures[6]]=6
database[3].weights[database[3].efeatures[7]]=5
database[3].weights[database[3].efeatures[8]]=-3
database[3].weights[database[3].efeatures[9]]=5
database[3].weights[database[3].efeatures[10]]=3
database[3].weights[database[3].efeatures[11]]=4
database[3].weights[database[3].efeatures[12]]=-3
database[3].weights[database[3].efeatures[13]]=2
database[3].weights[database[3].sfeatures[1]]=0
database[3].weights[database[3].sfeatures[2]]=3
database[3].weights[database[3].sfeatures[3]]=8
database[3].weights[database[3].sfeatures[4]]=4
database[3].weights[database[3].sfeatures[5]]=4
database[3].weights[database[3].sfeatures[6]]=1
database[3].weights[database[3].sfeatures[7]]=3
database[3].weights[database[3].sfeatures[8]]=3
database[3].weights[database[3].sfeatures[9]]=-4
database[3].weights[database[3].sfeatures[10]]=3
database[3].weights[database[3].sfeatures[11]]=1
database[3].weights[database[3].sfeatures[12]]=4
database[3].weights[database[3].sfeatures[13]]=5
database[3].weights[database[3].sfeatures[14]]=3
database[3].weights[database[3].sfeatures[15]]=4
database[3].weights[database[3].sfeatures[16]]=6
database[3].weights[database[3].sfeatures[17]]=2
database[3].weights[database[3].sfeatures[18]]=0
database[3].weights[database[3].sfeatures[19]]=2
database[3].weights[database[3].sfeatures[20]]=5
database[3].weights[database[3].sfeatures[21]]=11
database[3].weights[database[3].sfeatures[22]]=2
database[3].weights[database[3].sfeatures[23]]=2
database[3].weights[database[3].sfeatures[24]]=-1
database[4].weights[database[4].efeatures[1]]=-3
database[4].weights[database[4].efeatures[2]]=4
database[4].weights[database[4].efeatures[3]]=-3
database[4].weights[database[4].efeatures[4]]=-3
database[4].weights[database[4].efeatures[5]]=7
database[4].weights[database[4].efeatures[6]]=-1
database[4].weights[database[4].efeatures[7]]=-3
database[4].weights[database[4].efeatures[8]]=-4
database[4].weights[database[4].efeatures[9]]=0
database[4].weights[database[4].sfeatures[1]]=-3
database[4].weights[database[4].sfeatures[2]]=4
database[4].weights[database[4].sfeatures[3]]=-3
database[4].weights[database[4].sfeatures[4]]=-3
database[4].weights[database[4].sfeatures[5]]=7
database[4].weights[database[4].sfeatures[6]]=7
database[4].weights[database[4].sfeatures[7]]=3
database[4].weights[database[4].sfeatures[8]]=6
database[4].weights[database[4].sfeatures[9]]=10
database[4].weights[database[4].sfeatures[10]]=-2
database[4].weights[database[4].sfeatures[11]]=-1
database[4].weights[database[4].sfeatures[12]]=6
database[4].weights[database[4].sfeatures[13]]=3
database[4].weights[database[4].sfeatures[14]]=3
database[4].weights[database[4].sfeatures[15]]=2
database[4].weights[database[4].sfeatures[16]]=3
database[4].weights[database[4].sfeatures[17]]=7
database[4].weights[database[4].sfeatures[18]]=10
database[4].weights[database[4].sfeatures[19]]=-1
database[4].weights[database[4].sfeatures[20]]=5
database[4].weights[database[4].sfeatures[21]]=1
database[4].weights[database[4].sfeatures[22]]=1
database[4].weights[database[4].sfeatures[23]]=4
database[4].weights[database[4].sfeatures[24]]=0
database[4].weights[database[4].sfeatures[25]]=2
database[4].weights[database[4].sfeatures[26]]=6
database[5].weights[database[5].efeatures[1]]=4
database[5].weights[database[5].efeatures[2]]=2
database[5].weights[database[5].efeatures[3]]=4
database[5].weights[database[5].efeatures[4]]=3
database[5].weights[database[5].efeatures[5]]=7
database[5].weights[database[5].efeatures[6]]=11
database[5].weights[database[5].efeatures[7]]=-2
database[5].weights[database[5].efeatures[8]]=0
database[5].weights[database[5].efeatures[9]]=2
database[5].weights[database[5].efeatures[10]]=1
database[5].weights[database[5].efeatures[11]]=6
database[5].weights[database[5].sfeatures[1]]=4
database[5].weights[database[5].sfeatures[2]]=2
database[5].weights[database[5].sfeatures[3]]=4
database[5].weights[database[5].sfeatures[4]]=3
database[5].weights[database[5].sfeatures[5]]=7
database[5].weights[database[5].sfeatures[6]]=3
database[5].weights[database[5].sfeatures[7]]=4
database[5].weights[database[5].sfeatures[8]]=7
database[5].weights[database[5].sfeatures[9]]=11
database[5].weights[database[5].sfeatures[10]]=0
database[5].weights[database[5].sfeatures[11]]=10
database[5].weights[database[5].sfeatures[12]]=-6
database[5].weights[database[5].sfeatures[13]]=4
database[5].weights[database[5].sfeatures[14]]=7
database[5].weights[database[5].sfeatures[15]]=-1
database[5].weights[database[5].sfeatures[16]]=12
database[5].weights[database[5].sfeatures[17]]=1
database[5].weights[database[5].sfeatures[18]]=6
database[6].weights[database[6].efeatures[1]]=10
database[6].weights[database[6].efeatures[2]]=9
database[6].weights[database[6].efeatures[3]]=9
database[6].weights[database[6].efeatures[4]]=9
database[6].weights[database[6].efeatures[5]]=6
database[6].weights[database[6].efeatures[6]]=8
database[6].weights[database[6].efeatures[7]]=7
database[6].weights[database[6].efeatures[8]]=10
database[6].weights[database[6].sfeatures[1]]=10
database[6].weights[database[6].sfeatures[2]]=9
database[6].weights[database[6].sfeatures[3]]=9
database[6].weights[database[6].sfeatures[4]]=9
database[6].weights[database[6].sfeatures[5]]=6
database[6].weights[database[6].sfeatures[6]]=13
database[6].weights[database[6].sfeatures[7]]=9
database[6].weights[database[6].sfeatures[8]]=8
database[6].weights[database[6].sfeatures[9]]=7
database[6].weights[database[6].sfeatures[10]]=9
database[6].weights[database[6].sfeatures[11]]=7
database[7].weights[database[7].efeatures[1]]=7
database[7].weights[database[7].efeatures[2]]=5
database[7].weights[database[7].efeatures[3]]=6
database[7].weights[database[7].efeatures[4]]=7
database[7].weights[database[7].efeatures[5]]=6
database[7].weights[database[7].efeatures[6]]=7
database[7].weights[database[7].efeatures[7]]=8
database[7].weights[database[7].efeatures[8]]=9
database[7].weights[database[7].sfeatures[1]]=7
database[7].weights[database[7].sfeatures[2]]=5
database[7].weights[database[7].sfeatures[3]]=6
database[7].weights[database[7].sfeatures[4]]=7
database[7].weights[database[7].sfeatures[5]]=6
database[7].weights[database[7].sfeatures[6]]=7
database[7].weights[database[7].sfeatures[7]]=10
database[7].weights[database[7].sfeatures[8]]=7
database[7].weights[database[7].sfeatures[9]]=9
database[7].weights[database[7].sfeatures[10]]=9
database[7].weights[database[7].sfeatures[11]]=9
database[8].weights[database[8].efeatures[1]]=10
database[8].weights[database[8].efeatures[2]]=7
database[8].weights[database[8].efeatures[3]]=7
database[8].weights[database[8].efeatures[4]]=10
database[8].weights[database[8].efeatures[5]]=8
database[8].weights[database[8].efeatures[6]]=8
database[8].weights[database[8].efeatures[7]]=9
database[8].weights[database[8].efeatures[8]]=4
database[8].weights[database[8].sfeatures[1]]=10
database[8].weights[database[8].sfeatures[2]]=7
database[8].weights[database[8].sfeatures[3]]=7
database[8].weights[database[8].sfeatures[4]]=10
database[8].weights[database[8].sfeatures[5]]=8
database[8].weights[database[8].sfeatures[6]]=10
database[8].weights[database[8].sfeatures[7]]=8
database[8].weights[database[8].sfeatures[8]]=8
database[8].weights[database[8].sfeatures[9]]=8
database[8].weights[database[8].sfeatures[10]]=12
database[8].weights[database[8].sfeatures[11]]=8
database[9].weights[database[9].efeatures[1]]=8
database[9].weights[database[9].efeatures[2]]=10
database[9].weights[database[9].efeatures[3]]=7
database[9].weights[database[9].efeatures[4]]=7
database[9].weights[database[9].efeatures[5]]=8
database[9].weights[database[9].efeatures[6]]=7
database[9].weights[database[9].efeatures[7]]=9
database[9].weights[database[9].efeatures[8]]=9
database[9].weights[database[9].sfeatures[1]]=8
database[9].weights[database[9].sfeatures[2]]=10
database[9].weights[database[9].sfeatures[3]]=7
database[9].weights[database[9].sfeatures[4]]=7
database[9].weights[database[9].sfeatures[5]]=8
database[9].weights[database[9].sfeatures[6]]=8
database[9].weights[database[9].sfeatures[7]]=8
database[9].weights[database[9].sfeatures[8]]=7
database[9].weights[database[9].sfeatures[9]]=7
database[9].weights[database[9].sfeatures[10]]=9
database[9].weights[database[9].sfeatures[11]]=7
database[10].weights[database[10].efeatures[1]]=-4
database[10].weights[database[10].efeatures[2]]=8
database[10].weights[database[10].efeatures[3]]=5
database[10].weights[database[10].efeatures[4]]=1
database[10].weights[database[10].efeatures[5]]=9
database[10].weights[database[10].efeatures[6]]=-4
database[10].weights[database[10].efeatures[7]]=-1
database[10].weights[database[10].efeatures[8]]=10
database[10].weights[database[10].efeatures[9]]=7
database[10].weights[database[10].efeatures[10]]=4
database[10].weights[database[10].efeatures[11]]=4
database[10].weights[database[10].efeatures[12]]=3
database[10].weights[database[10].sfeatures[1]]=-4
database[10].weights[database[10].sfeatures[2]]=8
database[10].weights[database[10].sfeatures[3]]=5
database[10].weights[database[10].sfeatures[4]]=1
database[10].weights[database[10].sfeatures[5]]=9
database[10].weights[database[10].sfeatures[6]]=8
database[10].weights[database[10].sfeatures[7]]=-1
database[10].weights[database[10].sfeatures[8]]=2
database[10].weights[database[10].sfeatures[9]]=-4
database[10].weights[database[10].sfeatures[10]]=10
database[10].weights[database[10].sfeatures[11]]=8
database[10].weights[database[10].sfeatures[12]]=10
database[10].weights[database[10].sfeatures[13]]=3
database[10].weights[database[10].sfeatures[14]]=4
database[10].weights[database[10].sfeatures[15]]=3
database[10].weights[database[10].sfeatures[16]]=4
database[10].weights[database[10].sfeatures[17]]=4
database[11].weights[database[11].efeatures[1]]=6
database[11].weights[database[11].efeatures[2]]=5
database[11].weights[database[11].efeatures[3]]=6
database[11].weights[database[11].efeatures[4]]=9
database[11].weights[database[11].efeatures[5]]=9
database[11].weights[database[11].efeatures[6]]=5
database[11].weights[database[11].efeatures[7]]=10
database[11].weights[database[11].efeatures[8]]=9
database[11].weights[database[11].sfeatures[1]]=6
database[11].weights[database[11].sfeatures[2]]=5
database[11].weights[database[11].sfeatures[3]]=6
database[11].weights[database[11].sfeatures[4]]=9
database[11].weights[database[11].sfeatures[5]]=9
database[11].weights[database[11].sfeatures[6]]=7
database[11].weights[database[11].sfeatures[7]]=9
database[11].weights[database[11].sfeatures[8]]=5
database[11].weights[database[11].sfeatures[9]]=10
database[11].weights[database[11].sfeatures[10]]=8
database[11].weights[database[11].sfeatures[11]]=8
database[12].weights[database[12].efeatures[1]]=6
database[12].weights[database[12].efeatures[2]]=6
database[12].weights[database[12].efeatures[3]]=6
database[12].weights[database[12].efeatures[4]]=7
database[12].weights[database[12].efeatures[5]]=5
database[12].weights[database[12].efeatures[6]]=7
database[12].weights[database[12].efeatures[7]]=4
database[12].weights[database[12].efeatures[8]]=6
database[12].weights[database[12].efeatures[9]]=7
database[12].weights[database[12].efeatures[10]]=6
database[12].weights[database[12].efeatures[11]]=6
database[12].weights[database[12].sfeatures[1]]=6
database[12].weights[database[12].sfeatures[2]]=6
database[12].weights[database[12].sfeatures[3]]=6
database[12].weights[database[12].sfeatures[4]]=7
database[12].weights[database[12].sfeatures[5]]=5
database[12].weights[database[12].sfeatures[6]]=8
database[12].weights[database[12].sfeatures[7]]=5
database[12].weights[database[12].sfeatures[8]]=7
database[12].weights[database[12].sfeatures[9]]=9
database[12].weights[database[12].sfeatures[10]]=6
database[12].weights[database[12].sfeatures[11]]=7
database[13].weights[database[13].efeatures[1]]=10
database[13].weights[database[13].efeatures[2]]=7
database[13].weights[database[13].efeatures[3]]=9
database[13].weights[database[13].efeatures[4]]=9
database[13].weights[database[13].efeatures[5]]=6
database[13].weights[database[13].efeatures[6]]=14
database[13].weights[database[13].efeatures[7]]=4
database[13].weights[database[13].efeatures[8]]=5
database[13].weights[database[13].sfeatures[1]]=10
database[13].weights[database[13].sfeatures[2]]=7
database[13].weights[database[13].sfeatures[3]]=9
database[13].weights[database[13].sfeatures[4]]=9
database[13].weights[database[13].sfeatures[5]]=6
database[13].weights[database[13].sfeatures[6]]=12
database[13].weights[database[13].sfeatures[7]]=11
database[13].weights[database[13].sfeatures[8]]=14
database[13].weights[database[13].sfeatures[9]]=5
database[13].weights[database[13].sfeatures[10]]=9
database[13].weights[database[13].sfeatures[11]]=8
database[14].weights[database[14].efeatures[1]]=3
database[14].weights[database[14].efeatures[2]]=4
database[14].weights[database[14].efeatures[3]]=4
database[14].weights[database[14].efeatures[4]]=4
database[14].weights[database[14].efeatures[5]]=3
database[14].weights[database[14].efeatures[6]]=5
database[14].weights[database[14].efeatures[7]]=7
database[14].weights[database[14].efeatures[8]]=-1
database[14].weights[database[14].efeatures[9]]=5
database[14].weights[database[14].efeatures[10]]=4
database[14].weights[database[14].efeatures[11]]=5
database[14].weights[database[14].sfeatures[1]]=3
database[14].weights[database[14].sfeatures[2]]=4
database[14].weights[database[14].sfeatures[3]]=4
database[14].weights[database[14].sfeatures[4]]=4
database[14].weights[database[14].sfeatures[5]]=3
database[14].weights[database[14].sfeatures[6]]=4
database[14].weights[database[14].sfeatures[7]]=1
database[14].weights[database[14].sfeatures[8]]=4
database[14].weights[database[14].sfeatures[9]]=2
database[14].weights[database[14].sfeatures[10]]=2
database[14].weights[database[14].sfeatures[11]]=1
database[14].weights[database[14].sfeatures[12]]=5
database[14].weights[database[14].sfeatures[13]]=5
database[14].weights[database[14].sfeatures[14]]=3
database[14].weights[database[14].sfeatures[15]]=-1
database[14].weights[database[14].sfeatures[16]]=5
database[14].weights[database[14].sfeatures[17]]=6
database[14].weights[database[14].sfeatures[18]]=-1
database[14].weights[database[14].sfeatures[19]]=5
database[15].weights[database[15].efeatures[1]]=6
database[15].weights[database[15].efeatures[2]]=7
database[15].weights[database[15].efeatures[3]]=5
database[15].weights[database[15].efeatures[4]]=7
database[15].weights[database[15].efeatures[5]]=7
database[15].weights[database[15].efeatures[6]]=7
database[15].weights[database[15].efeatures[7]]=5
database[15].weights[database[15].efeatures[8]]=8
database[15].weights[database[15].sfeatures[1]]=6
database[15].weights[database[15].sfeatures[2]]=7
database[15].weights[database[15].sfeatures[3]]=5
database[15].weights[database[15].sfeatures[4]]=7
database[15].weights[database[15].sfeatures[5]]=7
database[15].weights[database[15].sfeatures[6]]=4
database[15].weights[database[15].sfeatures[7]]=6
database[15].weights[database[15].sfeatures[8]]=7
database[15].weights[database[15].sfeatures[9]]=7
database[15].weights[database[15].sfeatures[10]]=7
database[15].weights[database[15].sfeatures[11]]=7
database[15].weights[database[15].sfeatures[12]]=10
database[15].weights[database[15].sfeatures[13]]=6
database[15].weights[database[15].sfeatures[14]]=9
database[15].weights[database[15].sfeatures[15]]=7
database[15].weights[database[15].sfeatures[16]]=6
database[16].weights[database[16].efeatures[1]]=9
database[16].weights[database[16].efeatures[2]]=7
database[16].weights[database[16].efeatures[3]]=9
database[16].weights[database[16].efeatures[4]]=8
database[16].weights[database[16].efeatures[5]]=7
database[16].weights[database[16].efeatures[6]]=6
database[16].weights[database[16].efeatures[7]]=5
database[16].weights[database[16].efeatures[8]]=9
database[16].weights[database[16].efeatures[9]]=6
database[16].weights[database[16].efeatures[10]]=7
database[16].weights[database[16].efeatures[11]]=5
database[16].weights[database[16].sfeatures[1]]=9
database[16].weights[database[16].sfeatures[2]]=7
database[16].weights[database[16].sfeatures[3]]=9
database[16].weights[database[16].sfeatures[4]]=8
database[16].weights[database[16].sfeatures[5]]=7
database[16].weights[database[16].sfeatures[6]]=8
database[16].weights[database[16].sfeatures[7]]=7
database[16].weights[database[16].sfeatures[8]]=6
database[16].weights[database[16].sfeatures[9]]=5
database[17].weights[database[17].efeatures[1]]=6
database[17].weights[database[17].efeatures[2]]=6
database[17].weights[database[17].efeatures[3]]=5
database[17].weights[database[17].efeatures[4]]=5
database[17].weights[database[17].efeatures[5]]=5
database[17].weights[database[17].efeatures[6]]=5
database[17].weights[database[17].efeatures[7]]=7
database[17].weights[database[17].efeatures[8]]=4
database[17].weights[database[17].efeatures[9]]=7
database[17].weights[database[17].efeatures[10]]=5
database[17].weights[database[17].efeatures[11]]=5
database[17].weights[database[17].sfeatures[1]]=6
database[17].weights[database[17].sfeatures[2]]=6
database[17].weights[database[17].sfeatures[3]]=5
database[17].weights[database[17].sfeatures[4]]=5
database[17].weights[database[17].sfeatures[5]]=5
database[17].weights[database[17].sfeatures[6]]=4
database[17].weights[database[17].sfeatures[7]]=6
database[17].weights[database[17].sfeatures[8]]=5
database[17].weights[database[17].sfeatures[9]]=4
database[17].weights[database[17].sfeatures[10]]=5
database[18].weights[database[18].efeatures[1]]=7
database[18].weights[database[18].efeatures[2]]=8
database[18].weights[database[18].efeatures[3]]=5
database[18].weights[database[18].efeatures[4]]=11
database[18].weights[database[18].efeatures[5]]=8
database[18].weights[database[18].efeatures[6]]=7
database[18].weights[database[18].efeatures[7]]=7
database[18].weights[database[18].efeatures[8]]=7
database[18].weights[database[18].sfeatures[1]]=7
database[18].weights[database[18].sfeatures[2]]=8
database[18].weights[database[18].sfeatures[3]]=5
database[18].weights[database[18].sfeatures[4]]=11
database[18].weights[database[18].sfeatures[5]]=8
database[18].weights[database[18].sfeatures[6]]=9
database[18].weights[database[18].sfeatures[7]]=7
database[18].weights[database[18].sfeatures[8]]=7
database[18].weights[database[18].sfeatures[9]]=12
database[18].weights[database[18].sfeatures[10]]=8
database[19].weights[database[19].efeatures[1]]=5
database[19].weights[database[19].efeatures[2]]=4
database[19].weights[database[19].efeatures[3]]=4
database[19].weights[database[19].efeatures[4]]=5
database[19].weights[database[19].efeatures[5]]=2
database[19].weights[database[19].efeatures[6]]=3
database[19].weights[database[19].efeatures[7]]=3
database[19].weights[database[19].efeatures[8]]=6
database[19].weights[database[19].efeatures[9]]=6
database[19].weights[database[19].efeatures[10]]=7
database[19].weights[database[19].efeatures[11]]=4
database[19].weights[database[19].sfeatures[1]]=5
database[19].weights[database[19].sfeatures[2]]=4
database[19].weights[database[19].sfeatures[3]]=4
database[19].weights[database[19].sfeatures[4]]=5
database[19].weights[database[19].sfeatures[5]]=2
database[19].weights[database[19].sfeatures[6]]=5
database[19].weights[database[19].sfeatures[7]]=5
database[19].weights[database[19].sfeatures[8]]=6
database[19].weights[database[19].sfeatures[9]]=4
database[19].weights[database[19].sfeatures[10]]=4
database[19].weights[database[19].sfeatures[11]]=7
database[20].weights[database[20].efeatures[1]]=4
database[20].weights[database[20].efeatures[2]]=3
database[20].weights[database[20].efeatures[3]]=5
database[20].weights[database[20].efeatures[4]]=2
database[20].weights[database[20].efeatures[5]]=3
database[20].weights[database[20].efeatures[6]]=3
database[20].weights[database[20].efeatures[7]]=5
database[20].weights[database[20].efeatures[8]]=3
database[20].weights[database[20].efeatures[9]]=6
database[20].weights[database[20].efeatures[10]]=7
database[20].weights[database[20].efeatures[11]]=5
database[20].weights[database[20].sfeatures[1]]=4
database[20].weights[database[20].sfeatures[2]]=3
database[20].weights[database[20].sfeatures[3]]=5
database[20].weights[database[20].sfeatures[4]]=2
database[20].weights[database[20].sfeatures[5]]=3
database[20].weights[database[20].sfeatures[6]]=4
database[20].weights[database[20].sfeatures[7]]=2
database[20].weights[database[20].sfeatures[8]]=6
database[20].weights[database[20].sfeatures[9]]=5
database[20].weights[database[20].sfeatures[10]]=7
database[20].weights[database[20].sfeatures[11]]=5
database[21].weights[database[21].efeatures[1]]=5
database[21].weights[database[21].efeatures[2]]=3
database[21].weights[database[21].efeatures[3]]=4
database[21].weights[database[21].efeatures[4]]=6
database[21].weights[database[21].efeatures[5]]=4
database[21].weights[database[21].efeatures[6]]=3
database[21].weights[database[21].efeatures[7]]=5
database[21].weights[database[21].efeatures[8]]=6
database[21].weights[database[21].efeatures[9]]=7
database[21].weights[database[21].efeatures[10]]=5
database[21].weights[database[21].efeatures[11]]=6
database[21].weights[database[21].efeatures[12]]=5
database[21].weights[database[21].sfeatures[1]]=5
database[21].weights[database[21].sfeatures[2]]=3
database[21].weights[database[21].sfeatures[3]]=4
database[21].weights[database[21].sfeatures[4]]=6
database[21].weights[database[21].sfeatures[5]]=4
database[21].weights[database[21].sfeatures[6]]=3
database[21].weights[database[21].sfeatures[7]]=2
database[21].weights[database[21].sfeatures[8]]=7
database[21].weights[database[21].sfeatures[9]]=3
database[21].weights[database[21].sfeatures[10]]=3
database[21].weights[database[21].sfeatures[11]]=2
database[22].weights[database[22].efeatures[1]]=5
database[22].weights[database[22].efeatures[2]]=2
database[22].weights[database[22].efeatures[3]]=4
database[22].weights[database[22].efeatures[4]]=5
database[22].weights[database[22].efeatures[5]]=7
database[22].weights[database[22].efeatures[6]]=4
database[22].weights[database[22].efeatures[7]]=5
database[22].weights[database[22].efeatures[8]]=4
database[22].weights[database[22].efeatures[9]]=6
database[22].weights[database[22].efeatures[10]]=4
database[22].weights[database[22].efeatures[11]]=4
database[22].weights[database[22].sfeatures[1]]=5
database[22].weights[database[22].sfeatures[2]]=2
database[22].weights[database[22].sfeatures[3]]=4
database[22].weights[database[22].sfeatures[4]]=5
database[22].weights[database[22].sfeatures[5]]=7
database[22].weights[database[22].sfeatures[6]]=4
database[22].weights[database[22].sfeatures[7]]=5
database[22].weights[database[22].sfeatures[8]]=6
database[22].weights[database[22].sfeatures[9]]=4
database[22].weights[database[22].sfeatures[10]]=4
database[22].weights[database[22].sfeatures[11]]=4
database[22].weights[database[22].sfeatures[12]]=3
database[22].weights[database[22].sfeatures[13]]=4
database[23].weights[database[23].efeatures[1]]=3
database[23].weights[database[23].efeatures[2]]=3
database[23].weights[database[23].efeatures[3]]=6
database[23].weights[database[23].efeatures[4]]=5
database[23].weights[database[23].efeatures[5]]=4
database[23].weights[database[23].efeatures[6]]=4
database[23].weights[database[23].efeatures[7]]=5
database[23].weights[database[23].efeatures[8]]=4
database[23].weights[database[23].efeatures[9]]=5
database[23].weights[database[23].efeatures[10]]=3
database[23].weights[database[23].efeatures[11]]=6
database[23].weights[database[23].sfeatures[1]]=3
database[23].weights[database[23].sfeatures[2]]=3
database[23].weights[database[23].sfeatures[3]]=6
database[23].weights[database[23].sfeatures[4]]=5
database[23].weights[database[23].sfeatures[5]]=4
database[23].weights[database[23].sfeatures[6]]=3
database[23].weights[database[23].sfeatures[7]]=5
database[23].weights[database[23].sfeatures[8]]=5
database[23].weights[database[23].sfeatures[9]]=4
database[23].weights[database[23].sfeatures[10]]=6
database[23].weights[database[23].sfeatures[11]]=5
database[24].weights[database[24].efeatures[1]]=3
database[24].weights[database[24].efeatures[2]]=3
database[24].weights[database[24].efeatures[3]]=5
database[24].weights[database[24].efeatures[4]]=3
database[24].weights[database[24].efeatures[5]]=2
database[24].weights[database[24].efeatures[6]]=2
database[24].weights[database[24].efeatures[7]]=5
database[24].weights[database[24].efeatures[8]]=5
database[24].weights[database[24].efeatures[9]]=2
database[24].weights[database[24].efeatures[10]]=3
database[24].weights[database[24].efeatures[11]]=2
database[24].weights[database[24].efeatures[12]]=4
database[24].weights[database[24].sfeatures[1]]=3
database[24].weights[database[24].sfeatures[2]]=3
database[24].weights[database[24].sfeatures[3]]=5
database[24].weights[database[24].sfeatures[4]]=3
database[24].weights[database[24].sfeatures[5]]=2
database[24].weights[database[24].sfeatures[6]]=6
database[24].weights[database[24].sfeatures[7]]=6
database[24].weights[database[24].sfeatures[8]]=3
database[24].weights[database[24].sfeatures[9]]=5
database[24].weights[database[24].sfeatures[10]]=2
database[24].weights[database[24].sfeatures[11]]=3
database[24].weights[database[24].sfeatures[12]]=4
database[24].weights[database[24].sfeatures[13]]=2
database[24].weights[database[24].sfeatures[14]]=2
database[24].weights[database[24].sfeatures[15]]=2
database[24].weights[database[24].sfeatures[16]]=4
database[25].weights[database[25].efeatures[1]]=0
database[25].weights[database[25].efeatures[2]]=3
database[25].weights[database[25].efeatures[3]]=5
database[25].weights[database[25].efeatures[4]]=3
database[25].weights[database[25].efeatures[5]]=3
database[25].weights[database[25].efeatures[6]]=2
database[25].weights[database[25].efeatures[7]]=2
database[25].weights[database[25].efeatures[8]]=5
database[25].weights[database[25].efeatures[9]]=6
database[25].weights[database[25].efeatures[10]]=2
database[25].weights[database[25].efeatures[11]]=4
database[25].weights[database[25].sfeatures[1]]=0
database[25].weights[database[25].sfeatures[2]]=3
database[25].weights[database[25].sfeatures[3]]=5
database[25].weights[database[25].sfeatures[4]]=3
database[25].weights[database[25].sfeatures[5]]=3
database[25].weights[database[25].sfeatures[6]]=1
database[25].weights[database[25].sfeatures[7]]=6
database[25].weights[database[25].sfeatures[8]]=4
database[25].weights[database[25].sfeatures[9]]=4
database[25].weights[database[25].sfeatures[10]]=5
database[25].weights[database[25].sfeatures[11]]=4
database[25].weights[database[25].sfeatures[12]]=2
database[25].weights[database[25].sfeatures[13]]=2
database[25].weights[database[25].sfeatures[14]]=5
database[25].weights[database[25].sfeatures[15]]=4
database[26].weights[database[26].efeatures[1]]=12
database[26].weights[database[26].efeatures[2]]=10
database[26].weights[database[26].efeatures[3]]=6
database[26].weights[database[26].efeatures[4]]=7
database[26].weights[database[26].efeatures[5]]=12
database[26].weights[database[26].efeatures[6]]=8
database[26].weights[database[26].efeatures[7]]=10
database[26].weights[database[26].sfeatures[1]]=12
database[26].weights[database[26].sfeatures[2]]=10
database[26].weights[database[26].sfeatures[3]]=6
database[26].weights[database[26].sfeatures[4]]=7
database[26].weights[database[26].sfeatures[5]]=12
database[26].weights[database[26].sfeatures[6]]=9
database[26].weights[database[26].sfeatures[7]]=9
database[26].weights[database[26].sfeatures[8]]=6
database[26].weights[database[26].sfeatures[9]]=6
database[26].weights[database[26].sfeatures[10]]=10
database[27].weights[database[27].efeatures[1]]=4
database[27].weights[database[27].efeatures[2]]=6
database[27].weights[database[27].efeatures[3]]=7
database[27].weights[database[27].efeatures[4]]=5
database[27].weights[database[27].efeatures[5]]=5
database[27].weights[database[27].efeatures[6]]=7
database[27].weights[database[27].efeatures[7]]=4
database[27].weights[database[27].efeatures[8]]=7
database[27].weights[database[27].efeatures[9]]=4
database[27].weights[database[27].efeatures[10]]=4
database[27].weights[database[27].efeatures[11]]=5
database[27].weights[database[27].sfeatures[1]]=4
database[27].weights[database[27].sfeatures[2]]=6
database[27].weights[database[27].sfeatures[3]]=7
database[27].weights[database[27].sfeatures[4]]=5
database[27].weights[database[27].sfeatures[5]]=5
database[27].weights[database[27].sfeatures[6]]=4
database[27].weights[database[27].sfeatures[7]]=4
database[27].weights[database[27].sfeatures[8]]=7
database[27].weights[database[27].sfeatures[9]]=7
database[27].weights[database[27].sfeatures[10]]=4
database[27].weights[database[27].sfeatures[11]]=5
database[28].weights[database[28].efeatures[1]]=4
database[28].weights[database[28].efeatures[2]]=3
database[28].weights[database[28].efeatures[3]]=2
database[28].weights[database[28].efeatures[4]]=10
database[28].weights[database[28].efeatures[5]]=3
database[28].weights[database[28].efeatures[6]]=1
database[28].weights[database[28].efeatures[7]]=5
database[28].weights[database[28].efeatures[8]]=9
database[28].weights[database[28].efeatures[9]]=0
database[28].weights[database[28].efeatures[10]]=6
database[28].weights[database[28].efeatures[11]]=5
database[28].weights[database[28].sfeatures[1]]=4
database[28].weights[database[28].sfeatures[2]]=3
database[28].weights[database[28].sfeatures[3]]=2
database[28].weights[database[28].sfeatures[4]]=10
database[28].weights[database[28].sfeatures[5]]=3
database[28].weights[database[28].sfeatures[6]]=8
database[28].weights[database[28].sfeatures[7]]=-3
database[28].weights[database[28].sfeatures[8]]=7
database[28].weights[database[28].sfeatures[9]]=1
database[28].weights[database[28].sfeatures[10]]=9
database[28].weights[database[28].sfeatures[11]]=7
database[28].weights[database[28].sfeatures[12]]=3
database[28].weights[database[28].sfeatures[13]]=7
database[28].weights[database[28].sfeatures[14]]=6
database[28].weights[database[28].sfeatures[15]]=5
database[29].weights[database[29].efeatures[1]]=1
database[29].weights[database[29].efeatures[2]]=2
database[29].weights[database[29].efeatures[3]]=3
database[29].weights[database[29].efeatures[4]]=3
database[29].weights[database[29].efeatures[5]]=4
database[29].weights[database[29].efeatures[6]]=7
database[29].weights[database[29].efeatures[7]]=4
database[29].weights[database[29].efeatures[8]]=2
database[29].weights[database[29].sfeatures[1]]=1
database[29].weights[database[29].sfeatures[2]]=2
database[29].weights[database[29].sfeatures[3]]=3
database[29].weights[database[29].sfeatures[4]]=3
database[29].weights[database[29].sfeatures[5]]=4
database[29].weights[database[29].sfeatures[6]]=5
database[29].weights[database[29].sfeatures[7]]=4
database[29].weights[database[29].sfeatures[8]]=5
database[29].weights[database[29].sfeatures[9]]=7
database[29].weights[database[29].sfeatures[10]]=1
database[29].weights[database[29].sfeatures[11]]=1
database[29].weights[database[29].sfeatures[12]]=3
database[29].weights[database[29].sfeatures[13]]=5
database[29].weights[database[29].sfeatures[14]]=3
database[29].weights[database[29].sfeatures[15]]=4
database[29].weights[database[29].sfeatures[16]]=8
database[29].weights[database[29].sfeatures[17]]=2
database[29].weights[database[29].sfeatures[18]]=1
database[29].weights[database[29].sfeatures[19]]=5
database[30].weights[database[30].efeatures[1]]=4
database[30].weights[database[30].efeatures[2]]=3
database[30].weights[database[30].efeatures[3]]=4
database[30].weights[database[30].efeatures[4]]=5
database[30].weights[database[30].efeatures[5]]=5
database[30].weights[database[30].efeatures[6]]=6
database[30].weights[database[30].efeatures[7]]=4
database[30].weights[database[30].efeatures[8]]=8
database[30].weights[database[30].efeatures[9]]=6
database[30].weights[database[30].efeatures[10]]=5
database[30].weights[database[30].efeatures[11]]=5
database[30].weights[database[30].sfeatures[1]]=4
database[30].weights[database[30].sfeatures[2]]=3
database[30].weights[database[30].sfeatures[3]]=4
database[30].weights[database[30].sfeatures[4]]=5
database[30].weights[database[30].sfeatures[5]]=5
database[30].weights[database[30].sfeatures[6]]=3
database[30].weights[database[30].sfeatures[7]]=4
database[30].weights[database[30].sfeatures[8]]=4
database[30].weights[database[30].sfeatures[9]]=5
database[30].weights[database[30].sfeatures[10]]=5
database[31].weights[database[31].efeatures[1]]=4
database[31].weights[database[31].efeatures[2]]=3
database[31].weights[database[31].efeatures[3]]=2
database[31].weights[database[31].efeatures[4]]=4
database[31].weights[database[31].efeatures[5]]=4
database[31].weights[database[31].efeatures[6]]=4
database[31].weights[database[31].efeatures[7]]=2
database[31].weights[database[31].efeatures[8]]=3
database[31].weights[database[31].efeatures[9]]=4
database[31].weights[database[31].efeatures[10]]=1
database[31].weights[database[31].efeatures[11]]=3
database[31].weights[database[31].efeatures[12]]=1
database[31].weights[database[31].efeatures[13]]=2
database[31].weights[database[31].efeatures[14]]=5
database[31].weights[database[31].efeatures[15]]=3
database[31].weights[database[31].sfeatures[1]]=4
database[31].weights[database[31].sfeatures[2]]=3
database[31].weights[database[31].sfeatures[3]]=2
database[31].weights[database[31].sfeatures[4]]=4
database[31].weights[database[31].sfeatures[5]]=4
database[31].weights[database[31].sfeatures[6]]=3
database[31].weights[database[31].sfeatures[7]]=5
database[31].weights[database[31].sfeatures[8]]=6
database[31].weights[database[31].sfeatures[9]]=3
database[31].weights[database[31].sfeatures[10]]=4
database[31].weights[database[31].sfeatures[11]]=4
database[32].weights[database[32].efeatures[1]]=4
database[32].weights[database[32].efeatures[2]]=9
database[32].weights[database[32].efeatures[3]]=-2
database[32].weights[database[32].efeatures[4]]=8
database[32].weights[database[32].efeatures[5]]=-6
database[32].weights[database[32].efeatures[6]]=2
database[32].weights[database[32].efeatures[7]]=12
database[32].weights[database[32].efeatures[8]]=7
database[32].weights[database[32].efeatures[9]]=-10
database[32].weights[database[32].efeatures[10]]=13
database[32].weights[database[32].sfeatures[1]]=4
database[32].weights[database[32].sfeatures[2]]=9
database[32].weights[database[32].sfeatures[3]]=-2
database[32].weights[database[32].sfeatures[4]]=8
database[32].weights[database[32].sfeatures[5]]=-6
database[32].weights[database[32].sfeatures[6]]=-8
database[32].weights[database[32].sfeatures[7]]=16
database[32].weights[database[32].sfeatures[8]]=3
database[32].weights[database[32].sfeatures[9]]=2
database[32].weights[database[32].sfeatures[10]]=7
database[32].weights[database[32].sfeatures[11]]=-4
database[32].weights[database[32].sfeatures[12]]=4
database[32].weights[database[32].sfeatures[13]]=-5
database[32].weights[database[32].sfeatures[14]]=1
database[33].weights[database[33].efeatures[1]]=17
database[33].weights[database[33].efeatures[2]]=4
database[33].weights[database[33].efeatures[3]]=16
database[33].weights[database[33].efeatures[4]]=9
database[33].weights[database[33].efeatures[5]]=17
database[33].weights[database[33].efeatures[6]]=10
database[33].weights[database[33].efeatures[7]]=-1
database[33].weights[database[33].efeatures[8]]=9
database[33].weights[database[33].efeatures[9]]=2
database[33].weights[database[33].efeatures[10]]=4
database[33].weights[database[33].sfeatures[1]]=17
database[33].weights[database[33].sfeatures[2]]=4
database[33].weights[database[33].sfeatures[3]]=16
database[33].weights[database[33].sfeatures[4]]=9
database[33].weights[database[33].sfeatures[5]]=17
database[33].weights[database[33].sfeatures[6]]=5
database[33].weights[database[33].sfeatures[7]]=-1
database[33].weights[database[33].sfeatures[8]]=28
database[33].weights[database[33].sfeatures[9]]=10
database[33].weights[database[33].sfeatures[10]]=9
database[33].weights[database[33].sfeatures[11]]=-1
database[33].weights[database[33].sfeatures[12]]=3
database[33].weights[database[33].sfeatures[13]]=-1
database[33].weights[database[33].sfeatures[14]]=6
database[34].weights[database[34].efeatures[1]]=9
database[34].weights[database[34].efeatures[2]]=10
database[34].weights[database[34].efeatures[3]]=10
database[34].weights[database[34].efeatures[4]]=11
database[34].weights[database[34].efeatures[5]]=7
database[34].weights[database[34].efeatures[6]]=4
database[34].weights[database[34].efeatures[7]]=11
database[34].weights[database[34].efeatures[8]]=6
database[34].weights[database[34].sfeatures[1]]=9
database[34].weights[database[34].sfeatures[2]]=10
database[34].weights[database[34].sfeatures[3]]=10
database[34].weights[database[34].sfeatures[4]]=11
database[34].weights[database[34].sfeatures[5]]=7
database[34].weights[database[34].sfeatures[6]]=10
database[34].weights[database[34].sfeatures[7]]=4
database[34].weights[database[34].sfeatures[8]]=4
database[34].weights[database[34].sfeatures[9]]=7
database[34].weights[database[34].sfeatures[10]]=11
database[34].weights[database[34].sfeatures[11]]=13
database[35].weights[database[35].efeatures[1]]=10
database[35].weights[database[35].efeatures[2]]=7
database[35].weights[database[35].efeatures[3]]=7
database[35].weights[database[35].efeatures[4]]=7
database[35].weights[database[35].efeatures[5]]=6
database[35].weights[database[35].efeatures[6]]=7
database[35].weights[database[35].efeatures[7]]=10
database[35].weights[database[35].efeatures[8]]=4
database[35].weights[database[35].sfeatures[1]]=10
database[35].weights[database[35].sfeatures[2]]=7
database[35].weights[database[35].sfeatures[3]]=7
database[35].weights[database[35].sfeatures[4]]=7
database[35].weights[database[35].sfeatures[5]]=6
database[35].weights[database[35].sfeatures[6]]=10
database[35].weights[database[35].sfeatures[7]]=11
database[35].weights[database[35].sfeatures[8]]=7
database[35].weights[database[35].sfeatures[9]]=10
database[35].weights[database[35].sfeatures[10]]=9
database[35].weights[database[35].sfeatures[11]]=8
database[36].weights[database[36].efeatures[1]]=1
database[36].weights[database[36].efeatures[2]]=3
database[36].weights[database[36].efeatures[3]]=4
database[36].weights[database[36].efeatures[4]]=9
database[36].weights[database[36].efeatures[5]]=3
database[36].weights[database[36].efeatures[6]]=-1
database[36].weights[database[36].efeatures[7]]=16
database[36].weights[database[36].efeatures[8]]=3
database[36].weights[database[36].efeatures[9]]=-4
database[36].weights[database[36].efeatures[10]]=6
database[36].weights[database[36].efeatures[11]]=3
database[36].weights[database[36].sfeatures[1]]=1
database[36].weights[database[36].sfeatures[2]]=3
database[36].weights[database[36].sfeatures[3]]=4
database[36].weights[database[36].sfeatures[4]]=9
database[36].weights[database[36].sfeatures[5]]=3
database[36].weights[database[36].sfeatures[6]]=-4
database[36].weights[database[36].sfeatures[7]]=-1
database[36].weights[database[36].sfeatures[8]]=6
database[36].weights[database[36].sfeatures[9]]=-1
database[36].weights[database[36].sfeatures[10]]=-1
database[36].weights[database[36].sfeatures[11]]=3
database[36].weights[database[36].sfeatures[12]]=3
database[36].weights[database[36].sfeatures[13]]=4
database[36].weights[database[36].sfeatures[14]]=5
database[36].weights[database[36].sfeatures[15]]=2
database[36].weights[database[36].sfeatures[16]]=3
database[36].weights[database[36].sfeatures[17]]=0
database[36].weights[database[36].sfeatures[18]]=0
database[36].weights[database[36].sfeatures[19]]=7
database[37].weights[database[37].efeatures[1]]=5
database[37].weights[database[37].efeatures[2]]=8
database[37].weights[database[37].efeatures[3]]=3
database[37].weights[database[37].efeatures[4]]=6
database[37].weights[database[37].efeatures[5]]=8
database[37].weights[database[37].efeatures[6]]=6
database[37].weights[database[37].efeatures[7]]=6
database[37].weights[database[37].efeatures[8]]=8
database[37].weights[database[37].efeatures[9]]=2
database[37].weights[database[37].efeatures[10]]=7
database[37].weights[database[37].sfeatures[1]]=5
database[37].weights[database[37].sfeatures[2]]=8
database[37].weights[database[37].sfeatures[3]]=3
database[37].weights[database[37].sfeatures[4]]=6
database[37].weights[database[37].sfeatures[5]]=8
database[37].weights[database[37].sfeatures[6]]=5
database[37].weights[database[37].sfeatures[7]]=4
database[37].weights[database[37].sfeatures[8]]=6
database[37].weights[database[37].sfeatures[9]]=5
database[37].weights[database[37].sfeatures[10]]=7
database[37].weights[database[37].sfeatures[11]]=8
database[38].weights[database[38].efeatures[1]]=6
database[38].weights[database[38].efeatures[2]]=8
database[38].weights[database[38].efeatures[3]]=5
database[38].weights[database[38].efeatures[4]]=10
database[38].weights[database[38].efeatures[5]]=5
database[38].weights[database[38].efeatures[6]]=5
database[38].weights[database[38].efeatures[7]]=8
database[38].weights[database[38].efeatures[8]]=4
database[38].weights[database[38].sfeatures[1]]=6
database[38].weights[database[38].sfeatures[2]]=8
database[38].weights[database[38].sfeatures[3]]=5
database[38].weights[database[38].sfeatures[4]]=10
database[38].weights[database[38].sfeatures[5]]=5
database[38].weights[database[38].sfeatures[6]]=7
database[38].weights[database[38].sfeatures[7]]=3
database[38].weights[database[38].sfeatures[8]]=5
database[38].weights[database[38].sfeatures[9]]=12
database[38].weights[database[38].sfeatures[10]]=7
database[38].weights[database[38].sfeatures[11]]=9
database[38].weights[database[38].sfeatures[12]]=6
database[39].weights[database[39].efeatures[1]]=7
database[39].weights[database[39].efeatures[2]]=8
database[39].weights[database[39].efeatures[3]]=10
database[39].weights[database[39].efeatures[4]]=9
database[39].weights[database[39].efeatures[5]]=5
database[39].weights[database[39].efeatures[6]]=10
database[39].weights[database[39].efeatures[7]]=9
database[39].weights[database[39].efeatures[8]]=7
database[39].weights[database[39].sfeatures[1]]=7
database[39].weights[database[39].sfeatures[2]]=8
database[39].weights[database[39].sfeatures[3]]=10
database[39].weights[database[39].sfeatures[4]]=9
database[39].weights[database[39].sfeatures[5]]=5
database[39].weights[database[39].sfeatures[6]]=11
database[39].weights[database[39].sfeatures[7]]=6
database[39].weights[database[39].sfeatures[8]]=10
database[39].weights[database[39].sfeatures[9]]=10
database[39].weights[database[39].sfeatures[10]]=8
database[39].weights[database[39].sfeatures[11]]=8
database[40].weights[database[40].efeatures[1]]=11
database[40].weights[database[40].efeatures[2]]=7
database[40].weights[database[40].efeatures[3]]=9
database[40].weights[database[40].efeatures[4]]=5
database[40].weights[database[40].efeatures[5]]=9
database[40].weights[database[40].efeatures[6]]=12
database[40].weights[database[40].efeatures[7]]=8
database[40].weights[database[40].efeatures[8]]=10
database[40].weights[database[40].sfeatures[1]]=11
database[40].weights[database[40].sfeatures[2]]=7
database[40].weights[database[40].sfeatures[3]]=9
database[40].weights[database[40].sfeatures[4]]=5
database[40].weights[database[40].sfeatures[5]]=9
database[40].weights[database[40].sfeatures[6]]=4
database[40].weights[database[40].sfeatures[7]]=11
database[40].weights[database[40].sfeatures[8]]=12
database[40].weights[database[40].sfeatures[9]]=8
database[41].weights[database[41].efeatures[1]]=14
database[41].weights[database[41].efeatures[2]]=12
database[41].weights[database[41].efeatures[3]]=11
database[41].weights[database[41].efeatures[4]]=9
database[41].weights[database[41].efeatures[5]]=15
database[41].weights[database[41].efeatures[6]]=15
database[41].weights[database[41].efeatures[7]]=16
database[41].weights[database[41].efeatures[8]]=7
database[41].weights[database[41].sfeatures[1]]=14
database[41].weights[database[41].sfeatures[2]]=12
database[41].weights[database[41].sfeatures[3]]=11
database[41].weights[database[41].sfeatures[4]]=9
database[41].weights[database[41].sfeatures[5]]=15
database[41].weights[database[41].sfeatures[6]]=13
database[41].weights[database[41].sfeatures[7]]=10
database[41].weights[database[41].sfeatures[8]]=15
database[41].weights[database[41].sfeatures[9]]=16
database[42].weights[database[42].efeatures[1]]=1
database[42].weights[database[42].efeatures[2]]=4
database[42].weights[database[42].efeatures[3]]=5
database[42].weights[database[42].efeatures[4]]=3
database[42].weights[database[42].efeatures[5]]=5
database[42].weights[database[42].efeatures[6]]=3
database[42].weights[database[42].efeatures[7]]=1
database[42].weights[database[42].efeatures[8]]=3
database[42].weights[database[42].efeatures[9]]=2
database[42].weights[database[42].efeatures[10]]=2
database[42].weights[database[42].efeatures[11]]=3
database[42].weights[database[42].sfeatures[1]]=1
database[42].weights[database[42].sfeatures[2]]=4
database[42].weights[database[42].sfeatures[3]]=5
database[42].weights[database[42].sfeatures[4]]=3
database[42].weights[database[42].sfeatures[5]]=5
database[42].weights[database[42].sfeatures[6]]=2
database[42].weights[database[42].sfeatures[7]]=4
database[42].weights[database[42].sfeatures[8]]=5
database[42].weights[database[42].sfeatures[9]]=3
database[42].weights[database[42].sfeatures[10]]=5
database[42].weights[database[42].sfeatures[11]]=4
database[42].weights[database[42].sfeatures[12]]=5
database[42].weights[database[42].sfeatures[13]]=3
database[42].weights[database[42].sfeatures[14]]=3
database[42].weights[database[42].sfeatures[15]]=2
database[42].weights[database[42].sfeatures[16]]=3
database[42].weights[database[42].sfeatures[17]]=3
database[42].weights[database[42].sfeatures[18]]=3
database[42].weights[database[42].sfeatures[19]]=3
database[43].weights[database[43].efeatures[1]]=2
database[43].weights[database[43].efeatures[2]]=4
database[43].weights[database[43].efeatures[3]]=3
database[43].weights[database[43].efeatures[4]]=2
database[43].weights[database[43].efeatures[5]]=5
database[43].weights[database[43].efeatures[6]]=4
database[43].weights[database[43].efeatures[7]]=4
database[43].weights[database[43].efeatures[8]]=4
database[43].weights[database[43].efeatures[9]]=3
database[43].weights[database[43].efeatures[10]]=3
database[43].weights[database[43].efeatures[11]]=2
database[43].weights[database[43].sfeatures[1]]=2
database[43].weights[database[43].sfeatures[2]]=4
database[43].weights[database[43].sfeatures[3]]=3
database[43].weights[database[43].sfeatures[4]]=2
database[43].weights[database[43].sfeatures[5]]=5
database[43].weights[database[43].sfeatures[6]]=3
database[43].weights[database[43].sfeatures[7]]=3
database[43].weights[database[43].sfeatures[8]]=4
database[43].weights[database[43].sfeatures[9]]=2
database[43].weights[database[43].sfeatures[10]]=4
database[43].weights[database[43].sfeatures[11]]=3
database[43].weights[database[43].sfeatures[12]]=3
database[43].weights[database[43].sfeatures[13]]=3
database[43].weights[database[43].sfeatures[14]]=3
database[43].weights[database[43].sfeatures[15]]=2
database[43].weights[database[43].sfeatures[16]]=3
database[43].weights[database[43].sfeatures[17]]=3
database[43].weights[database[43].sfeatures[18]]=2
database[43].weights[database[43].sfeatures[19]]=3
database[43].weights[database[43].sfeatures[20]]=3
database[44].weights[database[44].efeatures[1]]=7
database[44].weights[database[44].efeatures[2]]=10
database[44].weights[database[44].efeatures[3]]=9
database[44].weights[database[44].efeatures[4]]=8
database[44].weights[database[44].efeatures[5]]=12
database[44].weights[database[44].efeatures[6]]=6
database[44].weights[database[44].efeatures[7]]=6
database[44].weights[database[44].efeatures[8]]=9
database[44].weights[database[44].sfeatures[1]]=7
database[44].weights[database[44].sfeatures[2]]=10
database[44].weights[database[44].sfeatures[3]]=9
database[44].weights[database[44].sfeatures[4]]=8
database[44].weights[database[44].sfeatures[5]]=12
database[44].weights[database[44].sfeatures[6]]=9
database[44].weights[database[44].sfeatures[7]]=9
database[44].weights[database[44].sfeatures[8]]=6
database[44].weights[database[44].sfeatures[9]]=11
database[44].weights[database[44].sfeatures[10]]=10
database[44].weights[database[44].sfeatures[11]]=8
database[45].weights[database[45].efeatures[1]]=6
database[45].weights[database[45].efeatures[2]]=4
database[45].weights[database[45].efeatures[3]]=3
database[45].weights[database[45].efeatures[4]]=4
database[45].weights[database[45].efeatures[5]]=8
database[45].weights[database[45].efeatures[6]]=6
database[45].weights[database[45].efeatures[7]]=7
database[45].weights[database[45].efeatures[8]]=8
database[45].weights[database[45].sfeatures[1]]=6
database[45].weights[database[45].sfeatures[2]]=4
database[45].weights[database[45].sfeatures[3]]=3
database[45].weights[database[45].sfeatures[4]]=4
database[45].weights[database[45].sfeatures[5]]=8
database[45].weights[database[45].sfeatures[6]]=6
database[45].weights[database[45].sfeatures[7]]=9
database[45].weights[database[45].sfeatures[8]]=6
database[45].weights[database[45].sfeatures[9]]=5
database[45].weights[database[45].sfeatures[10]]=6
database[45].weights[database[45].sfeatures[11]]=9
database[45].weights[database[45].sfeatures[12]]=5
database[46].weights[database[46].efeatures[1]]=6
database[46].weights[database[46].efeatures[2]]=6
database[46].weights[database[46].efeatures[3]]=3
database[46].weights[database[46].efeatures[4]]=6
database[46].weights[database[46].efeatures[5]]=8
database[46].weights[database[46].efeatures[6]]=7
database[46].weights[database[46].efeatures[7]]=10
database[46].weights[database[46].efeatures[8]]=8
database[46].weights[database[46].sfeatures[1]]=6
database[46].weights[database[46].sfeatures[2]]=6
database[46].weights[database[46].sfeatures[3]]=3
database[46].weights[database[46].sfeatures[4]]=6
database[46].weights[database[46].sfeatures[5]]=8
database[46].weights[database[46].sfeatures[6]]=6
database[46].weights[database[46].sfeatures[7]]=7
database[46].weights[database[46].sfeatures[8]]=5
database[46].weights[database[46].sfeatures[9]]=9
database[46].weights[database[46].sfeatures[10]]=7
database[46].weights[database[46].sfeatures[11]]=8
database[46].weights[database[46].sfeatures[12]]=8


text:
#=
    when it is known of num::T, den::T
    or given by construction that
       den > 0
       use FastRational{T}(num, den)
           - skip checking for zero or negative denominator

    when it is known of num::T, den::T
    or given by construction that
    or may be the case that
       den < 0 && den != typemin(T)
       use FastRationalChecked(num, den)
           - check for zero or negative denominator

    when it is known of num::T, den::T
    or given by construction that
    or may be the case that
       den == typemin(T)
       use FastRationalGuarded(num, den)
           - check for typemin(T) in denominator
           - check for zero or negative denominator
=#

basetype(::Type{FastRational{T}}) where T = T
basetype(::Type{Rational{T}}) where T = T
basetype(x) = basetype(typeof(x))

typemax(::Type{FastRational{T}}) where T = FastRational(typemax(T))
typemin(::Type{FastRational{T}}) where T = FastRational(typemin(T))

widen(::Type{FastRational{T}}) where T = FastRational{widen(T)}

FastRational{T}(x::Integer) where T = FastRational{T}(T(x), one(T), Val(true))
FastRational{T}(x::FastRational) where T = FastRational{T}(x.num, x.den)
FastRational(x::FastRational{T}) where T = FastRational{T}(x.num, x.den)
FastRational{T}(x::Rational) where T = FastRational{T}(x.num, x.den)
FastRational(x::Rational{T}) where T = FastRational{T}(x.num, x.den)
Rational{T}(x::FastRational) where T = Rational{T}(x.num, x.den)
Rational(x::FastRational{T}) where T = Rational{T}(x.num, x.den)

string(x::FastRational) = string(x.num//x.den)
show(io::IO, x::FastRational) = show(io, x.num//x.den)

zero(::Type{FastRational{T}}) where T = FastRational{T}(zero(T), one(T), Val(true))
one(::Type{FastRational{T}}) where T = FastRational{T}(one(T), one(T), Val(true))

iszero(x::FastRational{T}) where T = iszero(x.num)
isone(x::FastRational) where T = x.num === x.den
isinteger(x::FastRational) = iszero(x.num % x.den)
function iseven(x::FastRational)
    d, r = divrem(x.num, x.den)
    r == 0 && iseven(d)
end
function isodd(x::FastRational{T}) where {T<:SUN}
    d, r = divrem(x.num, x.den)
    r == 0 && isodd(d)
end

isfinite(x::FastRational) = true
isinf(x::FastRational) = false
isnan(x::FastRational) = false

signbit(x::FastRational) = xor(signbit(x.num), signbit(x.den))
sign(x::FastRational) = iszero(x) ? zero(x) : signbit(x) ? oftype(x, -1) : one(x)
abs(x::FastRational) = signbit(x) ? -x : x
abs2(x::FastRational) = x * x
-(x::FastRational{T}) where T = FastRational{T}(-x.num, x.den, Val(true))

function inv(x::FastRational{T}) where T
    den, num = x.num >= 0 ? (x.num, x.den) : (-x.num, -x.den)
    den > 0 || throw(DivideError())
    FastRational{T}(num, den, Val(true))
end

copysign(x::FastRational, y::Real) = signbit(y) ? -abs(x) : abs(x)
flipsign(x::FastRational, y::Real)= signbit(y) ? -x : x

==(x::FastRational, y::FastRational) = widemul(x.num, y.den) == widemul(x.den, y.num)

<=(x::FastRational, y::FastRational) = widemul(x.num, y.den) <= widemul(x.den, y.num)
<(x::FastRational, y::FastRational) = widemul(x.num, y.den) < widemul(x.den, y.num)

cmp(x::FastRational, y::FastRational) = cmp(widemul(x.num, y.den), widemul(x.den, y.num))

function +(x::FastRational{T}, y::FastRational{T}) where T
    num, den, ovf = addovf(x, y)
    !ovf && return FastRational{T}(num, den, Val(true))
    numer, denom = addq(widen(x.num), widen(x.den), widen(y.num), widen(y.den))
    numer, denom = canonical(numer, denom)
    return FastRational{T}(T(numer), T(denom), Val(true))
end

function -(x::FastRational{T}, y::FastRational{T}) where T
    num, den, ovf = subovf(x, y)
    !ovf && return FastRational{T}(num, den, Val(true))
    numer, denom = subq(widen(x.num), widen(x.den), widen(y.num), widen(y.den))
    numer, denom = canonical(numer, denom)
    return FastRational{T}(T(numer), T(denom), Val(true))
end

function *(x::FastRational{T}, y::FastRational{T}) where T
    num, den, ovf = mulovf(x, y)
    !ovf && return FastRational{T}(num, den, Val(true))
    numer, denom = mulq(widen(x.num), widen(x.den), widen(y.num), widen(y.den))
    numer, denom = canonical(numer, denom)
    return FastRational{T}(T(numer), T(denom), Val(true))
end

function /(x::FastRational{T}, y::FastRational{T}) where T
    num, den, ovf = divovf(x, y)
    if !ovf
        den > 0 || throw(DivideError())
        return FastRational{T}(num, den, Val(true))
    end
    numer, denom = divq(widen(x.num), widen(x.den), widen(y.num), widen(y.den))
    numer, denom = canonical(numer, denom)
    den = denom%T
    0 < den < typemax(T) || throw(DivideError())
    return FastRational{T}(T(numer), den, Val(true))
end

@inline function addovf(x::FastRational{T}, y::FastRational{T}) where {T<:SUN}
    num1, ovf  = mul_with_overflow(x.num, y.den)
    num2, ovfl = mul_with_overflow(x.den, y.num)
    ovf |= ovfl
    num, ovfl = add_with_overflow(num1, num2)
    ovf |= ovfl
    den, ovfl = mul_with_overflow(x.den, y.den)
    ovf |= ovfl
    return num, den, ovf
end

@inline function subovf(x::FastRational{T}, y::FastRational{T}) where {T<:SUN}
    num1, ovf  = mul_with_overflow(x.num, y.den)
    num2, ovfl = mul_with_overflow(x.den, y.num)
    ovf |= ovfl
    num, ovfl = sub_with_overflow(num1, num2)
    ovf |= ovfl
    den, ovfl = mul_with_overflow(x.den, y.den)
    ovf |= ovfl
    return num, den, ovf
end

@inline function mulovf(x::FastRational{T}, y::FastRational{T}) where {T<:SUN}
    num, ovf  = mul_with_overflow(x.num, y.num)
    den, ovfl = mul_with_overflow(x.den, y.den)
    ovf |= ovfl
    return num, den, ovf
end

@inline function divovf(x::FastRational{T}, y::FastRational{T}) where {T<:SUN}
    num, ovf  = mul_with_overflow(x.num, y.den)
    den, ovfl = mul_with_overflow(x.den, y.num)
    ovf |= ovfl | signbit(den)
    return num, den, ovf
end

@inline function addq(xnum::T, xden::T, ynum::T, yden::T) where {T<:SUN}
    num1 = xnum * yden
    num2 = xden * ynum
    num = num1 + num2
    den = xden * yden
    return num, den
end

@inline function subq(xnum::T, xden::T, ynum::T, yden::T) where {T<:SUN}
    num1 = xnum * yden
    num2 = xden * ynum
    num = num1 - num2
    den = xden * yden
    return num, den
end

@inline function mulq(xnum::T, xden::T, ynum::T, yden::T) where {T<:SUN}
    num = xnum * ynum
    den = xden * yden
    return num, den
end

@inline function divq(xnum::T, xden::T, ynum::T, yden::T) where {T<:SUN}
    num = xnum * yden
    den = xden * ynum
    return num, den
end

import Base.power_by_squaring
function ^(x::FastRational, n::Integer)
    n >= 0 ? power_by_squaring(x,n) : power_by_squaring(inv(x),-n)
end

//(x::FastRational{T}, y::SUN) where {T<:SUN} = x / FastRational{T}(y)
//(x::SUN, y::FastRational{T}) where {T<:SUN} = FastRational{T}(x) / y
//(x::FastRational{T}, y::FastRational{T}) where {T<:SUN} = x / y
//(x::FastRational{T}, y::Rational) where {T<:SUN} = x / FastRational{T}(y)
//(x::Rational, y::FastRational{T}) where {T<:SUN} = FastRational{T}(x) / y

Base.decompose(x::FastRational{T}) where T<:Union{Signed,Unsigned} = Base.decompose(x.num // x.den)

ext: jl


text:
using TransferFunctionGPKernel
using Test

@testset "TransferFunctionGPKernel.jl" begin
    # Write your tests here.
end


text:
using SciPy
using Test

@testset "SciPy.jl" begin
    # Print configulations before start testings.
    print_configulations()

    @testset "cluster" begin
        features  = [[ 1.9  2.3];
                    [ 1.5 2.5];
                    [ 0.8 0.6];
                    [ 0.4 1.8];
                    [ 0.1 0.1];
                    [ 0.2 1.8];
                    [ 2.0 0.5];
                    [ 0.3 1.5];
                    [ 1.0 1.0]]
        whitened = cluster.vq.whiten(features)
        @test whitened[1, 1] == 2.739596711878806
    end

    @testset "constants" begin
        @test constants.golden == 1.618033988749895
    end

    @testset "fft" begin
        fft = SciPy.fft.fft(exp.(π/8 * collect(1:8)))
        @test length(fft) == 8
    end

    @testset "integrate" begin
        f(x) = x^2
        result = SciPy.integrate.quad(f, 0, 4)
        @test result[1] == 21.333333333333336
    end

    @testset "interpolate" begin
        include("interpolateTest.jl")
    end

    @testset "stats" begin
        include("statsTest.jl")
    end

    @testset "optimize" begin
        include("optimizeTest.jl")
    end

    @testset "spatial" begin
        include("spatialTest.jl")
    end

end


text:
# Parts of this code were taken / derived from Graphs.jl. See LICENSE for
# licensing details.

# The Bellman Ford algorithm for single-source shortest path

###################################################################
#
#   The type that capsulates the state of Bellman Ford algorithm
#
###################################################################

struct NegativeCycleError <: Exception end

# AbstractPathState is defined in core
mutable struct BellmanFordState{V,T<:Real} <: AbstractPathState
    parents::Vector{V}
    dists::Vector{T}
end

"""
    bellman_ford_shortest_paths(g, s, distmx=weights(g))
    bellman_ford_shortest_paths(g, sources, distmx=weights(g))

Uses the [Bellman-Ford algorithm](http://en.wikipedia.org/wiki/Bellman–Ford_algorithm)
to compute shortest paths of all vertices of a `g` from a source vertex `s` (or a set of source
vertices `sources`). Returns a `BellmanFordState` with relevant traversal information.
"""
function bellman_ford_shortest_paths(
        g::AGraphOrDiGraph,
        sources::AbstractVector{Int},
        distmx::AEdgeMap{T},
    ) where T<:Real
    state = BellmanFordState(zeros(Int,nv(g)), fill(typemax(T), nv(g)))
    V = vertextype(g)
    active = Set{V}()
    for v in sources
        state.dists[v] = 0
        state.parents[v] = 0
        push!(active, v)
    end
    no_changes = false
    for i in 1:nv(g)
        no_changes = true
        new_active = Set{V}()
        for u in active
            for e in out_edges(g, u)
                v = dst(e)
                edist = distmx[e]
                if state.dists[v] > state.dists[u] + edist
                    state.dists[v] = state.dists[u] + edist
                    state.parents[v] = u
                    no_changes = false
                    push!(new_active, v)
                end
            end
        end
        if no_changes
            break
        end
        active = new_active
    end
    no_changes || throw(NegativeCycleError())
    return state
end

function bellman_ford_shortest_paths(
        g::AGraphOrDiGraph,
        sources::AbstractVector{Int})

    bellman_ford_shortest_paths(g, sources, weights(g))
end

bellman_ford_shortest_paths(
    g::AGraphOrDiGraph,
    v::Int,
    distmx::AEdgeMap=weights(g)
) = bellman_ford_shortest_paths(g, [v], distmx)

function has_negative_edge_cycle(g::AGraphOrDiGraph)
    try
        bellman_ford_shortest_paths(g, vertices(g))
    catch e
        isa(e, NegativeCycleError) && return true
    end
    return false
end


text:
# This file is a part of Julia. License is MIT: https://julialang.org/license

# name and module reflection

"""
    nameof(m::Module) -> Symbol

Get the name of a `Module` as a `Symbol`.

# Examples
```jldoctest
julia> nameof(Base.Broadcast)
:Broadcast
```
"""
nameof(m::Module) = ccall(:jl_module_name, Ref{Symbol}, (Any,), m)

"""
    parentmodule(m::Module) -> Module

Get a module's enclosing `Module`. `Main` is its own parent.

# Examples
```jldoctest
julia> parentmodule(Main)
Main

julia> parentmodule(Base.Broadcast)
Base
```
"""
parentmodule(m::Module) = ccall(:jl_module_parent, Ref{Module}, (Any,), m)

"""
    moduleroot(m::Module) -> Module

Find the root module of a given module. This is the first module in the chain of
parent modules of `m` which is either a registered root module or which is its
own parent module.
"""
function moduleroot(m::Module)
    while true
        is_root_module(m) && return m
        p = parentmodule(m)
        p == m && return m
        m = p
    end
end

"""
    @__MODULE__ -> Module

Get the `Module` of the toplevel eval,
which is the `Module` code is currently being read from.
"""
macro __MODULE__()
    return __module__
end

"""
    fullname(m::Module)

Get the fully-qualified name of a module as a tuple of symbols. For example,

# Examples
```jldoctest
julia> fullname(Base.Iterators)
(:Base, :Iterators)

julia> fullname(Main)
(:Main,)
```
"""
function fullname(m::Module)
    mn = nameof(m)
    if m === Main || m === Base || m === Core
        return (mn,)
    end
    mp = parentmodule(m)
    if mp === m
        return (mn,)
    end
    return (fullname(mp)..., mn)
end

"""
    names(x::Module; all::Bool = false, imported::Bool = false)

Get an array of the names exported by a `Module`, excluding deprecated names.
If `all` is true, then the list also includes non-exported names defined in the module,
deprecated names, and compiler-generated names.
If `imported` is true, then names explicitly imported from other modules
are also included.

As a special case, all names defined in `Main` are considered \"exported\",
since it is not idiomatic to explicitly export names from `Main`.
"""
names(m::Module; all::Bool = false, imported::Bool = false) =
    sort!(ccall(:jl_module_names, Array{Symbol,1}, (Any, Cint, Cint), m, all, imported))

isexported(m::Module, s::Symbol) = ccall(:jl_module_exports_p, Cint, (Any, Any), m, s) != 0
isdeprecated(m::Module, s::Symbol) = ccall(:jl_is_binding_deprecated, Cint, (Any, Any), m, s) != 0
isbindingresolved(m::Module, var::Symbol) = ccall(:jl_binding_resolved_p, Cint, (Any, Any), m, var) != 0

function binding_module(m::Module, s::Symbol)
    p = ccall(:jl_get_module_of_binding, Ptr{Cvoid}, (Any, Any), m, s)
    p == C_NULL && return m
    return unsafe_pointer_to_objref(p)::Module
end

function resolve(g::GlobalRef; force::Bool=false)
    if force || isbindingresolved(g.mod, g.name)
        return GlobalRef(binding_module(g.mod, g.name), g.name)
    end
    return g
end

const NamedTuple_typename = NamedTuple.body.body.name

function _fieldnames(@nospecialize t)
    if t.name === NamedTuple_typename
        if t.parameters[1] isa Tuple
            return t.parameters[1]
        else
            throw(ArgumentError("type does not have definite field names"))
        end
    end
    isdefined(t, :names) ? t.names : t.name.names
end

"""
    fieldname(x::DataType, i::Integer)

Get the name of field `i` of a `DataType`.

# Examples
```jldoctest
julia> fieldname(Rational, 1)
:num

julia> fieldname(Rational, 2)
:den
```
"""
function fieldname(t::DataType, i::Integer)
    if t.abstract
        throw(ArgumentError("type does not have definite field names"))
    end
    names = _fieldnames(t)
    n_fields = length(names)
    field_label = n_fields == 1 ? "field" : "fields"
    i > n_fields && throw(ArgumentError("Cannot access field $i since type $t only has $n_fields $field_label."))
    i < 1 && throw(ArgumentError("Field numbers must be positive integers. $i is invalid."))
    return names[i]::Symbol
end

fieldname(t::UnionAll, i::Integer) = fieldname(unwrap_unionall(t), i)
fieldname(t::Type{<:Tuple}, i::Integer) =
    i < 1 || i > fieldcount(t) ? throw(BoundsError(t, i)) : Int(i)

"""
    fieldnames(x::DataType)

Get a tuple with the names of the fields of a `DataType`.

# Examples
```jldoctest
julia> fieldnames(Rational)
(:num, :den)
```
"""
fieldnames(t::DataType) = (fieldcount(t); # error check to make sure type is specific enough
                           (_fieldnames(t)...,))
fieldnames(t::UnionAll) = fieldnames(unwrap_unionall(t))
fieldnames(::Core.TypeofBottom) =
    throw(ArgumentError("The empty type does not have field names since it does not have instances."))
fieldnames(t::Type{<:Tuple}) = ntuple(identity, fieldcount(t))

"""
    nameof(t::DataType) -> Symbol

Get the name of a (potentially `UnionAll`-wrapped) `DataType` (without its parent module)
as a symbol.

# Examples
```jldoctest
julia> module Foo
           struct S{T}
           end
       end
Foo

julia> nameof(Foo.S{T} where T)
:S
```
"""
nameof(t::DataType) = t.name.name
nameof(t::UnionAll) = nameof(unwrap_unionall(t))

"""
    parentmodule(t::DataType) -> Module

Determine the module containing the definition of a (potentially `UnionAll`-wrapped) `DataType`.

# Examples
```jldoctest
julia> module Foo
           struct Int end
       end
Foo

julia> parentmodule(Int)
Core

julia> parentmodule(Foo.Int)
Foo
```
"""
parentmodule(t::DataType) = t.name.module
parentmodule(t::UnionAll) = parentmodule(unwrap_unionall(t))

"""
    isconst(m::Module, s::Symbol) -> Bool

Determine whether a global is declared `const` in a given `Module`.
"""
isconst(m::Module, s::Symbol) =
    ccall(:jl_is_const, Cint, (Any, Any), m, s) != 0

"""
    @isdefined s -> Bool

Tests whether variable `s` is defined in the current scope.

# Examples
```jldoctest
julia> function f()
           println(@isdefined x)
           x = 3
           println(@isdefined x)
       end
f (generic function with 1 method)

julia> f()
false
true
```
"""
macro isdefined(s::Symbol)
    return Expr(:isdefined, esc(s))
end

"""
    objectid(x)

Get a hash value for `x` based on object identity. `objectid(x)==objectid(y)` if `x === y`.
"""
objectid(@nospecialize(x)) = ccall(:jl_object_id, UInt, (Any,), x)

# concrete datatype predicates

struct DataTypeLayout
    nfields::UInt32
    alignment::UInt32
    # alignment : 28;
    # haspadding : 1;
    # pointerfree : 1;
    # fielddesc_type : 2;
end

"""
    Base.datatype_alignment(dt::DataType) -> Int

Memory allocation minimum alignment for instances of this type.
Can be called on any `isconcretetype`.
"""
function datatype_alignment(dt::DataType)
    @_pure_meta
    dt.layout == C_NULL && throw(UndefRefError())
    alignment = unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).alignment
    return Int(alignment & 0x1FF)
end

"""
    Base.datatype_haspadding(dt::DataType) -> Bool

Return whether the fields of instances of this type are packed in memory,
with no intervening padding bytes.
Can be called on any `isconcretetype`.
"""
function datatype_haspadding(dt::DataType)
    @_pure_meta
    dt.layout == C_NULL && throw(UndefRefError())
    alignment = unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).alignment
    return (alignment >> 9) & 1 == 1
end

"""
    Base.datatype_pointerfree(dt::DataType) -> Bool

Return whether instances of this type can contain references to gc-managed memory.
Can be called on any `isconcretetype`.
"""
function datatype_pointerfree(dt::DataType)
    @_pure_meta
    dt.layout == C_NULL && throw(UndefRefError())
    alignment = unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).alignment
    return (alignment >> 10) & 0xFFFFF == 0
end

"""
    Base.datatype_fielddesc_type(dt::DataType) -> Int

Return the size in bytes of each field-description entry in the layout array,
located at `(dt.layout + sizeof(DataTypeLayout))`.
Can be called on any `isconcretetype`.

See also [`Base.fieldoffset`](@ref).
"""
function datatype_fielddesc_type(dt::DataType)
    @_pure_meta
    dt.layout == C_NULL && throw(UndefRefError())
    alignment = unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).alignment
    return (alignment >> 30) & 3
end

"""
    isimmutable(v) -> Bool

Return `true` iff value `v` is immutable.  See [Mutable Composite Types](@ref)
for a discussion of immutability. Note that this function works on values, so if you give it
a type, it will tell you that a value of `DataType` is mutable.

# Examples
```jldoctest
julia> isimmutable(1)
true

julia> isimmutable([1,2])
false
```
"""
isimmutable(@nospecialize(x)) = (@_pure_meta; !typeof(x).mutable)

"""
    Base.isstructtype(T) -> Bool

Determine whether type `T` was declared as a struct type
(i.e. using the `struct` or `mutable struct` keyword).
"""
function isstructtype(@nospecialize(t::Type))
    @_pure_meta
    t = unwrap_unionall(t)
    # TODO: what to do for `Union`?
    isa(t, DataType) || return false
    return length(t.types) != 0 || (t.size == 0 && !t.abstract)
end

"""
    Base.isprimitivetype(T) -> Bool

Determine whether type `T` was declared as a primitive type
(i.e. using the `primitive` keyword).
"""
function isprimitivetype(@nospecialize(t::Type))
    @_pure_meta
    t = unwrap_unionall(t)
    # TODO: what to do for `Union`?
    isa(t, DataType) || return false
    return length(t.types) == 0 && t.size != 0 && !t.abstract
end

"""
    isbitstype(T)

Return `true` if type `T` is a "plain data" type,
meaning it is immutable and contains no references to other values,
only `primitive` types and other `isbitstype` types.
Typical examples are numeric types such as [`UInt8`](@ref),
[`Float64`](@ref), and [`Complex{Float64}`](@ref).
This category of types is significant since they are valid as type parameters,
may not track [`isdefined`](@ref) / [`isassigned`](@ref) status,
and have a defined layout that is compatible with C.

# Examples
```jldoctest
julia> isbitstype(Complex{Float64})
true

julia> isbitstype(Complex)
false
```
"""
isbitstype(@nospecialize(t::Type)) = (@_pure_meta; isa(t, DataType) && t.isbitstype)

"""
    isbits(x)

Return `true` if `x` is an instance of an `isbitstype` type.
"""
isbits(@nospecialize x) = (@_pure_meta; typeof(x).isbitstype)

"""
    isdispatchtuple(T)

Determine whether type `T` is a tuple "leaf type",
meaning it could appear as a type signature in dispatch
and has no subtypes (or supertypes) which could appear in a call.
"""
isdispatchtuple(@nospecialize(t)) = (@_pure_meta; isa(t, DataType) && t.isdispatchtuple)

iskindtype(@nospecialize t) = (t === DataType || t === UnionAll || t === Union || t === typeof(Bottom))
isconcretedispatch(@nospecialize t) = isconcretetype(t) && !iskindtype(t)
has_free_typevars(@nospecialize(t)) = ccall(:jl_has_free_typevars, Cint, (Any,), t) != 0

# equivalent to isa(v, Type) && isdispatchtuple(Tuple{v}) || v === Union{}
# and is thus perhaps most similar to the old (pre-1.0) `isleaftype` query
const _TYPE_NAME = Type.body.name
function isdispatchelem(@nospecialize v)
    return (v === Bottom) || (v === typeof(Bottom)) || isconcretedispatch(v) ||
        (isa(v, DataType) && v.name === _TYPE_NAME && !has_free_typevars(v)) # isType(v)
end

"""
    isconcretetype(T)

Determine whether type `T` is a concrete type, meaning it could have direct instances
(values `x` such that `typeof(x) === T`).

# Examples
```jldoctest
julia> isconcretetype(Complex)
false

julia> isconcretetype(Complex{Float32})
true

julia> isconcretetype(Vector{Complex})
true

julia> isconcretetype(Vector{Complex{Float32}})
true

julia> isconcretetype(Union{})
false

julia> isconcretetype(Union{Int,String})
false
```
"""
isconcretetype(@nospecialize(t)) = (@_pure_meta; isa(t, DataType) && t.isconcretetype)

"""
    Base.isabstracttype(T)

Determine whether type `T` was declared as an abstract type
(i.e. using the `abstract` keyword).

# Examples
```jldoctest
julia> Base.isabstracttype(AbstractArray)
true

julia> Base.isabstracttype(Vector)
false
```
"""
function isabstracttype(@nospecialize(t))
    @_pure_meta
    t = unwrap_unionall(t)
    # TODO: what to do for `Union`?
    return isa(t, DataType) && t.abstract
end

"""
    Base.parameter_upper_bound(t::UnionAll, idx)

Determine the upper bound of a type parameter in the underlying datatype.
This method should generally not be relied upon:
code instead should usually use static parameters in dispatch to extract these values.

# Examples
```jldoctest
julia> struct Foo{T<:AbstractFloat, N}
           x::Tuple{T, N}
       end

julia> Base.parameter_upper_bound(Foo, 1)
AbstractFloat

julia> Base.parameter_upper_bound(Foo, 2)
Any
```
"""
function parameter_upper_bound(t::UnionAll, idx)
    @_pure_meta
    return rewrap_unionall((unwrap_unionall(t)::DataType).parameters[idx], t)
end

"""
    typeintersect(T, S)

Compute a type that contains the intersection of `T` and `S`. Usually this will be the
smallest such type or one close to it.
"""
typeintersect(@nospecialize(a),@nospecialize(b)) = (@_pure_meta; ccall(:jl_type_intersection, Any, (Any,Any), a, b))

"""
    fieldoffset(type, i)

The byte offset of field `i` of a type relative to the data start. For example, we could
use it in the following manner to summarize information about a struct:

```jldoctest
julia> structinfo(T) = [(fieldoffset(T,i), fieldname(T,i), fieldtype(T,i)) for i = 1:fieldcount(T)];

julia> structinfo(Base.Filesystem.StatStruct)
12-element Array{Tuple{UInt64,Symbol,DataType},1}:
 (0x0000000000000000, :device, UInt64)
 (0x0000000000000008, :inode, UInt64)
 (0x0000000000000010, :mode, UInt64)
 (0x0000000000000018, :nlink, Int64)
 (0x0000000000000020, :uid, UInt64)
 (0x0000000000000028, :gid, UInt64)
 (0x0000000000000030, :rdev, UInt64)
 (0x0000000000000038, :size, Int64)
 (0x0000000000000040, :blksize, Int64)
 (0x0000000000000048, :blocks, Int64)
 (0x0000000000000050, :mtime, Float64)
 (0x0000000000000058, :ctime, Float64)
```
"""
fieldoffset(x::DataType, idx::Integer) = (@_pure_meta; ccall(:jl_get_field_offset, Csize_t, (Any, Cint), x, idx))

"""
    fieldtype(T, name::Symbol | index::Int)

Determine the declared type of a field (specified by name or index) in a composite DataType `T`.

# Examples
```jldoctest
julia> struct Foo
           x::Int64
           y::String
       end

julia> fieldtype(Foo, :x)
Int64

julia> fieldtype(Foo, 2)
String
```
"""
fieldtype

"""
    fieldindex(T, name::Symbol, err:Bool=true)

Get the index of a named field, throwing an error if the field does not exist (when err==true)
or returning 0 (when err==false).

# Examples
```jldoctest
julia> struct Foo
           x::Int64
           y::String
       end

julia> Base.fieldindex(Foo, :z)
ERROR: type Foo has no field z
Stacktrace:
[...]

julia> Base.fieldindex(Foo, :z, false)
0
```
"""
function fieldindex(T::DataType, name::Symbol, err::Bool=true)
    return Int(ccall(:jl_field_index, Cint, (Any, Any, Cint), T, name, err)+1)
end

argument_datatype(@nospecialize t) = ccall(:jl_argument_datatype, Any, (Any,), t)
function argument_mt(@nospecialize t)
    dt = argument_datatype(t)
    (dt === nothing || !isdefined(dt.name, :mt)) && return nothing
    dt.name.mt
end

"""
    fieldcount(t::Type)

Get the number of fields that an instance of the given type would have.
An error is thrown if the type is too abstract to determine this.
"""
function fieldcount(@nospecialize t)
    if t isa UnionAll || t isa Union
        t = argument_datatype(t)
        if t === nothing
            throw(ArgumentError("type does not have a definite number of fields"))
        end
        t = t::DataType
    elseif t == Union{}
        throw(ArgumentError("The empty type does not have a well-defined number of fields since it does not have instances."))
    end
    if !(t isa DataType)
        throw(TypeError(:fieldcount, "", Type, t))
    end
    if t.name === NamedTuple_typename
        names, types = t.parameters
        if names isa Tuple
            return length(names)
        end
        if types isa DataType && types <: Tuple
            return fieldcount(types)
        end
        abstr = true
    else
        abstr = t.abstract || (t.name === Tuple.name && isvatuple(t))
    end
    if abstr
        throw(ArgumentError("type does not have a definite number of fields"))
    end
    return length(t.types)
end

# return all instances, for types that can be enumerated

"""
    instances(T::Type)

Return a collection of all instances of the given type, if applicable. Mostly used for
enumerated types (see `@enum`).

# Example
```jldoctest
julia> @enum Color red blue green

julia> instances(Color)
(red::Color = 0, blue::Color = 1, green::Color = 2)
```
"""
function instances end

function to_tuple_type(@nospecialize(t))
    @_pure_meta
    if isa(t,Tuple) || isa(t,AbstractArray) || isa(t,SimpleVector)
        t = Tuple{t...}
    end
    if isa(t,Type) && t<:Tuple
        for p in t.parameters
            if !(isa(p,Type) || isa(p,TypeVar))
                error("argument tuple type must contain only types")
            end
        end
    else
        error("expected tuple type")
    end
    t
end

function signature_type(@nospecialize(f), @nospecialize(args))
    f_type = isa(f, Type) ? Type{f} : typeof(f)
    arg_types = isa(args, Type) ? args.parameters : args
    return Tuple{f_type, arg_types...}
end

"""
    code_lowered(f, types; generated = true)

Return an array of the lowered forms (IR) for the methods matching the given generic function
and type signature.

If `generated` is `false`, the returned `CodeInfo` instances will correspond to fallback
implementations. An error is thrown if no fallback implementation exists.
If `generated` is `true`, these `CodeInfo` instances will correspond to the method bodies
yielded by expanding the generators.

Note that an error will be thrown if `types` are not leaf types when `generated` is
`true` and the corresponding method is a `@generated` method.
"""
function code_lowered(@nospecialize(f), @nospecialize(t = Tuple); generated::Bool = true)
    return map(method_instances(f, t)) do m
        if generated && isgenerated(m)
            if isa(m, Core.MethodInstance)
                return Core.Compiler.get_staged(m)
            else # isa(m, Method)
                error("Could not expand generator for `@generated` method ", m, ". ",
                      "This can happen if the provided argument types (", t, ") are ",
                      "not leaf types, but the `generated` argument is `true`.")
            end
        end
        return uncompressed_ast(m)
    end
end

isgenerated(m::Method) = isdefined(m, :generator)
isgenerated(m::Core.MethodInstance) = isgenerated(m.def)

# low-level method lookup functions used by the compiler

unionlen(x::Union) = unionlen(x.a) + unionlen(x.b)
unionlen(@nospecialize(x)) = 1

_uniontypes(x::Union, ts) = (_uniontypes(x.a,ts); _uniontypes(x.b,ts); ts)
_uniontypes(@nospecialize(x), ts) = (push!(ts, x); ts)
uniontypes(@nospecialize(x)) = _uniontypes(x, Any[])

function _methods(@nospecialize(f), @nospecialize(t), lim::Int, world::UInt)
    tt = signature_type(f, t)
    return _methods_by_ftype(tt, lim, world)
end

function _methods_by_ftype(@nospecialize(t), lim::Int, world::UInt)
    return _methods_by_ftype(t, lim, world, UInt[typemin(UInt)], UInt[typemax(UInt)])
end
function _methods_by_ftype(@nospecialize(t), lim::Int, world::UInt, min::Array{UInt,1}, max::Array{UInt,1})
    return ccall(:jl_matching_methods, Any, (Any, Cint, Cint, UInt, Ptr{UInt}, Ptr{UInt}), t, lim, 0, world, min, max)
end

# high-level, more convenient method lookup functions

# type for reflecting and pretty-printing a subset of methods
mutable struct MethodList
    ms::Array{Method,1}
    mt::Core.MethodTable
end

length(m::MethodList) = length(m.ms)
isempty(m::MethodList) = isempty(m.ms)
iterate(m::MethodList, s...) = iterate(m.ms, s...)
eltype(::Type{MethodList}) = Method

function MethodList(mt::Core.MethodTable)
    ms = Method[]
    visit(mt) do m
        push!(ms, m)
    end
    return MethodList(ms, mt)
end

"""
    methods(f, [types])

Returns the method table for `f`.

If `types` is specified, returns an array of methods whose types match.
"""
function methods(@nospecialize(f), @nospecialize(t))
    if isa(f, Core.Builtin)
        throw(ArgumentError("argument is not a generic function"))
    end
    t = to_tuple_type(t)
    world = typemax(UInt)
    return MethodList(Method[m[3] for m in _methods(f, t, -1, world)], typeof(f).name.mt)
end

methods(f::Core.Builtin) = MethodList(Method[], typeof(f).name.mt)

function methods_including_ambiguous(@nospecialize(f), @nospecialize(t))
    tt = signature_type(f, t)
    world = typemax(UInt)
    min = UInt[typemin(UInt)]
    max = UInt[typemax(UInt)]
    ms = ccall(:jl_matching_methods, Any, (Any, Cint, Cint, UInt, Ptr{UInt}, Ptr{UInt}), tt, -1, 1, world, min, max)::Array{Any,1}
    return MethodList(Method[m[3] for m in ms], typeof(f).name.mt)
end
function methods(@nospecialize(f))
    # return all matches
    return methods(f, Tuple{Vararg{Any}})
end

function visit(f, mt::Core.MethodTable)
    mt.defs !== nothing && visit(f, mt.defs)
    nothing
end
function visit(f, mc::Core.TypeMapLevel)
    if mc.targ !== nothing
        e = mc.targ::Vector{Any}
        for i in 1:length(e)
            isassigned(e, i) && visit(f, e[i])
        end
    end
    if mc.arg1 !== nothing
        e = mc.arg1::Vector{Any}
        for i in 1:length(e)
            isassigned(e, i) && visit(f, e[i])
        end
    end
    mc.list !== nothing && visit(f, mc.list)
    mc.any !== nothing && visit(f, mc.any)
    nothing
end
function visit(f, d::Core.TypeMapEntry)
    while d !== nothing
        f(d.func)
        d = d.next
    end
    nothing
end

function length(mt::Core.MethodTable)
    n = 0
    visit(mt) do m
        n += 1
    end
    return n::Int
end
isempty(mt::Core.MethodTable) = (mt.defs === nothing)

uncompressed_ast(m::Method) = isdefined(m,:source) ? uncompressed_ast(m, m.source) :
                              isdefined(m,:generator) ? error("Method is @generated; try `code_lowered` instead.") :
                              error("Code for this Method is not available.")
uncompressed_ast(m::Method, s::CodeInfo) = s
uncompressed_ast(m::Method, s::Array{UInt8,1}) = ccall(:jl_uncompress_ast, Any, (Any, Any), m, s)::CodeInfo
uncompressed_ast(m::Core.MethodInstance) = uncompressed_ast(m.def)

function method_instances(@nospecialize(f), @nospecialize(t), world::UInt = typemax(UInt))
    tt = signature_type(f, t)
    results = Vector{Union{Method,Core.MethodInstance}}()
    for method_data in _methods_by_ftype(tt, -1, world)
        mtypes, msp, m = method_data
        instance = Core.Compiler.code_for_method(m, mtypes, msp, world, false)
        push!(results, ifelse(isa(instance, Core.MethodInstance), instance, m))
    end
    return results
end

# this type mirrors jl_cgparams_t (documented in julia.h)
struct CodegenParams
    cached::Cint

    track_allocations::Cint
    code_coverage::Cint
    static_alloc::Cint
    prefer_specsig::Cint

    module_setup::Any
    module_activation::Any
    raise_exception::Any
    emit_function::Any
    emitted_function::Any

    CodegenParams(;cached::Bool=true,
                   track_allocations::Bool=true, code_coverage::Bool=true,
                   static_alloc::Bool=true, prefer_specsig::Bool=false,
                   module_setup=nothing, module_activation=nothing, raise_exception=nothing,
                   emit_function=nothing, emitted_function=nothing) =
        new(Cint(cached),
            Cint(track_allocations), Cint(code_coverage),
            Cint(static_alloc), Cint(prefer_specsig),
            module_setup, module_activation, raise_exception,
            emit_function, emitted_function)
end

# give a decent error message if we try to instantiate a staged function on non-leaf types
function func_for_method_checked(m::Method, @nospecialize types)
    if isdefined(m, :generator) && !isdispatchtuple(types)
        error("cannot call @generated function `", m, "` ",
              "with abstract argument types: ", types)
    end
    return m
end

"""
    code_typed(f, types; optimize=true)

Returns an array of type-inferred lowered form (IR) for the methods matching the given
generic function and type signature. The keyword argument `optimize` controls whether
additional optimizations, such as inlining, are also applied.
"""
function code_typed(@nospecialize(f), @nospecialize(types=Tuple); optimize=true)
    ccall(:jl_is_in_pure_context, Bool, ()) && error("code reflection cannot be used from generated functions")
    if isa(f, Core.Builtin)
        throw(ArgumentError("argument is not a generic function"))
    end
    types = to_tuple_type(types)
    asts = []
    world = ccall(:jl_get_world_counter, UInt, ())
    params = Core.Compiler.Params(world)
    for x in _methods(f, types, -1, world)
        meth = func_for_method_checked(x[3], types)
        (code, ty) = Core.Compiler.typeinf_code(meth, x[1], x[2], optimize, params)
        code === nothing && error("inference not successful") # inference disabled?
        push!(asts, code => ty)
    end
    return asts
end

function return_types(@nospecialize(f), @nospecialize(types=Tuple))
    ccall(:jl_is_in_pure_context, Bool, ()) && error("code reflection cannot be used from generated functions")
    if isa(f, Core.Builtin)
        throw(ArgumentError("argument is not a generic function"))
    end
    types = to_tuple_type(types)
    rt = []
    world = ccall(:jl_get_world_counter, UInt, ())
    params = Core.Compiler.Params(world)
    for x in _methods(f, types, -1, world)
        meth = func_for_method_checked(x[3], types)
        ty = Core.Compiler.typeinf_type(meth, x[1], x[2], params)
        ty === nothing && error("inference not successful") # inference disabled?
        push!(rt, ty)
    end
    return rt
end

"""
    which(f, types)

Returns the method of `f` (a `Method` object) that would be called for arguments of the given `types`.

If `types` is an abstract type, then the method that would be called by `invoke` is returned.
"""
function which(@nospecialize(f), @nospecialize(t))
    if isa(f, Core.Builtin)
        throw(ArgumentError("argument is not a generic function"))
    end
    t = to_tuple_type(t)
    tt = signature_type(f, t)
    m = ccall(:jl_gf_invoke_lookup, Any, (Any, UInt), tt, typemax(UInt))
    if m === nothing
        error("no unique matching method found for the specified argument types")
    end
    return m.func::Method
end

"""
    which(module, symbol)

Return the module in which the binding for the variable referenced by `symbol` in `module` was created.
"""
function which(m::Module, s::Symbol)
    if !isdefined(m, s)
        error("\"$s\" is not defined in module $m")
    end
    return binding_module(m, s)
end

# function reflection
"""
    nameof(f::Function) -> Symbol

Get the name of a generic `Function` as a symbol, or `:anonymous`.
"""
nameof(f::Function) = typeof(f).name.mt.name

functionloc(m::Core.MethodInstance) = functionloc(m.def)

"""
    functionloc(m::Method)

Returns a tuple `(filename,line)` giving the location of a `Method` definition.
"""
function functionloc(m::Method)
    ln = m.line
    if ln <= 0
        error("could not determine location of method definition")
    end
    return (find_source_file(string(m.file)), ln)
end

"""
    functionloc(f::Function, types)

Returns a tuple `(filename,line)` giving the location of a generic `Function` definition.
"""
functionloc(@nospecialize(f), @nospecialize(types)) = functionloc(which(f,types))

function functionloc(@nospecialize(f))
    mt = methods(f)
    if isempty(mt)
        if isa(f, Function)
            error("function has no definitions")
        else
            error("object is not callable")
        end
    end
    if length(mt) > 1
        error("function has multiple methods; please specify a type signature")
    end
    return functionloc(first(mt))
end

"""
    parentmodule(f::Function) -> Module

Determine the module containing the (first) definition of a generic
function.
"""
parentmodule(f::Function) = parentmodule(typeof(f))

"""
    parentmodule(f::Function, types) -> Module

Determine the module containing a given definition of a generic function.
"""
function parentmodule(@nospecialize(f), @nospecialize(types))
    m = methods(f, types)
    if isempty(m)
        error("no matching methods")
    end
    return first(m).module
end

"""
    hasmethod(f, Tuple type; world = typemax(UInt)) -> Bool

Determine whether the given generic function has a method matching the given
`Tuple` of argument types with the upper bound of world age given by `world`.

See also [`applicable`](@ref).

# Examples
```jldoctest
julia> hasmethod(length, Tuple{Array})
true
```
"""
function hasmethod(@nospecialize(f), @nospecialize(t); world = typemax(UInt))
    t = to_tuple_type(t)
    t = signature_type(f, t)
    return ccall(:jl_method_exists, Cint, (Any, Any, UInt), typeof(f).name.mt, t, world) != 0
end

"""
    isambiguous(m1, m2; ambiguous_bottom=false) -> Bool

Determine whether two methods `m1` and `m2` (typically of the same
function) are ambiguous.  This test is performed in the context of
other methods of the same function; in isolation, `m1` and `m2` might
be ambiguous, but if a third method resolving the ambiguity has been
defined, this returns `false`.

For parametric types, the `ambiguous_bottom` keyword argument controls whether
`Union{}` counts as an ambiguous intersection of type parameters – when `true`,
it is considered ambiguous, when `false` it is not.

# Examples
```jldoctest
julia> foo(x::Complex{<:Integer}) = 1
foo (generic function with 1 method)

julia> foo(x::Complex{<:Rational}) = 2
foo (generic function with 2 methods)

julia> m1, m2 = collect(methods(foo));

julia> typeintersect(m1.sig, m2.sig)
Tuple{#foo,Complex{Union{}}}

julia> Base.isambiguous(m1, m2, ambiguous_bottom=true)
true

julia> Base.isambiguous(m1, m2, ambiguous_bottom=false)
false
```
"""
function isambiguous(m1::Method, m2::Method; ambiguous_bottom::Bool=false)
    ti = typeintersect(m1.sig, m2.sig)
    ti === Bottom && return false
    if !ambiguous_bottom
        has_bottom_parameter(ti) && return false
    end
    ml = _methods_by_ftype(ti, -1, typemax(UInt))
    isempty(ml) && return true
    for m in ml
        if ti <: m[3].sig
            return false
        end
    end
    return true
end

"""
    delete_method(m::Method)

Make method `m` uncallable and force recompilation of any methods that use(d) it.
"""
function delete_method(m::Method)
    ccall(:jl_method_table_disable, Cvoid, (Any, Any), get_methodtable(m), m)
end

function get_methodtable(m::Method)
    ft = ccall(:jl_first_argument_datatype, Any, (Any,), m.sig)
    (ft::DataType).name.mt
end

"""
    has_bottom_parameter(t) -> Bool

Determine whether `t` is a Type for which one or more of its parameters is `Union{}`.
"""
function has_bottom_parameter(t::Type)
    ret = false
    for p in t.parameters
        ret |= (p == Bottom) || has_bottom_parameter(p)
    end
    ret
end
has_bottom_parameter(t::UnionAll) = has_bottom_parameter(unwrap_unionall(t))
has_bottom_parameter(t::Union) = has_bottom_parameter(t.a) & has_bottom_parameter(t.b)
has_bottom_parameter(t::TypeVar) = t.ub == Bottom || has_bottom_parameter(t.ub)
has_bottom_parameter(::Any) = false

min_world(m::Method) = reinterpret(UInt, m.min_world)
max_world(m::Method) = typemax(UInt)
min_world(m::Core.MethodInstance) = reinterpret(UInt, m.min_world)
max_world(m::Core.MethodInstance) = reinterpret(UInt, m.max_world)

"""
    propertynames(x, private=false)

Get a tuple or a vector of the properties (`x.property`) of an object `x`.
This is typically the same as [`fieldnames(typeof(x))`](@ref), but types
that overload [`getproperty`](@ref) should generally overload `propertynames`
as well to get the properties of an instance of the type.

`propertynames(x)` may return only "public" property names that are part
of the documented interface of `x`.   If you want it to also return "private"
fieldnames intended for internal use, pass `true` for the optional second argument.
REPL tab completion on `x.` shows only the `private=false` properties.
"""
propertynames(x) = fieldnames(typeof(x))
propertynames(m::Module) = names(m)
propertynames(x, private) = propertynames(x) # ignore private flag by default

max_stars_repo_name: dehann/julia

max_issues_repo_name: dehann/julia

max_forks_repo_name: dehann/julia


text:
# Alignment Anchor
# ================
#
# Sequence alignment anchor type.
#
# This file is a part of BioJulia.
# License is MIT: https://github.com/BioJulia/Bio.jl/blob/master/LICENSE.md

"""
A type to store the operation enocded in an alignment (CIGAR Operations).
Also stores the position in the alignment view of the sequences, and the
corresponding position in the unaltered source sequence (nucleotide or protein).

It stores the position values as Int types and the alignment operation is stored
as a type `Operation`, these are defined in the file `operations.jl` and loaded
into Bio.Align namespace as a series of global constants.
"""
immutable AlignmentAnchor
    seqpos::Int
    refpos::Int
    op::Operation
end

function AlignmentAnchor(pos::Tuple{Int,Int}, op)
    return AlignmentAnchor(pos[1], pos[2], op)
end

function Base.show(io::IO, anc::AlignmentAnchor)
    print(io, "AlignmentAnchor(", anc.seqpos, ", ", anc.refpos, ", '", anc.op, "')")
end