-
Notifications
You must be signed in to change notification settings - Fork 16
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
any_of
should accept a list of ArrayExpression
s
#199
Comments
For your second example, each
The value of In order to derive Union[
NDArray[Shape['3'], int]
NDArray[Shape['3, 4'], int]
NDArray[Shape['3'], float]
NDArray[Shape['3, 4'], float]
] You would need something explicit like your 3rd expression? |
Sure! Whichever interpretation. That works for me. I was just trying to think thru the edge cases in an implementation and treating each independently makes it easier |
Here's a quick monkeypatch that meets my needs until we can get #200 merged - def patch_array_expression() -> None:
"""
Allow SlotDefinitions to use `any_of` with `array`
see: https://github.com/linkml/linkml-model/issues/199
"""
from dataclasses import field, make_dataclass
from typing import Optional
from linkml_runtime.linkml_model import meta
new_dataclass = make_dataclass(
"AnonymousSlotExpression",
fields=[("array", Optional[meta.ArrayExpression], field(default=None))],
bases=(meta.AnonymousSlotExpression,),
)
meta.AnonymousSlotExpression = new_dataclass |
In translating NWB, I am replacing my ArrayLike class array representations with the linkml array spec. NWB models support a
dims
andshape
list of list expression such that a given dataset can have several different possible shapes: https://schema-language.readthedocs.io/en/stable/specification_language_description.html#dimsGiven the implementation of
array
at a slot level rather than a type, I need to be able to use it inany_of
like this:this, of course, opens up the potential for combinatorics between
any_of
used withrange
andarray
like this:which I would interpret as meaning the product:
and like this:
which would be (unambiguously)
and i actually think that's a good thing - if we refactor the generators like linkml/linkml#2019, separating the different phases of the build and using build results objects, then it would be easy to handle the combinatorics there (and i would implement it). It doesn't explode the complexity of arrays, it would just require better iteration in the generators (which is good anyway).
without this change, I don't think there would be a way to express a slot being able to have multiple exactly parameterized/labeled array shapes.
cc @rly
The text was updated successfully, but these errors were encountered: