downstream 0.4.2__py2.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.
Files changed (428) hide show
  1. downstream/__init__.py +15 -0
  2. downstream/downstream/__init__.py +4 -0
  3. downstream/genome_instrumentation/_BitSurface.py +2 -0
  4. downstream/genome_instrumentation/_StructSurface.py +2 -0
  5. downstream/genome_instrumentation/__init__.py +7 -0
  6. downstream/interop/__init__.py +23 -0
  7. downstream/interop/_make_stratum_retention_policy_from_site_selection_algo.py +278 -0
  8. downstream/interop/_stratum_retention_interop_hybrid_algo.py +14 -0
  9. downstream/interop/_stratum_retention_interop_steady_algo.py +14 -0
  10. downstream/interop/_stratum_retention_interop_tilted_algo.py +14 -0
  11. downstream/interop/_stratum_retention_interop_tilted_sticky_algo.py +14 -0
  12. downstream/pylib/Literal.py +4 -0
  13. downstream/pylib/__init__.py +69 -0
  14. downstream/pylib/bit_ceil.py +11 -0
  15. downstream/pylib/bit_count_immediate_zeros.py +10 -0
  16. downstream/pylib/bit_count_leading_ones.py +18 -0
  17. downstream/pylib/bit_decode_gray.py +8 -0
  18. downstream/pylib/bit_drop_msb.py +6 -0
  19. downstream/pylib/bit_encode_gray.py +7 -0
  20. downstream/pylib/bit_floor.py +8 -0
  21. downstream/pylib/bit_invert.py +7 -0
  22. downstream/pylib/bit_reverse.py +9 -0
  23. downstream/pylib/calc_dyadic_lcm_upper_bound.py +25 -0
  24. downstream/pylib/count_factors_of_2.py +19 -0
  25. downstream/pylib/enforce_typing.py +41 -0
  26. downstream/pylib/fast_pow2_divide.py +39 -0
  27. downstream/pylib/fast_pow2_mod.py +34 -0
  28. downstream/pylib/get_powersof2triangle_val_at_index.py +11 -0
  29. downstream/pylib/hanoi/__init__.py +33 -0
  30. downstream/pylib/hanoi/get_hanoi_value_at_index.py +10 -0
  31. downstream/pylib/hanoi/get_hanoi_value_incidence_at_index.py +11 -0
  32. downstream/pylib/hanoi/get_hanoi_value_index_cadence.py +4 -0
  33. downstream/pylib/hanoi/get_hanoi_value_index_offset.py +3 -0
  34. downstream/pylib/hanoi/get_incidence_count_of_hanoi_value_through_index.py +15 -0
  35. downstream/pylib/hanoi/get_index_of_hanoi_value_next_incidence.py +28 -0
  36. downstream/pylib/hanoi/get_index_of_hanoi_value_nth_incidence.py +14 -0
  37. downstream/pylib/hanoi/get_max_hanoi_value_through_index.py +10 -0
  38. downstream/pylib/hanoi/get_min_hanoi_value_with_incidence_at_least.py +26 -0
  39. downstream/pylib/jupyter_hide_toggle.py +64 -0
  40. downstream/pylib/log_args_and_result.py +54 -0
  41. downstream/pylib/longevity_ordering_alternating/__init__.py +17 -0
  42. downstream/pylib/longevity_ordering_alternating/get_longevity_directionality.py +3 -0
  43. downstream/pylib/longevity_ordering_alternating/get_longevity_index_of_mapped_position.py +44 -0
  44. downstream/pylib/longevity_ordering_alternating/get_longevity_mapped_position_of_index.py +35 -0
  45. downstream/pylib/longevity_ordering_alternating/get_longevity_reversed_position_within_level.py +14 -0
  46. downstream/pylib/longevity_ordering_common/__init__.py +19 -0
  47. downstream/pylib/longevity_ordering_common/get_longevity_level_of_index.py +3 -0
  48. downstream/pylib/longevity_ordering_common/get_longevity_level_of_mapped_position.py +12 -0
  49. downstream/pylib/longevity_ordering_common/get_longevity_num_positions_at_level.py +2 -0
  50. downstream/pylib/longevity_ordering_common/get_longevity_num_positions_at_lower_levels.py +7 -0
  51. downstream/pylib/longevity_ordering_common/get_longevity_offset_of_level.py +8 -0
  52. downstream/pylib/longevity_ordering_descending/__init__.py +11 -0
  53. downstream/pylib/longevity_ordering_descending/get_longevity_index_of_mapped_position.py +14 -0
  54. downstream/pylib/longevity_ordering_descending/get_longevity_mapped_position_of_index.py +21 -0
  55. downstream/pylib/longevity_ordering_naive/__init__.py +15 -0
  56. downstream/pylib/longevity_ordering_naive/get_longevity_index_of_mapped_position.py +10 -0
  57. downstream/pylib/longevity_ordering_naive/get_longevity_mapped_position_of_index.py +24 -0
  58. downstream/pylib/longevity_ordering_naive/get_longevity_position_within_level.py +23 -0
  59. downstream/pylib/longevity_ordering_piecewise_ascending/__init__.py +11 -0
  60. downstream/pylib/longevity_ordering_piecewise_ascending/get_longevity_index_of_mapped_position.py +28 -0
  61. downstream/pylib/longevity_ordering_piecewise_ascending/get_longevity_mapped_position_of_index.py +22 -0
  62. downstream/pylib/modulo.py +35 -0
  63. downstream/pylib/oeis/__init__.py +35 -0
  64. downstream/pylib/oeis/get_a000295_index_of_value.py +12 -0
  65. downstream/pylib/oeis/get_a000295_value_at_index.py +8 -0
  66. downstream/pylib/oeis/get_a005187_index_of_value.py +540 -0
  67. downstream/pylib/oeis/get_a005187_value_at_index.py +3 -0
  68. downstream/pylib/oeis/get_a025480_value_at_index.py +3 -0
  69. downstream/pylib/oeis/get_a030109_index_of_value.py +13 -0
  70. downstream/pylib/oeis/get_a030109_value_at_index.py +6 -0
  71. downstream/pylib/oeis/get_a037870_value_at_index.py +5 -0
  72. downstream/pylib/oeis/get_a048881_value_at_index.py +4 -0
  73. downstream/pylib/oeis/get_a059893_index_of_value.py +6 -0
  74. downstream/pylib/oeis/get_a059893_value_at_index.py +7 -0
  75. downstream/pylib/oeis/get_a083058_index_of_value.py +7 -0
  76. downstream/pylib/oeis/get_a083058_value_at_index.py +2 -0
  77. downstream/pylib/oeis/get_a130654_value_at_index.py +17 -0
  78. downstream/pylib/oeis/get_a341916_index_of_value.py +7 -0
  79. downstream/pylib/oeis/get_a341916_value_at_index.py +7 -0
  80. downstream/pylib/prepend_cmap_with_color.py +15 -0
  81. downstream/pylib/round_to_one_sigfig.py +13 -0
  82. downstream/pylib/sign.py +23 -0
  83. downstream/pylib/site_selection_eval/__init__.py +13 -0
  84. downstream/pylib/site_selection_eval/get_first_decreasing_hanoi_value_deposition.py +27 -0
  85. downstream/pylib/site_selection_eval/get_first_deposition_over_too_new_site.py +93 -0
  86. downstream/pylib/site_selection_eval/get_first_resolved_resident_rank_inconsistency.py +35 -0
  87. downstream/pylib/site_selection_eval/make_surface_history_df.py +70 -0
  88. downstream/pylib/site_selection_viz/_SurfaceHistoryToStratumRetentionPolicyShim.py +38 -0
  89. downstream/pylib/site_selection_viz/__init__.py +17 -0
  90. downstream/pylib/site_selection_viz/_apply_pseudo_linear_yticks.py +37 -0
  91. downstream/pylib/site_selection_viz/_apply_pseudo_log_yticks.py +26 -0
  92. downstream/pylib/site_selection_viz/_geomspace_filter_surface_history_df.py +22 -0
  93. downstream/pylib/site_selection_viz/_linspace_filter_surface_history_df.py +22 -0
  94. downstream/pylib/site_selection_viz/site_deposition_depth_by_rank_heatmap.py +66 -0
  95. downstream/pylib/site_selection_viz/site_deposition_rank_by_rank_heatmap.py +65 -0
  96. downstream/pylib/site_selection_viz/site_differentia_by_rank_heatmap.py +54 -0
  97. downstream/pylib/site_selection_viz/site_hanoi_value_by_rank_heatmap.py +57 -0
  98. downstream/pylib/site_selection_viz/stratum_persistence_dripplot.py +23 -0
  99. downstream/pylib/tee_release.py +10 -0
  100. downstream/pylib/test/__init__.py +0 -0
  101. downstream/pylib/test/test_Literal.py +5 -0
  102. downstream/pylib/test/test_bit_ceil.py +52 -0
  103. downstream/pylib/test/test_bit_count_immediate_zeros.py +46 -0
  104. downstream/pylib/test/test_bit_count_leading_ones.py +22 -0
  105. downstream/pylib/test/test_bit_decode_gray.py +7 -0
  106. downstream/pylib/test/test_bit_drop_msb.py +27 -0
  107. downstream/pylib/test/test_bit_encode_gray.py +27 -0
  108. downstream/pylib/test/test_bit_floor.py +14 -0
  109. downstream/pylib/test/test_bit_invert.py +33 -0
  110. downstream/pylib/test/test_bit_reverse.py +27 -0
  111. downstream/pylib/test/test_calc_dyadic_lcm_upper_bound.py +62 -0
  112. downstream/pylib/test/test_count_factors_of_2.py +21 -0
  113. downstream/pylib/test/test_enforce_typing.py +36 -0
  114. downstream/pylib/test/test_fast_pow2_divide.py +72 -0
  115. downstream/pylib/test/test_fast_pow2_mod.py +66 -0
  116. downstream/pylib/test/test_get_powersof2triangle_val_at_index.py +95 -0
  117. downstream/pylib/test/test_hanoi/__init__.py +0 -0
  118. downstream/pylib/test/test_hanoi/test_get_hanoi_value_at_index.py +116 -0
  119. downstream/pylib/test/test_hanoi/test_get_hanoi_value_incidence_at_index.py +12 -0
  120. downstream/pylib/test/test_hanoi/test_get_incidence_count_of_hanoi_value_through_index.py +22 -0
  121. downstream/pylib/test/test_hanoi/test_get_index_of_hanoi_value_next_incidence.py +37 -0
  122. downstream/pylib/test/test_hanoi/test_get_index_of_hanoi_value_nth_incidence.py +15 -0
  123. downstream/pylib/test/test_hanoi/test_get_max_hanoi_value_through_index.py +12 -0
  124. downstream/pylib/test/test_hanoi/test_get_min_hanoi_value_with_incidence_at_least.py +32 -0
  125. downstream/pylib/test/test_log_args_and_result.py +41 -0
  126. downstream/pylib/test/test_longevity_ordering_alternating/__init__.py +0 -0
  127. downstream/pylib/test/test_longevity_ordering_alternating/test_get_longevity_index_of_mapped_position.py +31 -0
  128. downstream/pylib/test/test_longevity_ordering_alternating/test_get_longevity_mapped_position_of_index.py +128 -0
  129. downstream/pylib/test/test_longevity_ordering_alternating/test_get_longevity_reversed_position_within_level.py +21 -0
  130. downstream/pylib/test/test_longevity_ordering_common/__init__.py +0 -0
  131. downstream/pylib/test/test_longevity_ordering_common/test_get_longevity_level_of_index.py +10 -0
  132. downstream/pylib/test/test_longevity_ordering_common/test_get_longevity_level_of_mapped_position.py +76 -0
  133. downstream/pylib/test/test_longevity_ordering_common/test_get_longevity_num_positions_at_level.py +10 -0
  134. downstream/pylib/test/test_longevity_ordering_common/test_get_longevity_offset_of_level.py +23 -0
  135. downstream/pylib/test/test_longevity_ordering_common/test_longevity_num_positions_at_lower_levels.py +7 -0
  136. downstream/pylib/test/test_longevity_ordering_descending/__init__.py +0 -0
  137. downstream/pylib/test/test_longevity_ordering_descending/test_get_longevity_index_of_mapped_position.py +28 -0
  138. downstream/pylib/test/test_longevity_ordering_descending/test_get_longevity_mapped_position_of_index.py +101 -0
  139. downstream/pylib/test/test_longevity_ordering_naive/__init__.py +0 -0
  140. downstream/pylib/test/test_longevity_ordering_naive/test_get_longevity_index_of_mapped_position.py +28 -0
  141. downstream/pylib/test/test_longevity_ordering_naive/test_get_longevity_mapped_position_of_index.py +101 -0
  142. downstream/pylib/test/test_longevity_ordering_naive/test_get_longevity_position_within_level.py +51 -0
  143. downstream/pylib/test/test_longevity_ordering_piecewise_ascending/__init__.py +0 -0
  144. downstream/pylib/test/test_longevity_ordering_piecewise_ascending/test_get_longevity_index_of_mapped_position.py +28 -0
  145. downstream/pylib/test/test_longevity_ordering_piecewise_ascending/test_get_longevity_mapped_position_of_index.py +101 -0
  146. downstream/pylib/test/test_modulo.py +30 -0
  147. downstream/pylib/test/test_oeis/__init__.py +0 -0
  148. downstream/pylib/test/test_oeis/test_get_a000295_index_of_value.py +35 -0
  149. downstream/pylib/test/test_oeis/test_get_a000295_value_at_index.py +41 -0
  150. downstream/pylib/test/test_oeis/test_get_a005187_index_of_value.py +9 -0
  151. downstream/pylib/test/test_oeis/test_get_a005187_value_at_index.py +73 -0
  152. downstream/pylib/test/test_oeis/test_get_a025480_value_at_index.py +91 -0
  153. downstream/pylib/test/test_oeis/test_get_a030109_index_of_value.py +13 -0
  154. downstream/pylib/test/test_oeis/test_get_a030109_value_at_index.py +90 -0
  155. downstream/pylib/test/test_oeis/test_get_a037870_value_at_index.py +97 -0
  156. downstream/pylib/test/test_oeis/test_get_a048881_value_at_index.py +112 -0
  157. downstream/pylib/test/test_oeis/test_get_a059893_index_of_value.py +13 -0
  158. downstream/pylib/test/test_oeis/test_get_a059893_value_at_index.py +78 -0
  159. downstream/pylib/test/test_oeis/test_get_a083058_index_of_value.py +10 -0
  160. downstream/pylib/test/test_oeis/test_get_a083058_value_at_index.py +81 -0
  161. downstream/pylib/test/test_oeis/test_get_a130654_value_at_index.py +139 -0
  162. downstream/pylib/test/test_oeis/test_get_a341916_index_of_value.py +13 -0
  163. downstream/pylib/test/test_oeis/test_get_a341916_value_at_index.py +74 -0
  164. downstream/pylib/test/test_prepend_cmap_with_color.py +14 -0
  165. downstream/pylib/test/test_round_to_one_sigfig.py +8 -0
  166. downstream/pylib/test/test_sign.py +19 -0
  167. downstream/serialization/__init__.py +11 -0
  168. downstream/serialization/_col_from_surf_int.py +60 -0
  169. downstream/serialization/_col_from_surf_packet.py +89 -0
  170. downstream/serialization/_sort_differentiae_by_deposition_rank.py +71 -0
  171. downstream/site_selection_strategy/__init__.py +4 -0
  172. downstream/site_selection_strategy/site_selection_algorithms/__init__.py +15 -0
  173. downstream/site_selection_strategy/site_selection_algorithms/hybrid_algo/__init__.py +9 -0
  174. downstream/site_selection_strategy/site_selection_algorithms/hybrid_algo/_calc_resident_deposition_rank.py +32 -0
  175. downstream/site_selection_strategy/site_selection_algorithms/hybrid_algo/_iter_resident_deposition_ranks.py +28 -0
  176. downstream/site_selection_strategy/site_selection_algorithms/hybrid_algo/_pick_deposition_site.py +36 -0
  177. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/__init__.py +37 -0
  178. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_enact/__init__.py +5 -0
  179. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_enact/_pick_deposition_site.py +79 -0
  180. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/__init__.py +33 -0
  181. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_calc_resident_deposition_rank_wrt_bin.py +79 -0
  182. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_bin_number_of_position.py +36 -0
  183. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_bin_offset_at_position.py +7 -0
  184. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_bin_width_at_position.py +65 -0
  185. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_bin_position.py +35 -0
  186. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_bin_width.py +20 -0
  187. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_segment_bin_count.py +5 -0
  188. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_segment_bin_width.py +9 -0
  189. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_segment_position.py +30 -0
  190. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_segment_width.py +8 -0
  191. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_num_bins.py +3 -0
  192. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_num_positions.py +5 -0
  193. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_num_segments.py +5 -0
  194. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_iter_bin_coords.py +26 -0
  195. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_scry/__init__.py +7 -0
  196. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_scry/_calc_resident_deposition_rank.py +37 -0
  197. downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_scry/_iter_resident_deposition_ranks.py +40 -0
  198. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/__init__.py +11 -0
  199. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_enact/__init__.py +0 -0
  200. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_enact/_pick_deposition_site.py +43 -0
  201. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/__init__.py +59 -0
  202. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_calc_hanoi_invasion_rank.py +10 -0
  203. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_calc_invading_hanoi_value.py +17 -0
  204. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_calc_resident_hanoi_value.py +77 -0
  205. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_epoch_rank.py +16 -0
  206. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_global_epoch.py +20 -0
  207. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_global_num_reservations.py +12 -0
  208. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_grip_reservation_index_logical.py +51 -0
  209. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_grip_reservation_index_physical.py +44 -0
  210. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_hanoi_num_reservations.py +44 -0
  211. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_reservation_position_logical.py +19 -0
  212. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_reservation_position_physical.py +26 -0
  213. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_reservation_width_physical.py +19 -0
  214. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_site_genesis_reservation_index_physical.py +33 -0
  215. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_site_hanoi_value_assigned.py +32 -0
  216. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_site_reservation_index_logical.py +39 -0
  217. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_site_reservation_index_physical.py +41 -0
  218. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_scry/__init__.py +7 -0
  219. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_scry/_calc_resident_deposition_rank.py +222 -0
  220. downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_scry/_iter_resident_deposition_ranks.py +31 -0
  221. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/__init__.py +14 -0
  222. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_enact/__init__.py +5 -0
  223. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_enact/_pick_deposition_site.py +59 -0
  224. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/__init__.py +59 -0
  225. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_fractional_downgrade_num_reservations_provided.py +36 -0
  226. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_fractional_downgrade_rank.py +60 -0
  227. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_fractional_downgrade_state.py +295 -0
  228. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_num_incidence_reservations_at_rank.py +23 -0
  229. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_num_reservations_provided.py +39 -0
  230. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_num_sites_reserved_per_incidence_at_rank.py +24 -0
  231. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_regime_mx.py +21 -0
  232. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_regime_num_reservations_available.py +23 -0
  233. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_regime_num_reservations_provided.py +39 -0
  234. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_regime_reservation_downgrade_rank.py +58 -0
  235. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_safe_downgrade_rank.py +152 -0
  236. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_surface_rank_capacity.py +13 -0
  237. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_upcoming_hanoi_invasion_rank.py +20 -0
  238. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_upcoming_hanoi_invasion_value.py +30 -0
  239. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_has_hanoi_value_filled_first_reservation_layer.py +32 -0
  240. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_is_2x_reservation_eligible.py +28 -0
  241. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_is_hanoi_invadable_and_uninvaded.py +11 -0
  242. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_is_hanoi_invaded.py +19 -0
  243. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_is_hanoi_invader.py +17 -0
  244. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_iter_hanoi_invader_values.py +18 -0
  245. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/__init__.py +7 -0
  246. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_calc_resident_deposition_rank.py +41 -0
  247. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/__init__.py +29 -0
  248. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_calc_incidence_of_deposited_hanoi_value.py +68 -0
  249. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_calc_rank_of_deposited_hanoi_value.py +36 -0
  250. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_calc_reservation_reference_incidence.py +101 -0
  251. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_calc_resident_hanoi_context.py +138 -0
  252. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_get_reservation_index_elimination_rank.py +114 -0
  253. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_iter_candidate_hanoi_occupants.py +30 -0
  254. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_iter_candidate_reservation_indices.py +33 -0
  255. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_iter_candidate_reservation_sizes.py +28 -0
  256. downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_iter_resident_deposition_ranks.py +2 -0
  257. downstream/site_selection_strategy/site_selection_algorithms/tilted_sticky_algo/__init__.py +9 -0
  258. downstream/site_selection_strategy/site_selection_algorithms/tilted_sticky_algo/_calc_resident_deposition_rank.py +42 -0
  259. downstream/site_selection_strategy/site_selection_algorithms/tilted_sticky_algo/_iter_resident_deposition_ranks.py +31 -0
  260. downstream/site_selection_strategy/site_selection_algorithms/tilted_sticky_algo/_pick_deposition_site.py +32 -0
  261. downstream-0.4.2.dist-info/LICENSE +21 -0
  262. downstream-0.4.2.dist-info/METADATA +106 -0
  263. downstream-0.4.2.dist-info/RECORD +428 -0
  264. downstream-0.4.2.dist-info/WHEEL +6 -0
  265. downstream-0.4.2.dist-info/top_level.txt +3 -0
  266. pylib/hanoi/__init__.py +33 -0
  267. pylib/hanoi/get_hanoi_value_at_index.py +10 -0
  268. pylib/hanoi/get_hanoi_value_incidence_at_index.py +11 -0
  269. pylib/hanoi/get_hanoi_value_index_cadence.py +4 -0
  270. pylib/hanoi/get_hanoi_value_index_offset.py +3 -0
  271. pylib/hanoi/get_incidence_count_of_hanoi_value_through_index.py +15 -0
  272. pylib/hanoi/get_index_of_hanoi_value_next_incidence.py +28 -0
  273. pylib/hanoi/get_index_of_hanoi_value_nth_incidence.py +14 -0
  274. pylib/hanoi/get_max_hanoi_value_through_index.py +10 -0
  275. pylib/hanoi/get_min_hanoi_value_with_incidence_at_least.py +26 -0
  276. pylib/longevity_ordering_alternating/__init__.py +17 -0
  277. pylib/longevity_ordering_alternating/get_longevity_directionality.py +3 -0
  278. pylib/longevity_ordering_alternating/get_longevity_index_of_mapped_position.py +44 -0
  279. pylib/longevity_ordering_alternating/get_longevity_mapped_position_of_index.py +35 -0
  280. pylib/longevity_ordering_alternating/get_longevity_reversed_position_within_level.py +14 -0
  281. pylib/longevity_ordering_common/__init__.py +19 -0
  282. pylib/longevity_ordering_common/get_longevity_level_of_index.py +3 -0
  283. pylib/longevity_ordering_common/get_longevity_level_of_mapped_position.py +12 -0
  284. pylib/longevity_ordering_common/get_longevity_num_positions_at_level.py +2 -0
  285. pylib/longevity_ordering_common/get_longevity_num_positions_at_lower_levels.py +7 -0
  286. pylib/longevity_ordering_common/get_longevity_offset_of_level.py +8 -0
  287. pylib/longevity_ordering_descending/__init__.py +11 -0
  288. pylib/longevity_ordering_descending/get_longevity_index_of_mapped_position.py +14 -0
  289. pylib/longevity_ordering_descending/get_longevity_mapped_position_of_index.py +21 -0
  290. pylib/longevity_ordering_naive/__init__.py +15 -0
  291. pylib/longevity_ordering_naive/get_longevity_index_of_mapped_position.py +10 -0
  292. pylib/longevity_ordering_naive/get_longevity_mapped_position_of_index.py +24 -0
  293. pylib/longevity_ordering_naive/get_longevity_position_within_level.py +23 -0
  294. pylib/longevity_ordering_piecewise_ascending/__init__.py +11 -0
  295. pylib/longevity_ordering_piecewise_ascending/get_longevity_index_of_mapped_position.py +28 -0
  296. pylib/longevity_ordering_piecewise_ascending/get_longevity_mapped_position_of_index.py +22 -0
  297. pylib/oeis/__init__.py +35 -0
  298. pylib/oeis/get_a000295_index_of_value.py +12 -0
  299. pylib/oeis/get_a000295_value_at_index.py +8 -0
  300. pylib/oeis/get_a005187_index_of_value.py +540 -0
  301. pylib/oeis/get_a005187_value_at_index.py +3 -0
  302. pylib/oeis/get_a025480_value_at_index.py +3 -0
  303. pylib/oeis/get_a030109_index_of_value.py +13 -0
  304. pylib/oeis/get_a030109_value_at_index.py +6 -0
  305. pylib/oeis/get_a037870_value_at_index.py +5 -0
  306. pylib/oeis/get_a048881_value_at_index.py +4 -0
  307. pylib/oeis/get_a059893_index_of_value.py +6 -0
  308. pylib/oeis/get_a059893_value_at_index.py +7 -0
  309. pylib/oeis/get_a083058_index_of_value.py +7 -0
  310. pylib/oeis/get_a083058_value_at_index.py +2 -0
  311. pylib/oeis/get_a130654_value_at_index.py +17 -0
  312. pylib/oeis/get_a341916_index_of_value.py +7 -0
  313. pylib/oeis/get_a341916_value_at_index.py +7 -0
  314. pylib/site_selection_eval/__init__.py +13 -0
  315. pylib/site_selection_eval/get_first_decreasing_hanoi_value_deposition.py +27 -0
  316. pylib/site_selection_eval/get_first_deposition_over_too_new_site.py +93 -0
  317. pylib/site_selection_eval/get_first_resolved_resident_rank_inconsistency.py +35 -0
  318. pylib/site_selection_eval/make_surface_history_df.py +70 -0
  319. pylib/site_selection_viz/_SurfaceHistoryToStratumRetentionPolicyShim.py +38 -0
  320. pylib/site_selection_viz/__init__.py +17 -0
  321. pylib/site_selection_viz/_apply_pseudo_linear_yticks.py +37 -0
  322. pylib/site_selection_viz/_apply_pseudo_log_yticks.py +26 -0
  323. pylib/site_selection_viz/_geomspace_filter_surface_history_df.py +22 -0
  324. pylib/site_selection_viz/_linspace_filter_surface_history_df.py +22 -0
  325. pylib/site_selection_viz/site_deposition_depth_by_rank_heatmap.py +66 -0
  326. pylib/site_selection_viz/site_deposition_rank_by_rank_heatmap.py +65 -0
  327. pylib/site_selection_viz/site_differentia_by_rank_heatmap.py +54 -0
  328. pylib/site_selection_viz/site_hanoi_value_by_rank_heatmap.py +57 -0
  329. pylib/site_selection_viz/stratum_persistence_dripplot.py +23 -0
  330. test_downstream/test_interop/__init__.py +0 -0
  331. test_downstream/test_interop/test_make_stratum_retention_policy_from_site_selection_algo.py +244 -0
  332. test_downstream/test_serialization/__init__.py +0 -0
  333. test_downstream/test_serialization/test_col_from_surf_int.py +113 -0
  334. test_downstream/test_serialization/test_col_from_surf_packet.py +98 -0
  335. test_downstream/test_serialization/test_sort_differentiae_by_deposition_rank.py +111 -0
  336. test_downstream/test_site_selection_strategy/__init__.py +0 -0
  337. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/__init__.py +0 -0
  338. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_hybrid_algo/__init__.py +0 -0
  339. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_hybrid_algo/test_calc_resident_deposition_rank.py +62 -0
  340. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_hybrid_algo/test_iter_resident_deposition_ranks.py +28 -0
  341. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/__init__.py +0 -0
  342. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_enact/__init__.py +0 -0
  343. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_enact/test_pick_deposition_site.py +60 -0
  344. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/__init__.py +0 -0
  345. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_bin_number_of_position.py +16 -0
  346. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_bin_width_at_position.py +101 -0
  347. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_bin_position.py +26 -0
  348. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_bin_width.py +48 -0
  349. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_segment_bin_count.py +12 -0
  350. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_segment_bin_width.py +21 -0
  351. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_segment_position.py +40 -0
  352. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_segment_width.py +21 -0
  353. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_num_bins.py +32 -0
  354. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_num_segments.py +22 -0
  355. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_iter_bin_coords.py +23 -0
  356. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_scry/__init__.py +0 -0
  357. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_scry/test_calc_resident_deposition_rank.py +60 -0
  358. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_scry/test_iter_resident_deposition_ranks.py +25 -0
  359. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/__init__.py +0 -0
  360. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_enact/__init__.py +0 -0
  361. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_enact/test_pick_deposition_site.py +247 -0
  362. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/__init__.py +0 -0
  363. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_calc_hanoi_invasion_rank.py +26 -0
  364. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_calc_invading_hanoi_value.py +25 -0
  365. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_calc_resident_hanoi_value.py +67 -0
  366. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_epoch_rank.py +34 -0
  367. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_global_epoch.py +86 -0
  368. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_global_num_reservtions.py +98 -0
  369. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_global_num_reservtions_at_epoch.py +114 -0
  370. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_grip_reservation_index_logical.py +95 -0
  371. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_grip_reservation_index_logical_at_epoch.py +79 -0
  372. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_grip_reservation_index_physical.py +94 -0
  373. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_grip_reservation_index_physical_at_epoch.py +79 -0
  374. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_hanoi_num_reservtions.py +77 -0
  375. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_reservation_position_logical.py +66 -0
  376. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_reservation_position_physical.py +67 -0
  377. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_reservation_width_physical.py +59 -0
  378. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_site_genesis_reservation_index_physical.py +26 -0
  379. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_site_hanoi_value_assigned.py +62 -0
  380. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_site_reservation_index_logical.py +73 -0
  381. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_site_reservation_index_logical_at_epoch.py +64 -0
  382. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_site_reservation_index_physical.py +73 -0
  383. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_site_reservation_index_physical_at_epoch.py +64 -0
  384. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_scry/__init__.py +0 -0
  385. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_scry/test_calc_resident_deposition_rank.py +78 -0
  386. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_scry/test_iter_resident_deposition_ranks.py +25 -0
  387. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/__init__.py +0 -0
  388. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/__init__.py +1 -0
  389. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_fractional_downgrade_num_reservations_provided.py +23 -0
  390. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_fractional_downgrade_rank.py +23 -0
  391. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_fractional_downgrade_state.py +20 -0
  392. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_num_incidence_reservations_at_rank.py +31 -0
  393. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_num_reservations_provided.py +18 -0
  394. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_num_sites_reserved_per_incidence_at_rank.py +29 -0
  395. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_regime_mx.py +45 -0
  396. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_regime_num_reservations_available.py +26 -0
  397. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_regime_num_reservations_provided.py +18 -0
  398. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_regime_reservation_downgrade_rank.py +18 -0
  399. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_safe_downgrade_rank.py +46 -0
  400. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_surface_rank_capacity.py +32 -0
  401. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_upcoming_hanoi_invasion_rank.py +171 -0
  402. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_get_upcoming_hanoi_invasion_value.py +266 -0
  403. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_has_hanoi_value_filled_first_reservation_layer.py +48 -0
  404. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_is_2x_reservation_eligible.py +44 -0
  405. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_is_hanoi_invadable_and_uninvaded.py +34 -0
  406. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_is_hanoi_invaded.py +35 -0
  407. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_is_hanoi_invader.py +21 -0
  408. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/test_iter_hanoi_invader_values.py +18 -0
  409. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_pick_deposition_site.py +55 -0
  410. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/__init__.py +0 -0
  411. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_calc_resident_deposition_rank.py +266 -0
  412. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/__init__.py +0 -0
  413. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/_impl/__init__.py +9 -0
  414. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/_impl/_make_num_reservations_provided_df.py +46 -0
  415. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/_impl/_make_reference_incidence_df.py +107 -0
  416. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/test_calc_incidence_of_deposited_hanoi_value.py +43 -0
  417. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/test_calc_rank_of_deposited_hanoi_value.py +41 -0
  418. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/test_calc_reservation_reference_incidence.py +43 -0
  419. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/test_calc_resident_hanoi_context.py +335 -0
  420. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/test_get_reservation_index_elimination_rank.py +86 -0
  421. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/test_iter_candidate_hanoi_occupants.py +51 -0
  422. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/test_iter_candidate_reservation_indices.py +25 -0
  423. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_impl/test_iter_candidate_reservation_sizes.py +16 -0
  424. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/test_iter_resident_deposition_ranks.py +6 -0
  425. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_sticky_algo/__init__.py +0 -0
  426. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_sticky_algo/test_calc_resident_deposition_rank.py +72 -0
  427. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_sticky_algo/test_iter_resident_deposition_ranks.py +28 -0
  428. test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_sticky_algo/test_pick_deposition_site.py +24 -0
