Skip to content

Commit

Permalink
dead code elimination
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanLukes committed Aug 23, 2024
1 parent 6beda7b commit 32a45e1
Show file tree
Hide file tree
Showing 48 changed files with 625 additions and 1,156 deletions.
3 changes: 3 additions & 0 deletions src/renkon/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2024-present Dylan Lukes <[email protected]>
#
# SPDX-License-Identifier: BSD-3-Clause
19 changes: 0 additions & 19 deletions src/renkon/api/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions src/renkon/api/stats.py

This file was deleted.

10 changes: 5 additions & 5 deletions src/renkon/cli/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

from renkon.cli.tty import MIN_MATCH_GREEN, MIN_SCORE_GREEN, mask_to_blocks
from renkon.core.engine import BatchInferenceEngine
from renkon.core.trait import AnyTrait, EqualNumeric, EqualString, Linear2, Linear3, Linear4
from renkon.core.trait.integral import Integral
from renkon.core.trait.negative import Negative
from renkon.core.trait.nonzero import Nonzero
from renkon.core.trait.positive import Positive
from renkon.core.old_trait import AnyTrait, EqualNumeric, EqualString, Linear2, Linear3, Linear4
from renkon.core.old_trait.integral import Integral
from renkon.core.old_trait.negative import Negative
from renkon.core.old_trait.nonzero import Nonzero
from renkon.core.old_trait.positive import Positive
from renkon.settings import Settings

ENABLED_TRAITS: dict[type[AnyTrait], bool] = {
Expand Down
4 changes: 2 additions & 2 deletions src/renkon/core/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from polars import DataFrame

from renkon.core.model import Schema
from renkon.core.trait import AnyTrait, AnyTraitSketch
from renkon.core.trait.util.instantiate import instantiate_trait
from renkon.core.old_trait import AnyTrait, AnyTraitSketch
from renkon.core.old_trait.util.instantiate import instantiate_trait

type BatchID = str
type BatchResults = MutableMapping[AnyTraitSketch, AnyTrait | None]
Expand Down
4 changes: 2 additions & 2 deletions src/renkon/core/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: BSD-3-Clause

__all__ = [
"Type",
"RenkonType",
"ColumnName",
"ColumnNames",
"ColumnType",
Expand All @@ -28,5 +28,5 @@
from renkon.core.model.trait.result import TraitResult, TraitResultScore
from renkon.core.model.trait.sketch import TraitSketch
from renkon.core.model.trait.spec import TraitId, TraitSpec
from renkon.core.model.type import Type
from renkon.core.model.type import RenkonType
from renkon.core.model.type_aliases import ColumnName, ColumnNames, ColumnType, ColumnTypes, ColumnTypeSet
12 changes: 6 additions & 6 deletions src/renkon/core/model/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from polars.type_aliases import SchemaDict
from pydantic import ConfigDict, RootModel

from renkon.core.model.type import Type, tyconv_pl_to_rk
from renkon.core.model.type import RenkonType, tyconv_pl_to_rk
from renkon.core.model.type_aliases import ColumnName, ColumnNames


class Schema(RootModel[dict[ColumnName, Type]], Mapping[ColumnName, Type], Hashable):
class Schema(RootModel[dict[ColumnName, RenkonType]], Mapping[ColumnName, RenkonType], Hashable):
"""
Represents a schema for some or all of the columns a data frame.
Expand All @@ -19,18 +19,18 @@ class Schema(RootModel[dict[ColumnName, Type]], Mapping[ColumnName, Type], Hasha
"""

model_config = ConfigDict(frozen=True)
root: dict[ColumnName, Type]
root: dict[ColumnName, RenkonType]

def __hash__(self) -> int:
return hash(tuple(self.root.items()))

@overload
def __getitem__(self, key: ColumnName) -> Type: ...
def __getitem__(self, key: ColumnName) -> RenkonType: ...

@overload
def __getitem__(self, key: ColumnNames) -> Self: ...

def __getitem__(self, key: ColumnName | ColumnNames) -> Type | Self:
def __getitem__(self, key: ColumnName | ColumnNames) -> RenkonType | Self:
match key:
case str():
return self.root[key]
Expand All @@ -52,7 +52,7 @@ def columns(self) -> ColumnNames:
return tuple(self.root.keys())

@property
def dtypes(self) -> tuple[Type, ...]:
def dtypes(self) -> tuple[RenkonType, ...]:
return tuple(self.root.values())

@classmethod
Expand Down
2 changes: 2 additions & 0 deletions src/renkon/core/model/trait/kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TraitKind(StrEnum):
:cvar MODEL: A model of the data, e.g. a linear regression model.
:cvar STATISTICAL: A statistical test or measure, e.g. a t-test.
:cvar TEXTUAL: A textual (string) expression over columns, e.g. "a contains 'b'".
:cvar REFINEMENT: A refinement of the type of a column (e.g. not null, positive, etc).
"""

Expand All @@ -24,3 +25,4 @@ class TraitKind(StrEnum):
MODEL = "model"
STATISTICAL = "statistical"
TEXTUAL = "textual"
REFINEMENT = "refinement"
2 changes: 1 addition & 1 deletion src/renkon/core/model/trait/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ class TraitResult(BaseModel):
score: TraitResultScore
match_mask: BitSeries

param_bindings: dict[str, tuple[str, Any]]
params: dict[str, tuple[str, Any]]
8 changes: 4 additions & 4 deletions src/renkon/core/model/trait/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from renkon.core.model.trait.kind import TraitKind
from renkon.core.model.trait.pattern import TraitPattern
from renkon.core.model.type import Type
from renkon.core.model.type import RenkonType

type TraitId = str

Expand Down Expand Up @@ -60,8 +60,8 @@ class TraitSpec(BaseModel):
kind: TraitKind
pattern: TraitPattern
commutors: list[set[str]] = []
typevars: dict[str, Type] = {}
typings: dict[str, Annotated[Type | str, Field(union_mode="left_to_right")]] = {}
typevars: dict[str, RenkonType] = {}
typings: dict[str, Annotated[RenkonType | str, Field(union_mode="left_to_right")]] = {}

@property
def metavars(self) -> set[str]:
Expand Down Expand Up @@ -109,7 +109,7 @@ def _check_typings_keys_in_pattern(self) -> Self:
@model_validator(mode="after")
def _check_typings_vals_valid_types_or_typevars(self) -> Self:
for key, value in self.typings.items():
if isinstance(value, Type):
if isinstance(value, RenkonType):
continue

if value not in self.typevars:
Expand Down
4 changes: 2 additions & 2 deletions src/renkon/core/model/type/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__all__ = [
"TypeStr",
"is_type_str",
"Type",
"RenkonType",
"IntType",
"FloatType",
"StringType",
Expand All @@ -32,8 +32,8 @@
BottomType,
FloatType,
IntType,
RenkonType,
StringType,
Type,
TypeStr,
UnionType,
any_,
Expand Down
Loading

0 comments on commit 32a45e1

Please sign in to comment.