Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/jacobian/math/number_theory/_factorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ def _operation[RequestT: StrictModel, ResultT: StrictModel](
_operation(
operation_id="integer.compute.prime_factorization",
title="Factor an integer",
description="Compute a complete prime-power factorization.",
description=(
"Factor an integer into prime powers and return the complete "
"prime-power factorization."
),
request_model=NonzeroFactorizationRequest,
result_model=PrimeFactorizationResult,
implementation=_compute_prime_factorization,
Expand Down
26 changes: 26 additions & 0 deletions tests/catalog/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,32 @@ def fail_descriptor(*_args: object) -> None:
assert browse.operations


def test_natural_prime_power_query_ranks_factorization_before_prime_navigation() -> (
None
):
catalog = Catalog.open()

result = catalog.search(
OperationDiscoveryRequest(
query="factor an integer into prime powers",
limit=5,
)
)
positions = {
match.operation_id: index for index, match in enumerate(result.matches)
}

assert all(
positions["integer.compute.prime_factorization"]
< positions[prime_navigation_id]
for prime_navigation_id in (
"integer.compute.next_prime",
"integer.compute.nth_prime",
"integer.compute.previous_prime",
)
)


def test_search_finds_lattice_hnf_in_matrix_domain() -> None:
catalog = Catalog.open()

Expand Down