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

WIP: Make Scheme.[dtype|labels] a property #279

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions audformat/core/scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,30 @@ def __init__(
)
dtype = dtype_labels

self.dtype = dtype
r"""Data type"""
self.labels = labels
r"""List of labels"""
self._dtype = dtype
self._labels = labels

self.minimum = minimum if self.is_numeric else None
r"""Minimum value"""
self.maximum = maximum if self.is_numeric else None
r"""Maximum value"""

@property
def dtype(self) -> str:
r"""Data type"""
return self._dtype

@property
def labels(self) -> typing.Optional[typing.Union[dict, list, str]]:
r"""Labels of scheme"""
if (
self._labels is not None
and not isinstance(self._labels, str)
):
return self._labels.copy()
else:
return self._labels

@property
def is_numeric(self) -> bool:
r"""Check if data type is numeric.
Expand Down Expand Up @@ -327,7 +342,7 @@ def replace_labels(
f"'{dtype_labels}'"
)

self.labels = labels
self._labels = labels

if self._db is not None and self._id is not None:
labels = self._labels_to_list(labels)
Expand Down