def getNPS(self,NPSRaw,ordersRaw,weekPivot): NPSRaw = NPSRaw[260:] for i in range(0,len(NPSRaw)): pkOrder = BaseFunction().getColumn(ordersRaw,0) NPSRaw[i].append(ordersRaw[pkOrder.index(NPSRaw[i][0])][4]) myDict = BaseFunction().getDict(NPSRaw,weekPivot,5) allKey = BaseFunction().sortKey(myDict) NPSLunch = [10] * len(allKey) NPSDinner = [10] * len(allKey) NPSTotal = [10] * len(allKey) #first loop scan different key for i in range(0,len(allKey)): lunchCount = 0 dinnerCount = 0 #second loop scan every value in one key for j in range(0,len(myDict[allKey[i]])): temp = myDict[allKey[i]][j] if temp[4] != None: if temp[5].hour < 15: NPSLunch[i] = NPSLunch[i] + BaseFunction().getScore(temp[4]) lunchCount += 1 else: NPSDinner[i] = NPSDinner[i] + BaseFunction().getScore(temp[4]) dinnerCount += 1 NPSTotal[i] = NPSTotal[i] + BaseFunction().getScore(temp[4]) NPSLunch[i] = (NPSLunch[i]-10)*100/lunchCount NPSDinner[i] = (NPSDinner[i]-10)*100/dinnerCount NPSTotal[i] = (NPSTotal[i]-10)*100/(lunchCount+dinnerCount) return(NPSLunch,NPSDinner,NPSTotal)
def getDaysRepaet(self,ordersRaw,weekPivot): myDict = BaseFunction().getDict(ordersRaw,weekPivot,4) allKey = BaseFunction().sortKey(myDict) fourDaysRepaet = [0] * len(allKey) eightDaysRepaet = [0] * len(allKey) #first loop scan different key for i in range(2,len(allKey)): #create 14 days recode id and get more than 1 number temp14 = BaseFunction().getColumn(myDict[allKey[i-1]],1) temp14 = temp14 + BaseFunction().getColumn(myDict[allKey[i-2]],1) for j in range(0,len(set(temp14))): if temp14.count(list(set(temp14))[j]) > 1: fourDaysRepaet[i] += 1 #create 28 days recode id if i > 3: temp28 = BaseFunction().getColumn(myDict[allKey[i-1]],1) temp28 = temp28 + BaseFunction().getColumn(myDict[allKey[i-2]],1) temp28 = temp28 + BaseFunction().getColumn(myDict[allKey[i-3]],1) temp28 = temp28 + BaseFunction().getColumn(myDict[allKey[i-4]],1) for j in range(0,len(set(temp28))): if temp28.count(list(set(temp28))[j]) > 1: eightDaysRepaet[i] += 1 fourDaysRepaet[i] = fourDaysRepaet[i]*100/len(set(temp14)) if i > 3: eightDaysRepaet[i] = eightDaysRepaet[i]*100/len(set(temp28)) return(fourDaysRepaet,eightDaysRepaet)
def getBentoNum(self,orderDetailsRaw,ordersRaw,weekPivot): #Get all key to prepare myDict = BaseFunction().getDict(orderDetailsRaw,weekPivot,3) allKey = BaseFunction().sortKey(myDict) #create 2 lists bentoLunch = [0] * len(allKey) bentoDinner = [0] * len(allKey) status = BaseFunction().getStatus(orderDetailsRaw,ordersRaw) pkOrder = BaseFunction().getColumn(orderDetailsRaw,1) meal = BaseFunction().getMeal(BaseFunction().getColumn(orderDetailsRaw,2)) #first loop scan different key for i in range(0,len(allKey)): #second loop scan every value in one key for j in range(0,len(myDict[allKey[i]])): temp = myDict[allKey[i]][j] if status[pkOrder.index(temp[1])] == "Delivered": if meal[pkOrder.index(temp[1])] == "lunch": bentoLunch[i] += 1 else: bentoDinner[i] += 1 bentoLunch[i] = bentoLunch[i]/5 bentoDinner[i] =bentoDinner[i]/5 return(bentoLunch,bentoDinner)
Nik_u = np.zeros((N, 1)) Nik_v = np.zeros((M, 1)) # 1. u方向细分 X_M_piece = np.zeros((M, piece_u)) # 沿着u方向的网格 Y_M_piece = np.zeros((M, piece_u)) Z_M_piece = np.zeros((M, piece_u)) if FLAG_U == 1: NodeVector_u = np.linspace(0, 1, n + k + 2) # 均匀B样条的u向节点向量 u = np.linspace(k / (n + k + 1), (n + 1) / (n + k + 1), piece_u) # u向节点分成若干份 for i in range(M): for j in range(piece_u): for ii in range(n + 1): Nik_u[ii][0] = BaseFunction(ii, k, u[j], NodeVector_u) X_M_piece[i][j] = np.dot(X[i], Nik_u) Y_M_piece[i][j] = np.dot(Y[i], Nik_u) Z_M_piece[i][j] = np.dot(Z[i], Nik_u) if FLAG_U == 2: NodeVector_u = U_quasi_uniform(n, k) # 准均匀B样条的u向节点向量 u = np.linspace(0, 1 - 0.0001, piece_u) # u向节点分成若干份 for i in range(M): for j in range(piece_u): for ii in range(n + 1): Nik_u[ii][0] = BaseFunction(ii, k, u[j], NodeVector_u) X_M_piece[i][j] = np.dot(X[i], Nik_u) Y_M_piece[i][j] = np.dot(Y[i], Nik_u) Z_M_piece[i][j] = np.dot(Z[i], Nik_u) print(Nik_u)
from LinearEquationsSystem import LinearEquationsSystem from Solution import Solution from myFunctions import printVector # 2n+1 piramid wzdłuż każdej osi n = 1 # Lista funkcji bazowych -> piramid eArr = [] # pomija piramidy na brzegu Dirichleta # piramidy o środkach poniżej osi OX for j in range(-n, 0): for i in range(-n, n+1): eArr.append( BaseFunction(n, i, j) ) # piramidy o środkach powyżej osi OX, na lewo od osi OY for j in range(0, n+1): for i in range(-n, 0): eArr.append( BaseFunction(n, i, j) ) # # dopisuje piramidy na brzegu Dirichleta # # na środku układu # eArr.append( BaseFunction(n, 0, 0) ) # # wzdłuż osi OY # for i in range(1, n+1): # eArr.append( BaseFunction(n, 0, i) ) # # wzdłuż osi OX # for i in range(1, n+1): # eArr.append( BaseFunction(n, i, 0) )