cpp-pd-code-simplify-interface 0.1.8__tar.gz → 0.1.10__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.10}/PKG-INFO +6 -1
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.10}/README.md +5 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.10}/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.10}/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.10}/cpp_pd_code_simplify_interface/data/src/pdcode_simplify.cpp +69 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.10}/pyproject.toml +1 -1
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.10}/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.10}/cpp_pd_code_simplify_interface/__init__.py +0 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.10}/cpp_pd_code_simplify_interface/__main__.py +0 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.10}/cpp_pd_code_simplify_interface/main.py +0 -0
- {cpp_pd_code_simplify_interface-0.1.8 → cpp_pd_code_simplify_interface-0.1.10}/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.10
|
|
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,11 @@ result = simplify.simplify(pd_code)
|
|
|
59
59
|
print(result["final_pd_code"])
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
+
Returned `final_pd_code` strings are normalized for display: each crossing is
|
|
63
|
+
written from the under-incoming edge and labels are renumbered along oriented
|
|
64
|
+
components from `1`. This is applied only at the final JSON boundary; the C++
|
|
65
|
+
backend keeps its internal numbering unchanged while simplifying.
|
|
66
|
+
|
|
62
67
|
The default `max_paths=-1` uses deterministic heuristic green-path sampling in
|
|
63
68
|
the C++ backend. Use `ban_heuristic=True` to request exhaustive green-path
|
|
64
69
|
enumeration for a manageable input. Use `reduction_round=K` to cap applied
|
|
@@ -39,6 +39,11 @@ result = simplify.simplify(pd_code)
|
|
|
39
39
|
print(result["final_pd_code"])
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
Returned `final_pd_code` strings are normalized for display: each crossing is
|
|
43
|
+
written from the under-incoming edge and labels are renumbered along oriented
|
|
44
|
+
components from `1`. This is applied only at the final JSON boundary; the C++
|
|
45
|
+
backend keeps its internal numbering unchanged while simplifying.
|
|
46
|
+
|
|
42
47
|
The default `max_paths=-1` uses deterministic heuristic green-path sampling in
|
|
43
48
|
the C++ backend. Use `ban_heuristic=True` to request exhaustive green-path
|
|
44
49
|
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,75 @@ 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
|
+
const Diagram diagram(code);
|
|
1877
|
+
PDCode oriented(code.size());
|
|
1878
|
+
std::set<int> labels;
|
|
1879
|
+
std::map<int, int> next_label;
|
|
1880
|
+
|
|
1881
|
+
auto label_at = [&](int crossing, int strand) {
|
|
1882
|
+
const Endpoint other = diagram.crossings[crossing].adjacent[strand];
|
|
1883
|
+
return diagram.code[other.crossing][other.strand];
|
|
1884
|
+
};
|
|
1885
|
+
|
|
1886
|
+
for (int crossing = 0; crossing < static_cast<int>(code.size()); ++crossing) {
|
|
1887
|
+
for (int strand = 0; strand < 4; ++strand) {
|
|
1888
|
+
const int label = label_at(crossing, strand);
|
|
1889
|
+
oriented[crossing][strand] = label;
|
|
1890
|
+
labels.insert(label);
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
if (!diagram.crossings[crossing].directions[0][2]) {
|
|
1894
|
+
throw std::invalid_argument("Could not orient final PD crossing from an under-incoming strand");
|
|
1895
|
+
}
|
|
1896
|
+
for (int tail = 0; tail < 4; ++tail) {
|
|
1897
|
+
for (int head = 0; head < 4; ++head) {
|
|
1898
|
+
if (!diagram.crossings[crossing].directions[tail][head]) {
|
|
1899
|
+
continue;
|
|
1900
|
+
}
|
|
1901
|
+
const int in_label = label_at(crossing, tail);
|
|
1902
|
+
const int out_label = label_at(crossing, head);
|
|
1903
|
+
const auto inserted = next_label.insert(std::make_pair(in_label, out_label));
|
|
1904
|
+
if (!inserted.second && inserted.first->second != out_label) {
|
|
1905
|
+
throw std::invalid_argument("Final PD component orientation is inconsistent");
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
std::map<int, int> relabel;
|
|
1912
|
+
int next_output_label = 1;
|
|
1913
|
+
for (int start : labels) {
|
|
1914
|
+
if (relabel.count(start) != 0) {
|
|
1915
|
+
continue;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
int current = start;
|
|
1919
|
+
while (relabel.count(current) == 0) {
|
|
1920
|
+
relabel[current] = next_output_label++;
|
|
1921
|
+
const auto next = next_label.find(current);
|
|
1922
|
+
if (next == next_label.end()) {
|
|
1923
|
+
throw std::invalid_argument("Final PD component orientation is incomplete");
|
|
1924
|
+
}
|
|
1925
|
+
current = next->second;
|
|
1926
|
+
}
|
|
1927
|
+
if (current != start) {
|
|
1928
|
+
throw std::invalid_argument("Final PD component orientation reached another component");
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
for (Crossing& crossing : oriented) {
|
|
1933
|
+
for (int& label : crossing) {
|
|
1934
|
+
label = relabel.at(label);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
return format_pd_code(oriented);
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1871
1940
|
std::string format_endpoint(const Endpoint& endpoint) {
|
|
1872
1941
|
std::ostringstream out;
|
|
1873
1942
|
out << '(' << endpoint.crossing << ", " << endpoint.strand << ')';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|