How to use factor_line method in tox

Best Python code snippet using tox_python

commons.py

Source:commons.py Github

copy

Full Screen

1import numpy as np2from fractions import Fraction3from decimal import Decimal4from pdb import set_trace 5def add_identity_matrix(matrix, position, size,value):6 adicional_row = np.zeros(size)7 adicional_row = adicional_row+value8 identity = np.identity(size)9 sub_matrix = np.insert(identity, 0, adicional_row, axis=0)10 arrays_list = []11 for line_index in range(matrix.shape[0]):12 extended_row = np.insert(matrix[line_index], position, sub_matrix[line_index])13 arrays_list.append(extended_row)14 return np.array(arrays_list)15def parse_to_fpi(matrix):16 position = (matrix.shape[1])-117 size = matrix.shape[0]-118 return add_identity_matrix(matrix,position,size,0)19def put_tableux_form(matrix):20 matrix_A_lines = (matrix.shape[0]-1)21 matrix = add_identity_matrix(matrix,0,matrix_A_lines,0) # adds array of operations 22 matrix[0,:] = (-1)*matrix[0,:] # Negative vector c23 return matrix24def pivoting(matrix, line_index, column_index):25 26 factor_line = (matrix[line_index,:]).copy()27 for index in range(0,matrix.shape[0]):#line28 factor = Fraction( Fraction( (-matrix[index,column_index])),Fraction( (factor_line[column_index]))).limit_denominator(1000000)29 30 if index == line_index:31 for column in range(0,matrix.shape[1]):32 matrix[index,column] = Fraction(Fraction((matrix[index,column])) , Fraction((factor_line[column_index]))).limit_denominator(1000000)33 34 else:35 for column in range(0,matrix.shape[1]):#column36 matrix[index,column] = Fraction( (factor_line[column]*factor)+ matrix[index,column] ).limit_denominator(1000000)37 f = open('primeiro.txt', 'r')38 conteudo = f.readlines()39 40 for index in range(0,matrix.shape[0]):41 conteudo.append(str(matrix[index,:].tolist())+"\n")42 conteudo.append("\n\n") 43 f = open('primeiro.txt', 'w')44 f.writelines(conteudo)45 f.close()46def canonical_form(matrix,base_columns):47 if(not verify_canonical_form(matrix,base_columns)):48 put_canonical_form(matrix,base_columns)49def verify_canonical_form(matrix,base_columns):50 begin_A_columns = matrix.shape[0]-151 for index in range(begin_A_columns,matrix.shape[1]):52 count_ones = 053 base = None54 if (matrix[0,index] == 0):55 for line in range(1,matrix.shape[0]): 56 if(matrix[line,index] == 1):57 count_ones+=158 base = line59 elif(matrix[line,index] == 0):60 continue61 else:62 base = None63 break64 if(base is not None and count_ones == 1):65 base_columns[base] = index #to the base line of the 'base' line, my pivo is in the column base_columns [base]66 if(all( i >0 for i in base_columns)):67 return True68 else:69 return False70def put_canonical_form(matrix,base_columns):71 for linha in range(1 , base_columns.shape[0]):72 matrix[0,:] = matrix[linha,:]*( (-matrix[0,int(base_columns[linha])])/matrix[linha,int(base_columns[linha])])+matrix[0,:] ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful