function

“The truth value of an array with more than one element is ambiguous” in python

非 Y 不嫁゛ 提交于 2021-02-11 12:33:39
问题 this is how I got the two arrays (array 1 and array2) for my function: x = np.arange(-5, 5,0.01) prob=stats.norm.pdf(x,0,1) prob_array=numpy.array(prob).reshape(1000,1) #array1 x_tran=m.transpose() x_tran_array=array(x_tran) mu_array=array(mu) # mu is stock return mu_array1=numpy.array(mu_array).reshape(54966,1) sigma_array=array(sigma) #sigma is the historical volatility sigma_array1=numpy.array(sigma_array).reshape(54966,1) mu1_mat=mat(ones((1,1000))) #for matrix calculation original_x=mu

Functions in Tkinter

元气小坏坏 提交于 2021-02-11 12:33:30
问题 So I am practicing using Tkinter with python, and I am just trying to learn the basics. My code right now is import Tkinter as tk class Example(tk.Frame): def __init__(self, parent): tk.Frame.__init__(self, parent) self.prompt = tk.Label(self, text="Press a button", anchor="w") self.button1 = tk.Button(self, text="Button 1", command = self.button1) self.button2 = tk.Button(self, text="Button 2", command = self.button2) self.output = tk.Label(self, text="") # lay the widgets out on the screen.

solve_ivp differential equation solver, way to not integrate all return values?

断了今生、忘了曾经 提交于 2021-02-11 12:31:59
问题 Hey i have a model which gives diferential return values. But also a value which isnt a differential (z) def model(t, f): x = f[0] y = f[1] dx_dt = 2x*y dy_dt = x**3 z = 2*x return dx_dt, dy_dt, z My solver can solve this equations and give me x and y at the respective time values. t = np.linspace(0, 10, 100) f0 = [2, 1, 0] result = solve_ivp(model, [np.min(t), np.max(t)], f0, t_eval=t) But now i want also my solution for z which should NOT be integrated by the solver. Is there any

Firebase functions RangeError: Maximum call stack size exceeded

烈酒焚心 提交于 2021-02-11 12:26:42
问题 I have a Callable function that uploads an image and update Firestore and Storage accordingly. The function does what it should do. but I still get this error: Unhandled error RangeError: Maximum call stack size exceeded here is the function: export const uploadImageToStripe = functions.https.onCall(async (data, context) => { let businessDoc: DocumentSnapshot try { if (!fireStoreDB) { fireStoreDB = admin.firestore(); fireStoreDB.settings(settings); } businessDoc = await fireStoreDB.collection

Firebase functions RangeError: Maximum call stack size exceeded

天涯浪子 提交于 2021-02-11 12:26:05
问题 I have a Callable function that uploads an image and update Firestore and Storage accordingly. The function does what it should do. but I still get this error: Unhandled error RangeError: Maximum call stack size exceeded here is the function: export const uploadImageToStripe = functions.https.onCall(async (data, context) => { let businessDoc: DocumentSnapshot try { if (!fireStoreDB) { fireStoreDB = admin.firestore(); fireStoreDB.settings(settings); } businessDoc = await fireStoreDB.collection

How do nested Javascript returns “pass up” promises?

天大地大妈咪最大 提交于 2021-02-11 12:23:14
问题 This question has two parts, both relating to how Javascript promises are passed around functions using return statements. 1) I have simple Javascript function, which includes multiple return statements. The inner function returns a promise to an arrow function, the arrow function is also returned, like this: const returnMe(data){ return () => { return Promise.resolve(data); }; }; Could I write the following code? returnMe("Hello!").then((msg) => { console.log(msg) }); /// --> output "Hello!"

validate names in kotlin

喜你入骨 提交于 2021-02-11 12:22:01
问题 My problem is the user insert a name like "Jon Snow" and I don't know how to validate with a function if the names first char is upper case and if they are spare by a space fun checkName(nome:String):Boolean{ if (name[0].isUpperCase()){ var count=0 //if (nome) do { count++ }while (name[count]==' ') var charAfterSpace:Char=nome[count]+1 when(charAfterSpace.isUpperCase()){ false->return false //else->return true } } return false } 回答1: Split the string then check if all the elements match the

JavaScript arrow syntax: What does the equals sign on the right hand side mean?

为君一笑 提交于 2021-02-11 12:15:38
问题 I am studying JavaScript syntax. I occasionally see a pattern that confuses me: an equals sign on the right hand side of the arrow. For example, something like this: .then(data => myVariable = data) I don't know what is going on in that syntax. It looks like it is taking the value of data and assigning it to the variable named myVariable . Can somebody explain this? 回答1: You're right. It's an arrow function (without an accompanying block) that "returns" an assignment expression - in effect

R user-defined/dynamic summary function within dplyr::summarise

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-11 12:14:29
问题 Somewhat hard to define this question without sounding like lots of similar questions! I have a function for which I want one of the parameters to be a function name, that will be passed to dplyr::summarise, e.g. "mean" or "sum": data(mtcars) f <- function(x = mtcars, groupcol = "cyl", zCol = "disp", zFun = "mean") { zColquo = quo_name(zCol) cellSummaries <- x %>% group_by(gear, !!sym(groupcol)) %>% # 1 preset grouper, 1 user-defined summarise(Count = n(), # 1 preset summary, 1 user defined !

Why is my treeview in the tkinter shows this?

时光毁灭记忆、已成空白 提交于 2021-02-11 12:13:10
问题 Currently the bug seems to be loosening it's position from my project. I have a last bug which I need to fix in order to complete my project. Code looks like this: c.execute("SELECT * FROM c20 WHERE Position = 'chain';") data1 = c.fetchall() c.execute("SELECT * FROM c20 WHERE Position = 'center';") data2 = c.fetchall() c.execute("SELECT * FROM c20 WHERE Position = 'Total';") data3 = c.fetchall() data1 = p_mod.list_multiply(data, int(copies_data)) data2 = p_mod.list_multiply(data2, int(copies