typespecs.api module#
- typespecs.api.ITSELF = <ITSELF>#
Sentinel object specifying metadata-stripped annotation itself.
- class typespecs.api.ItselfType[source]#
Bases:
objectSentinel object specifying metadata-stripped annotation itself.
- class typespecs.api.Spec(*args: Any, **kwargs: Any)[source]#
Bases:
ReadonlyDict[str,Any]Type specification.
This is a subclass of the read-only dictionary without any runtime modifications. It is intended to distinguish a type specification from other type metadata.
- class typespecs.api.SpecFrame(data=None, index: Axes | None = None, columns: Axes | None = None, dtype: Dtype | None = None, copy: bool | None = None)[source]#
Bases:
DataFrameSpecification DataFrame.
This is a subclass of the pandas DataFrame without any runtime modifications. It is intended to distinguish a specification DataFrame from other DataFrames.
- typespecs.api.from_annotated(obj: Any, /, data: str | None = 'data', default: dict[str, ~typing.Any] | ~typing.Any=<NA>, merge: bool = True, separator: str = '/', type: str | None = 'type') SpecFrame[source]#
Create a specification DataFrame from given object with annotations.
- Parameters:
obj – The object to convert.
data – Name of the column for the actual data of the annotations. If it is
None, the data column will not be created.default – Default value for each column. Either a single value or a dictionary mapping column names to values is accepted.
merge – Whether to merge all sub-annotations into a single row. If it is
False, each sub-annotation will have its own row.separator – Separator for concatenating root and sub-indices.
type – Name of the column for the metadata-stripped annotations. If it is
None, the type column will not be created.
- Returns:
Created specification DataFrame.
- typespecs.api.from_annotation(obj: Any, /, *, default: dict[str, ~typing.Any] | ~typing.Any=<NA>, index: str = 'root', merge: bool = True, separator: str = '/', type: str | None = 'type') SpecFrame[source]#
Create a specification DataFrame from given annotation.
- Parameters:
obj – The annotation to convert.
default – Default value for each column. Either a single value or a dictionary mapping column names to values is accepted.
index – Root index of the created specification DataFrame.
merge – Whether to merge all sub-annotations into a single row. If it is
False, each sub-annotation will have its own row.separator – Separator for concatenating root and sub-indices.
type – Name of the column for the metadata-stripped annotations. If it is
None, the type column will not be created.
- Returns:
Created specification DataFrame.
- typespecs.api.from_annotations(obj: dict[str, ~typing.Any], /, *, default: dict[str, ~typing.Any] | ~typing.Any = <NA>, merge: bool = True, separator: str = '/', type: str | None = 'type') SpecFrame[source]#
Create a specification DataFrame from given annotations.
- Parameters:
obj – The annotations to convert.
default – Default value for each column. Either a single value or a dictionary mapping column names to values is accepted.
merge – Whether to merge all sub-annotations into a single row. If it is
False, each sub-annotation will have its own row.separator – Separator for concatenating root and sub-indices.
type – Name of the column for the metadata-stripped annotations. If it is
None, the type column will not be created.
- Returns:
Created specification DataFrame.