conceptflow 0.4.0__tar.gz → 0.5.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.
- {conceptflow-0.4.0/src/conceptflow.egg-info → conceptflow-0.5.0}/PKG-INFO +3 -3
- {conceptflow-0.4.0 → conceptflow-0.5.0}/README.md +1 -1
- {conceptflow-0.4.0 → conceptflow-0.5.0}/pyproject.toml +4 -1
- conceptflow-0.5.0/src/conceptflow/_version.py +1 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/core/context.py +6 -1
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/core/incomplete_context.py +6 -1
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/_loaders.py +8 -4
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/decomposition/bipartite.py +78 -22
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/decomposition/ordinal_factorization.py +41 -10
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/exploration/builder.py +15 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/io/cxt.py +3 -1
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/io/formats.py +11 -5
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/quality.py +3 -1
- conceptflow-0.5.0/src/conceptflow/visualization/_checks.py +44 -0
- conceptflow-0.5.0/src/conceptflow/visualization/_clearance.py +123 -0
- conceptflow-0.5.0/src/conceptflow/visualization/_text.py +52 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/visualization/d3_backend.py +96 -18
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/visualization/dimflux_layout.py +19 -11
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/visualization/graph_data.py +2 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/visualization/graphviz.py +5 -1
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/visualization/html_figure.py +21 -4
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/visualization/layered_layout.py +18 -5
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/visualization/nested.py +120 -32
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/visualization/static.py +18 -5
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/visualization/tikz.py +29 -3
- {conceptflow-0.4.0 → conceptflow-0.5.0/src/conceptflow.egg-info}/PKG-INFO +3 -3
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow.egg-info/SOURCES.txt +7 -2
- conceptflow-0.5.0/tests/test_browser.py +304 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_context_handling.py +12 -1
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_cxt_io.py +24 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_d3_backend.py +41 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_datasets.py +11 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_docs_examples.py +1 -1
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_html_figure.py +21 -3
- conceptflow-0.5.0/tests/test_layout_and_graphviz.py +164 -0
- conceptflow-0.5.0/tests/test_oracles.py +396 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_ord2factor.py +41 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_patch_0_3_1.py +1 -1
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_review_fixes.py +1 -1
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_static_figures.py +4 -2
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_tikz.py +1 -1
- conceptflow-0.5.0/tests/test_visualization_options.py +158 -0
- conceptflow-0.4.0/src/conceptflow/_version.py +0 -1
- conceptflow-0.4.0/src/conceptflow/model_selection/__init__.py +0 -11
- conceptflow-0.4.0/tests/test_layout_and_graphviz.py +0 -85
- {conceptflow-0.4.0 → conceptflow-0.5.0}/LICENSE +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/setup.cfg +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/_deprecation.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/algorithms/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/algorithms/_bitset.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/algorithms/_membership.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/algorithms/_registry.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/algorithms/derivation.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/algorithms/enumeration.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/algorithms/generators.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/algorithms/hasse.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/algorithms/implications.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/algorithms/order.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/algorithms/reduction.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/cluster/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/cluster/concept_lattice.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/core/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/core/concept.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/core/lattice.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/core/many_valued_context.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/core/operations.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/README.md +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/animals_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/binary_relations_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/bodiesofwater_de.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/bodiesofwater_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/driveconcepts_de.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/driveconcepts_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/famous_animals_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/forum_romanum_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/livingbeings_de.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/livingbeings_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/missmarple_de.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/missmarple_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/music_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/newzealand_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/officesupplies_de.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/officesupplies_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/planets_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/seasoningplanner_de.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/tealady.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository/triangles_en.cxt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/datasets/data/fca_repository.json +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/decomposition/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/decomposition/boolean_factorization.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/exploration/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/exploration/combinations.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/exploration/view.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/feature_extraction/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/feature_extraction/concept_encoder.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/io/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/metrics/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/metrics/measures.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/metrics/rules.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/preprocessing/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/preprocessing/conceptual_scaler.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/preprocessing/scales.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/rules/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/rules/implication_basis.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/rules/outlier_detector.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/validation/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/validation/input.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/visualization/__init__.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/visualization/lattice_plot.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow.egg-info/dependency_links.txt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow.egg-info/requires.txt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow.egg-info/top_level.txt +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_algorithm_registry.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_audit_regressions.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_boolean_factorization.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_check_estimator.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_cluster_estimator.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_concept.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_concept_encoder.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_conceptual_scaler.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_context_operations.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_derivation.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_dimflux_layout.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_enumeration.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_exploration.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_formal_context.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_generators.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_graph_data.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_hasse.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_implication_basis_estimator.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_implications.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_incomplete_context.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_lattice.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_lattice_navigation.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_many_valued_context.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_measures.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_metrics.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_nested_combinations.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_nested_visualization.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_ordinal_factorization.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_public_api.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_quality.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_reduction.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_scales.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_sklearn_compatibility.py +0 -0
- {conceptflow-0.4.0 → conceptflow-0.5.0}/tests/test_validation_input.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: conceptflow
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: A scikit-learn compatible Formal Concept Analysis framework.
|
|
5
5
|
Author-email: Anurag Sharma <sharma@cs.uni-kassel.de>
|
|
6
6
|
License: BSD 3-Clause License
|
|
@@ -37,7 +37,7 @@ Project-URL: Documentation, https://conceptflow.readthedocs.io
|
|
|
37
37
|
Project-URL: Repository, https://github.com/anuragxorma/conceptflow
|
|
38
38
|
Project-URL: Issues, https://github.com/anuragxorma/conceptflow/issues
|
|
39
39
|
Keywords: formal-concept-analysis,fca,scikit-learn,concept-lattice,conceptual-scaling
|
|
40
|
-
Classifier: Development Status ::
|
|
40
|
+
Classifier: Development Status :: 4 - Beta
|
|
41
41
|
Classifier: Intended Audience :: Science/Research
|
|
42
42
|
Classifier: License :: OSI Approved :: BSD License
|
|
43
43
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -72,7 +72,7 @@ Dynamic: license-file
|
|
|
72
72
|

|
|
73
73
|

|
|
74
74
|
[](https://conceptflow.readthedocs.io)
|
|
75
|
-

|
|
76
76
|
|
|
77
77
|
ConceptFlow is a Python library for **Formal Concept Analysis (FCA)** that
|
|
78
78
|
fits into the scientific Python stack. Its machine-learning parts are proper
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|
[](https://conceptflow.readthedocs.io)
|
|
6
|
-

|
|
7
7
|
|
|
8
8
|
ConceptFlow is a Python library for **Formal Concept Analysis (FCA)** that
|
|
9
9
|
fits into the scientific Python stack. Its machine-learning parts are proper
|
|
@@ -20,7 +20,7 @@ keywords = [
|
|
|
20
20
|
"conceptual-scaling",
|
|
21
21
|
]
|
|
22
22
|
classifiers = [
|
|
23
|
-
"Development Status ::
|
|
23
|
+
"Development Status :: 4 - Beta",
|
|
24
24
|
"Intended Audience :: Science/Research",
|
|
25
25
|
"License :: OSI Approved :: BSD License",
|
|
26
26
|
"Programming Language :: Python :: 3",
|
|
@@ -78,6 +78,9 @@ version = { attr = "conceptflow._version.__version__" }
|
|
|
78
78
|
[tool.pytest.ini_options]
|
|
79
79
|
testpaths = ["tests"]
|
|
80
80
|
pythonpath = ["src"]
|
|
81
|
+
# scikit-mine (dim-flux -> fcapy -> scikit-mine) still imports numpy.core.
|
|
82
|
+
filterwarnings = ["ignore:numpy.core:DeprecationWarning:skmine"]
|
|
83
|
+
markers = ["browser: interactive pages in headless Firefox (needs Playwright)"]
|
|
81
84
|
|
|
82
85
|
[tool.ruff]
|
|
83
86
|
line-length = 100
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.0"
|
|
@@ -268,8 +268,13 @@ class FormalContext:
|
|
|
268
268
|
for item in items:
|
|
269
269
|
if _is_index(item):
|
|
270
270
|
if not 0 <= item < size:
|
|
271
|
+
hint = (
|
|
272
|
+
f" Integers are positions; for the {kind} named '{item}', "
|
|
273
|
+
f"pass the string '{item}'."
|
|
274
|
+
if str(item) in index_of else ""
|
|
275
|
+
)
|
|
271
276
|
raise IndexError(
|
|
272
|
-
f"{kind} index {item} is out of range for {size} {kind}s."
|
|
277
|
+
f"{kind} index {item} is out of range for {size} {kind}s.{hint}"
|
|
273
278
|
)
|
|
274
279
|
resolved.append(int(item))
|
|
275
280
|
else:
|
|
@@ -280,8 +280,13 @@ class IncompleteContext:
|
|
|
280
280
|
for item in items:
|
|
281
281
|
if _is_index(item):
|
|
282
282
|
if not 0 <= item < len(names):
|
|
283
|
+
hint = (
|
|
284
|
+
f" Integers are positions; for the {kind} named '{item}', "
|
|
285
|
+
f"pass the string '{item}'."
|
|
286
|
+
if str(item) in index_of else ""
|
|
287
|
+
)
|
|
283
288
|
raise IndexError(
|
|
284
|
-
f"{kind} index {item} is out of range for {len(names)} {kind}s."
|
|
289
|
+
f"{kind} index {item} is out of range for {len(names)} {kind}s.{hint}"
|
|
285
290
|
)
|
|
286
291
|
resolved.append(int(item))
|
|
287
292
|
else:
|
|
@@ -289,8 +289,8 @@ def make_random_context(
|
|
|
289
289
|
with probability ``density``.
|
|
290
290
|
|
|
291
291
|
Objects are named ``g0, g1, ...`` and attributes ``m0, m1, ...``.
|
|
292
|
-
``random_state`` is an int, a NumPy
|
|
293
|
-
scikit-learn.
|
|
292
|
+
``random_state`` is an int, None, a NumPy ``RandomState`` (as in
|
|
293
|
+
scikit-learn) or a NumPy ``Generator`` (``np.random.default_rng``).
|
|
294
294
|
"""
|
|
295
295
|
for name, value in (("n_objects", n_objects), ("n_attributes", n_attributes)):
|
|
296
296
|
if isinstance(value, bool) or not isinstance(value, numbers.Integral) or value < 0:
|
|
@@ -298,5 +298,9 @@ def make_random_context(
|
|
|
298
298
|
if isinstance(density, bool) or not isinstance(density, numbers.Real) or not 0 <= density <= 1:
|
|
299
299
|
raise ValueError("density must be a number in [0, 1].")
|
|
300
300
|
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
shape = (n_objects, n_attributes)
|
|
302
|
+
if isinstance(random_state, np.random.Generator):
|
|
303
|
+
values = random_state.random(shape)
|
|
304
|
+
else:
|
|
305
|
+
values = check_random_state(random_state).random_sample(shape)
|
|
306
|
+
return FormalContext.from_array(values < density)
|
|
@@ -8,15 +8,17 @@ Bipartite Subgraphs" (arXiv:2211.10446, 2022), used by Ord2Factor:
|
|
|
8
8
|
- ``minimum_bipartite_deletion``: a smallest such set (the paper's SAT
|
|
9
9
|
formulation, Definition 1, solved with MiniSat 2.2; exponential in the
|
|
10
10
|
worst case, as the problem is NP-hard);
|
|
11
|
-
- ``greedy_bipartite_deletion``:
|
|
12
|
-
- ``annealing_bipartite_deletion``:
|
|
11
|
+
- ``greedy_bipartite_deletion``: an inclusion-minimal set (Algorithm 1);
|
|
12
|
+
- ``annealing_bipartite_deletion``: an inclusion-minimal set improved by
|
|
13
13
|
simulated annealing (Algorithm 2).
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
The paper states that both return an inclusion-minimal set (no deleted
|
|
16
|
+
vertex can be kept), but its ``greedy-fill`` only ensures that every
|
|
17
|
+
deleted vertex has a neighbour on both sides of the bipartition it built;
|
|
18
|
+
with a *different* 2-colouring a deleted vertex can sometimes be kept (in
|
|
19
|
+
about a fifth of small random cases). Both functions therefore end with a
|
|
20
|
+
pass that keeps every deleted vertex whose return leaves the graph
|
|
21
|
+
bipartite, which makes the paper's guarantee hold.
|
|
20
22
|
|
|
21
23
|
Graphs are dicts mapping each vertex to the set of its neighbours, as
|
|
22
24
|
returned by ``incompatibility_graph``. Each function returns the set D of
|
|
@@ -26,6 +28,8 @@ vertices to delete.
|
|
|
26
28
|
from __future__ import annotations
|
|
27
29
|
|
|
28
30
|
import math
|
|
31
|
+
import threading
|
|
32
|
+
import time
|
|
29
33
|
from collections.abc import Hashable
|
|
30
34
|
|
|
31
35
|
from sklearn.utils import check_random_state
|
|
@@ -59,7 +63,25 @@ def is_bipartite(graph: Graph, deleted=frozenset()) -> bool:
|
|
|
59
63
|
# ---------------------------------------------------------------------------
|
|
60
64
|
|
|
61
65
|
|
|
62
|
-
def
|
|
66
|
+
def _solve(solver, deadline: float | None) -> bool:
|
|
67
|
+
"""Run the solver, interrupting it at ``deadline`` (time.monotonic())."""
|
|
68
|
+
if deadline is None:
|
|
69
|
+
return solver.solve()
|
|
70
|
+
remaining = deadline - time.monotonic()
|
|
71
|
+
if remaining <= 0:
|
|
72
|
+
raise TimeoutError
|
|
73
|
+
timer = threading.Timer(remaining, solver.interrupt)
|
|
74
|
+
timer.start()
|
|
75
|
+
try:
|
|
76
|
+
result = solver.solve_limited(expect_interrupt=True)
|
|
77
|
+
finally:
|
|
78
|
+
timer.cancel()
|
|
79
|
+
if result is None: # interrupted
|
|
80
|
+
raise TimeoutError
|
|
81
|
+
return result
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _deletable_with_at_most(graph: Graph, vertices: list, k: int, deadline=None):
|
|
63
85
|
"""D with |D| <= k making the graph bipartite, or None (MiniSat 2.2)."""
|
|
64
86
|
from pysat.card import CardEnc, EncType
|
|
65
87
|
from pysat.solvers import Minisat22
|
|
@@ -87,13 +109,13 @@ def _deletable_with_at_most(graph: Graph, vertices: list, k: int):
|
|
|
87
109
|
encoding=EncType.seqcounter,
|
|
88
110
|
)
|
|
89
111
|
with Minisat22(bootstrap_with=clauses + at_most.clauses) as solver:
|
|
90
|
-
if not solver
|
|
112
|
+
if not _solve(solver, deadline):
|
|
91
113
|
return None
|
|
92
114
|
true = {literal for literal in solver.get_model() if literal > 0}
|
|
93
115
|
return {vertex for vertex in vertices if var(index[vertex], 3) in true}
|
|
94
116
|
|
|
95
117
|
|
|
96
|
-
def minimum_bipartite_deletion(graph: Graph) -> set:
|
|
118
|
+
def minimum_bipartite_deletion(graph: Graph, max_time: float | None = None) -> set:
|
|
97
119
|
"""
|
|
98
120
|
A smallest set of vertices whose deletion makes the graph bipartite.
|
|
99
121
|
|
|
@@ -102,21 +124,36 @@ def minimum_bipartite_deletion(graph: Graph) -> set:
|
|
|
102
124
|
at most ``k`` vertices are in D. The smallest ``k`` is found as in the
|
|
103
125
|
paper: ``k`` is doubled until the instance is satisfiable, then the gap
|
|
104
126
|
is closed by binary search.
|
|
127
|
+
|
|
128
|
+
The problem is NP-hard and the time grows quickly with the graph (a few
|
|
129
|
+
hundred edges take seconds, a few thousand can take hours). With
|
|
130
|
+
``max_time`` (seconds), ``TimeoutError`` is raised once that much time
|
|
131
|
+
has passed; the heuristics below are fast alternatives.
|
|
105
132
|
"""
|
|
133
|
+
deadline = None if max_time is None else time.monotonic() + max_time
|
|
134
|
+
try:
|
|
135
|
+
return _minimum_deletion(graph, deadline)
|
|
136
|
+
except TimeoutError:
|
|
137
|
+
raise TimeoutError(
|
|
138
|
+
f"No smallest deletion set found within max_time={max_time} seconds."
|
|
139
|
+
) from None
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _minimum_deletion(graph: Graph, deadline) -> set:
|
|
106
143
|
vertices = sorted(graph, key=repr)
|
|
107
144
|
if is_bipartite(graph):
|
|
108
145
|
return set()
|
|
109
146
|
|
|
110
147
|
# k = 0 is unsatisfiable (the graph is not bipartite).
|
|
111
148
|
low, k = 0, 1
|
|
112
|
-
best = _deletable_with_at_most(graph, vertices, k)
|
|
149
|
+
best = _deletable_with_at_most(graph, vertices, k, deadline)
|
|
113
150
|
while best is None:
|
|
114
151
|
low, k = k, 2 * k
|
|
115
|
-
best = _deletable_with_at_most(graph, vertices, k)
|
|
152
|
+
best = _deletable_with_at_most(graph, vertices, k, deadline)
|
|
116
153
|
high = k
|
|
117
154
|
while high - low > 1:
|
|
118
155
|
middle = (low + high) // 2
|
|
119
|
-
found = _deletable_with_at_most(graph, vertices, middle)
|
|
156
|
+
found = _deletable_with_at_most(graph, vertices, middle, deadline)
|
|
120
157
|
if found is None:
|
|
121
158
|
low = middle
|
|
122
159
|
else:
|
|
@@ -149,15 +186,28 @@ def _greedy_fill(graph: Graph, a: set, b: set, d: set, rng) -> tuple[set, set, s
|
|
|
149
186
|
return a, b, d
|
|
150
187
|
|
|
151
188
|
|
|
189
|
+
def _keep_what_fits(graph: Graph, d: set) -> set:
|
|
190
|
+
"""
|
|
191
|
+
Make ``d`` inclusion-minimal: put back every vertex whose return leaves
|
|
192
|
+
the graph bipartite (in a fixed order, so results are reproducible).
|
|
193
|
+
"""
|
|
194
|
+
d = set(d)
|
|
195
|
+
for vertex in sorted(d, key=repr):
|
|
196
|
+
if is_bipartite(graph, d - {vertex}):
|
|
197
|
+
d.discard(vertex)
|
|
198
|
+
return d
|
|
199
|
+
|
|
200
|
+
|
|
152
201
|
def greedy_bipartite_deletion(graph: Graph, random_state=None) -> set:
|
|
153
202
|
"""
|
|
154
|
-
|
|
155
|
-
bipartite
|
|
156
|
-
vertex in D)
|
|
203
|
+
An inclusion-minimal set of vertices whose deletion makes the graph
|
|
204
|
+
bipartite: the paper's Algorithm 1 (``greedy-fill`` starting with every
|
|
205
|
+
vertex in D), then the final pass described in the module docstring.
|
|
206
|
+
Polynomial time.
|
|
157
207
|
"""
|
|
158
208
|
rng = check_random_state(random_state)
|
|
159
209
|
_, _, d = _greedy_fill(graph, set(), set(), set(graph), rng)
|
|
160
|
-
return d
|
|
210
|
+
return _keep_what_fits(graph, d)
|
|
161
211
|
|
|
162
212
|
|
|
163
213
|
def annealing_bipartite_deletion(
|
|
@@ -169,11 +219,17 @@ def annealing_bipartite_deletion(
|
|
|
169
219
|
"""
|
|
170
220
|
Simulated annealing (the paper's Algorithm 2), starting from the greedy
|
|
171
221
|
solution. A neighbouring solution moves a random vertex ``u`` of D into
|
|
172
|
-
A or B (at random), moves its neighbours
|
|
173
|
-
``greedy-fill``. A smaller D is always accepted, a larger one with
|
|
222
|
+
A or B (at random), moves all its neighbours in A and B into D, and
|
|
223
|
+
refills with ``greedy-fill``. A smaller D is always accepted, a larger one with
|
|
174
224
|
probability ``exp(-(growth) / t)``, where the temperature falls linearly
|
|
175
|
-
from ``temperature`` to 0 over ``n_iterations`` steps
|
|
176
|
-
the final D is returned
|
|
225
|
+
from ``temperature`` to 0 over ``n_iterations`` steps (the paper's
|
|
226
|
+
linear cooling). As in the paper, the final D is returned, after the
|
|
227
|
+
final pass that makes it inclusion-minimal.
|
|
228
|
+
|
|
229
|
+
The defaults (``temperature=1``, 1000 iterations) are smaller than the
|
|
230
|
+
paper's recommendation (50, quadratic cooling, 10000 iterations): on
|
|
231
|
+
ordinal-factorization graphs they give the same results about ten times
|
|
232
|
+
faster.
|
|
177
233
|
"""
|
|
178
234
|
rng = check_random_state(random_state)
|
|
179
235
|
a, b, d = _greedy_fill(graph, set(), set(), set(graph), rng)
|
|
@@ -199,4 +255,4 @@ def annealing_bipartite_deletion(
|
|
|
199
255
|
current_temperature > 0 and math.exp(change / current_temperature) > rng.random_sample()
|
|
200
256
|
):
|
|
201
257
|
a, b, d = new_a, new_b, new_d
|
|
202
|
-
return d
|
|
258
|
+
return _keep_what_fits(graph, d)
|
{conceptflow-0.4.0 → conceptflow-0.5.0}/src/conceptflow/decomposition/ordinal_factorization.py
RENAMED
|
@@ -20,12 +20,15 @@ Implemented
|
|
|
20
20
|
|
|
21
21
|
from __future__ import annotations
|
|
22
22
|
|
|
23
|
+
import numbers
|
|
24
|
+
import time
|
|
23
25
|
from collections import deque
|
|
24
26
|
from collections.abc import Iterable
|
|
25
27
|
from dataclasses import dataclass
|
|
26
28
|
|
|
27
29
|
import numpy as np
|
|
28
30
|
from sklearn.base import BaseEstimator
|
|
31
|
+
from sklearn.utils import check_scalar
|
|
29
32
|
|
|
30
33
|
from conceptflow.core import ConceptLattice, FormalContext
|
|
31
34
|
from conceptflow.validation import check_binary_context_input
|
|
@@ -407,12 +410,15 @@ class Ord2Factor(BaseEstimator):
|
|
|
407
410
|
Parameters
|
|
408
411
|
----------
|
|
409
412
|
method:
|
|
410
|
-
``"
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
413
|
+
``"annealing"`` (default): the greedy result improved by simulated
|
|
414
|
+
annealing; seconds even for contexts with hundreds of crosses, and
|
|
415
|
+
on small contexts as good as ``"exact"`` in our tests.
|
|
416
|
+
``"exact"``: in each round a smallest set of crosses to drop, from
|
|
417
|
+
the papers' SAT formulation solved with MiniSat 2.2. Exponential:
|
|
418
|
+
about 20 s for a 15 x 15 context of density 0.4, hours a little
|
|
419
|
+
beyond; limited by ``max_time``. ``"greedy"``: an inclusion-minimal
|
|
420
|
+
set (Algorithm 1 of the 2022 paper, plus a final pass that keeps
|
|
421
|
+
every cross it can), in polynomial time, but often far worse.
|
|
416
422
|
|
|
417
423
|
n_iterations, temperature:
|
|
418
424
|
Steps and starting temperature of ``method="annealing"``.
|
|
@@ -423,6 +429,10 @@ class Ord2Factor(BaseEstimator):
|
|
|
423
429
|
lattice_algorithm:
|
|
424
430
|
Concept enumeration algorithm for the complement lattice.
|
|
425
431
|
|
|
432
|
+
max_time:
|
|
433
|
+
Time limit in seconds for ``method="exact"`` (default 60); ``fit``
|
|
434
|
+
raises ``TimeoutError`` once it is exceeded. ``None``: no limit.
|
|
435
|
+
|
|
426
436
|
Attributes
|
|
427
437
|
----------
|
|
428
438
|
factors_:
|
|
@@ -445,19 +455,21 @@ class Ord2Factor(BaseEstimator):
|
|
|
445
455
|
|
|
446
456
|
def __init__(
|
|
447
457
|
self,
|
|
448
|
-
method: str = "
|
|
458
|
+
method: str = "annealing",
|
|
449
459
|
n_iterations: int = 1000,
|
|
450
460
|
temperature: float = 1.0,
|
|
451
461
|
random_state=None,
|
|
452
462
|
lattice_algorithm: str = "nextclosure",
|
|
463
|
+
max_time: float | None = 60.0,
|
|
453
464
|
):
|
|
454
465
|
self.method = method
|
|
455
466
|
self.n_iterations = n_iterations
|
|
456
467
|
self.temperature = temperature
|
|
457
468
|
self.random_state = random_state
|
|
458
469
|
self.lattice_algorithm = lattice_algorithm
|
|
470
|
+
self.max_time = max_time
|
|
459
471
|
|
|
460
|
-
def _deletion(self, graph, rng):
|
|
472
|
+
def _deletion(self, graph, rng, deadline):
|
|
461
473
|
from conceptflow.decomposition.bipartite import (
|
|
462
474
|
annealing_bipartite_deletion,
|
|
463
475
|
greedy_bipartite_deletion,
|
|
@@ -465,7 +477,10 @@ class Ord2Factor(BaseEstimator):
|
|
|
465
477
|
)
|
|
466
478
|
|
|
467
479
|
if self.method == "exact":
|
|
468
|
-
|
|
480
|
+
remaining = None if deadline is None else deadline - time.monotonic()
|
|
481
|
+
if remaining is not None and remaining <= 0:
|
|
482
|
+
raise TimeoutError
|
|
483
|
+
return minimum_bipartite_deletion(graph, max_time=remaining)
|
|
469
484
|
if self.method == "greedy":
|
|
470
485
|
return greedy_bipartite_deletion(graph, random_state=rng)
|
|
471
486
|
return annealing_bipartite_deletion(
|
|
@@ -486,19 +501,35 @@ class Ord2Factor(BaseEstimator):
|
|
|
486
501
|
or self.n_iterations < 0
|
|
487
502
|
):
|
|
488
503
|
raise ValueError("n_iterations must be a non-negative integer.")
|
|
504
|
+
if self.max_time is not None:
|
|
505
|
+
check_scalar(
|
|
506
|
+
self.max_time, "max_time", numbers.Real, min_val=0, include_boundaries="neither"
|
|
507
|
+
)
|
|
489
508
|
|
|
490
509
|
context = check_binary_context_input(X)
|
|
491
510
|
rng = check_random_state(self.random_state)
|
|
492
511
|
incidence = np.array(context.incidence, dtype=bool)
|
|
493
512
|
removed: set[IncidencePair] = set()
|
|
494
513
|
rounds = 0
|
|
514
|
+
deadline = (
|
|
515
|
+
None if self.max_time is None or self.method != "exact"
|
|
516
|
+
else time.monotonic() + self.max_time
|
|
517
|
+
)
|
|
495
518
|
|
|
496
519
|
while True:
|
|
497
520
|
current = FormalContext(context.objects, context.attributes, incidence)
|
|
498
521
|
graph = incompatibility_graph(current)
|
|
499
522
|
if is_bipartite(graph):
|
|
500
523
|
break
|
|
501
|
-
|
|
524
|
+
try:
|
|
525
|
+
dropped = self._deletion(graph, rng, deadline)
|
|
526
|
+
except TimeoutError:
|
|
527
|
+
raise TimeoutError(
|
|
528
|
+
f'method="exact" did not finish within max_time={self.max_time} '
|
|
529
|
+
"seconds: it is exponential in the size of the context. Use "
|
|
530
|
+
'method="annealing" (the default) for larger contexts, or raise '
|
|
531
|
+
"max_time (None: no limit)."
|
|
532
|
+
) from None
|
|
502
533
|
for g, m in dropped:
|
|
503
534
|
incidence[g, m] = False
|
|
504
535
|
removed |= dropped
|
|
@@ -67,8 +67,18 @@ class ExplorationBuilder:
|
|
|
67
67
|
scale_names=tuple(scale.source_attribute for scale in scales),
|
|
68
68
|
)
|
|
69
69
|
|
|
70
|
+
@staticmethod
|
|
71
|
+
def _check_scales(scales) -> None:
|
|
72
|
+
if isinstance(scales, (str, Scale)) or not all(
|
|
73
|
+
isinstance(scale, Scale) for scale in scales
|
|
74
|
+
):
|
|
75
|
+
raise TypeError(
|
|
76
|
+
f"scales must be a list of Scale objects, got {scales!r}."
|
|
77
|
+
)
|
|
78
|
+
|
|
70
79
|
def _scale(self, mvc: ManyValuedContext, scales: list[Scale]):
|
|
71
80
|
"""Scale ``mvc`` into a formal context with this builder's policy."""
|
|
81
|
+
self._check_scales(scales)
|
|
72
82
|
scaler = ConceptualScaler(
|
|
73
83
|
scales=scales,
|
|
74
84
|
output="context",
|
|
@@ -199,6 +209,11 @@ class ExplorationBuilder:
|
|
|
199
209
|
backward-compatible signatures; do not rely on it to include or
|
|
200
210
|
exclude anything.
|
|
201
211
|
"""
|
|
212
|
+
self._check_scales(scales)
|
|
213
|
+
if not isinstance(name_template, str):
|
|
214
|
+
raise TypeError(
|
|
215
|
+
f"name_template must be a string, got {name_template!r}."
|
|
216
|
+
)
|
|
202
217
|
children: list[ExplorationView] = []
|
|
203
218
|
|
|
204
219
|
parent_object_count = parent.context.n_objects
|
|
@@ -120,7 +120,8 @@ def read_cxt(path: str | Path) -> FormalContext:
|
|
|
120
120
|
|
|
121
121
|
def write_cxt(context: FormalContext, path: str | Path) -> None:
|
|
122
122
|
"""
|
|
123
|
-
Write a FormalContext to a Burmeister .cxt file
|
|
123
|
+
Write a FormalContext to a Burmeister .cxt file (missing folders are
|
|
124
|
+
created).
|
|
124
125
|
"""
|
|
125
126
|
path = Path(path)
|
|
126
127
|
|
|
@@ -146,4 +147,5 @@ def write_cxt(context: FormalContext, path: str | Path) -> None:
|
|
|
146
147
|
for row in context.incidence:
|
|
147
148
|
lines.append("".join("X" if value else "." for value in row))
|
|
148
149
|
|
|
150
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
149
151
|
path.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
|
@@ -89,8 +89,10 @@ def context_from_json(text: str) -> FormalContext:
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
def write_json(context: FormalContext, path: str | Path) -> None:
|
|
92
|
-
"""Write a context as FCART/fcapy JSON."""
|
|
93
|
-
Path(path)
|
|
92
|
+
"""Write a context as FCART/fcapy JSON (missing folders are created)."""
|
|
93
|
+
path = Path(path)
|
|
94
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
95
|
+
path.write_text(context_to_json(context), encoding="utf-8")
|
|
94
96
|
|
|
95
97
|
|
|
96
98
|
def read_json(path: str | Path) -> FormalContext:
|
|
@@ -107,9 +109,11 @@ def write_csv(
|
|
|
107
109
|
) -> None:
|
|
108
110
|
"""
|
|
109
111
|
Write a context as CSV: a header row of attributes, then one row per
|
|
110
|
-
object starting with its name.
|
|
112
|
+
object starting with its name. Missing folders are created.
|
|
111
113
|
"""
|
|
112
|
-
|
|
114
|
+
path = Path(path)
|
|
115
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
116
|
+
with path.open("w", newline="", encoding="utf-8") as file:
|
|
113
117
|
writer = csv.writer(file, delimiter=delimiter)
|
|
114
118
|
writer.writerow(["", *context.attributes])
|
|
115
119
|
for name, row in zip(context.objects, context.incidence):
|
|
@@ -128,7 +132,9 @@ def read_csv(
|
|
|
128
132
|
|
|
129
133
|
Cells must be one of ``true_values`` or ``false_values`` (surrounding
|
|
130
134
|
whitespace is ignored); anything else raises ``ValueError`` naming the
|
|
131
|
-
cell, instead of being guessed.
|
|
135
|
+
cell, instead of being guessed. A row shorter than the header is padded
|
|
136
|
+
with empty cells (no cross), as some spreadsheet programs drop trailing
|
|
137
|
+
empty cells; a longer row raises ``ValueError``.
|
|
132
138
|
"""
|
|
133
139
|
true_values, false_values = set(true_values), set(false_values)
|
|
134
140
|
|
|
@@ -112,10 +112,12 @@ class RedundancyReport:
|
|
|
112
112
|
derivable_attributes:
|
|
113
113
|
Attribute -> other attributes whose extents intersect to exactly its
|
|
114
114
|
extent: the column can be computed from them (it is reducible).
|
|
115
|
-
|
|
115
|
+
Duplicate, universal and empty attributes are reported above
|
|
116
|
+
instead.
|
|
116
117
|
|
|
117
118
|
derivable_objects:
|
|
118
119
|
The same for objects: the row is the intersection of other rows.
|
|
120
|
+
Duplicate, full and empty objects are reported above instead.
|
|
119
121
|
"""
|
|
120
122
|
|
|
121
123
|
duplicate_objects: list[tuple[str, ...]] = field(default_factory=list)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Argument checks shared by the renderers.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from collections.abc import Callable
|
|
8
|
+
from numbers import Integral, Real
|
|
9
|
+
|
|
10
|
+
from sklearn.utils import check_scalar
|
|
11
|
+
|
|
12
|
+
# Width of the details panel in the interactive pages; it sits beside the
|
|
13
|
+
# drawing from PANEL_BESIDE_FROM pixels on, below it in narrower pages.
|
|
14
|
+
DETAILS_PANEL_WIDTH = 280
|
|
15
|
+
PANEL_BESIDE_FROM = 560
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def html_page_layout(width, height) -> dict:
|
|
19
|
+
"""
|
|
20
|
+
Check the size of an interactive page and split it into drawing and
|
|
21
|
+
details panel: the drawing width and the CSS for the panel's place.
|
|
22
|
+
"""
|
|
23
|
+
check_scalar(width, "width", Real, min_val=0, include_boundaries="neither")
|
|
24
|
+
check_scalar(height, "height", Real, min_val=0, include_boundaries="neither")
|
|
25
|
+
if width >= PANEL_BESIDE_FROM:
|
|
26
|
+
return {
|
|
27
|
+
"drawing_width": width - DETAILS_PANEL_WIDTH,
|
|
28
|
+
"columns": f"1fr {DETAILS_PANEL_WIDTH}px",
|
|
29
|
+
"panel_border": "border-left",
|
|
30
|
+
}
|
|
31
|
+
return {"drawing_width": width, "columns": "1fr", "panel_border": "border-top"}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def check_max_label_items(max_label_items) -> None:
|
|
35
|
+
"""``None`` (show every label) or how many to show before "+n"."""
|
|
36
|
+
if max_label_items is not None:
|
|
37
|
+
check_scalar(max_label_items, "max_label_items", Integral, min_val=0)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def object_formatter(object_label: Callable | None) -> Callable[[str], str]:
|
|
41
|
+
"""``object_label`` with its result turned into text, as every backend needs."""
|
|
42
|
+
if object_label is None:
|
|
43
|
+
return str
|
|
44
|
+
return lambda name: str(object_label(name))
|