Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing extra arguments to heatmapf callable #180

Open
vegardjervell opened this issue Sep 17, 2021 · 5 comments
Open

Passing extra arguments to heatmapf callable #180

vegardjervell opened this issue Sep 17, 2021 · 5 comments

Comments

@vegardjervell
Copy link

First of all i want to say this all looks great! I needed to pass some extra arguments to the function i was making a heatmap for, so i added it as a kwarg to the heatmapf function (same style as scipy.integrate.quad() and other functions that take in callables).

I think it would be a nice little addition to the library. Linking a pull request where I've implemented it.

@SpyrosBl
Copy link

SpyrosBl commented Dec 2, 2021

Hello, I saw your post, implemented your changes to the base code and wanted some help or a clarification. I am trying to implement a function, similar to the "Shannon Entropy" example given in the basic documentation page. The only difference is that I pass two variables p, q to the function instead of only p (as in the Shannon). I do come across to the following error " missing 1 required positional argument: 'q' " . But if I leave out q, and return to the single value function everything seems to work. Any ideas?

@vegardjervell
Copy link
Author

vegardjervell commented Dec 2, 2021

Hi, awesome! I've written a little example here of how I've been using it locally in my project,

def some_func(x, args):
    a, b, c = args
    x, y, z = x
    return x*a + y*b + z*c

scale=60
fig, tax = tr.figure(scale=scale)
tax.heatmapf(some_func, scale=scale, boundary=False, fargs=(1,-2,3), vmin=-2, vmax=3)
plt.show()

So i just pass any additional arguments as a tuple, and pack them out inside the function. I'm a bit new to Github btw, so I didn't immediately see how i could link my pull request to this issue.

@SpyrosBl
Copy link

SpyrosBl commented Dec 2, 2021

You are a Top Guy, many thanks, now I understand your implementation!

@vegardjervell
Copy link
Author

Thanks! Feel free to add the example to the docs, if you didn't understand it right away, most other people probably wont either :)

@SpyrosBl
Copy link

SpyrosBl commented Dec 2, 2021

Will certainly do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants