function

For loop works perfectly fine, but once I make a function out of it, it suddenly doesn't give the right results in R

爷,独闯天下 提交于 2021-01-29 17:37:52
问题 I have the following for-loop which does exactly what I want: for (t in 3:20){ XX <- c(rep(0,22)) for (k in (1:(t-2))){ XX[k] <- (theta^(k-1) * (P[t-k] - P[t-k-1])) } X[t] = (1-theta) * sum(XX) + theta^(t-1) P[t] <- D[t] + (0.7/0.3) * X[t] - 0.1*3^2*1*(20-t-1 + (1/0.3)) } However, once I make a function out of and use the function the results are suddenly wrong: BGJS <- function(theta){ for (t in 3:20){ XX <- c(rep(0,22)) for (k in (1:(t-2))){ XX[k] <- (theta^(k-1) * (P[t-k] - P[t-k-1])) } X

Custom max_pool layer: ValueError: The channel dimension of the inputs should be defined. Found `None`

a 夏天 提交于 2021-01-29 17:26:50
问题 I am working on tensorflow2 and I am trying to implement Max unpool with indices to implement SegNet. When I run it I get the following problem. I am defining the def MaxUnpool2D and then calling it in the model. I suppose that the problem is given by the fact that updates and mask have got shape (None, H,W,ch). def MaxUnpooling2D(updates, mask): size = 2 mask = tf.cast(mask, 'int32') input_shape = tf.shape(updates, out_type='int32') # calculation new shape output_shape = ( input_shape[0],

changing the colour based on the graphs positions matplotlib

独自空忆成欢 提交于 2021-01-29 17:24:27
问题 With the dataset below i am trying to plot a line graph on matplotlib. I am trying to make a function that looks at the previous number and checks whether the current number is higher. If the current function is bigger it would draw a blue line going to the next point such as it would draw a blue line between (1,100) and (2,9313) . If its not greater (6,203542) and (7,203542) , a red line would be drawn. import matplotlib.pyplot as plt x_long = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] L

Python class instance changed during local function variable

坚强是说给别人听的谎言 提交于 2021-01-29 15:41:48
问题 Let's for example define a class and a function class class1(object): """description of class""" pass def fun2(x,y): x.test=1; return x.value+y then define a class instance and run it as a local variable in the function z=class1() z.value=1 fun2(z,y=2) However, if you try to run the code z.test a result 1 would be returned. That was, though the attribute to x was done inside the fun2() locally, it extended to class instance x globally as well. This seemed to violate the first thing one learn

Function to calcuute future values =)

若如初见. 提交于 2021-01-29 15:14:53
问题 guys, need help with my function, just one moment...if "Range" is null (Cell have value "") then ignore it, because i have alredy done it to count i dont know how to change for ignoring such cells. Thank you Public Function future (ByVal r1 As Range, ByVal r2 As Range, ByVal r3 As Byte) As Variant On Error GoTo errHandler If (r1.Columns.Count <> r2.Columns.Count Or r1.Rows.Count <> 1 Or r2.Rows.Count <> 1) Then future = "ERROR!""" Exit Function End If Dim denominatorSum As Double Dim

Can we pass state variable as an argument to external util function from react js function defined inside a component?

可紊 提交于 2021-01-29 14:51:07
问题 I need to pass state variable as a parameter to external function. I am trying to do something like this. https://stackblitz.com/edit/react-vvdfx4?file=index.js Expected to work like a slackblits link provided It is working properly here but unable to figure out why it is throwing error in my project. I am passing array of object as argument. `GlobalHeader.js:340 Uncaught TypeError: Object(...) is not a function at GlobalHeader.temp (GlobalHeader.js:340) at GlobalHeader.<anonymous>

Python definition function parameter passing [closed]

柔情痞子 提交于 2021-01-29 13:41:54
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . For most of you this is probably common sense but I am finding it very, very hard to get a handle on this. If you create a function such as def one(): x=1 y=2 z=3 h=33 j=454 l=353 m=898 then lets say I have

Parallelise output of input function in Snakemake

南楼画角 提交于 2021-01-29 13:30:51
问题 Hello Snakemake community, I am having quite some troubles to define correctly a function in Snakemake and call it in the params section. The output of the function is a list and my aim is to use each item of the list as a parameter of a shell command. In other words, I would like to run multiple jobs in parallel of the same shell command with a different parameter. This is the function: import os, glob def get_scontigs_names(wildcards): scontigs = glob.glob(os.path.join("reference",

Python-Why aren't my elif statements not getting evaluated in this recursive multiplication which takes into account negative numbers

和自甴很熟 提交于 2021-01-29 11:32:47
问题 Hi I have looked up a few recursive multiplication of 2 numbers in python, but none of them take into account the possibility of negative numbers or if they do they don't explain the entire steps. I have coded the following the program but I am getting an error, can someone please let me know what is wrong with it? def mult(a,b): if a==0 | b==0: return 0 elif a==1: return b elif a > 0 & b >0: return b + mult(a-1,b) elif a < 0 & b > 0: return - b + mult(a+1,b)) elif a > 0 & b < 0: return - b +

How to Call a Function with 'on_press' command inside same class using KIVY button

 ̄綄美尐妖づ 提交于 2021-01-29 11:14:27
问题 I'm trying to call a popup and the have the user input text. After hitting the save button inside my popup it updates a new widget. I have almost everything working but I don't know how to properly call a function inside the same class. I have two functions inside of my 'class Trackers(Screen):' how can I make a button that 'on_press' command will trigger another function? The line of code I need to be fixed is this: okay = Button(text='Save', on_press=self.addit(str(text_input), num), on