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

Allow multi subjects & objects in graph funcs #3086

Merged
merged 5 commits into from
Mar 24, 2025
Merged

Allow multi subjects & objects in graph funcs #3086

merged 5 commits into from
Mar 24, 2025

Conversation

nicholascar
Copy link
Member

This PR allows graph.subjects() & graph.objects() to receive a list of objects & subjects respectively, rather than just single values

@ashleysommer
Copy link
Contributor

@nicholascar Is this a feature for v7.x or v8.0?

Is this too much feature-overlap with graph.triples_choices()?

@nicholascar
Copy link
Member Author

@nicholascar Is this a feature for v7.x or v8.0?

Is this too much feature-overlap with graph.triples_choices()?

Good pick on that overlap. I do want to slim down all the various graph functions so we have fewer but more capable ones than now. This is because it's too hard to remember many functions. Easier to remember fewer and then see their permissive signatures for all the options.

So I'd like to boil down triples_choices() into just triples() perhaps and this PR helps me think about how to get there by doing just the simple subjects() and objects() equivalents first

@nicholascar nicholascar merged commit 0c277e9 into main Mar 24, 2025
17 of 20 checks passed
@nicholascar nicholascar deleted the allow-multi branch March 24, 2025 04:47
@@ -847,26 +847,32 @@ def set(
def subjects(
self,
predicate: Union[None, Path, _PredicateType] = None,
object: Optional[_ObjectType] = None,
object: Optional[Union[_ObjectType, List[_ObjectType]]] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

@nicholascar : Was there a reason this used List[...] instead of Sequence[...]?

Copy link
Contributor

Choose a reason for hiding this comment

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

The use case I have in mind: I often load sets with URIRef instead of lists to de-duplicate.

@@ -847,26 +847,32 @@ def set(
def subjects(
self,
predicate: Union[None, Path, _PredicateType] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

If object gets a plurality expansion, why not predicate too (and likewise with other functions)? Something to do with Path?

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.

3 participants