This commit is contained in:
sneakers-the-rat 2024-08-05 20:59:01 -07:00
parent 51ceb14309
commit 83dd59d30d
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
6 changed files with 11 additions and 7 deletions

View file

@ -308,7 +308,7 @@ There are several different ways to create references between objects in nwb/hdm
- Implicitly, hdmf creates references between objects according to some naming conventions, eg. - Implicitly, hdmf creates references between objects according to some naming conventions, eg.
an attribute/dataset that is a `VectorIndex` named `mydata_index` will be linked to a `VectorData` an attribute/dataset that is a `VectorIndex` named `mydata_index` will be linked to a `VectorData`
object `mydata`. object `mydata`.
- There is currrently a note in the schema language docs that there will be an additional - There is currently a note in the schema language docs that there will be an additional
[Relationships](https://schema-language.readthedocs.io/en/latest/description.html#relationships) system [Relationships](https://schema-language.readthedocs.io/en/latest/description.html#relationships) system
that explicitly models relationships, but it is unclear how that would be different than references. that explicitly models relationships, but it is unclear how that would be different than references.

View file

@ -26,7 +26,7 @@ from linkml_runtime.linkml_model import (
) )
from pydantic import BaseModel from pydantic import BaseModel
from nwb_schema_language import Attribute, Dataset, Group, Schema, CompoundDtype from nwb_schema_language import Attribute, CompoundDtype, Dataset, Group, Schema
if sys.version_info.minor >= 11: if sys.version_info.minor >= 11:
from typing import TypeVarTuple, Unpack from typing import TypeVarTuple, Unpack

View file

@ -3,12 +3,12 @@ Adapters for attribute types
""" """
from abc import abstractmethod from abc import abstractmethod
from typing import ClassVar, Optional, TypedDict, Type from typing import ClassVar, Optional, Type, TypedDict
from linkml_runtime.linkml_model.meta import SlotDefinition from linkml_runtime.linkml_model.meta import SlotDefinition
from nwb_linkml.adapters.adapter import Adapter, BuildResult, is_1d
from nwb_linkml.adapters.array import ArrayAdapter from nwb_linkml.adapters.array import ArrayAdapter
from nwb_linkml.adapters.adapter import BuildResult, is_1d, Adapter
from nwb_linkml.maps import Map from nwb_linkml.maps import Map
from nwb_linkml.maps.dtype import handle_dtype from nwb_linkml.maps.dtype import handle_dtype
from nwb_schema_language import Attribute from nwb_schema_language import Attribute
@ -24,16 +24,19 @@ def _make_ifabsent(val: str | int | float | None) -> str | None:
elif isinstance(val, float): elif isinstance(val, float):
return f"float({val})" return f"float({val})"
else: else:
return str(value) return str(val)
class AttrDefaults(TypedDict): class AttrDefaults(TypedDict):
"""Default fields for an attribute"""
equals_string: str | None equals_string: str | None
equals_number: float | int | None equals_number: float | int | None
ifabsent: str | None ifabsent: str | None
class AttributeMap(Map): class AttributeMap(Map):
"""Base class for attribute mapping transformations :)"""
@classmethod @classmethod
def handle_defaults(cls, attr: Attribute) -> AttrDefaults: def handle_defaults(cls, attr: Attribute) -> AttrDefaults:

View file

@ -7,7 +7,7 @@ from typing import ClassVar, Optional, Type
from linkml_runtime.linkml_model.meta import ArrayExpression, SlotDefinition from linkml_runtime.linkml_model.meta import ArrayExpression, SlotDefinition
from nwb_linkml.adapters.adapter import BuildResult, is_1d, is_compound, has_attrs from nwb_linkml.adapters.adapter import BuildResult, has_attrs, is_1d, is_compound
from nwb_linkml.adapters.array import ArrayAdapter from nwb_linkml.adapters.array import ArrayAdapter
from nwb_linkml.adapters.classes import ClassAdapter from nwb_linkml.adapters.classes import ClassAdapter
from nwb_linkml.maps import QUANTITY_MAP, Map from nwb_linkml.maps import QUANTITY_MAP, Map

View file

@ -2,7 +2,7 @@
Adapter for NWB groups to linkml Classes Adapter for NWB groups to linkml Classes
""" """
from typing import Type, List from typing import List, Type
from linkml_runtime.linkml_model import SlotDefinition from linkml_runtime.linkml_model import SlotDefinition

View file

@ -7,6 +7,7 @@ from typing import Any, Type
import nptyping import nptyping
import numpy as np import numpy as np
from nwb_schema_language import CompoundDtype, DTypeType, FlatDtype, ReferenceDtype from nwb_schema_language import CompoundDtype, DTypeType, FlatDtype, ReferenceDtype
flat_to_linkml = { flat_to_linkml = {