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

Make Ensemble._*_col public #214

Closed
hombit opened this issue Aug 30, 2023 · 7 comments
Closed

Make Ensemble._*_col public #214

hombit opened this issue Aug 30, 2023 · 7 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@hombit
Copy link
Contributor

hombit commented Aug 30, 2023

Ensemble.batch(func, *args) requires the user to assign *args with column names. A simple and dataset-agnostic way to do it is specifying it via Ensemble object itself:

ens.batch(func, ens._time_col, ens._flux_col)

However, by Python convention, object attributes staring with _ are not the part of the public interface and user should avoid using them. I suggest removing this prefix to have ens.time_col, ens.flux_col, etc instead. If we have a good reason to prevent the user from accidental change of these values, we could have private ens.__time_col and public read-only property, following this pattern:

class C:
    def __init__(self, x):
        self.__x = x
    @property
    def x(self):
        return self.__x
@dougbrn
Copy link
Collaborator

dougbrn commented Aug 30, 2023

The original intent was to shield these a bit from users, particularly with some aversion to users being able to assign something like ens.time_col at will. However, as we've developed and used TAPE more and more, it is apparent that users should be able to access these. I think I'm in favor of the property implementation here over making them directly part of the public interface. But that's not a strong preference.

I do think we should hold off on this until the refactor is complete, as these will likely be properties of the SourceFrame and ObjectFrame, and we may need to think a bit about the best way to show them from the ensemble level (if we want to at all)

@nevencaplar nevencaplar added enhancement New feature or request good first issue Good for newcomers labels Sep 6, 2023
@nevencaplar
Copy link
Member

In similar vein, I would advocate for making Ensemble()._object and Ensemble()._source public (Ensemble().object and Ensemble().source). For instance, we use the Ensemble()._source in help docs. So it does seem that we want these to be public (and I see that I want to use them)

@wilsonbb
Copy link
Collaborator

I do have a draft PR for making Ensemble()._object and Ensemble()._source public. I can go ahead and send it out if people are ok with having to fix their local notebooks after the API change.

@dougbrn
Copy link
Collaborator

dougbrn commented Sep 19, 2023

That sounds good to me if you already have it ready to go 👍

@dougbrn
Copy link
Collaborator

dougbrn commented Oct 6, 2023

@hombit How does this change, if at all, with #261?

Once we have #261, we'll be able to return series objects for the critical columns. Obviously the _flux_col variables are returning the string name, not the critical columns. But users would be able to get the names presumably doing something like this:
ens.source.flux.name (or ens.flux.name if it lived at the ensemble level). Is there an advantage to protecting the internally used labels, while giving users a single property interface to get at data and columns names as needed?

@hombit
Copy link
Contributor Author

hombit commented Oct 7, 2023

.name solution sounds good to me!

We potentially could also think about some sugar and let users pass both names and column objects, e.g. "flux" or ens.flux. But it could go to a separate issue to be implemented later

@dougbrn
Copy link
Collaborator

dougbrn commented Dec 22, 2023

Closing this, as #261 will implement.

@dougbrn dougbrn closed this as completed Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants