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.
- downstream/__init__.py +15 -0
- downstream/downstream/__init__.py +4 -0
- downstream/genome_instrumentation/_BitSurface.py +2 -0
- downstream/genome_instrumentation/_StructSurface.py +2 -0
- downstream/genome_instrumentation/__init__.py +7 -0
- downstream/interop/__init__.py +23 -0
- downstream/interop/_make_stratum_retention_policy_from_site_selection_algo.py +278 -0
- downstream/interop/_stratum_retention_interop_hybrid_algo.py +14 -0
- downstream/interop/_stratum_retention_interop_steady_algo.py +14 -0
- downstream/interop/_stratum_retention_interop_tilted_algo.py +14 -0
- downstream/interop/_stratum_retention_interop_tilted_sticky_algo.py +14 -0
- downstream/pylib/Literal.py +4 -0
- downstream/pylib/__init__.py +69 -0
- downstream/pylib/bit_ceil.py +11 -0
- downstream/pylib/bit_count_immediate_zeros.py +10 -0
- downstream/pylib/bit_count_leading_ones.py +18 -0
- downstream/pylib/bit_decode_gray.py +8 -0
- downstream/pylib/bit_drop_msb.py +6 -0
- downstream/pylib/bit_encode_gray.py +7 -0
- downstream/pylib/bit_floor.py +8 -0
- downstream/pylib/bit_invert.py +7 -0
- downstream/pylib/bit_reverse.py +9 -0
- downstream/pylib/calc_dyadic_lcm_upper_bound.py +25 -0
- downstream/pylib/count_factors_of_2.py +19 -0
- downstream/pylib/enforce_typing.py +41 -0
- downstream/pylib/fast_pow2_divide.py +39 -0
- downstream/pylib/fast_pow2_mod.py +34 -0
- downstream/pylib/get_powersof2triangle_val_at_index.py +11 -0
- downstream/pylib/hanoi/__init__.py +33 -0
- downstream/pylib/hanoi/get_hanoi_value_at_index.py +10 -0
- downstream/pylib/hanoi/get_hanoi_value_incidence_at_index.py +11 -0
- downstream/pylib/hanoi/get_hanoi_value_index_cadence.py +4 -0
- downstream/pylib/hanoi/get_hanoi_value_index_offset.py +3 -0
- downstream/pylib/hanoi/get_incidence_count_of_hanoi_value_through_index.py +15 -0
- downstream/pylib/hanoi/get_index_of_hanoi_value_next_incidence.py +28 -0
- downstream/pylib/hanoi/get_index_of_hanoi_value_nth_incidence.py +14 -0
- downstream/pylib/hanoi/get_max_hanoi_value_through_index.py +10 -0
- downstream/pylib/hanoi/get_min_hanoi_value_with_incidence_at_least.py +26 -0
- downstream/pylib/jupyter_hide_toggle.py +64 -0
- downstream/pylib/log_args_and_result.py +54 -0
- downstream/pylib/longevity_ordering_alternating/__init__.py +17 -0
- downstream/pylib/longevity_ordering_alternating/get_longevity_directionality.py +3 -0
- downstream/pylib/longevity_ordering_alternating/get_longevity_index_of_mapped_position.py +44 -0
- downstream/pylib/longevity_ordering_alternating/get_longevity_mapped_position_of_index.py +35 -0
- downstream/pylib/longevity_ordering_alternating/get_longevity_reversed_position_within_level.py +14 -0
- downstream/pylib/longevity_ordering_common/__init__.py +19 -0
- downstream/pylib/longevity_ordering_common/get_longevity_level_of_index.py +3 -0
- downstream/pylib/longevity_ordering_common/get_longevity_level_of_mapped_position.py +12 -0
- downstream/pylib/longevity_ordering_common/get_longevity_num_positions_at_level.py +2 -0
- downstream/pylib/longevity_ordering_common/get_longevity_num_positions_at_lower_levels.py +7 -0
- downstream/pylib/longevity_ordering_common/get_longevity_offset_of_level.py +8 -0
- downstream/pylib/longevity_ordering_descending/__init__.py +11 -0
- downstream/pylib/longevity_ordering_descending/get_longevity_index_of_mapped_position.py +14 -0
- downstream/pylib/longevity_ordering_descending/get_longevity_mapped_position_of_index.py +21 -0
- downstream/pylib/longevity_ordering_naive/__init__.py +15 -0
- downstream/pylib/longevity_ordering_naive/get_longevity_index_of_mapped_position.py +10 -0
- downstream/pylib/longevity_ordering_naive/get_longevity_mapped_position_of_index.py +24 -0
- downstream/pylib/longevity_ordering_naive/get_longevity_position_within_level.py +23 -0
- downstream/pylib/longevity_ordering_piecewise_ascending/__init__.py +11 -0
- downstream/pylib/longevity_ordering_piecewise_ascending/get_longevity_index_of_mapped_position.py +28 -0
- downstream/pylib/longevity_ordering_piecewise_ascending/get_longevity_mapped_position_of_index.py +22 -0
- downstream/pylib/modulo.py +35 -0
- downstream/pylib/oeis/__init__.py +35 -0
- downstream/pylib/oeis/get_a000295_index_of_value.py +12 -0
- downstream/pylib/oeis/get_a000295_value_at_index.py +8 -0
- downstream/pylib/oeis/get_a005187_index_of_value.py +540 -0
- downstream/pylib/oeis/get_a005187_value_at_index.py +3 -0
- downstream/pylib/oeis/get_a025480_value_at_index.py +3 -0
- downstream/pylib/oeis/get_a030109_index_of_value.py +13 -0
- downstream/pylib/oeis/get_a030109_value_at_index.py +6 -0
- downstream/pylib/oeis/get_a037870_value_at_index.py +5 -0
- downstream/pylib/oeis/get_a048881_value_at_index.py +4 -0
- downstream/pylib/oeis/get_a059893_index_of_value.py +6 -0
- downstream/pylib/oeis/get_a059893_value_at_index.py +7 -0
- downstream/pylib/oeis/get_a083058_index_of_value.py +7 -0
- downstream/pylib/oeis/get_a083058_value_at_index.py +2 -0
- downstream/pylib/oeis/get_a130654_value_at_index.py +17 -0
- downstream/pylib/oeis/get_a341916_index_of_value.py +7 -0
- downstream/pylib/oeis/get_a341916_value_at_index.py +7 -0
- downstream/pylib/prepend_cmap_with_color.py +15 -0
- downstream/pylib/round_to_one_sigfig.py +13 -0
- downstream/pylib/sign.py +23 -0
- downstream/pylib/site_selection_eval/__init__.py +13 -0
- downstream/pylib/site_selection_eval/get_first_decreasing_hanoi_value_deposition.py +27 -0
- downstream/pylib/site_selection_eval/get_first_deposition_over_too_new_site.py +93 -0
- downstream/pylib/site_selection_eval/get_first_resolved_resident_rank_inconsistency.py +35 -0
- downstream/pylib/site_selection_eval/make_surface_history_df.py +70 -0
- downstream/pylib/site_selection_viz/_SurfaceHistoryToStratumRetentionPolicyShim.py +38 -0
- downstream/pylib/site_selection_viz/__init__.py +17 -0
- downstream/pylib/site_selection_viz/_apply_pseudo_linear_yticks.py +37 -0
- downstream/pylib/site_selection_viz/_apply_pseudo_log_yticks.py +26 -0
- downstream/pylib/site_selection_viz/_geomspace_filter_surface_history_df.py +22 -0
- downstream/pylib/site_selection_viz/_linspace_filter_surface_history_df.py +22 -0
- downstream/pylib/site_selection_viz/site_deposition_depth_by_rank_heatmap.py +66 -0
- downstream/pylib/site_selection_viz/site_deposition_rank_by_rank_heatmap.py +65 -0
- downstream/pylib/site_selection_viz/site_differentia_by_rank_heatmap.py +54 -0
- downstream/pylib/site_selection_viz/site_hanoi_value_by_rank_heatmap.py +57 -0
- downstream/pylib/site_selection_viz/stratum_persistence_dripplot.py +23 -0
- downstream/pylib/tee_release.py +10 -0
- downstream/pylib/test/__init__.py +0 -0
- downstream/pylib/test/test_Literal.py +5 -0
- downstream/pylib/test/test_bit_ceil.py +52 -0
- downstream/pylib/test/test_bit_count_immediate_zeros.py +46 -0
- downstream/pylib/test/test_bit_count_leading_ones.py +22 -0
- downstream/pylib/test/test_bit_decode_gray.py +7 -0
- downstream/pylib/test/test_bit_drop_msb.py +27 -0
- downstream/pylib/test/test_bit_encode_gray.py +27 -0
- downstream/pylib/test/test_bit_floor.py +14 -0
- downstream/pylib/test/test_bit_invert.py +33 -0
- downstream/pylib/test/test_bit_reverse.py +27 -0
- downstream/pylib/test/test_calc_dyadic_lcm_upper_bound.py +62 -0
- downstream/pylib/test/test_count_factors_of_2.py +21 -0
- downstream/pylib/test/test_enforce_typing.py +36 -0
- downstream/pylib/test/test_fast_pow2_divide.py +72 -0
- downstream/pylib/test/test_fast_pow2_mod.py +66 -0
- downstream/pylib/test/test_get_powersof2triangle_val_at_index.py +95 -0
- downstream/pylib/test/test_hanoi/__init__.py +0 -0
- downstream/pylib/test/test_hanoi/test_get_hanoi_value_at_index.py +116 -0
- downstream/pylib/test/test_hanoi/test_get_hanoi_value_incidence_at_index.py +12 -0
- downstream/pylib/test/test_hanoi/test_get_incidence_count_of_hanoi_value_through_index.py +22 -0
- downstream/pylib/test/test_hanoi/test_get_index_of_hanoi_value_next_incidence.py +37 -0
- downstream/pylib/test/test_hanoi/test_get_index_of_hanoi_value_nth_incidence.py +15 -0
- downstream/pylib/test/test_hanoi/test_get_max_hanoi_value_through_index.py +12 -0
- downstream/pylib/test/test_hanoi/test_get_min_hanoi_value_with_incidence_at_least.py +32 -0
- downstream/pylib/test/test_log_args_and_result.py +41 -0
- downstream/pylib/test/test_longevity_ordering_alternating/__init__.py +0 -0
- downstream/pylib/test/test_longevity_ordering_alternating/test_get_longevity_index_of_mapped_position.py +31 -0
- downstream/pylib/test/test_longevity_ordering_alternating/test_get_longevity_mapped_position_of_index.py +128 -0
- downstream/pylib/test/test_longevity_ordering_alternating/test_get_longevity_reversed_position_within_level.py +21 -0
- downstream/pylib/test/test_longevity_ordering_common/__init__.py +0 -0
- downstream/pylib/test/test_longevity_ordering_common/test_get_longevity_level_of_index.py +10 -0
- downstream/pylib/test/test_longevity_ordering_common/test_get_longevity_level_of_mapped_position.py +76 -0
- downstream/pylib/test/test_longevity_ordering_common/test_get_longevity_num_positions_at_level.py +10 -0
- downstream/pylib/test/test_longevity_ordering_common/test_get_longevity_offset_of_level.py +23 -0
- downstream/pylib/test/test_longevity_ordering_common/test_longevity_num_positions_at_lower_levels.py +7 -0
- downstream/pylib/test/test_longevity_ordering_descending/__init__.py +0 -0
- downstream/pylib/test/test_longevity_ordering_descending/test_get_longevity_index_of_mapped_position.py +28 -0
- downstream/pylib/test/test_longevity_ordering_descending/test_get_longevity_mapped_position_of_index.py +101 -0
- downstream/pylib/test/test_longevity_ordering_naive/__init__.py +0 -0
- downstream/pylib/test/test_longevity_ordering_naive/test_get_longevity_index_of_mapped_position.py +28 -0
- downstream/pylib/test/test_longevity_ordering_naive/test_get_longevity_mapped_position_of_index.py +101 -0
- downstream/pylib/test/test_longevity_ordering_naive/test_get_longevity_position_within_level.py +51 -0
- downstream/pylib/test/test_longevity_ordering_piecewise_ascending/__init__.py +0 -0
- downstream/pylib/test/test_longevity_ordering_piecewise_ascending/test_get_longevity_index_of_mapped_position.py +28 -0
- downstream/pylib/test/test_longevity_ordering_piecewise_ascending/test_get_longevity_mapped_position_of_index.py +101 -0
- downstream/pylib/test/test_modulo.py +30 -0
- downstream/pylib/test/test_oeis/__init__.py +0 -0
- downstream/pylib/test/test_oeis/test_get_a000295_index_of_value.py +35 -0
- downstream/pylib/test/test_oeis/test_get_a000295_value_at_index.py +41 -0
- downstream/pylib/test/test_oeis/test_get_a005187_index_of_value.py +9 -0
- downstream/pylib/test/test_oeis/test_get_a005187_value_at_index.py +73 -0
- downstream/pylib/test/test_oeis/test_get_a025480_value_at_index.py +91 -0
- downstream/pylib/test/test_oeis/test_get_a030109_index_of_value.py +13 -0
- downstream/pylib/test/test_oeis/test_get_a030109_value_at_index.py +90 -0
- downstream/pylib/test/test_oeis/test_get_a037870_value_at_index.py +97 -0
- downstream/pylib/test/test_oeis/test_get_a048881_value_at_index.py +112 -0
- downstream/pylib/test/test_oeis/test_get_a059893_index_of_value.py +13 -0
- downstream/pylib/test/test_oeis/test_get_a059893_value_at_index.py +78 -0
- downstream/pylib/test/test_oeis/test_get_a083058_index_of_value.py +10 -0
- downstream/pylib/test/test_oeis/test_get_a083058_value_at_index.py +81 -0
- downstream/pylib/test/test_oeis/test_get_a130654_value_at_index.py +139 -0
- downstream/pylib/test/test_oeis/test_get_a341916_index_of_value.py +13 -0
- downstream/pylib/test/test_oeis/test_get_a341916_value_at_index.py +74 -0
- downstream/pylib/test/test_prepend_cmap_with_color.py +14 -0
- downstream/pylib/test/test_round_to_one_sigfig.py +8 -0
- downstream/pylib/test/test_sign.py +19 -0
- downstream/serialization/__init__.py +11 -0
- downstream/serialization/_col_from_surf_int.py +60 -0
- downstream/serialization/_col_from_surf_packet.py +89 -0
- downstream/serialization/_sort_differentiae_by_deposition_rank.py +71 -0
- downstream/site_selection_strategy/__init__.py +4 -0
- downstream/site_selection_strategy/site_selection_algorithms/__init__.py +15 -0
- downstream/site_selection_strategy/site_selection_algorithms/hybrid_algo/__init__.py +9 -0
- downstream/site_selection_strategy/site_selection_algorithms/hybrid_algo/_calc_resident_deposition_rank.py +32 -0
- downstream/site_selection_strategy/site_selection_algorithms/hybrid_algo/_iter_resident_deposition_ranks.py +28 -0
- downstream/site_selection_strategy/site_selection_algorithms/hybrid_algo/_pick_deposition_site.py +36 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/__init__.py +37 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_enact/__init__.py +5 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_enact/_pick_deposition_site.py +79 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/__init__.py +33 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_calc_resident_deposition_rank_wrt_bin.py +79 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_bin_number_of_position.py +36 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_bin_offset_at_position.py +7 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_bin_width_at_position.py +65 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_bin_position.py +35 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_bin_width.py +20 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_segment_bin_count.py +5 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_segment_bin_width.py +9 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_segment_position.py +30 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_nth_segment_width.py +8 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_num_bins.py +3 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_num_positions.py +5 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_get_num_segments.py +5 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_impl/_iter_bin_coords.py +26 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_scry/__init__.py +7 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_scry/_calc_resident_deposition_rank.py +37 -0
- downstream/site_selection_strategy/site_selection_algorithms/steady_algo/_scry/_iter_resident_deposition_ranks.py +40 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/__init__.py +11 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_enact/__init__.py +0 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_enact/_pick_deposition_site.py +43 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/__init__.py +59 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_calc_hanoi_invasion_rank.py +10 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_calc_invading_hanoi_value.py +17 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_calc_resident_hanoi_value.py +77 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_epoch_rank.py +16 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_global_epoch.py +20 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_global_num_reservations.py +12 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_grip_reservation_index_logical.py +51 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_grip_reservation_index_physical.py +44 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_hanoi_num_reservations.py +44 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_reservation_position_logical.py +19 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_reservation_position_physical.py +26 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_reservation_width_physical.py +19 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_site_genesis_reservation_index_physical.py +33 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_site_hanoi_value_assigned.py +32 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_site_reservation_index_logical.py +39 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_impl/_get_site_reservation_index_physical.py +41 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_scry/__init__.py +7 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_scry/_calc_resident_deposition_rank.py +222 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_algo/_scry/_iter_resident_deposition_ranks.py +31 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/__init__.py +14 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_enact/__init__.py +5 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_enact/_pick_deposition_site.py +59 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/__init__.py +59 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_fractional_downgrade_num_reservations_provided.py +36 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_fractional_downgrade_rank.py +60 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_fractional_downgrade_state.py +295 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_num_incidence_reservations_at_rank.py +23 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_num_reservations_provided.py +39 -0
- 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
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_regime_mx.py +21 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_regime_num_reservations_available.py +23 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_regime_num_reservations_provided.py +39 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_regime_reservation_downgrade_rank.py +58 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_safe_downgrade_rank.py +152 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_surface_rank_capacity.py +13 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_upcoming_hanoi_invasion_rank.py +20 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_get_upcoming_hanoi_invasion_value.py +30 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_has_hanoi_value_filled_first_reservation_layer.py +32 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_is_2x_reservation_eligible.py +28 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_is_hanoi_invadable_and_uninvaded.py +11 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_is_hanoi_invaded.py +19 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_is_hanoi_invader.py +17 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_impl/_iter_hanoi_invader_values.py +18 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/__init__.py +7 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_calc_resident_deposition_rank.py +41 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/__init__.py +29 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_calc_incidence_of_deposited_hanoi_value.py +68 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_calc_rank_of_deposited_hanoi_value.py +36 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_calc_reservation_reference_incidence.py +101 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_calc_resident_hanoi_context.py +138 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_get_reservation_index_elimination_rank.py +114 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_iter_candidate_hanoi_occupants.py +30 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_iter_candidate_reservation_indices.py +33 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_impl/_iter_candidate_reservation_sizes.py +28 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_hadamard_order_site_rungs_algo/_scry/_iter_resident_deposition_ranks.py +2 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_sticky_algo/__init__.py +9 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_sticky_algo/_calc_resident_deposition_rank.py +42 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_sticky_algo/_iter_resident_deposition_ranks.py +31 -0
- downstream/site_selection_strategy/site_selection_algorithms/tilted_sticky_algo/_pick_deposition_site.py +32 -0
- downstream-0.4.2.dist-info/LICENSE +21 -0
- downstream-0.4.2.dist-info/METADATA +106 -0
- downstream-0.4.2.dist-info/RECORD +428 -0
- downstream-0.4.2.dist-info/WHEEL +6 -0
- downstream-0.4.2.dist-info/top_level.txt +3 -0
- pylib/hanoi/__init__.py +33 -0
- pylib/hanoi/get_hanoi_value_at_index.py +10 -0
- pylib/hanoi/get_hanoi_value_incidence_at_index.py +11 -0
- pylib/hanoi/get_hanoi_value_index_cadence.py +4 -0
- pylib/hanoi/get_hanoi_value_index_offset.py +3 -0
- pylib/hanoi/get_incidence_count_of_hanoi_value_through_index.py +15 -0
- pylib/hanoi/get_index_of_hanoi_value_next_incidence.py +28 -0
- pylib/hanoi/get_index_of_hanoi_value_nth_incidence.py +14 -0
- pylib/hanoi/get_max_hanoi_value_through_index.py +10 -0
- pylib/hanoi/get_min_hanoi_value_with_incidence_at_least.py +26 -0
- pylib/longevity_ordering_alternating/__init__.py +17 -0
- pylib/longevity_ordering_alternating/get_longevity_directionality.py +3 -0
- pylib/longevity_ordering_alternating/get_longevity_index_of_mapped_position.py +44 -0
- pylib/longevity_ordering_alternating/get_longevity_mapped_position_of_index.py +35 -0
- pylib/longevity_ordering_alternating/get_longevity_reversed_position_within_level.py +14 -0
- pylib/longevity_ordering_common/__init__.py +19 -0
- pylib/longevity_ordering_common/get_longevity_level_of_index.py +3 -0
- pylib/longevity_ordering_common/get_longevity_level_of_mapped_position.py +12 -0
- pylib/longevity_ordering_common/get_longevity_num_positions_at_level.py +2 -0
- pylib/longevity_ordering_common/get_longevity_num_positions_at_lower_levels.py +7 -0
- pylib/longevity_ordering_common/get_longevity_offset_of_level.py +8 -0
- pylib/longevity_ordering_descending/__init__.py +11 -0
- pylib/longevity_ordering_descending/get_longevity_index_of_mapped_position.py +14 -0
- pylib/longevity_ordering_descending/get_longevity_mapped_position_of_index.py +21 -0
- pylib/longevity_ordering_naive/__init__.py +15 -0
- pylib/longevity_ordering_naive/get_longevity_index_of_mapped_position.py +10 -0
- pylib/longevity_ordering_naive/get_longevity_mapped_position_of_index.py +24 -0
- pylib/longevity_ordering_naive/get_longevity_position_within_level.py +23 -0
- pylib/longevity_ordering_piecewise_ascending/__init__.py +11 -0
- pylib/longevity_ordering_piecewise_ascending/get_longevity_index_of_mapped_position.py +28 -0
- pylib/longevity_ordering_piecewise_ascending/get_longevity_mapped_position_of_index.py +22 -0
- pylib/oeis/__init__.py +35 -0
- pylib/oeis/get_a000295_index_of_value.py +12 -0
- pylib/oeis/get_a000295_value_at_index.py +8 -0
- pylib/oeis/get_a005187_index_of_value.py +540 -0
- pylib/oeis/get_a005187_value_at_index.py +3 -0
- pylib/oeis/get_a025480_value_at_index.py +3 -0
- pylib/oeis/get_a030109_index_of_value.py +13 -0
- pylib/oeis/get_a030109_value_at_index.py +6 -0
- pylib/oeis/get_a037870_value_at_index.py +5 -0
- pylib/oeis/get_a048881_value_at_index.py +4 -0
- pylib/oeis/get_a059893_index_of_value.py +6 -0
- pylib/oeis/get_a059893_value_at_index.py +7 -0
- pylib/oeis/get_a083058_index_of_value.py +7 -0
- pylib/oeis/get_a083058_value_at_index.py +2 -0
- pylib/oeis/get_a130654_value_at_index.py +17 -0
- pylib/oeis/get_a341916_index_of_value.py +7 -0
- pylib/oeis/get_a341916_value_at_index.py +7 -0
- pylib/site_selection_eval/__init__.py +13 -0
- pylib/site_selection_eval/get_first_decreasing_hanoi_value_deposition.py +27 -0
- pylib/site_selection_eval/get_first_deposition_over_too_new_site.py +93 -0
- pylib/site_selection_eval/get_first_resolved_resident_rank_inconsistency.py +35 -0
- pylib/site_selection_eval/make_surface_history_df.py +70 -0
- pylib/site_selection_viz/_SurfaceHistoryToStratumRetentionPolicyShim.py +38 -0
- pylib/site_selection_viz/__init__.py +17 -0
- pylib/site_selection_viz/_apply_pseudo_linear_yticks.py +37 -0
- pylib/site_selection_viz/_apply_pseudo_log_yticks.py +26 -0
- pylib/site_selection_viz/_geomspace_filter_surface_history_df.py +22 -0
- pylib/site_selection_viz/_linspace_filter_surface_history_df.py +22 -0
- pylib/site_selection_viz/site_deposition_depth_by_rank_heatmap.py +66 -0
- pylib/site_selection_viz/site_deposition_rank_by_rank_heatmap.py +65 -0
- pylib/site_selection_viz/site_differentia_by_rank_heatmap.py +54 -0
- pylib/site_selection_viz/site_hanoi_value_by_rank_heatmap.py +57 -0
- pylib/site_selection_viz/stratum_persistence_dripplot.py +23 -0
- test_downstream/test_interop/__init__.py +0 -0
- test_downstream/test_interop/test_make_stratum_retention_policy_from_site_selection_algo.py +244 -0
- test_downstream/test_serialization/__init__.py +0 -0
- test_downstream/test_serialization/test_col_from_surf_int.py +113 -0
- test_downstream/test_serialization/test_col_from_surf_packet.py +98 -0
- test_downstream/test_serialization/test_sort_differentiae_by_deposition_rank.py +111 -0
- test_downstream/test_site_selection_strategy/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_hybrid_algo/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_hybrid_algo/test_calc_resident_deposition_rank.py +62 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_hybrid_algo/test_iter_resident_deposition_ranks.py +28 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_enact/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_enact/test_pick_deposition_site.py +60 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_bin_number_of_position.py +16 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_bin_width_at_position.py +101 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_bin_position.py +26 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_bin_width.py +48 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_segment_bin_count.py +12 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_segment_bin_width.py +21 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_segment_position.py +40 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_nth_segment_width.py +21 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_num_bins.py +32 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_get_num_segments.py +22 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_impl/test_iter_bin_coords.py +23 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_scry/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_scry/test_calc_resident_deposition_rank.py +60 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_steady_algo/test_scry/test_iter_resident_deposition_ranks.py +25 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_enact/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_enact/test_pick_deposition_site.py +247 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_calc_hanoi_invasion_rank.py +26 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_calc_invading_hanoi_value.py +25 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_calc_resident_hanoi_value.py +67 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_epoch_rank.py +34 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_global_epoch.py +86 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_global_num_reservtions.py +98 -0
- 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
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_grip_reservation_index_logical.py +95 -0
- 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
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_grip_reservation_index_physical.py +94 -0
- 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
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_hanoi_num_reservtions.py +77 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_reservation_position_logical.py +66 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_reservation_position_physical.py +67 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_reservation_width_physical.py +59 -0
- 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
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_site_hanoi_value_assigned.py +62 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_site_reservation_index_logical.py +73 -0
- 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
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_impl/test_get_site_reservation_index_physical.py +73 -0
- 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
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_scry/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_scry/test_calc_resident_deposition_rank.py +78 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_algo/test_scry/test_iter_resident_deposition_ranks.py +25 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_impl/__init__.py +1 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_pick_deposition_site.py +55 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_hadamard_order_site_rungs_algo/test_scry/__init__.py +0 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_sticky_algo/__init__.py +0 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_sticky_algo/test_calc_resident_deposition_rank.py +72 -0
- test_downstream/test_site_selection_strategy/test_site_selection_algorithms/test_tilted_sticky_algo/test_iter_resident_deposition_ranks.py +28 -0
- 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,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,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_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,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
|