Skip to content

Commit 74f1fa7

Browse files
Grace Lee Rui YueGrace Lee Rui Yue
authored andcommitted
fix: rank integer factorization for prime-power queries
1 parent 2e54684 commit 74f1fa7

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/jacobian/math/number_theory/_factorization.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ def _operation[RequestT: StrictModel, ResultT: StrictModel](
121121
_operation(
122122
operation_id="integer.compute.prime_factorization",
123123
title="Factor an integer",
124-
description="Compute a complete prime-power factorization.",
124+
description=(
125+
"Factor an integer into prime powers and return the complete "
126+
"prime-power factorization."
127+
),
125128
request_model=NonzeroFactorizationRequest,
126129
result_model=PrimeFactorizationResult,
127130
implementation=_compute_prime_factorization,

tests/catalog/test_catalog.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,32 @@ def fail_descriptor(*_args: object) -> None:
122122
assert browse.operations
123123

124124

125+
def test_natural_prime_power_query_ranks_factorization_before_prime_navigation() -> (
126+
None
127+
):
128+
catalog = Catalog.open()
129+
130+
result = catalog.search(
131+
OperationDiscoveryRequest(
132+
query="factor an integer into prime powers",
133+
limit=5,
134+
)
135+
)
136+
positions = {
137+
match.operation_id: index for index, match in enumerate(result.matches)
138+
}
139+
140+
assert all(
141+
positions["integer.compute.prime_factorization"]
142+
< positions[prime_navigation_id]
143+
for prime_navigation_id in (
144+
"integer.compute.next_prime",
145+
"integer.compute.nth_prime",
146+
"integer.compute.previous_prime",
147+
)
148+
)
149+
150+
125151
def test_search_finds_lattice_hnf_in_matrix_domain() -> None:
126152
catalog = Catalog.open()
127153

0 commit comments

Comments
 (0)