cbrkit 0.2.1__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cbrkit-0.2.1 → cbrkit-0.3.0}/PKG-INFO +1 -1
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/global_sim/graph/_astar.py +2 -2
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/global_sim/graph/_model.py +1 -1
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/loaders.py +21 -6
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/retrieval.py +2 -2
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/sim/taxonomy.py +3 -1
- {cbrkit-0.2.1 → cbrkit-0.3.0}/pyproject.toml +1 -1
- {cbrkit-0.2.1 → cbrkit-0.3.0}/LICENSE +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/README.md +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/__init__.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/__main__.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/api.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/cli.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/global_sim/__init__.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/global_sim/_aggregate.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/global_sim/_attribute_value.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/global_sim/graph/__init__.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/py.typed +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/sim/__init__.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/sim/_helpers.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/sim/collections.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/sim/generic.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/sim/numeric.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/sim/strings.py +0 -0
- {cbrkit-0.2.1 → cbrkit-0.3.0}/cbrkit/typing.py +0 -0
|
@@ -22,7 +22,7 @@ from cbrkit.typing import Casebase, FloatProtocol, KeyType, SimPairFunc, SimType
|
|
|
22
22
|
logger = logging.getLogger(__name__)
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
@dataclass
|
|
25
|
+
@dataclass(slots=True)
|
|
26
26
|
class GraphMapping(Generic[GraphData, NodeKey, NodeData, EdgeKey, EdgeData]):
|
|
27
27
|
"""Store all mappings and perform integrity checks on them"""
|
|
28
28
|
|
|
@@ -107,7 +107,7 @@ class GraphMapping(Generic[GraphData, NodeKey, NodeData, EdgeKey, EdgeData]):
|
|
|
107
107
|
self.edge_mappings[x] = y
|
|
108
108
|
|
|
109
109
|
|
|
110
|
-
@dataclass
|
|
110
|
+
@dataclass(slots=True)
|
|
111
111
|
class SearchNode(Generic[GraphData, NodeKey, NodeData, EdgeKey, EdgeData]):
|
|
112
112
|
"""Specific search node"""
|
|
113
113
|
|
|
@@ -19,7 +19,7 @@ class NodeProtocol(Hashable, Protocol[NodeData]):
|
|
|
19
19
|
data: NodeData
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
@dataclass
|
|
22
|
+
@dataclass(slots=True)
|
|
23
23
|
class Graph(Generic[GraphData, NodeKey, NodeData, EdgeKey, EdgeData]):
|
|
24
24
|
nodes: dict[NodeKey, NodeProtocol[NodeData]]
|
|
25
25
|
edges: dict[EdgeKey, EdgeProtocol[EdgeData, NodeKey]]
|
|
@@ -53,6 +53,8 @@ def python(import_name: str) -> Any:
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
class DataFrameCasebase(abc.Mapping):
|
|
56
|
+
__slots__ = ("df",)
|
|
57
|
+
|
|
56
58
|
df: DataFrame
|
|
57
59
|
|
|
58
60
|
def __init__(self, df: DataFrame) -> None:
|
|
@@ -96,9 +98,16 @@ def _csv_pandas(path: FilePath) -> dict[int, pd.Series]:
|
|
|
96
98
|
return cast(dict[int, pd.Series], dataframe(df))
|
|
97
99
|
|
|
98
100
|
|
|
99
|
-
def json(path: FilePath) -> dict[
|
|
101
|
+
def json(path: FilePath) -> dict[Any, Any]:
|
|
100
102
|
with open(path, "rb") as fp:
|
|
101
|
-
|
|
103
|
+
data = orjson.loads(fp.read())
|
|
104
|
+
|
|
105
|
+
if isinstance(data, list):
|
|
106
|
+
return dict(enumerate(data))
|
|
107
|
+
elif isinstance(data, dict):
|
|
108
|
+
return data
|
|
109
|
+
else:
|
|
110
|
+
raise TypeError(f"Invalid data type: {type(data)}")
|
|
102
111
|
|
|
103
112
|
|
|
104
113
|
def toml(path: FilePath) -> dict[str, Any]:
|
|
@@ -106,12 +115,18 @@ def toml(path: FilePath) -> dict[str, Any]:
|
|
|
106
115
|
return tomllib.load(fp)
|
|
107
116
|
|
|
108
117
|
|
|
109
|
-
def yaml(path: FilePath) -> dict[
|
|
110
|
-
data: dict[
|
|
118
|
+
def yaml(path: FilePath) -> dict[Any, Any]:
|
|
119
|
+
data: dict[Any, Any] = {}
|
|
111
120
|
|
|
112
121
|
with open(path, "rb") as fp:
|
|
113
|
-
for doc in yamllib.safe_load_all(fp):
|
|
114
|
-
|
|
122
|
+
for doc_idx, doc in enumerate(yamllib.safe_load_all(fp)):
|
|
123
|
+
if isinstance(doc, list):
|
|
124
|
+
for idx, item in enumerate(doc):
|
|
125
|
+
data[doc_idx + idx] = item
|
|
126
|
+
elif isinstance(doc, dict):
|
|
127
|
+
data |= doc
|
|
128
|
+
else:
|
|
129
|
+
raise TypeError(f"Invalid document type: {type(doc)}")
|
|
115
130
|
|
|
116
131
|
return data
|
|
117
132
|
|
|
@@ -29,7 +29,7 @@ def _similarities2ranking(
|
|
|
29
29
|
return sorted(sim_map, key=lambda key: unpack_sim(sim_map[key]), reverse=True)
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
@dataclass
|
|
32
|
+
@dataclass(slots=True)
|
|
33
33
|
class _Result(Generic[KeyType, ValueType, SimType]):
|
|
34
34
|
similarities: SimMap[KeyType, SimType]
|
|
35
35
|
ranking: list[KeyType]
|
|
@@ -47,7 +47,7 @@ class _Result(Generic[KeyType, ValueType, SimType]):
|
|
|
47
47
|
return cls(similarities=similarities, ranking=ranking, casebase=casebase)
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
@dataclass
|
|
50
|
+
@dataclass(slots=True)
|
|
51
51
|
class Result(Generic[KeyType, ValueType, SimType]):
|
|
52
52
|
final: _Result[KeyType, ValueType, SimType]
|
|
53
53
|
intermediate: list[_Result[KeyType, ValueType, SimType]]
|
|
@@ -11,7 +11,7 @@ class SerializedNode(TypedDict, total=False):
|
|
|
11
11
|
children: list["SerializedNode | str"]
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
@dataclass
|
|
14
|
+
@dataclass(slots=True)
|
|
15
15
|
class TaxonomyNode:
|
|
16
16
|
key: str
|
|
17
17
|
weight: float | None
|
|
@@ -21,6 +21,8 @@ class TaxonomyNode:
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class Taxonomy:
|
|
24
|
+
__slots__ = ("root", "nodes")
|
|
25
|
+
|
|
24
26
|
root: TaxonomyNode
|
|
25
27
|
nodes: dict[str, TaxonomyNode]
|
|
26
28
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|