def initialize(self, inDict): """ Function to initialize the OutStream. It basically looks for the "data" object and links it to the system. @ In, inDict, dict, contains all the Objects are going to be used in the current step. The sources are searched into this. @ Out, None """ if self.subDirectory is not None: if not os.path.exists(self.subDirectory): os.makedirs(self.subDirectory) self.sourceData = [] for agrosindex in range(self.numberAggregatedOS): foundData = False for output in inDict['Output']: if output.name.strip() == self.sourceName[ agrosindex] and output.type in DataObjects.knownTypes( ): self.sourceData.append(output) foundData = True if not foundData: for inp in inDict['Input']: if not type(inp) == type(""): if inp.name.strip() == self.sourceName[ agrosindex] and inp.type in DataObjects.knownTypes( ): self.sourceData.append(inp) foundData = True elif type(inp) == Models.ROM: self.sourceData.append(inp) foundData = True # good enough if not foundData and 'TargetEvaluation' in inDict.keys(): if inDict['TargetEvaluation'].name.strip( ) == self.sourceName[agrosindex] and inDict[ 'TargetEvaluation'].type in DataObjects.knownTypes(): self.sourceData.append(inDict['TargetEvaluation']) foundData = True if not foundData and 'SolutionExport' in inDict.keys(): if inDict['SolutionExport'].name.strip( ) == self.sourceName[agrosindex] and inDict[ 'SolutionExport'].type in DataObjects.knownTypes(): self.sourceData.append(inDict['SolutionExport']) foundData = True if not foundData: self.raiseAnError( IOError, 'the DataObject "{data}" was not found among the "<Input>" nodes for this step!' .format(data=self.sourceName[agrosindex]))
def insert_shipper(): data = request.json shipper = bo.Shippers(ShipperID=data['ShipperID'], ShipperName=data['ShipperName'], Phone=data['Phone']) result = do.Shippers(ConnectionData).insert(shipper) return jsonify({'message': result}), 200
def update_category_by_id(category_id): data = request.json category = bo.Category(CategoryID=category_id, CategoryName=data['CategoryName'], Description=data['Description']) result = do.Category(ConnectionData).update(category) return jsonify({'message': result[0]}), result[1]
def insert_order_detail(): data = request.json orderr = bo.OrderDetail(OrderID=data['OrderID'], ProductID=data['ProductID'], Quantity=data['Quantity']) result = do.OrderDetail(ConnectionData).insert(orderr) return jsonify({'message': result}), 200
def update_categories_by_id(categories_id): data = request.json c = bo.Employees(CategoryID=CategoryID, CategoryName=data['CategoryName'], Description=data['Description']) result = do.Employees(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def update_shipper_by_id(shipper_id): data = request.json c = bo.Shipper(ShipperID=shipper_id, ShipperName=data['ShipperName'], Phone=data['Phone']) result = do.Shipper(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def test_insert(): #ConnectionString = 'database=northwind user=postgres password=postgres host=10.0.2.15 port=5432' c2 = do.Customer(ConnectionData) c1 = bo.Customer(1, 'DAU xanh', 'Peter', '566 Nui Thanh', 'Danang', '50000', 'Vietnam') s1 = c2.insert(c1) return s1
def update_shipper_by_id(shipper_id): data = request.json shipper = bo.Shippers(shipper_id=shipper_id, shipper_name=data['shipper_name'], phone=data['phone']) result = do.Shippers(ConnectionData).update(shipper) return jsonify({'message': result[0]}), result[1]
def run(self, input): """ This method executes the postprocessor action. In this case, it computes the safest point @ In, input, object, object contained the data to process. (inputToInternal output) @ Out, dataCollector, PointSet, PointSet containing the elaborated data """ nearestPointsInd = [] dataCollector = DataObjects.returnInstance('PointSet', self) dataCollector.type = 'PointSet' surfTree = spatial.KDTree(copy.copy(self.surfPointsMatrix[:, 0:self.surfPointsMatrix.shape[-1] - 1])) self.controllableSpace.shape = (np.prod(self.controllableSpace.shape[0:len(self.controllableSpace.shape) - 1]), self.controllableSpace.shape[-1]) self.nonControllableSpace.shape = (np.prod(self.nonControllableSpace.shape[0:len(self.nonControllableSpace.shape) - 1]), self.nonControllableSpace.shape[-1]) self.raiseADebug('RESHAPED CONTROLLABLE SPACE:') self.raiseADebug(self.controllableSpace) self.raiseADebug('RESHAPED NON-CONTROLLABLE SPACE:') self.raiseADebug(self.nonControllableSpace) for ncLine in range(self.nonControllableSpace.shape[0]): queryPointsMatrix = np.append(self.controllableSpace, np.tile(self.nonControllableSpace[ncLine, :], (self.controllableSpace.shape[0], 1)), axis = 1) self.raiseADebug('QUERIED POINTS MATRIX:') self.raiseADebug(queryPointsMatrix) nearestPointsInd = surfTree.query(queryPointsMatrix)[-1] distList = [] indexList = [] probList = [] for index in range(len(nearestPointsInd)): if self.surfPointsMatrix[np.where(np.prod(surfTree.data[nearestPointsInd[index], 0: self.surfPointsMatrix.shape[-1] - 1] == self.surfPointsMatrix[:, 0:self.surfPointsMatrix.shape[-1] - 1], axis = 1))[0][0], -1] == 1: distList.append(np.sqrt(np.sum(np.power(queryPointsMatrix[index, 0:self.controllableSpace.shape[-1]] - surfTree.data[nearestPointsInd[index], 0:self.controllableSpace.shape[-1]], 2)))) indexList.append(index) if distList == []: self.raiseAnError(ValueError, 'no safest point found for the current set of non-controllable variables: ' + str(self.nonControllableSpace[ncLine, :]) + '.') else: for cVarIndex in range(len(self.controllableOrd)): dataCollector.updateInputValue(self.controllableOrd[cVarIndex], copy.copy(queryPointsMatrix[indexList[distList.index(max(distList))], cVarIndex])) for ncVarIndex in range(len(self.nonControllableOrd)): dataCollector.updateInputValue(self.nonControllableOrd[ncVarIndex], copy.copy(queryPointsMatrix[indexList[distList.index(max(distList))], len(self.controllableOrd) + ncVarIndex])) if queryPointsMatrix[indexList[distList.index(max(distList))], len(self.controllableOrd) + ncVarIndex] == self.nonControllableDist[self.nonControllableOrd[ncVarIndex]].lowerBound: if self.nonControllableGrid[self.nonControllableOrd[ncVarIndex]][0] == 'CDF': prob = self.nonControllableGrid[self.nonControllableOrd[ncVarIndex]][2] / float(2) else: prob = self.nonControllableDist[self.nonControllableOrd[ncVarIndex]].cdf(self.nonControllableDist[self.nonControllableOrd[ncVarIndex]].lowerBound + self.nonControllableGrid[self.nonControllableOrd[ncVarIndex]][2] / float(2)) elif queryPointsMatrix[indexList[distList.index(max(distList))], len(self.controllableOrd) + ncVarIndex] == self.nonControllableDist[self.nonControllableOrd[ncVarIndex]].upperBound: if self.nonControllableGrid[self.nonControllableOrd[ncVarIndex]][0] == 'CDF': prob = self.nonControllableGrid[self.nonControllableOrd[ncVarIndex]][2] / float(2) else: prob = 1 - self.nonControllableDist[self.nonControllableOrd[ncVarIndex]].cdf(self.nonControllableDist[self.nonControllableOrd[ncVarIndex]].upperBound - self.nonControllableGrid[self.nonControllableOrd[ncVarIndex]][2] / float(2)) else: if self.nonControllableGrid[self.nonControllableOrd[ncVarIndex]][0] == 'CDF': prob = self.nonControllableGrid[self.nonControllableOrd[ncVarIndex]][2] else: prob = self.nonControllableDist[self.nonControllableOrd[ncVarIndex]].cdf(queryPointsMatrix[indexList[distList.index(max(distList))], len(self.controllableOrd) + ncVarIndex] + self.nonControllableGrid[self.nonControllableOrd[ncVarIndex]][2] / float(2)) - self.nonControllableDist[self.nonControllableOrd[ncVarIndex]].cdf(queryPointsMatrix[indexList[distList.index(max(distList))], len(self.controllableOrd) + ncVarIndex] - self.nonControllableGrid[self.nonControllableOrd[ncVarIndex]][2] / float(2)) probList.append(prob) dataCollector.updateOutputValue('Probability', np.prod(probList)) dataCollector.updateMetadata('ProbabilityWeight', np.prod(probList)) dataCollector.updateMetadata('ExpectedSafestPointCoordinates', self.stat.run(dataCollector)['expectedValue']) self.raiseADebug(dataCollector.getParametersValues('input')) self.raiseADebug(dataCollector.getParametersValues('output')) self.raiseADebug(dataCollector.getMetadata('ExpectedSafestPointCoordinates')) return dataCollector
def update_orderdetails_by_id(orderdetails_id): data = request.json c = bo.OrderDetails(OrderDetailID=OrderDetailID, OrderID=data['OrderID'], ProductID=data['ProductID'], Quantity=data['Quantity']) result = do.OrderDetails(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def _exposureDataCallback(self, keyVar): """New exposureData seen """ if keyVar[0] is None: return self.expDataList.addItem(DataObjects.ExpData(keyVar)) self.predExpDataList.sharedValue = self.expDataList.sharedValue self.redraw()
def insert_order(): data = request.json order = bo.Order(CustomerID=data['CustomerID'], EmployeeID=data['EmployeeID'], OrderDate=data['OrderDate'], ShipperID=data['ShipperID']) result = do.Order(ConnectionData).insert(order) return jsonify({'message': result}), 200
def shipper_insert(): data = request.json c1 = bo.Shipper(data['ShipperID'], data['ShipperName'], data['Phone']) c2 = do.Shipper(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
def update_orderdetail_by_id(customer_id): data = request.json c = bo.oderDetail(CustomerID=od_id, OrderID=data['OrderID'], ProductID=data['ProductID'], Quantity=data['Quantity']) result = do.oderDetail(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def update_order_detail_by_id(odd_id): data = request.json orderr = bo.OrderDetail(OrderDetailID=odd_id, OrderID=data['OrderID'], ProductID=data['ProductID'], Quantity=data['Quantity']) result = do.OrderDetail(ConnectionData).update(orderr) return jsonify({'message': result[0]}), result[1]
def orderdetail_insert(): data = request.json c1 = bo.oderDetail(data['OrderDetailID'], data['OrderID'], data['ProductID'], data['Quantity']) c2 = do.oderDetail(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
def product_insert(): data = request.json c1 = bo.Product(data['ProductID'], data['ProductName'], data['SupplierID'], data['CategoryID'], data['Unit'], data['Price']) c2 = do.Product(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
def update_order_by_id(od_id): data = request.json order = bo.Order(OrderID=od_id, CustomerID=data['CustomerID'], EmployeeID=data['EmployeeID'], OrderDate=data['OrderDate'], ShipperID=data['ShipperID']) result = do.Order(ConnectionData).update(order) return jsonify({'message': result[0]}), result[1]
def update_orders_by_id(supplier_id): data = request.json c = bo.Orders(OrderID=OrderID, CustomerID=data['CustomerID'], EmployeeID=data['EmployeeID'], OrderDate=data['OrderDate'], ShipperID=data['ShipperID']) result = do.Orders(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def __init__(self, master, width=40, helpURL=None): """Create an exposure table """ Tkinter.Frame.__init__(self, master) self.expDataList = DataObjects.DataList( sharedName="plateIDExpType", uniqueName="expNum", ) self.predExpDataList = DataObjects.DataList( sharedName="plateIDExpType", uniqueName="expNum", ) qlModel = TUI.Models.getModel("apogeeql") qlModel.exposureData.addCallback(self._exposureDataCallback) self.headerWdg = RO.Wdg.Text( master=self, width=width, height=3, readOnly=True, helpText="Data about finished and predicted exposures", helpURL=helpURL, ) self.headerWdg.grid(row=0, column=0, sticky="ew") self.headerWdg.tag_configure("title", justify="center") self.headerWdg.tag_configure("header", font="courier") self.logWdg = RO.Wdg.LogWdg( master=self, width=width, height=9, helpText="Data about finished and predicted exposures", helpURL=helpURL, ) self.logWdg.grid(row=1, column=0, sticky="news") self.logWdg.text.configure(font="Courier") self.grid_rowconfigure(1, weight=1) self.grid_columnconfigure(0, weight=1) qlModel.exposureData.addCallback(self._exposureDataCallback) qlModel.predictedExposure.addCallback(self._predictedExposureCallback) self.redraw()
def user_insert(): data = request.json c1 = bo.Customer(data['CustomerID'], data['CustomerName'], data['ContactName'], data['Address'], data['City'], data['PostalCode'], data['Country']) c2 = do.Customer(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
def order_detail_insert(): data = request.json c1 = bo.OrderDetails(OrderDetailID=data['order_id'], ProductID=data['product_id'], Quantity=data['quantity']) c2 = do.OrderDetails(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
def update_product_by_id(product_id): data = request.json c = bo.Product(ProductID=product_id, ProductName=data['ProductName'], SupplierID=data['SupplierID'], CategoryID=data['CategoryID'], Unit=data['Unit'], Price=data['Price']) result = do.Product(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def update_employees_by_id(employees_id): data = request.json c = bo.Employees(EmployeeID=EmployeeID, LastName=data['LastName'], FirstName=data['FirstName'], BirthDate=data['BirthDate'], Photo=data['Photo'], Notes=data['Notes']) result = do.Employees(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def update_user_by_id(customer_id): data = request.json c = bo.Customer(CustomerID=customer_id, CustomerName=data['CustomerName'], ContactName=data['ContactName'], Address=data['Address'], City=data['City'], PostalCode=data['PostalCode'], Country=data['Country']) result = do.Customer(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def order_insert(): data = request.json c1 = bo.Orders(OrderID=data['customer_id'], EmployeeID=data['employee_id'], OrderDate=data['order_date'], ShipperID=data['shipper_id']) c2 = do.Orders(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
def update_supplier_by_id(supplier_id): data = request.json c = bo.Supplier(SupplierID=supplier_id, SupplierName=data['SupplierName'], ContactName=data['ContactName'], Address=data['Address'], City=data['City'], PostalCode=data['PostalCode'], Country=data['Country'], Phone=data['Phone']) result = do.Supplier(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def product_insert(): data = request.json c1 = bo.Products(ProductID=data['product_name'], Unit=data['Unit'], Price=data['price'], SupplierID=data['supplier_id'], CategoryID=data['category_id']) c2 = do.Products(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
def employee_insert(): data = request.json c1 = bo.Employee(last_name=data['last_name'], first_name=data['first_name'], birth_date=data['birth_date'], photo=data['photo'], notes=data['notes']) c2 = do.Employee(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
def employee_insert(): data = request.json c1 = bo.Employee(LastName=data['LastName'], FirstName=data['FirstName'], Birthdate=data['Birthdate'], Photo=data['Photo'], Notes=data['Notes']) c2 = do.Employee(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200