cpp-pd-code-simplify-interface 0.1.9__py3-none-any.whl → 0.1.10__py3-none-any.whl
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/data/src/pdcode_simplify.cpp +54 -14
- {cpp_pd_code_simplify_interface-0.1.9.dist-info → cpp_pd_code_simplify_interface-0.1.10.dist-info}/METADATA +5 -4
- {cpp_pd_code_simplify_interface-0.1.9.dist-info → cpp_pd_code_simplify_interface-0.1.10.dist-info}/RECORD +5 -5
- {cpp_pd_code_simplify_interface-0.1.9.dist-info → cpp_pd_code_simplify_interface-0.1.10.dist-info}/WHEEL +0 -0
- {cpp_pd_code_simplify_interface-0.1.9.dist-info → cpp_pd_code_simplify_interface-0.1.10.dist-info}/entry_points.txt +0 -0
|
@@ -1873,28 +1873,68 @@ std::string format_final_pd_code(const PDCode& code) {
|
|
|
1873
1873
|
return format_pd_code(code);
|
|
1874
1874
|
}
|
|
1875
1875
|
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
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
|
+
}
|
|
1883
1907
|
}
|
|
1884
1908
|
}
|
|
1885
1909
|
}
|
|
1886
|
-
|
|
1887
|
-
|
|
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
|
+
}
|
|
1888
1930
|
}
|
|
1889
1931
|
|
|
1890
|
-
|
|
1891
|
-
const int offset = 1 - minimum_label;
|
|
1892
|
-
for (Crossing& crossing : shifted) {
|
|
1932
|
+
for (Crossing& crossing : oriented) {
|
|
1893
1933
|
for (int& label : crossing) {
|
|
1894
|
-
label
|
|
1934
|
+
label = relabel.at(label);
|
|
1895
1935
|
}
|
|
1896
1936
|
}
|
|
1897
|
-
return format_pd_code(
|
|
1937
|
+
return format_pd_code(oriented);
|
|
1898
1938
|
}
|
|
1899
1939
|
|
|
1900
1940
|
std::string format_endpoint(const Endpoint& endpoint) {
|
|
@@ -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,9 +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
|
|
63
|
-
|
|
64
|
-
|
|
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.
|
|
65
66
|
|
|
66
67
|
The default `max_paths=-1` uses deterministic heuristic green-path sampling in
|
|
67
68
|
the C++ backend. Use `ban_heuristic=True` to request exhaustive green-path
|
|
@@ -2,10 +2,10 @@ cpp_pd_code_simplify_interface/__init__.py,sha256=aaNwD--zgQX13xiU1hpuvgXy8vVTFG
|
|
|
2
2
|
cpp_pd_code_simplify_interface/__main__.py,sha256=fdA1QWBe5LNX0fbtaJXa1-dwEhrg_4sS_5UnjaajcMo,80
|
|
3
3
|
cpp_pd_code_simplify_interface/main.py,sha256=4t-6xvjQjsuEWP_oiwedGtgrLYu3316uATrl9t4Q8zs,32778
|
|
4
4
|
cpp_pd_code_simplify_interface/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
5
|
-
cpp_pd_code_simplify_interface-0.1.
|
|
6
|
-
cpp_pd_code_simplify_interface-0.1.
|
|
7
|
-
cpp_pd_code_simplify_interface-0.1.
|
|
5
|
+
cpp_pd_code_simplify_interface-0.1.10.dist-info/entry_points.txt,sha256=ThorC4Enxp317TKITsXm9pE0gUp7pt-pP6Dl5mEPUR8,91
|
|
6
|
+
cpp_pd_code_simplify_interface-0.1.10.dist-info/METADATA,sha256=mFNvOlxRrKm62IouC_r5wWyt7KuJ7XqcAdVq39goeDA,4028
|
|
7
|
+
cpp_pd_code_simplify_interface-0.1.10.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
|
|
8
8
|
cpp_pd_code_simplify_interface/data/include/pdcode_simplify/pdcode_simplify.hpp,sha256=0WflWW2MB2EAK8GbcKKr9SbnoByMV3hFxt4m4mAerzQ,4917
|
|
9
9
|
cpp_pd_code_simplify_interface/data/src/native_interface.cpp,sha256=16HbKJBPA_EGdbyom4sSoQ7lisDBwaKrl7NsphmlA-k,6555
|
|
10
|
-
cpp_pd_code_simplify_interface/data/src/pdcode_simplify.cpp,sha256=
|
|
11
|
-
cpp_pd_code_simplify_interface-0.1.
|
|
10
|
+
cpp_pd_code_simplify_interface/data/src/pdcode_simplify.cpp,sha256=EUW5kLkhVxurDhdKZ4dhEXr1_7cUZL42ejXqr6vUo2E,91148
|
|
11
|
+
cpp_pd_code_simplify_interface-0.1.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|