From b504102d638f4a843998850fd55f5045695a553c Mon Sep 17 00:00:00 2001 From: Kotaro Uetake <60615504+ktro2828@users.noreply.github.com> Date: Fri, 15 Nov 2024 01:42:18 +0900 Subject: [PATCH] style: update code style (#37) Signed-off-by: ktro2828 --- t4_devkit/tier4.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/t4_devkit/tier4.py b/t4_devkit/tier4.py index 735e980..3363d71 100644 --- a/t4_devkit/tier4.py +++ b/t4_devkit/tier4.py @@ -245,9 +245,7 @@ def get_table(self, schema: str | SchemaName) -> list[SchemaTable]: Returns: List of dataclasses. """ - if isinstance(schema, SchemaName): - schema = schema.value - return getattr(self, schema) + return getattr(self, SchemaName(schema)) def get(self, schema: str | SchemaName, token: str) -> SchemaTable: """Return a record identified by the associated token. @@ -271,8 +269,7 @@ def get_idx(self, schema: str | SchemaName, token: str) -> int: Returns: The index of the record in table. """ - if isinstance(schema, SchemaName): - schema = schema.value + schema = SchemaName(schema) if self._token2idx.get(schema) is None: raise KeyError(f"{schema} is not registered.") if self._token2idx[schema].get(token) is None: @@ -586,17 +583,13 @@ def box_velocity( if not has_prev and not has_next: return np.array([np.nan, np.nan, np.nan]) - first: SampleAnnotation - if has_prev: - first = self.get("sample_annotation", current.prev) - else: - first = current + first: SampleAnnotation = ( + self.get("sample_annotation", current.prev) if has_prev else current + ) - last: SampleAnnotation - if has_next: - last = self.get("sample_annotation", current.next) - else: - last = current + last: SampleAnnotation = ( + self.get("sample_annotation", current.next) if has_next else current + ) pos_last = last.translation pos_first = first.translation