cpp-pd-code-simplify-interface 0.1.17__tar.gz → 0.1.18__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.
Files changed (12) hide show
  1. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/PKG-INFO +3 -2
  2. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/README.md +2 -1
  3. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/cpp_pd_code_simplify_interface/data/src/pdcode_simplify.cpp +11 -55
  4. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/pyproject.toml +1 -1
  5. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/build_backend/cpp_pd_code_simplify_interface_build_backend.py +0 -0
  6. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/cpp_pd_code_simplify_interface/__init__.py +0 -0
  7. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/cpp_pd_code_simplify_interface/__main__.py +0 -0
  8. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/cpp_pd_code_simplify_interface/_worker.py +0 -0
  9. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/cpp_pd_code_simplify_interface/data/include/pdcode_simplify/pdcode_simplify.hpp +0 -0
  10. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/cpp_pd_code_simplify_interface/data/src/native_interface.cpp +0 -0
  11. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/cpp_pd_code_simplify_interface/main.py +0 -0
  12. {cpp_pd_code_simplify_interface-0.1.17 → cpp_pd_code_simplify_interface-0.1.18}/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.17
3
+ Version: 0.1.18
4
4
  Summary: Python interface for cpp-pd-code-simplify with runtime C++ compilation.
5
5
  License-Expression: MIT
6
6
  Author: GGN_2015
@@ -79,7 +79,8 @@ the C++ backend for that phase. The backend call runs in a helper process, so
79
79
  `Ctrl+C` can terminate active C++ work and its worker threads cleanly.
80
80
  Use `show_step_pd=True`, or CLI flag `--show-step-pd`, to print
81
81
  `step_pd_code[ROUND]: PD[...]` to stdout after each mid-simplification witness
82
- is applied and before that round's automatic R1/nugatory cleanup.
82
+ is applied and canonicalized, before that round's automatic R1/nugatory
83
+ cleanup.
83
84
 
84
85
  Batch use:
85
86
 
@@ -59,7 +59,8 @@ the C++ backend for that phase. The backend call runs in a helper process, so
59
59
  `Ctrl+C` can terminate active C++ work and its worker threads cleanly.
60
60
  Use `show_step_pd=True`, or CLI flag `--show-step-pd`, to print
61
61
  `step_pd_code[ROUND]: PD[...]` to stdout after each mid-simplification witness
62
- is applied and before that round's automatic R1/nugatory cleanup.
62
+ is applied and canonicalized, before that round's automatic R1/nugatory
63
+ cleanup.
63
64
 
64
65
  Batch use:
65
66
 
