Add pyfftw sdp#1132
Conversation
|
Review these changes at https://app.gitnotebooks.com/stumpy-dev/stumpy/pull/1132 |
There was a problem hiding this comment.
@NimaSarajpoor I've left some comments for you to address. I think we can afford to be clearer since all of this pyfftw stuff will be hard to maintain. We should probably be as verbose (and add more comments cross referencing their docs as possible). I'll do another few passes after you've responded and made modifications. I think this pyfftw stuff needs to be crystal clear
|
@seanlaw |
|
@NimaSarajpoor This might be a distraction but a (very, very small) part of me was wondering if we should be using a closure instead of a class: https://realpython.com/python-closure/ I don't know if it makes things easier/harder to read. Given all of the array allocations, maybe a class is the right thing to use. I just wanted to bring it to your attention since I'm not sure we're getting the full benefits of a class since:
Just something to consider. No pressure though. |
This is something that bothered me too but thought the reason for being bothered is just my lack of experience and, also, I didn't know/think about an alternative option.
Thanks for sharing this! I will go through this and try to modify the script. Let's see how it will look like. |
|
@seanlaw |
Yeah, it feels pretty natural! There is one thing that still bothers me and that is "how do you change/reset max_n after the function has been created?" The natural thing to do is to overwrite the existing It feels like we're very close.
Indeed. This is partially why I didn't like using the class approach! |
I did not think about this scenario. I am now thinking in what scenario(s) a user might want to change We can define a new function inside |
Okay... on second thought, I think it should be okay to allow the returned callable object has a "callable feature" for resetting |
Can you please show me a complete example of how this works (i.e., from instantiating a new object to changing the |
Maybe I should've used the name |
I don't think I understand what you mean by "user cannot check if the array is resized". Can you articulate what could possibly go wrong? What would somebody need/want to verify? Do the arrays automatically get resized if, later, somebody uses an array that is larger than |
Yes. Based on the current design, if
Please ignore. That was stupid!
What do you think about this? Now that we are planning to add |
I guess I would need to consider what the side effect would be if the preallocated were to be automatically resized (i.e., what would be the problem with this?). Currently, I don't see any issues with automatically resizing the preallocated array |
NimaSarajpoor
left a comment
There was a problem hiding this comment.
@seanlaw
I just left one comment. I think it should be ready to merge after discussing/addressing that comment.
seanlaw
left a comment
There was a problem hiding this comment.
@NimaSarajpoor I've left some comments for you to consider. Once completed, please let me know as I'd like to go over the code in more detail before you move on (as it's been a while since I've gone over things).
|
|
||
| Parameters | ||
| ---------- | ||
| max_n : int, default 2**20 |
There was a problem hiding this comment.
The more I think about this, the more I feel like max_n is the wrong parameter name because "max" implies that the array length cannot exceed this number but we might actually violate that. Perhaps, what we're really talking about is the "initial size/length" and so maybe something like init_size or init_len.
There was a problem hiding this comment.
Additionally, I notice that we are overloading n in n_threads and next_fast_n so the n is starting to either losing meaning or we are being inconsistent when we add max_n.
I can handle two different meanings for n within the same function but probably not more. I almost feel like I might be okay with nfl = pyfftw.next_fast_len(n) as long as it is defined clearly (i.e., this assignment isn't hidden/buried and I can quickly lookup what nfl is)
There was a problem hiding this comment.
Currently, n appears in the following cases:
- The len of
T-->n - next_fast_len(n) -->
next_fast_n - The (initial) len of (real-valued) preallocated array -->
max_n - number of threads -->
n_threads
- Good
- The value returned by
next_fast_len(n)is strongly tied ton. So, I think it should be okay to keepnext_fast_n. This is used in several lines. So using a name that reflects its description should help with the readability of the code. - As you pointed out, it is better to avoid using
max_n. I thinkinit_lenis a good choice. - Can we use
num_threadsinstead? I can seen_threadsis used in other modules though as well.
There was a problem hiding this comment.
- Okay, keep it as
next_fast_n - Cool. Let's do
init_lenthen - I think
n_threadsis fine. We're already use to seeing it elsewhere and I never get it confused with other code.
I think simply changing max_n to init_len should be sufficient
This is to address
PR 3described in #1118 (comment). Have copied the corresponding notes below: