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

Filter for RecordDataBase #159

Merged
merged 21 commits into from
Apr 22, 2024
Merged

Filter for RecordDataBase #159

merged 21 commits into from
Apr 22, 2024

Conversation

nickhaf
Copy link
Collaborator

@nickhaf nickhaf commented Apr 10, 2024

Implemented a filter function for databases.
Wrote a method for Base.filter() that takes a filter function, a database and, additionally, the level on which the filter function should be applied (Record, Study, Model, Taxon).
The filter function can also work with rating() or certainty() so the function definition works a bit more naturally, see documentation of filter().

@nickhaf nickhaf marked this pull request as draft April 10, 2024 14:21
Copy link
Contributor

Docs can be previewed here: https://formal-methods-mpi.github.io/Taxonomy.jl/previews/PR159

@nickhaf nickhaf self-assigned this Apr 10, 2024
Copy link
Contributor

Docs can be previewed here: https://formal-methods-mpi.github.io/Taxonomy.jl/previews/PR159

Copy link
Contributor

Docs can be previewed here: https://formal-methods-mpi.github.io/Taxonomy.jl/previews/PR159

Copy link
Contributor

Docs can be previewed here: https://formal-methods-mpi.github.io/Taxonomy.jl/previews/PR159

Copy link
Contributor

Docs can be previewed here: https://formal-methods-mpi.github.io/Taxonomy.jl/previews/PR159

"""
function Base.filter(f, db::RecordDatabase, level::AbstractString)::RecordDatabase

@assert level in ["Record", "Study", "Model", "Taxon"] "Invalid level. Choose from 'Record', 'Study', 'Model', 'Taxon'"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not that happy with this solution, works for now but do you have a more elegant way?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine. I assume that you dislike, that this implementation is not generic in terms of levels, and that you are traversing each layer manually? In such cases, recursion is usually a more elegant way but since the depth is predefined to not exceed 4 this is fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@aaronpeikert Yes, recursion was one concern. Going along with that I was also thinking of some way to add the aimed level into the function f instead having to define it in an extra argument, because that would be more flexible in case new levels are added. However I agree that for now this approach works just fine, so I will leave it at that.

Copy link
Contributor

Docs can be previewed here: https://formal-methods-mpi.github.io/Taxonomy.jl/previews/PR159

Copy link
Contributor

Docs can be previewed here: https://formal-methods-mpi.github.io/Taxonomy.jl/previews/PR159

@nickhaf nickhaf requested a review from aaronpeikert April 11, 2024 09:39
@nickhaf nickhaf marked this pull request as ready for review April 11, 2024 09:39
Copy link
Contributor

@aaronpeikert aaronpeikert left a comment

Choose a reason for hiding this comment

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

This is a much needed feature. Thank you for taking it on! I love that you invested so much in testing.

"""
function Base.filter(f, db::RecordDatabase, level::AbstractString)::RecordDatabase

@assert level in ["Record", "Study", "Model", "Taxon"] "Invalid level. Choose from 'Record', 'Study', 'Model', 'Taxon'"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine. I assume that you dislike, that this implementation is not generic in terms of levels, and that you are traversing each layer manually? In such cases, recursion is usually a more elegant way but since the depth is predefined to not exceed 4 this is fine.

@aaronpeikert
Copy link
Contributor

Ignore the failure on nightly.

@nickhaf nickhaf merged commit 7ff936b into main Apr 22, 2024
5 of 6 checks passed
@nickhaf nickhaf deleted the filters_rework branch April 22, 2024 08:58
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.

2 participants