@@ -68,6 +68,8 @@ struct CrossingState {
68
68
 
69
69
  using LabelMap = std::unordered_map<int, std::vector<Endpoint>>;
70
70
 
71
+ PDCode canonical_output_code(const PDCode& code);
72
+
71
73
  LabelMap build_label_map(const PDCode& code) {
72
74
  LabelMap labels;
73
75
  for (int c = 0; c < static_cast<int>(code.size()); ++c) {
@@ -227,6 +229,7 @@ PDCode erase_r1_moves(PDCode code, std::size_t& crossingless_components, int& mo
227
229
  }
228
230
 
229
231
  crossingless_components = after_removal.crossingless_components;
232
+ code = canonical_output_code(code);
230
233
  ++moves;
231
234
  changed = true;
232
235
  break;
@@ -237,7 +240,7 @@ PDCode erase_r1_moves(PDCode code, std::size_t& crossingless_components, int& mo
237
240
  }
238
241
  }
239
242
 
240
- return renumber_r1_order(code);
243
+ return canonical_output_code(renumber_r1_order(code));
241
244
  }
242
245
 
243
246
  std::map<int, std::set<int>> base_pd_graph(const PDCode& code) {
@@ -457,7 +460,7 @@ PDCode erase_one_nugatory_crossing(
457
460
  code = replace_arc_value(code, dx, bx);
458
461
  crossingless_components = after_removal.crossingless_components;
459
462
  ++moves;
460
- return renumber_full_dfs(code);
463
+ return canonical_output_code(renumber_full_dfs(code));
461
464
  }
462
465
 
463
466
  std::vector<std::vector<int>> raw_faces_from_pd_code(const PDCode& code) {
@@ -1842,14 +1845,6 @@ void emit_step_pd(const SimplifierOptions& options, int round, const PDCode& cod
1842
1845
  }
1843
1846
  }
1844
1847
 
1845
- std::string no_path_restart_signature(
1846
- const PDCode& code,
1847
- std::size_t crossingless_components) {
1848
- std::ostringstream out;
1849
- out << crossingless_components << ':' << format_final_pd_code(code);
1850
- return out.str();
1851
- }
1852
-
1853
1848
  PDCode canonical_output_code(const PDCode& code) {
1854
1849
  return parse_pd_code(format_final_pd_code(code));
1855
1850
  }
@@ -2199,7 +2194,7 @@ PDSimplificationResult simplify_pd_code(
2199
2194
  const PDCode& code,
2200
2195
  std::size_t known_crossingless_components) {
2201
2196
  PDSimplificationResult result;
2202
- result.code = code;
2197
+ result.code = canonical_output_code(code);
2203
2198
  result.crossingless_components = known_crossingless_components;
2204
2199
 
2205
2200
  result.code = erase_r1_moves(
@@ -2550,7 +2545,6 @@ ReductionResult reduce_pd_code(
2550
2545
  ReductionResult output;
2551
2546
  output.code = code;
2552
2547
  output.crossingless_components = known_crossingless_components;
2553
- std::set<std::string> exhausted_no_path_signatures;
2554
2548
 
2555
2549
  try {
2556
2550
  check_timeout(run_options);
@@ -2568,7 +2562,7 @@ ReductionResult reduce_pd_code(
2568
2562
 
2569
2563
  const PDSimplificationResult prepared =
2570
2564
  simplify_pd_code(code, known_crossingless_components);
2571
- output.code = prepared.code;
2565
+ output.code = canonical_output_code(prepared.code);
2572
2566
  output.crossingless_components = prepared.crossingless_components;
2573
2567
  output.reidemeister_i_moves = prepared.reidemeister_i_moves;
2574
2568
  output.nugatory_crossing_moves = prepared.nugatory_crossing_moves;
@@ -2643,45 +2637,6 @@ ReductionResult reduce_pd_code(
2643
2637
  }
2644
2638
 
2645
2639
  if (!search.found) {
2646
- if (run_options.max_paths == -1) {
2647
- check_timeout(run_options);
2648
- const std::string signature = no_path_restart_signature(
2649
- output.code, output.crossingless_components);
2650
- if (exhausted_no_path_signatures.insert(signature).second) {
2651
- const std::size_t before_restart_crossings = output.code.size();
2652
- const std::size_t before_restart_crossingless =
2653
- output.crossingless_components;
2654
- const PDSimplificationResult restarted =
2655
- simplify_pd_code(
2656
- canonical_output_code(output.code),
2657
- output.crossingless_components);
2658
- const bool changed =
2659
- restarted.code != output.code ||
2660
- restarted.crossingless_components != output.crossingless_components;
2661
- output.code = restarted.code;
2662
- output.crossingless_components = restarted.crossingless_components;
2663
- output.reidemeister_i_moves += restarted.reidemeister_i_moves;
2664
- output.nugatory_crossing_moves += restarted.nugatory_crossing_moves;
2665
- {
2666
- std::ostringstream message;
2667
- message << "round " << round
2668
- << " canonical_restart changed="
2669
- << (changed ? "yes" : "no")
2670
- << " crossings=" << before_restart_crossings
2671
- << " -> " << output.code.size()
2672
- << " crossingless_components="
2673
- << before_restart_crossingless
2674
- << " -> " << output.crossingless_components
2675
- << " r1_moves=" << restarted.reidemeister_i_moves
2676
- << " nugatory_moves="
2677
- << restarted.nugatory_crossing_moves;
2678
- emit_progress(run_options, message.str());
2679
- }
2680
- if (changed) {
2681
- continue;
2682
- }
2683
- }
2684
- }
2685
2640
  {
2686
2641
  std::ostringstream message;
2687
2642
  message << "round " << round
@@ -2695,14 +2650,15 @@ ReductionResult reduce_pd_code(
2695
2650
  check_timeout(run_options);
2696
2651
  const MidSimplificationApplyResult applied =
2697
2652
  apply_simplification_witness(output.code, search, output.crossingless_components);
2653
+ const PDCode applied_code = canonical_output_code(applied.code);
2698
2654
  ++output.mid_simplification_rounds;
2699
- emit_step_pd(run_options, round, applied.code);
2700
- output.code = applied.code;
2655
+ emit_step_pd(run_options, round, applied_code);
2656
+ output.code = applied_code;
2701
2657
  output.crossingless_components = applied.crossingless_components;
2702
2658
  check_timeout(run_options);
2703
2659
  const PDSimplificationResult simplified =
2704
2660
  simplify_pd_code(output.code, output.crossingless_components);
2705
- output.code = simplified.code;
2661
+ output.code = canonical_output_code(simplified.code);
2706
2662
  output.crossingless_components = simplified.crossingless_components;
2707
2663
  output.reidemeister_i_moves += simplified.reidemeister_i_moves;
2708
2664
  output.nugatory_crossing_moves += simplified.nugatory_crossing_moves;
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cpp-pd-code-simplify-interface"
3
- version = "0.1.17"
3
+ version = "0.1.18"
4
4
  description = "Python interface for cpp-pd-code-simplify with runtime C++ compilation."
5
5
  authors = [
6
6
  {name = "GGN_2015", email = "neko@jlulug.org"}