downstream/__init__.py ADDED
@@ -0,0 +1,15 @@
1
+ """Top-level package for downstream."""
2
+
3
+ __author__ = "Matthew Andres Moreno"
4
+ __email__ = "m.more500@gmail.com"
5
+ __version__ = "0.4.2"
6
+
7
+
8
+ from . import genome_instrumentation, interop, site_selection_strategy
9
+
10
+ __all__ = [
11
+ "interop",
12
+ "genome_instrumentation",
13
+ "serialization",
14
+ "site_selection_strategy",
15
+ ]
@@ -0,0 +1,4 @@
1
+ from ..genome_instrumentation import * # noqa: F403
2
+ from ..interop import * # noqa: F403
3
+ from ..serialization import * # noqa: F403
4
+ from ..site_selection_strategy import * # noqa: F403
@@ -0,0 +1,2 @@
1
+ class BitSurface:
2
+ """Placeholder."""
@@ -0,0 +1,2 @@
1
+ class StructSurface:
2
+ """Placeholder."""
@@ -0,0 +1,7 @@
1
+ from ._BitSurface import BitSurface
2
+ from ._StructSurface import StructSurface
3
+
4
+ __all__ = [
5
+ "BitSurface",
6
+ "StructSurface",
7
+ ]
@@ -0,0 +1,23 @@
1
+ from . import (
2
+ _stratum_retention_interop_hybrid_algo as stratum_retention_interop_hybrid_algo,
3
+ )
4
+ from . import (
5
+ _stratum_retention_interop_steady_algo as stratum_retention_interop_steady_algo,
6
+ )
7
+ from . import (
8
+ _stratum_retention_interop_tilted_algo as stratum_retention_interop_tilted_algo,
9
+ )
10
+ from . import (
11
+ _stratum_retention_interop_tilted_sticky_algo as stratum_retention_interop_tilted_sticky_algo,
12
+ )
13
+ from ._make_stratum_retention_policy_from_site_selection_algo import (
14
+ make_stratum_retention_policy_from_site_selection_algo,
15
+ )
16
+
17
+ __all__ = [
18
+ "make_stratum_retention_policy_from_site_selection_algo",
19
+ "stratum_retention_interop_hybrid_algo",
20
+ "stratum_retention_interop_steady_algo",
21
+ "stratum_retention_interop_tilted_algo",
22
+ "stratum_retention_interop_tilted_sticky_algo",
23
+ ]
@@ -0,0 +1,278 @@
1
+ import numbers
2
+ import types
3
+ import typing
4
+
5
+ from hstrat.stratum_retention_strategy.stratum_retention_algorithms._detail import (
6
+ PolicyCouplerBase,
7
+ PolicyCouplerFactory,
8
+ PolicySpecBase,
9
+ )
10
+ import more_itertools as mit
11
+
12
+
13
+ class _PolicySpecBase:
14
+ pass
15
+
16
+
17
+ class _GenDropRanksFtorBase:
18
+ pass
19
+
20
+
21
+ class _CalcNumStrataRetainedExactFtorBase:
22
+ pass
23
+
24
+
25
+ class _CalcRankAtColumnIndexFtorBase:
26
+ pass
27
+
28
+
29
+ class _IterRetainedRanksFtorBase:
30
+ pass
31
+
32
+
33
+ class _CalcNumStrataRetainedUpperBoundFtorBase:
34
+ pass
35
+
36
+
37
+ def make_stratum_retention_policy_from_site_selection_algo(
38
+ site_selection_algo: types.ModuleType,
39
+ ) -> PolicyCouplerBase:
40
+ """Create object infrastructure for a stratum retention policy equivalent
41
+ to provided surface site selection algorithm."""
42
+
43
+ class PolicySpec(PolicySpecBase, _PolicySpecBase):
44
+ """Contains all policy parameters, if any."""
45
+
46
+ _site_selection_algo: types.ModuleType = site_selection_algo
47
+ _surface_size: int
48
+
49
+ def __init__(
50
+ self: "PolicySpec",
51
+ surface_size: int,
52
+ ):
53
+ """Construct the policy spec.
54
+
55
+ Parameters
56
+ ----------
57
+ surface_size : int
58
+ How many sites does surface contain?
59
+ """
60
+ assert surface_size > 1
61
+ self._surface_size = surface_size
62
+
63
+ def __eq__(self: "PolicySpec", other: typing.Any) -> bool:
64
+ return isinstance(other, _PolicySpecBase) and (
65
+ self._surface_size,
66
+ self._site_selection_algo,
67
+ ) == (
68
+ other._surface_size,
69
+ other._site_selection_algo,
70
+ )
71
+
72
+ def __repr__(self: "PolicySpec") -> str:
73
+ return f"""{
74
+ self.GetAlgoIdentifier()
75
+ }.{
76
+ PolicySpec.__qualname__
77
+ }(surface_size={
78
+ self._surface_size
79
+ })"""
80
+
81
+ def __str__(self: "PolicySpec") -> str:
82
+ return f"""{
83
+ self.GetAlgoTitle()
84
+ } (surface size: {
85
+ self._surface_size
86
+ })"""
87
+
88
+ def GetEvalCtor(self: "PolicySpec") -> str:
89
+ return (
90
+ "downstream.interop.stratum_retention_interop_"
91
+ f"{site_selection_algo.__name__}.{self!r}"
92
+ )
93
+
94
+ def GetSurfaceSize(self: "PolicySpec") -> int:
95
+ return self._surface_size
96
+
97
+ @staticmethod
98
+ def GetAlgoIdentifier() -> str:
99
+ """Get programatic name for underlying retention algorithm."""
100
+ return site_selection_algo.__name__
101
+
102
+ @staticmethod
103
+ def GetAlgoTitle() -> str:
104
+ """Get human-readable name for underlying retention algorithm."""
105
+ return site_selection_algo.__name__.replace("_", " ")
106
+
107
+ class CalcNumStrataRetainedExactFtor(_CalcNumStrataRetainedExactFtorBase):
108
+ def __init__(
109
+ self: "CalcNumStrataRetainedExactFtor",
110
+ policy_spec: typing.Optional[PolicySpec],
111
+ ) -> None:
112
+ pass
113
+
114
+ def __eq__(
115
+ self: "CalcNumStrataRetainedExactFtor",
116
+ other: typing.Any,
117
+ ) -> bool:
118
+ return isinstance(other, _CalcNumStrataRetainedExactFtorBase)
119
+
120
+ def __call__(
121
+ self: "CalcNumStrataRetainedExactFtor",
122
+ policy: PolicyCouplerBase,
123
+ num_strata_deposited: int,
124
+ ) -> int:
125
+ return sum(
126
+ 1 for __ in policy.IterRetainedRanks(num_strata_deposited)
127
+ )
128
+
129
+ class CalcRankAtColumnIndexFtor(_CalcRankAtColumnIndexFtorBase):
130
+ def __init__(
131
+ self: "CalcRankAtColumnIndexFtor",
132
+ policy_spec: typing.Optional[PolicySpec],
133
+ ) -> None:
134
+ pass
135
+
136
+ def __eq__(
137
+ self: "CalcRankAtColumnIndexFtor",
138
+ other: typing.Any,
139
+ ) -> bool:
140
+ return isinstance(other, _CalcRankAtColumnIndexFtorBase)
141
+
142
+ def __call__(
143
+ self: "CalcRankAtColumnIndexFtor",
144
+ policy: PolicyCouplerBase,
145
+ index: int,
146
+ num_strata_deposited: int,
147
+ ) -> int:
148
+ if (
149
+ not 0
150
+ <= index
151
+ < policy.CalcNumStrataRetainedExact(num_strata_deposited)
152
+ ):
153
+ raise IndexError
154
+ res = mit.nth(
155
+ policy.IterRetainedRanks(num_strata_deposited), index
156
+ )
157
+ assert res is not None
158
+ return res
159
+
160
+ class GenDropRanksFtor(_GenDropRanksFtorBase):
161
+ def __init__(
162
+ self: "GenDropRanksFtor",
163
+ policy_spec: typing.Optional[PolicySpec],
164
+ ) -> None:
165
+ pass
166
+
167
+ def __eq__(
168
+ self: "GenDropRanksFtor",
169
+ other: typing.Any,
170
+ ) -> bool:
171
+ return isinstance(other, _GenDropRanksFtorBase)
172
+
173
+ def __call__(
174
+ self: "GenDropRanksFtor",
175
+ policy: PolicyCouplerBase,
176
+ num_stratum_depositions_completed: int,
177
+ retained_ranks: typing.Optional[typing.Iterable[int]] = None,
178
+ ) -> typing.Iterator[int]:
179
+ # convert for compat with numpy dtypes
180
+ assert isinstance(
181
+ num_stratum_depositions_completed, numbers.Integral
182
+ )
183
+ num_stratum_depositions_completed = int(
184
+ num_stratum_depositions_completed,
185
+ )
186
+
187
+ if num_stratum_depositions_completed == 0:
188
+ return
189
+
190
+ algo = site_selection_algo
191
+ surface_size = policy.GetSpec().GetSurfaceSize()
192
+
193
+ target_site = algo.pick_deposition_site(
194
+ num_stratum_depositions_completed, surface_size
195
+ )
196
+ target_rank = algo.calc_resident_deposition_rank(
197
+ target_site, surface_size, num_stratum_depositions_completed
198
+ )
199
+ if target_rank != 0:
200
+ yield target_rank
201
+ return
202
+ elif 0 not in algo.iter_resident_deposition_ranks(
203
+ surface_size,
204
+ num_stratum_depositions_completed + 1,
205
+ ):
206
+ yield 0
207
+ return
208
+
209
+ class IterRetainedRanksFtor(_IterRetainedRanksFtorBase):
210
+ def __init__(
211
+ self: "IterRetainedRanksFtor",
212
+ policy_spec: typing.Optional[PolicySpec],
213
+ ) -> None:
214
+ pass
215
+
216
+ def __eq__(
217
+ self: "IterRetainedRanksFtor",
218
+ other: typing.Any,
219
+ ) -> bool:
220
+ return isinstance(other, _IterRetainedRanksFtorBase)
221
+
222
+ def __call__(
223
+ self: "IterRetainedRanksFtor",
224
+ policy: PolicyCouplerBase,
225
+ num_strata_deposited: int,
226
+ ) -> typing.Iterator[int]:
227
+ # convert for compat with numpy dtypes
228
+ assert isinstance(num_strata_deposited, numbers.Integral)
229
+ num_strata_deposited = int(num_strata_deposited)
230
+
231
+ if num_strata_deposited == 0:
232
+ return
233
+ algo = site_selection_algo
234
+ surface_size = policy.GetSpec().GetSurfaceSize()
235
+ ranks = sorted(
236
+ algo.iter_resident_deposition_ranks(
237
+ surface_size,
238
+ num_strata_deposited,
239
+ )
240
+ )
241
+ last_zero = ranks.count(0) - (ranks[0] == 0)
242
+ assert 0 <= last_zero < len(ranks)
243
+ yield from ranks[last_zero:]
244
+
245
+ class CalcNumStrataRetainedUpperBoundFtor(
246
+ _CalcNumStrataRetainedUpperBoundFtorBase,
247
+ ):
248
+ def __init__(
249
+ self: "CalcNumStrataRetainedUpperBoundFtor",
250
+ policy_spec: typing.Optional[PolicySpec],
251
+ ) -> None:
252
+ pass
253
+
254
+ def __eq__(
255
+ self: "CalcNumStrataRetainedUpperBoundFtor",
256
+ other: typing.Any,
257
+ ) -> bool:
258
+ return isinstance(other, _CalcNumStrataRetainedUpperBoundFtorBase)
259
+
260
+ def __call__(
261
+ self: "CalcNumStrataRetainedUpperBoundFtor",
262
+ policy: PolicyCouplerBase,
263
+ num_strata_deposited: int,
264
+ ) -> typing.Iterator[int]:
265
+ surface_size = policy.GetSpec().GetSurfaceSize()
266
+ return min(
267
+ num_strata_deposited,
268
+ surface_size,
269
+ )
270
+
271
+ return PolicyCouplerFactory(
272
+ policy_spec_t=PolicySpec,
273
+ gen_drop_ranks_ftor_t=GenDropRanksFtor,
274
+ calc_num_strata_retained_exact_ftor_t=CalcNumStrataRetainedExactFtor,
275
+ calc_rank_at_column_index_ftor_t=CalcRankAtColumnIndexFtor,
276
+ iter_retained_ranks_ftor_t=IterRetainedRanksFtor,
277
+ calc_num_strata_retained_upper_bound_ftor_t=CalcNumStrataRetainedUpperBoundFtor,
278
+ )
@@ -0,0 +1,14 @@
1
+ from ..site_selection_strategy.site_selection_algorithms import (
2
+ hybrid_algo as _site_selection_algo,
3
+ )
4
+ from ._make_stratum_retention_policy_from_site_selection_algo import (
5
+ make_stratum_retention_policy_from_site_selection_algo,
6
+ )
7
+
8
+ Policy = make_stratum_retention_policy_from_site_selection_algo(
9
+ _site_selection_algo
10
+ )
11
+ PolicySpec = Policy.policy_spec_t
12
+
13
+ # prevent name leakage
14
+ del make_stratum_retention_policy_from_site_selection_algo
@@ -0,0 +1,14 @@
1
+ from ..site_selection_strategy.site_selection_algorithms import (
2
+ steady_algo as _site_selection_algo,
3
+ )
4
+ from ._make_stratum_retention_policy_from_site_selection_algo import (
5
+ make_stratum_retention_policy_from_site_selection_algo,
6
+ )
7
+
8
+ Policy = make_stratum_retention_policy_from_site_selection_algo(
9
+ _site_selection_algo
10
+ )
11
+ PolicySpec = Policy.policy_spec_t
12
+
13
+ # prevent name leakage
14
+ del make_stratum_retention_policy_from_site_selection_algo
@@ -0,0 +1,14 @@
1
+ from ..site_selection_strategy.site_selection_algorithms import (
2
+ tilted_algo as _site_selection_algo,
3
+ )
4
+ from ._make_stratum_retention_policy_from_site_selection_algo import (
5
+ make_stratum_retention_policy_from_site_selection_algo,
6
+ )
7
+
8
+ Policy = make_stratum_retention_policy_from_site_selection_algo(
9
+ _site_selection_algo,
10
+ )
11
+ PolicySpec = Policy.policy_spec_t
12
+
13
+ # prevent name leakage
14
+ del make_stratum_retention_policy_from_site_selection_algo
@@ -0,0 +1,14 @@
1
+ from ..site_selection_strategy.site_selection_algorithms import (
2
+ tilted_sticky_algo as _site_selection_algo,
3
+ )
4
+ from ._make_stratum_retention_policy_from_site_selection_algo import (
5
+ make_stratum_retention_policy_from_site_selection_algo,
6
+ )
7
+
8
+ Policy = make_stratum_retention_policy_from_site_selection_algo(
9
+ _site_selection_algo,
10
+ )
11
+ PolicySpec = Policy.policy_spec_t
12
+
13
+ # prevent name leakage
14
+ del make_stratum_retention_policy_from_site_selection_algo
@@ -0,0 +1,4 @@
1
+ try:
2
+ from typing import Literal # noqa: F401
3
+ except ImportError:
4
+ from typing_extensions import Literal # noqa: F401
@@ -0,0 +1,69 @@
1
+ from . import (
2
+ hanoi,
3
+ longevity_ordering_alternating,
4
+ longevity_ordering_descending,
5
+ longevity_ordering_naive,
6
+ longevity_ordering_piecewise_ascending,
7
+ oeis,
8
+ site_selection_eval,
9
+ site_selection_viz,
10
+ )
11
+ from .Literal import Literal
12
+ from .bit_ceil import bit_ceil
13
+ from .bit_count_immediate_zeros import bit_count_immediate_zeros
14
+ from .bit_count_leading_ones import bit_count_leading_ones
15
+ from .bit_decode_gray import bit_decode_gray
16
+ from .bit_drop_msb import bit_drop_msb
17
+ from .bit_encode_gray import bit_encode_gray
18
+ from .bit_floor import bit_floor
19
+ from .bit_invert import bit_invert
20
+ from .bit_reverse import bit_reverse
21
+ from .calc_dyadic_lcm_upper_bound import calc_dyadic_lcm_upper_bound
22
+ from .count_factors_of_2 import count_factors_of_2
23
+ from .enforce_typing import enforce_typing
24
+ from .fast_pow2_divide import fast_pow2_divide
25
+ from .fast_pow2_mod import fast_pow2_mod
26
+ from .get_powersof2triangle_val_at_index import (
27
+ get_powersof2triangle_val_at_index,
28
+ )
29
+ from .jupyter_hide_toggle import jupyter_hide_toggle
30
+ from .log_args_and_result import log_args_and_result
31
+ from .modulo import modulo
32
+ from .prepend_cmap_with_color import prepend_cmap_with_color
33
+ from .round_to_one_sigfig import round_to_one_sigfig
34
+ from .sign import sign
35
+ from .tee_release import tee_release
36
+
37
+ __all__ = [
38
+ "bit_ceil",
39
+ "bit_count_immediate_zeros",
40
+ "bit_count_leading_ones",
41
+ "bit_drop_msb",
42
+ "bit_decode_gray",
43
+ "bit_invert",
44
+ "bit_encode_gray",
45
+ "bit_floor",
46
+ "bit_reverse",
47
+ "calc_dyadic_lcm_upper_bound",
48
+ "count_factors_of_2",
49
+ "enforce_typing",
50
+ "fast_pow2_divide",
51
+ "fast_pow2_mod",
52
+ "get_powersof2triangle_val_at_index",
53
+ "jupyter_hide_toggle",
54
+ "Literal",
55
+ "log_args_and_result",
56
+ "modulo",
57
+ "prepend_cmap_with_color",
58
+ "round_to_one_sigfig",
59
+ "hanoi",
60
+ "longevity_ordering_naive",
61
+ "longevity_ordering_alternating",
62
+ "longevity_ordering_piecewise_ascending",
63
+ "longevity_ordering_descending",
64
+ "oeis",
65
+ "sign",
66
+ "site_selection_eval",
67
+ "site_selection_viz",
68
+ "tee_release",
69
+ ]
@@ -0,0 +1,11 @@
1
+ def bit_ceil(n: int) -> int:
2
+ """Calculate the smallest power of 2 not smaller than n."""
3
+ # adapted from https://github.com/mmore500/hstrat/blob/e9c2994c7a6514162f1ab685d88c374372dc1cf0/hstrat/_auxiliary_lib/_bit_ceil.py
4
+ assert n >= 0
5
+ if n:
6
+ # see https://stackoverflow.com/a/14267825/17332200
7
+ exp = (n - 1).bit_length()
8
+ res = 1 << exp
9
+ return res
10
+ else:
11
+ return 1
@@ -0,0 +1,10 @@
1
+ from .bit_drop_msb import bit_drop_msb
2
+
3
+
4
+ def bit_count_immediate_zeros(x: int) -> int:
5
+ """Count the number of zeros immediately following the first binary digit
6
+ of x.
7
+
8
+ Equivalent to [OEIS:A290255](https://oeis.org/A290255).
9
+ """
10
+ return x.bit_length() - bit_drop_msb(x).bit_length() - bool(x)
@@ -0,0 +1,18 @@
1
+ from .bit_invert import bit_invert
2
+
3
+
4
+ def bit_count_leading_ones(n: int) -> int:
5
+ """Count the number of consecutive leading 1's in the binary representation
6
+ of an integer.
7
+
8
+ Examples
9
+ --------
10
+ >>> bit_count_leading_ones(0b11110000)
11
+ 4
12
+ >>> bit_count_leading_ones(0b1111)
13
+ 4
14
+ >>> bit_count_leading_ones(0b100000000)
15
+ 1
16
+ """
17
+ # see https://stackoverflow.com/a/77756334/17332200
18
+ return n.bit_length() - bit_invert(n).bit_length()
@@ -0,0 +1,8 @@
1
+ def bit_decode_gray(n: int) -> int:
2
+ x = n
3
+ e = 1
4
+ while x:
5
+ x = n >> e
6
+ e <<= 1
7
+ n ^= x
8
+ return n
@@ -0,0 +1,6 @@
1
+ from .bit_floor import bit_floor
2
+
3
+
4
+ def bit_drop_msb(n: int) -> int:
5
+ """Drop most significant bit from binary representation of integer n."""
6
+ return n & (~bit_floor(n))
@@ -0,0 +1,7 @@
1
+ def bit_encode_gray(n: int) -> int:
2
+ """Encode an integer using Gray code.
3
+
4
+ Gray code is a binary numeral system where two successive values differ in
5
+ only one bit. See <https://en.wikipedia.org/wiki/Gray_code>.
6
+ """
7
+ return n ^ (n >> 1)
@@ -0,0 +1,8 @@
1
+ def bit_floor(n: int) -> int:
2
+ """Calculate the largest power of two not greater than n.
3
+
4
+ If zero, returns zero.
5
+ """
6
+ # adapted from https://github.com/mmore500/hstrat/blob/e9c2994c7a6514162f1ab685d88c374372dc1cf0/hstrat/_auxiliary_lib/_bit_floor.py
7
+ mask = 1 << (n >> 1).bit_length()
8
+ return n & mask
@@ -0,0 +1,7 @@
1
+ def bit_invert(n: int) -> int:
2
+ """Calculate the bitwise inverse of n.
3
+
4
+ Doesn't do funky stuff with sign bits, like Python's built-in bitwise not.
5
+ """
6
+ mask = (1 << n.bit_length()) - 1
7
+ return n ^ mask
@@ -0,0 +1,9 @@
1
+ # adapted from https://stackoverflow.com/a/37579581
2
+ def bit_reverse(n: int) -> int:
3
+ """Reverse the bit sequence of an integer."""
4
+ assert n >= 0
5
+ res = 0
6
+ while n:
7
+ res = (res << 1) + (n & 1)
8
+ n >>= 1
9
+ return res
@@ -0,0 +1,25 @@
1
+ from .count_factors_of_2 import count_factors_of_2
2
+
3
+
4
+ def calc_dyadic_lcm_upper_bound(a: int, b: int) -> int:
5
+ """Calculate an upper bound of the least common multiple (LCM) of two
6
+ integers as their product less their common factors of 2.
7
+
8
+ Returns
9
+ -------
10
+ int
11
+ The upper bound of the LCM of `a` and `b` obtained by removing
12
+ the common factors of 2.
13
+
14
+ Examples
15
+ --------
16
+ >>> calc_dyadic_lcm_upper_bound(12, 18)
17
+ 108
18
+ >>> calc_dyadic_lcm_upper_bound(13, 17)
19
+ 221
20
+ """
21
+ assert a
22
+ assert b
23
+ least_factors_of_2 = min(count_factors_of_2(a), count_factors_of_2(b))
24
+ res = a * b >> least_factors_of_2
25
+ return res
@@ -0,0 +1,19 @@
1
+ def count_factors_of_2(number: int) -> int:
2
+ """Counts the number of factors of 2 in a given integer using bitwise operations.
3
+
4
+ Returns
5
+ -------
6
+ int
7
+ The number of factors of 2.
8
+
9
+ Examples
10
+ --------
11
+ >>> count_factors_of_2(12)
12
+ 2
13
+ >>> count_factors_of_2(1024)
14
+ 10
15
+ """
16
+ if number == 0:
17
+ return 0
18
+ else:
19
+ return (number & -number).bit_length() - 1
@@ -0,0 +1,41 @@
1
+ from functools import wraps
2
+ from typing import Any, Callable, get_type_hints
3
+
4
+
5
+ def enforce_typing(func: Callable) -> Callable:
6
+ """Enforces argument and return types on wrapped function at runtime.
7
+
8
+ Raises TypeError for detected violations.
9
+ """
10
+ # Get type hints
11
+ hints = get_type_hints(func)
12
+
13
+ @wraps(func)
14
+ def wrapper(*args: Any, **kwargs: Any) -> Any:
15
+ # Check argument types
16
+ arg_names = list(func.__annotations__.keys())
17
+ for arg_name, value in zip(arg_names, args):
18
+ expected_type = hints.get(arg_name)
19
+ if expected_type and not isinstance(value, expected_type):
20
+ actual_type = type(value)
21
+ raise TypeError(
22
+ f"Argument '{arg_name}' must be of type {expected_type}, "
23
+ f"but got {actual_type} with value {value}",
24
+ )
25
+
26
+ # Call the original function
27
+ result = func(*args, **kwargs)
28
+
29
+ # Check return type
30
+ if "return" in hints:
31
+ expected_return_type = hints["return"]
32
+ if not isinstance(result, expected_return_type):
33
+ actual_return_type = type(result)
34
+ raise TypeError(
35
+ f"Return value must be of type {expected_return_type}, "
36
+ f"but got {actual_return_type} with value {result}",
37
+ )
38
+
39
+ return result
40
+
41
+ return wrapper