cbrkit 0.18.2__tar.gz → 0.18.3__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.
Files changed (28) hide show
  1. {cbrkit-0.18.2 → cbrkit-0.18.3}/PKG-INFO +1 -1
  2. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/sim/graphs/_model.py +27 -30
  3. {cbrkit-0.18.2 → cbrkit-0.18.3}/pyproject.toml +1 -1
  4. {cbrkit-0.18.2 → cbrkit-0.18.3}/LICENSE +0 -0
  5. {cbrkit-0.18.2 → cbrkit-0.18.3}/README.md +0 -0
  6. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/__init__.py +0 -0
  7. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/__main__.py +0 -0
  8. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/adaptation.py +0 -0
  9. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/api.py +0 -0
  10. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/cli.py +0 -0
  11. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/eval/__init__.py +0 -0
  12. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/eval/_common.py +0 -0
  13. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/eval/_retrieval.py +0 -0
  14. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/helpers.py +0 -0
  15. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/loaders.py +0 -0
  16. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/py.typed +0 -0
  17. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/retrieval.py +0 -0
  18. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/sim/__init__.py +0 -0
  19. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/sim/_aggregator.py +0 -0
  20. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/sim/_attribute_value.py +0 -0
  21. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/sim/collections.py +0 -0
  22. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/sim/generic.py +0 -0
  23. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/sim/graphs/__init__.py +0 -0
  24. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/sim/graphs/_astar.py +0 -0
  25. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/sim/numbers.py +0 -0
  26. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/sim/strings/__init__.py +0 -0
  27. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/sim/strings/taxonomy.py +0 -0
  28. {cbrkit-0.18.2 → cbrkit-0.18.3}/cbrkit/typing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cbrkit
3
- Version: 0.18.2
3
+ Version: 0.18.3
4
4
  Summary: Customizable Case-Based Reasoning (CBR) toolkit for Python with a built-in API and CLI.
5
5
  Home-page: https://wi2trier.github.io/cbrkit/
6
6
  License: MIT
@@ -147,11 +147,7 @@ try:
147
147
  )
148
148
  edges = immutables.Map(
149
149
  (edge_id, Edge(edge_id, nodes[source_id], nodes[target_id], edge_data))
150
- for edge_id, (
151
- source_id,
152
- target_id,
153
- edge_data,
154
- ) in g.edge_index_map().items()
150
+ for edge_id, (source_id, target_id, edge_data) in g.edge_index_map().items()
155
151
  )
156
152
 
157
153
  return Graph(nodes, edges, g.attrs)
@@ -164,43 +160,44 @@ except ImportError:
164
160
  try:
165
161
  import networkx as nx
166
162
 
167
- def to_networkx[N, E](g: Graph[Any, N, E, Any]) -> "nx.DiGraph":
163
+ def to_networkx(g: Graph) -> nx.DiGraph:
168
164
  ng = nx.DiGraph()
169
- # Set graph attributes
170
- ng.graph.update(g.data)
165
+ ng.graph = g.data
171
166
 
172
- # Add nodes with their data
173
- for node in g.nodes.values():
174
- ng.add_node(node.key, data=node.data)
167
+ ng.add_nodes_from(
168
+ (
169
+ node.key,
170
+ (node.data if isinstance(node.data, Mapping) else {"data": node.data}),
171
+ )
172
+ for node in g.nodes
173
+ )
175
174
 
176
- # Add edges with their data
177
- for edge in g.edges.values():
178
- ng.add_edge(edge.source.key, edge.target.key, key=edge.key, data=edge.data)
175
+ ng.add_edges_from(
176
+ (
177
+ edge.source.key,
178
+ edge.target.key,
179
+ (
180
+ {**edge.data, "key": edge.key}
181
+ if isinstance(edge.data, Mapping)
182
+ else {"data": edge.data, "key": edge.key}
183
+ ),
184
+ )
185
+ for edge in g.edges.values()
186
+ )
179
187
 
180
188
  return ng
181
189
 
182
- def from_networkx[N, E](g: "nx.DiGraph") -> Graph[Any, N, E, Any]:
183
- # Create nodes
190
+ def from_networkx(g: nx.DiGraph) -> Graph:
184
191
  nodes = immutables.Map(
185
- (node_id, Node(node_id, g.nodes[node_id].get("data")))
186
- for node_id in g.nodes
192
+ (idx, Node(idx, data)) for idx, data in g.nodes(data=True)
187
193
  )
188
194
 
189
- # Create edges
190
195
  edges = immutables.Map(
191
- (
192
- edge_data.get("key", idx),
193
- Edge(
194
- edge_data.get("key", idx),
195
- nodes[source],
196
- nodes[target],
197
- edge_data.get("data"),
198
- ),
199
- )
200
- for idx, (source, target, edge_data) in enumerate(g.edges(data=True))
196
+ (idx, Edge(idx, nodes[source_id], nodes[target_id], edge_data))
197
+ for idx, (source_id, target_id, edge_data) in enumerate(g.edges(data=True))
201
198
  )
202
199
 
203
- return Graph(nodes, edges, dict(g.graph))
200
+ return Graph(nodes, edges, g.graph)
204
201
 
205
202
  __all__ += ["to_networkx", "from_networkx"]
206
203
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cbrkit"
3
- version = "0.18.2"
3
+ version = "0.18.3"
4
4
  description = "Customizable Case-Based Reasoning (CBR) toolkit for Python with a built-in API and CLI."
5
5
  authors = ["Mirko Lenz <mirko@mirkolenz.com>"]
6
6
  license = "MIT"
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