cpp-pd-code-simplify-interface 0.1.8__py3-none-any.whl → 0.1.9__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.
@@ -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::format_pd_code(result.code))
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 << ')';
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cpp-pd-code-simplify-interface
3
- Version: 0.1.8
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
@@ -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.8.dist-info/entry_points.txt,sha256=ThorC4Enxp317TKITsXm9pE0gUp7pt-pP6Dl5mEPUR8,91
6
- cpp_pd_code_simplify_interface-0.1.8.dist-info/METADATA,sha256=BApOUJ3sW3u7ULBD8YuI-YMPtkABDLbB-ayxVZonDKE,3726
7
- cpp_pd_code_simplify_interface-0.1.8.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
8
- cpp_pd_code_simplify_interface/data/include/pdcode_simplify/pdcode_simplify.hpp,sha256=h5aob9gqRq8Gz2Hs4ePzyoRAXFCIGRBShlRw3TxQ7wQ,4843
9
- cpp_pd_code_simplify_interface/data/src/native_interface.cpp,sha256=yXUJ0LHZDqz7WgFTwsq0U9pddH0KFTiOPr5sNyj7o1Y,6549
10
- cpp_pd_code_simplify_interface/data/src/pdcode_simplify.cpp,sha256=hXBEDQQC3C2KlHlKTbmuKqC3l48XF5p76iODfMqolWQ,88691
11
- cpp_pd_code_simplify_interface-0.1.8.dist-info/RECORD,,
5
+ cpp_pd_code_simplify_interface-0.1.9.dist-info/entry_points.txt,sha256=ThorC4Enxp317TKITsXm9pE0gUp7pt-pP6Dl5mEPUR8,91
6
+ cpp_pd_code_simplify_interface-0.1.9.dist-info/METADATA,sha256=rtMStQ-caLgzlWUXmJhJfDQZstn1Sys_tSN-rKPM_LY,3933
7
+ cpp_pd_code_simplify_interface-0.1.9.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
8
+ cpp_pd_code_simplify_interface/data/include/pdcode_simplify/pdcode_simplify.hpp,sha256=0WflWW2MB2EAK8GbcKKr9SbnoByMV3hFxt4m4mAerzQ,4917
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=c0aJLqzjHloMrVuDf0RD-JksSFfUiDAvSPnn9tC-gIs,89428
11
+ cpp_pd_code_simplify_interface-0.1.9.dist-info/RECORD,,