Skip to content

Conversation

@xgarrido
Copy link
Contributor

Following discussion #81 , this PR proposes to extend the ability to get window for (Log)TopHatWindow the same as BandpowerWindow.

When filling data via add_ell_cl function, the (Log)TopHatWindow object is associated to a window_ind tag which indexes its position related to data index.

When retrieving the windows via get_bandpower_windows (it may be worth renaming this function into get_windows since it is not anymore dedicated to only BandpowerWindow), then the full binning array is computed given the selected indices (here again, in the same way as BandpowerWindow).

The important thing to think about is that (Log)TopHatWindow object is now storing the whole bin edges and not a pair of min/max value. Nevertheless, it should be backward compatible since min/max scalar values can also be represented by one entry array.

We may understand this feature is not required or desired and that it exists other way to extract the windows (using get_tag functions for instance, see #81 discussion) but the important point is that it allows to treat BandpowerWindow and (Log)TopHatWindow objects the same way without assuming or accessing the type of window.

This will close #81

…lass)

- the `get_section` method in now an empty method from `BaseWindow` class and is properly implemented
for inherited class

- when adding window with `add_ell_cl` the duplication of windows with corresponding window indices
is also done for TopHatWindow and its inherited class such as `LogTopHatWindow`
Copy link
Collaborator

@joezuntz joezuntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looked okay, apart from the note below.

But I'm not committing to this use of the Window functions. I think we need to decide whether to rethink either the basic window functions or the bandpower ones.

if isinstance(window, BandpowerWindow):
if len(ell) != window.nv:
if isinstance(window, (BandpowerWindow, TopHatWindow)):
nv = window.nv if isinstance(window, BandpowerWindow) else len(window.min)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will crash if window.min is an integer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, we must ensure window.min is an array. This will fail here but also here.

The min/max class attributes must be arrays. We can use np.asarray within the __init__ of TopHatWindow but I think this is related to the redesign/rethink of the window classes you mention.

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

Successfully merging this pull request may close these issues.

TopHatWindow (mis-)use

2 participants