cpp-pd-code-simplify-interface 0.1.8__tar.gz → 0.1.9__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.
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.9}/PKG-INFO +5 -1
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.9}/README.md +4 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.9}/cpp_pd_code_simplify_interface/data/include/pdcode_simplify/pdcode_simplify.hpp +1 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.9}/cpp_pd_code_simplify_interface/data/src/native_interface.cpp +1 -1
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.9}/cpp_pd_code_simplify_interface/data/src/pdcode_simplify.cpp +29 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.9}/pyproject.toml +1 -1
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.9}/build_backend/cpp_pd_code_simplify_interface_build_backend.py +0 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.9}/cpp_pd_code_simplify_interface/__init__.py +0 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.9}/cpp_pd_code_simplify_interface/__main__.py +0 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.9}/cpp_pd_code_simplify_interface/main.py +0 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.9}/cpp_pd_code_simplify_interface/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cpp-pd-code-simplify-interface
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.9
|
|
4
4
|
Summary: Python interface for cpp-pd-code-simplify with runtime C++ compilation.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Author: GGN_2015
|
|
@@ -59,6 +59,10 @@ result = simplify.simplify(pd_code)
|
|
|
59
59
|
print(result["final_pd_code"])
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
+
Returned `final_pd_code` strings are normalized so the smallest edge label is
|
|
63
|
+
`1`. This is applied only at the final JSON boundary; the C++ backend keeps its
|
|
64
|
+
internal numbering unchanged while simplifying.
|
|
65
|
+
|
|
62
66
|
The default `max_paths=-1` uses deterministic heuristic green-path sampling in
|
|
63
67
|
the C++ backend. Use `ban_heuristic=True` to request exhaustive green-path
|
|
64
68
|
enumeration for a manageable input. Use `reduction_round=K` to cap applied
|
|
@@ -39,6 +39,10 @@ result = simplify.simplify(pd_code)
|
|
|
39
39
|
print(result["final_pd_code"])
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
Returned `final_pd_code` strings are normalized so the smallest edge label is
|
|
43
|
+
`1`. This is applied only at the final JSON boundary; the C++ backend keeps its
|
|
44
|
+
internal numbering unchanged while simplifying.
|
|
45
|
+
|
|
42
46
|
The default `max_paths=-1` uses deterministic heuristic green-path sampling in
|
|
43
47
|
the C++ backend. Use `ban_heuristic=True` to request exhaustive green-path
|
|
44
48
|
enumeration for a manageable input. Use `reduction_round=K` to cap applied
|
|
@@ -125,6 +125,7 @@ struct ReductionResult {
|
|
|
125
125
|
|
|
126
126
|
PDCODE_SIMPLIFY_API PDCode parse_pd_code(const std::string& text);
|
|
127
127
|
PDCODE_SIMPLIFY_API std::string format_pd_code(const PDCode& code);
|
|
128
|
+
PDCODE_SIMPLIFY_API std::string format_final_pd_code(const PDCode& code);
|
|
128
129
|
PDCODE_SIMPLIFY_API std::string format_endpoint(const Endpoint& endpoint);
|
|
129
130
|
PDCODE_SIMPLIFY_API std::string format_direction(Direction direction);
|
|
130
131
|
|
|
@@ -92,7 +92,7 @@ std::string result_to_json(
|
|
|
92
92
|
append_component_counts(out, *after_removal_components);
|
|
93
93
|
out << "},";
|
|
94
94
|
}
|
|
95
|
-
out << "\"final_pd_code\":\"" << json_escape(pdcode_simplify::
|
|
95
|
+
out << "\"final_pd_code\":\"" << json_escape(pdcode_simplify::format_final_pd_code(result.code))
|
|
96
96
|
<< "\",";
|
|
97
97
|
out << "\"final_crossings\":" << result.code.size() << ",";
|
|
98
98
|
out << "\"final_components\":{";
|
|
@@ -1868,6 +1868,35 @@ std::string format_pd_code(const PDCode& code) {
|
|
|
1868
1868
|
return out.str();
|
|
1869
1869
|
}
|
|
1870
1870
|
|
|
1871
|
+
std::string format_final_pd_code(const PDCode& code) {
|
|
1872
|
+
if (code.empty()) {
|
|
1873
|
+
return format_pd_code(code);
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
bool has_label = false;
|
|
1877
|
+
int minimum_label = 0;
|
|
1878
|
+
for (const Crossing& crossing : code) {
|
|
1879
|
+
for (int label : crossing) {
|
|
1880
|
+
if (!has_label || label < minimum_label) {
|
|
1881
|
+
minimum_label = label;
|
|
1882
|
+
has_label = true;
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
if (!has_label || minimum_label == 1) {
|
|
1887
|
+
return format_pd_code(code);
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
PDCode shifted = code;
|
|
1891
|
+
const int offset = 1 - minimum_label;
|
|
1892
|
+
for (Crossing& crossing : shifted) {
|
|
1893
|
+
for (int& label : crossing) {
|
|
1894
|
+
label += offset;
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
return format_pd_code(shifted);
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1871
1900
|
std::string format_endpoint(const Endpoint& endpoint) {
|
|
1872
1901
|
std::ostringstream out;
|
|
1873
1902
|
out << '(' << endpoint.crossing << ", " << endpoint.strand << ')';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|