Best Python code snippet using tox_python
commons.py
Source: commons.py
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,:] ...
Check out the latest blogs from LambdaTest on this topic:
I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.
The web paradigm has changed considerably over the last few years. Web 2.0, a term coined way back in 1999, was one of the pivotal moments in the history of the Internet. UGC (User Generated Content), ease of use, and interoperability for the end-users were the key pillars of Web 2.0. Consumers who were only consuming content up till now started creating different forms of content (e.g., text, audio, video, etc.).
Mobile devices and mobile applications – both are booming in the world today. The idea of having the power of a computer in your pocket is revolutionary. As per Statista, mobile accounts for more than half of the web traffic worldwide. Mobile devices (excluding tablets) contributed to 54.4 percent of global website traffic in the fourth quarter of 2021, increasing consistently over the past couple of years.
Even though several frameworks are available in the market for automation testing, Selenium is one of the most renowned open-source frameworks used by experts due to its numerous features and benefits.
JUnit is one of the most popular unit testing frameworks in the Java ecosystem. The JUnit 5 version (also known as Jupiter) contains many exciting innovations, including support for new features in Java 8 and above. However, many developers still prefer to use the JUnit 4 framework since certain features like parallel execution with JUnit 5 are still in the experimental phase.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!