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

Clean __contains__ #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions pyradigm/pyradigm.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,8 @@ def get_subset(self, subset_ids):
return MLDataset()

def __contains__(self, item):
"Boolean test of membership of a sample in the dataset."
if item in self.keys:
return True
else:
return False
"""Boolean test of membership of a sample in the dataset."""
return item in self.keys
Copy link
Owner

Choose a reason for hiding this comment

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

Hey Scott, thanks for the PR. For a simple test, the suggested code is certainly more compact. However, I planned to add more functionality for [non-]membership, in case of multiple items or a more complex test (e.g. missing data). I should perhaps add a note or TODO here to reflect that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What more complex test would you add? Isn't missing data not contained in the dataset?

Copy link
Owner

Choose a reason for hiding this comment

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

For example, when the missing data is partial, or data is not of certain type across all subjects. I'm still thinking through other use cases, though. But thanks for the suggestion to compactify it.


@staticmethod
def __get_subset_from_dict(input_dict, subset):
Expand Down