def test_sophisticated(): """make sure the functions we test all implement the same computation""" values = some_values() values_nparray = (numpyarray(values[0]), numpyarray(values[1]), values[2]) result = python_abs(*values) for func in TEST_THESE_ARRAY: assert result == func(*values) for func in TEST_THESE_NPARRAY: assert result == func(*values_nparray)
def possible(self, matrix): m = numpyarray(matrix) indices = numpywhere(m == '#') indice_row = int(indices[0]) indice_col = int(indices[-1]) move_right = indice_col + 1 move_down = indice_row + 1 if int(move_right) >= int(len(matrix[0])): move_right = len(matrix[0]) - 1 if matrix[indice_row][move_right] == 'x' and matrix[move_down][indice_col] == 'x': print('\n!!!Fim das jogadas possíveis!!!') print(' ###### GAME OVER ##### ') print('') return True else: return False
def move_right(self,matrix): m = numpyarray(matrix) indices = numpywhere(m == '#') indice_row = int(indices[0]) indice_col = int(indices[-1]) move_right = indice_col + 1 if int(move_right) >= int(len(matrix[0])): move_right = len(matrix[0]) - 1 print('Você não pode andar para a direita\n') if matrix[indice_row][move_right] != 'x': matrix[indice_row][indice_col] = 'o' matrix[indice_row][move_right] = '#' return matrix else: print('Você não pode andar para a direita\n') return False
def move_down(self,matrix): #matrix = self.play() #recebe x e y de onde esta o robo | get robot coord m = numpyarray(matrix) indices = numpywhere(m == '#') indice_row = int(indices[0]) indice_col = int(indices[-1]) move_down = indice_row + 1 if int(move_down) >= int(len(matrix)): move_down = len(matrix) - 1 print('Você não pode andar para a baixo\n') if matrix[move_down][indice_col] != 'x': matrix[indice_row][indice_col] = 'o' matrix[move_down][indice_col] = '#' return matrix else: print('Você não pode andar para baixo\n') return False
def some_values_nparray(): d = TEST_WORLDLENGTH // 2 r = TEST_RADIUS return (numpyarray([randint(-d, d), randint(-d, d)]), numpyarray([randint(-d, d), randint(-d, d)]), randint(r))
elif (network2_prediction == ((network_prediction + 1) % 3)): network2_wins += 1 print("network 2 wins") print(" network 1 won ", network_wins, " network 2 won ", network2_wins, " round played ", round_played) print("Winrate of neural network 1 = ", network_wins / round_played * 100, "%", " Winrate of neural network 2 = ", network2_wins / round_played * 100, "%") for i in range(rounds): while len(moves) < model_size: moves.append(random.randint(0, 2)) network_moves = [] network_moves.append(moves) network_moves = numpyarray(network_moves) network_moves = py.reshape( network_moves, (network_moves.shape[0], network_moves.shape[1])) network_prediction = model.predict(network_moves).argmax() network_prediction = (network_prediction + 1) % 3 moves.append(network2_prediction) #moves.append(network_prediction) while len(moves) > model_size: del moves[0] while len(moves2) < model2_size: moves2.append(random.randint(0, 2)) network2_moves = [] network2_moves.append(moves) network2_moves = numpyarray(network2_moves) network2_moves = py.reshape(
# extract array of points arrdict = {} errdict = {} arrdata = [] errdata = [] for key, val in plfiledict.iteritems(): pointlist = [] errlist = [] for k in xrange(1, val.__histo__.GetNbinsX() + 1): pointlist.append(val.__histo__.GetBinContent(k)) errlist.append(val.__histo__.GetBinError(k)) if len(arrdata) == 0: for k in xrange(1, val.__data__.GetNbinsX() + 1): arrdata.append(val.__data__.GetBinContent(k)) errdata.append(val.__data__.GetBinError(k)) arrdict[key] = numpyarray(pointlist, "d") errdict[key] = numpyarray(errlist, "d") sampleslist = arrdict.keys() ks_dataprob = {} print "\033[34;1mkstest \033[m histo::" + plfiledict.values()[0].histoname print " |-- kolmogorov-smirnov test" for i in sampleslist: ks_dataprob[i] = checkks(arrdict[i], arrdata, opt.icl, opt.verbose) try: print " |-- %s and %s emerge from the same distribution? %u " % ("data", i, ks_dataprob[i]) except TypeError: print " |-- %s and %s emerge from the same distribution? CANNOT SAY ANYTHING " % ("data", i) print " |-- psi test (0 db is the perfect hypothesis)" nearestzero = (None, 1.0e10) psiBoutput = {}
# extract array of points arrdict = {} errdict = {} arrdata = [] errdata = [] for key, val in plfiledict.iteritems(): pointlist = [] errlist = [] for k in xrange(1, val.__histo__.GetNbinsX() + 1): pointlist.append(val.__histo__.GetBinContent(k)) errlist.append(val.__histo__.GetBinError(k)) if len(arrdata) == 0: for k in xrange(1, val.__data__.GetNbinsX() + 1): arrdata.append(val.__data__.GetBinContent(k)) errdata.append(val.__data__.GetBinError(k)) arrdict[key] = numpyarray(pointlist, 'd') errdict[key] = numpyarray(errlist, 'd') sampleslist = arrdict.keys() ks_dataprob = {} print "\033[34;1mkstest \033[m histo::" + plfiledict.values()[0].histoname print " |-- kolmogorov-smirnov test" for i in sampleslist: ks_dataprob[i] = checkks(arrdict[i], arrdata, opt.icl, opt.verbose) try: print " |-- %s and %s emerge from the same distribution? %u " % ( "data", i, ks_dataprob[i]) except TypeError: print " |-- %s and %s emerge from the same distribution? CANNOT SAY ANYTHING " % ( "data", i) print " |-- psi test (0 db is the perfect hypothesis)"
def __init__(self,np_array): from numpy import array as numpyarray self.np_array = numpyarray(np_array)