Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 7 additions & 8 deletions arc/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@
BOARD_GAP_STR = " " * settings.board_gap
PAIR_GAP_STR = "\n" + " " * settings.pair_gap + "\n"

COLORMAP = {0: 0, 1: 4, 2: 1, 3: 2, 4: 3, 5: 8, 6: 5, 7: 166, 8: 6, 9: 52}
COLORMAP = {0: 0, 1: 4, 2: 1, 3: 2, 4: 3, 5: 220, 6: 5, 7: 166, 8: 6, 9: 52}

class Board(pydantic.RootModel):
root: list[list[int]]

class Board(pydantic.BaseModel):
__root__: list[list[int]]

@pydantic.validator("__root__", pre=True)
@pydantic.validator("root", pre=True)
def validate_native_list(cls, v):
if isinstance(v, np.ndarray):
v = v.tolist()
return v

@pydantic.validator("__root__")
@pydantic.validator("root")
def validate_non_ragged(cls, v):
if len(set(lengths := list(map(len, v)))) != 1:
raise ValueError(
Expand All @@ -36,7 +35,7 @@ def validate_non_ragged(cls, v):

@property
def data(self):
return self.__root__
return self.root

@property
def data_flat(self):
Expand Down Expand Up @@ -75,7 +74,7 @@ def fmt_cell(self, row: int, col: int, colored=False) -> str:
color = COLORMAP[value]
value_str = f"{CELL_PADDING_STR}{value}{CELL_PADDING_STR}"
if colored:
return f"{fg(15)}{bg(color)}{value_str}{attr(0)}"
return f"{fg(15)}{bg(color)}{value_str}{attr('reset')}"
else:
return value_str

Expand Down
3 changes: 1 addition & 2 deletions arc/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@

import numpy as np
import pydantic
import pydantic.generics

from arc.interface import Board, BoardPair, EvalResult, EvalResultList, TopKList

C = TypeVar("C")
A = TypeVar("A")


class MetricResult(pydantic.generics.GenericModel, Generic[C, A]):
class MetricResult(pydantic.BaseModel, Generic[C, A]):
name: str
compute_results: Optional[list[C]] = None
aggregate_result: Optional[A] = None
Expand Down
4 changes: 2 additions & 2 deletions arc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import os.path
from typing import Optional

import pydantic
from pydantic_settings import BaseSettings


class Settings(pydantic.BaseSettings):
class Settings(BaseSettings):
cache_path: str = os.path.expanduser("~/.arc/cache")
dataset_dir: Optional[str] = None
cell_padding: int = 1
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"loguru",
"tqdm",
"pydantic",
"pydantic-settings",
"filelock",
"colored",
"matplotlib",
Expand Down