def test_bill_01(self): self.pile_data= u"2013.11.11 | 0.7 | 电子\n1 * ipad : 2399.00\n1 * " \ u"显示器 : 1799.00\n12 * 啤酒 : 25.00\n5 * 面包 : " \ u"9.00\n2013.11.11\n2014.3.2 1000 200" cashier_obj = Cashier(self.pile_data) ret = cashier_obj.bill() self.assertEqual(ret, '3083.60')
def __init__(self, lengthOfSimulation, averageTimePerCus, probabilityOfNewArrival, numCashiers): self.numCashiers = numCashiers self._probabilityOfNewArrival = probabilityOfNewArrival self._lengthOfSimulation = lengthOfSimulation self._averageTimePerCus = averageTimePerCus self._cashiers = [Cashier(x) for x in range(1, numCashiers + 1)]
def create_new_cashier(cls, shopping_cart=None, credit_card=None, merchant_processor=None): return Cashier(shopping_cart=shopping_cart or cls.create_cart(), credit_card=credit_card or cls.create_new_credit_card(), merchant_processor=merchant_processor or cls.create_new_merchant_processor())
def __init__(self, lengthOfSimulation, averageTimePerCus, probabilityOfNewArrival, numCashiers): self._probabilityOfNewArrival = probabilityOfNewArrival self._lengthOfSimulation = lengthOfSimulation self._averageTimePerCus = averageTimePerCus self._cashiers = list() for count in range(numCashiers): self._cashiers.append(Cashier(count + 1))
def __init__(self, lengthOfSimulation, averageTimePerCus, probabilityOfNewArrival, cashierCount): self.probabilityOfNewArrival = probabilityOfNewArrival self.lengthOfSimulation = lengthOfSimulation self.averageTimePerCus = averageTimePerCus self.cashierCount = cashierCount self.cashier = [] for count in range(0, self.cashierCount): self.cashier.append(Cashier(count + 1))
def __init__(self, lengthOfSimulation, averageTimePerCus, probabilityOfNewArrival, numberOfLines): self._probabilityOfNewArrival = probabilityOfNewArrival self._lengthOfSimulation = lengthOfSimulation self._averageTimePerCus = averageTimePerCus self._numberOfLines = numberOfLines self._cashiers = [] # create a list of that contains many cashiers for i in xrange(numberOfLines): cashier = Cashier(i) self._cashiers.append(cashier)
def __init__(self, lengthOfSimulation, averageTimePerCus, probabilityOfNewArrival): """ :param lengthOfSimulation: :type lengthOfSimulation: :param averageTimePerCus: :type averageTimePerCus: :param probabilityOfNewArrival: :type probabilityOfNewArrival: """ self._probabilityOfNewArrival = probabilityOfNewArrival self._lengthOfSimulation = lengthOfSimulation self._averageTimePerCus = averageTimePerCus self._cashier = Cashier()
def login(self): '''前台:admin登陆''' in_num=input("请输入您的账号:").strip() cash=Basic.queryOneCashier(in_num) if not cash: print("不存在该账号.") return False cashier=Cashier(cash) in_pwd=input("请输入您的密码:").strip() if cashier.getPwd()==in_pwd: self.admin=cashier print("登陆成功.") return True else: print("密码错误.") return False
def generate_output(): # Load JSON f = open('competition/test_cases.json') test_cases = json.load(f) myCashier = Cashier() userID = '5ea023be-b530-4816-8eda-5340cfabe9b0' output_paths = [] for test_db in test_cases: print(test_db['name']) dbName = test_db['name'] dbId = test_db['uuid'] receipts = myCashier.process(dbName) # Generate output file path = "outputs/output-{}.json".format(dbName) output_paths.append(path) output_json(dbId, userID, receipts, path=path) return output_paths
def run(): with open('input.txt', 'r') as f: simulationData = f.readlines() numberOfRegisters = int(simulationData[0].strip('\n')) del (simulationData[0]) registers = [] for i in range(numberOfRegisters): if i == numberOfRegisters - 1: trainee = Trainee(i) registers.append(Register(i, trainee)) else: cashier = Cashier(i) registers.append(Register(i, cashier)) print "Simulation starts with {register} registers; #{register} is a training register.".format( register=numberOfRegisters) CustomerNumber = 1 for customerData in simulationData: customerEntry = customerData.strip('\n').split(' ') customerType = customerEntry[0] customerArrival = int(customerEntry[1]) customerItems = int(customerEntry[2]) if customerType == 'A': customer = CustomerA(customerType, customerArrival, customerItems, CustomerNumber) else: customer = CustomerB(customerType, customerArrival, customerItems, CustomerNumber) customer.enqueCustomer(registers) CustomerNumber = CustomerNumber + 1 for register in registers: for item in range(register.queue.size()): if not register.queue.isEmpty(): customer = register.queue.dequeue() ProcessingTime = register.customerProcessingTime( register.cashier, customer)
def evaluate_intenvory(dbs, gt_path): # Load JSON groundtruth with open(gt_path) as f: gt_data = json.load(f) gt_list = gt_data['lists'] if not DEBUG: remove_putback_products(gt_list) # with open('gt_final.json', 'w') as outfile: # json.dump(gt_data, outfile) # Metrics tp, fp, tn, fn = 0, 0, 0, 0 overall_num_preds, overall_num_gt = 0, 0 for i in range(len(dbs)): print("\n\nEvaluating database: ", dbs[i]) # Metrics per database db_tp, db_fp, db_tn, db_fn = 0, 0, 0, 0 db_pred_counts, db_gt_counts = 0, 0 ########## Generate Prediction ########## dbName = dbs[i] myCashier = Cashier() receipts = myCashier.process(dbName) ########## Evaluate Ground truth ########## gt_entry = gt_list[i] # Find groundtruth entry for this database tmp_i = 0 while (gt_entry['dataset'] != dbName): tmp_i += 1 gt_entry = gt_list[tmp_i] assert (tmp_i < len(gt_list)) assert (gt_entry['dataset'] == dbName) event_list = gt_entry['events'] for event in event_list: gt_products = event['observation']['products'] gt_customerID = event['observation']['target_id'] # Find the corresponding customer receipts if (gt_customerID in receipts): # Find the corresponding products on the receipt customer_receipt = receipts[gt_customerID] for gt_product in gt_products: gt_productID = gt_product['id'] for productID, entry in customer_receipt.purchaseList.items( ): if (gt_productID == productID): product, quantity = entry if (quantity > 0): db_tp += 1 customer_receipt.purchaseList[productID] = ( product, quantity - 1 ) # entry = (product, quantity) db_gt_counts += 1 else: # No such customer for gt_product in gt_products: db_gt_counts += 1 # Print False Items num_receipt = 0 for id, customer_receipt in receipts.items(): if VERBOSE: print("============== False Receipt {} ==============".format( num_receipt)) print("Customer ID: " + id) print("Purchase List: ") for _, entry in customer_receipt.purchaseList.items(): product, quantity = entry if quantity != 0: if VERBOSE: print( "*Name: " + product.name + ", Quantities: " + str(quantity), product.thumbnail) db_fp += quantity num_receipt += 1 db_fn = db_gt_counts - db_tp db_pred_counts = db_tp + db_fp overall_num_preds += db_pred_counts overall_num_gt += db_gt_counts tp += db_tp fp += db_fp fn += db_fn # Display DB Evaluation print( "Database: {}, Correct Items on Receipts: {}/{}, Total GT items: {}" .format(dbName, db_tp, db_pred_counts, db_gt_counts)) print("\n================== Evaluation Summary ==================") print("Databases: ", dbs) print("Ground truth version: ", gt_path) precision = 0.0 if tp + fp == 0 else tp * 100.0 / (tp + fp) print("Overall precision is: {:.1f}%".format(precision)) recall = 0.0 if tp + fn == 0 else tp * 100.0 / (tp + fn) print("Overall recall is: {:.1f}%".format(recall)) if (precision + recall == 0): f1 = 0 else: f1 = 2 * precision * recall / (precision + recall) print("Overall F1 is: {:.1f}%".format(f1))
def test_bill_02(self): self.pile_data = u"3 * 蔬菜 : 5.98\n8 * 餐巾纸 : 3.20\n2014.01.01 输出\n" cashier_obj = Cashier(self.pile_data) ret = cashier_obj.bill() self.assertEqual(ret, '43.54')
def printer_machine(cls): resource = Resource() while True: user_input = input( "\nWhat format would you like 'coloured' or 'greyscale'?\n") while user_input.lower() not in [ 'coloured', 'greyscale', 'report', 'off' ]: user_input = input( "Invalid!!!! Please put in 'coloured' or 'greyscale'\n") while user_input == 'report': print(resource.report()) user_input = input( "\nWhat format would you like 'coloured' or 'greyscale'?\n" ) # This switch off the printer if 'off' is been typed if user_input == 'off': return 'Thanks for using our service Bye.....' number_of_pages = input("How many pages?\n") while number_of_pages.isnumeric() is not True: print("You've entered an invalid number") number_of_pages = input("How many pages?\n") # This checks if there is enough resource to print the pages the users want. # If No the printer tells the user no enough resources but if yes then the # monies(currencies) is being asked from users ink_and_price = resource.check_resource(user_input, number_of_pages) if ink_and_price != True: print(ink_and_price) else: print(f'Your price is ₦{resource.calculate_bill()}') print("Please insert Monies.") # This catches an error if the user type in a string instead of a number try: biyar = int(input('How many Biyar: ')) faiba = int(input('How many Faiba: ')) muri = int(input('How many Muri: ')) wazobia = int(input('How many Wazobia: ')) except ValueError: print("You've entered an invalid input") Printer.printer_machine() # This add all the currencies payed by the user calculate_money = Cashier(biyar, faiba, muri, wazobia) calculate_money.get_total() # This confirm the payment if it is less than or greater than the actual cost print(calculate_money.confirming_payment(resource)) # This update the resources after printing the pages resource.deduct_resource() print( 'Thanks for using our Printing service. Hope you enjoyed it!!' ) print( "===================================================================" )
from cashier import Cashier dbName = "cps-test-01" receipts = Cashier().process(dbName)
print("Trying to kill find_person.py") p2.kill() print("find_person.py killed") sys.exit(0) # Main function - the basic system logic for Baxter to run the shop - uses # loops and managing variables where appropriate if __name__ == '__main__': signal.signal(signal.SIGINT, signal_handler) release_robot() # Note that Cashier's constructor will ask for some commands from the # operator like to calibrate the hand above the first banknote etc. cashier = Cashier() p = subprocess.Popen(["rosrun", "perception", "find_colours.py"], stdout=subprocess.PIPE) p2 = subprocess.Popen(["rosrun", "interaction", "find_person.py"], stdout=subprocess.PIPE) # Initialise a baxter object, of shopkeeper class baxter = ShopKeeper() # Set up the communications with Baxter and other nodes comms = Communications(baxter) # Subscribe to the right gripper's state to detect torque changes rospy.Subscriber("/robot/end_effector/right_gripper/state", EndEffectorState, baxter.gripperholding)
def __init__(self, length_of_simulation, average_time_per_cus, probability_of_new_arrival): self._probability_of_new_arrival = probability_of_new_arrival self._length_of_simulation = length_of_simulation self._average_time_per_cus = average_time_per_cus self._cashier = Cashier()
def setCashiers(self, cashiersAmount): return [ Cashier(self.getNewBreakTime(0)) for i in range(cashiersAmount) ]
def __init__(self, lengthOfSimulation, averageTimePerCus, probabilityOfNewArrival): self._probabilityOfNewArrival = probabilityOfNewArrival self._lengthOfSimulation = lengthOfSimulation self._avarageTimePerCus = averageTimePerCus self._cashier = Cashier()
import requests from cashier import cache, Cashier from time import time c = Cashier(file_name="testing") c.clear() data = requests.get("https://news.ycombinator.com") if data.status_code == 200: page = data.content else: page = "" print "Failed to scrape test urls" exit() urls = [] def getURL(page): start_link = page.find("a href") if start_link == -1: return None, 0 start_quote = page.find('"', start_link) end_quote = page.find('"', start_quote + 1) url = page[start_quote + 1: end_quote] return url, end_quote part_page = page while True: