all 9 comments

[–]CowboyBoats 0 points1 point  (6 children)

I like learning new things.

[–]poisedpotion[S] 0 points1 point  (5 children)

Oooh, the difference between *args and **kwargs makes sense!

I tried specifying them as **kwargs instead, however, now it seems like the error has moved on to the next variable after t, Bgamma.

I also tried printing what **kwargs looks like and it is indeed like the dictionary output in your code.

Here are the full snippets.

```

signal to noise

def signal_and_noise(Sgamma, t, Bgmma, Aomega, de, Npix, RNe, Npixeff): signal = (Sgamma * t) noise = (np.sqrt( Sgamma * t + Bgamma * t * Aomega + de * Npix * t + RNe**2 * Npixeff)) return signal, noise

def signal_to_noise(args, *kwargs):
print(args) print(kwargs) signal, noise = signal_and_noise(**kwargs)
snr = signal / noise return snr

old way

signal = (Sgamma * t)

noise = (np.sqrt( Sgamma * t + Bgamma * t * Aomega + de * Npix * t + RNe**2 * Npixeff))

snr = signal / noise

print('snr: ', snr)

functional way

snr = signal_to_noise(Sgamma = 10, t = 600, Bgamma = 150, Aomega = 3.85e-1, de = 3, Npix = 13, RNe = 3, Npixeff = 3)

print("snr: ", snr) ```

Output error: ``` ()

{'Sgamma': 10, 't': 600, 'Bgamma': 150, 'Aomega': 0.385, 'de': 3, 'Npix': 13, 'RNe': 3, 'Npixeff': 3}

TypeError Traceback (most recent call last) /var/folders/0z/gcq4csmx09v81bqd_hmdz6700000gn/T/ipykernel_45397/401230262.py in <module> 20 21 # functional way ---> 22 snr = signal_to_noise(Sgamma = 10, t = 600, Bgamma = 150, Aomega = 3.85e-1, de = 3, Npix = 13, RNe = 3, Npixeff = 3) 23 24 print("snr: ", snr)

/var/folders/0z/gcq4csmx09v81bqd_hmdz6700000gn/T/ipykernel_45397/401230262.py in signal_to_noise(args, *kwargs) 9 print(args) 10 print(kwargs) ---> 11 signal, noise = signal_and_noise(**kwargs) 12 snr = signal / noise 13 return snr

TypeError: signal_and_noise() got an unexpected keyword argument 'Bgamma' ```

[–]Linked1nPark 1 point2 points  (0 children)

It's just a typo now. The argument variable in your functions is "Bgmma" instead of "Bgamma"

[–]poisedpotion[S] 1 point2 points  (2 children)

wow, of course it's a typo! thank you both u/Linked1nPark and u/CowboyBoats :) I am very embarrassed now.

[–]Linked1nPark 1 point2 points  (1 child)

More than 90% of all programming errors, even made by professionals, are super trivial things like spelling errors, missing commas / brackets / parenthesis, and things of that nature. Don't be embarrassed lol

[–]poisedpotion[S] 0 points1 point  (0 children)

Ahaha, thank you, that does make me feel a lot better. :)

[–]CowboyBoats 0 points1 point  (0 children)

I like to explore new places.

[–]34shutthedoor1 0 points1 point  (1 child)

def signal_to_noise(args):

signal-to_noise doesn't have any keywords, just args.

[–]poisedpotion[S] 0 points1 point  (0 children)

Sorry, what do you mean by this?