Python List or Dictionary using UUT Ch simulation example

Simulated UUT, channel, Measured value and results with a mini test report

Python code example demo

# -*- coding: utf-8 -*-
"""
Created on Tue Mar 21 12:25:12 2023

@author: aleja
"""
import random

List_of_Test_Info=[]
List_For_TestReport=[]

def Add_to_Test_Info(List_of_Test_Info,UUT_Num,Ch,Meas):
    Test_Info={}
    Test_Info['UUT']=UUT_Num
    Test_Info['Channel']=Ch
    Test_Info['MeasValue']=Meas
    List_of_Test_Info.append(Test_Info)
    #List_of_Test_Info.append({'U':UUT_Num, 'C':Ch,'M':Meas})
    return

def Add_to_TestReport(List_For_TestReport,item,result):
    TestReport_Info={}
    TestReport_Info=item
    TestReport_Info.update({'Result':result})  #add
    List_For_TestReport.append(TestReport_Info)
    return
def TestReport_Title():
    #Create a mini test report
    print("\n")
    print("-----------------------------------------")
    print("      ================")
    print("      Test Report mini")
    print("      ================")
    return           

def TestReport_UUT(UUT_Num):
    print("UUT: " + str(UUT_Num))
    print("-----")
    return

def TestReport_Column_Header():
    print("Channel   Measured       Result")
    print("=======  ==========  ==============")
    return    
    
if __name__=="__main__":
    #create some sim data 
    Num_of_UUTs=4
    Limits={}
    Limits={'low':3.2,"high":3.8}
    for c in range(10):  #channel
     for u in range(Num_of_UUTs):  #uuts
        Add_to_Test_Info(List_of_Test_Info,u,c,random.randrange(30,40)/10) 

    #simple limits to create result
    for test in List_of_Test_Info:
         if Limits['low']<=test['MeasValue']<=Limits['high']:
           print(test , "Passed");
           Add_to_TestReport(List_For_TestReport,test,"Passed")
         else:
             print(test , "***Failed***");
             Add_to_TestReport(List_For_TestReport,test,"***Failed***")
      #future reference for k,v in test.items():              
         # future reference print(k,v);


    #Create a mini test report
    TestReport_Title()

    for UUT_Num in range(Num_of_UUTs):
        TestReport_UUT(UUT_Num)
        TestReport_Column_Header()
        for TestRpt in List_For_TestReport:
           if TestRpt['UUT']==UUT_Num:
             print(TestRpt['Channel'],"         ",TestRpt['MeasValue'],"      ",TestRpt['Result'])
             
             
    

Notes

  • Presentation: example List of Dictionary with UUT,channel, sim measurement and result
  • Programming Language used: Python 3.7 in Spyder
  • Presentation app: Microsoft’s PowerPoint
  • Presentation shown to spark ideas of use.
  • This presentation is not connected to or endorsed by any company.
  • Use at your own risk.
  • Tags: Python, Python3.7, List of Dictionary, Mini Test Report, append to list, update(add to dictionary), random

About LV_TS_Test_Engineer_3000_VI

Automated Test Equipment Software
This entry was posted in Test Sector and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s