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

New Dataset superclass #89

Merged
merged 6 commits into from
Nov 26, 2024
Merged

New Dataset superclass #89

merged 6 commits into from
Nov 26, 2024

Conversation

willdumm
Copy link
Contributor

@willdumm willdumm commented Nov 22, 2024

Addressing #55, I consolidating some branch lengths-related code into a new superclass BranchLengthDataset. I can't seem to find any other duplicated code.

The only opportunity for more code reuse would be to abstract methods like to that map over all attributes of the class and apply some function. This could be done in BranchLengthDataset using the vars builtin, but I think it might be more trouble than it's worth.

Will close #55

@willdumm willdumm marked this pull request as ready for review November 22, 2024 19:25
@willdumm willdumm requested a review from matsen November 22, 2024 19:30
@willdumm willdumm marked this pull request as draft November 22, 2024 20:58
Copy link
Contributor

@matsen matsen left a comment

Choose a reason for hiding this comment

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

👍

@matsen matsen marked this pull request as ready for review November 22, 2024 21:13
@willdumm
Copy link
Contributor Author

@matsen I also addressed #22, by moving some methods and functions around. All pre-existing functions and methods should work as they did before.

@willdumm willdumm linked an issue Nov 22, 2024 that may be closed by this pull request
Copy link
Contributor

@matsen matsen left a comment

Choose a reason for hiding this comment

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

I appreciate what you're doing here, but there's something that doesn't quite make sense.

The ModelBase covers all sorts of models, e.g. SHM models, so it doesn't make sense for it to have a method selection_factors_of_sequences. We could call it something generic like evaluate_sequences, as long as all the components will make sense for SHM models and DXSM models.

netam/models.py Outdated
def selection_factors_of_sequences(self, sequences, encoder=None):
if encoder is None:
raise ValueError("An encoder must be provided.")
device = next(self.parameters()).device
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make this a @property .

@willdumm
Copy link
Contributor Author

willdumm commented Nov 25, 2024

I've changed selection_factors_of_sequences to evaluate_sequences, and added a device property to the ModelBase and AbstractBinarySelectionModel classes.

@willdumm willdumm merged commit 469420e into main Nov 26, 2024
2 checks passed
@willdumm willdumm deleted the 55-new-superclass branch November 26, 2024 18:03
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.

Consolidate branch length methods to new Dataset subclass Make the DNSM Crepe work like the SHM Crepe
2 participants