|
| 1 | +"""Plane algebraic curve operation declarations.""" |
| 2 | + |
| 3 | +from collections.abc import Callable |
| 4 | +from typing import Any |
| 5 | + |
| 6 | +from jacobian._models import StrictModel |
| 7 | +from jacobian.catalog._examples import example |
| 8 | +from jacobian.catalog.models import MathTool, OperationExample |
| 9 | +from jacobian.math.plane_algebraic_curves._models import ( |
| 10 | + AffineChartRequest, |
| 11 | + AffineChartResult, |
| 12 | + AffineCurveRequest, |
| 13 | + AffineCurveResult, |
| 14 | + ProjectiveClosureRequest, |
| 15 | + ProjectiveClosureResult, |
| 16 | +) |
| 17 | +from jacobian.math.plane_algebraic_curves._operations import ( |
| 18 | + compute_affine_chart, |
| 19 | + compute_affine_curve_check, |
| 20 | + compute_projective_closure, |
| 21 | +) |
| 22 | + |
| 23 | + |
| 24 | +def _op[RequestT: StrictModel, ResultT: StrictModel]( |
| 25 | + operation_id: str, |
| 26 | + title: str, |
| 27 | + description: str, |
| 28 | + request_model: type[RequestT], |
| 29 | + result_model: type[ResultT], |
| 30 | + operation: Callable[[RequestT], ResultT], |
| 31 | + *tags: str, |
| 32 | + examples: tuple[OperationExample, ...] = (), |
| 33 | + version: str = "1", |
| 34 | +) -> MathTool[RequestT, ResultT]: |
| 35 | + return MathTool( |
| 36 | + operation_id=operation_id, |
| 37 | + version=version, |
| 38 | + title=title, |
| 39 | + description=description, |
| 40 | + request_type=request_model, |
| 41 | + result_type=result_model, |
| 42 | + run=operation, |
| 43 | + tags=tags, |
| 44 | + examples=examples, |
| 45 | + ) |
| 46 | + |
| 47 | + |
| 48 | +TOOLS: tuple[MathTool[Any, Any], ...] = ( |
| 49 | + _op( |
| 50 | + "algebraic_geometry.affine_plane_curve.check", |
| 51 | + "Check an affine plane curve", |
| 52 | + "Check that a polynomial defines a valid affine plane curve f(x,y)=0 " |
| 53 | + "and return its degree.", |
| 54 | + AffineCurveRequest, |
| 55 | + AffineCurveResult, |
| 56 | + compute_affine_curve_check, |
| 57 | + "algebraic-geometry", |
| 58 | + "affine-curve", |
| 59 | + "exact", |
| 60 | + examples=( |
| 61 | + example( |
| 62 | + "circle", |
| 63 | + "Check the unit circle x^2 + y^2 - 1 = 0.", |
| 64 | + { |
| 65 | + "variables": ["x", "y"], |
| 66 | + "polynomial": "x**2 + y**2 - 1", |
| 67 | + }, |
| 68 | + ), |
| 69 | + ), |
| 70 | + ), |
| 71 | + _op( |
| 72 | + "algebraic_geometry.plane_curve.projective_closure.compute", |
| 73 | + "Compute the projective closure of an affine curve", |
| 74 | + "Homogenize an affine plane curve to obtain its projective closure.", |
| 75 | + ProjectiveClosureRequest, |
| 76 | + ProjectiveClosureResult, |
| 77 | + compute_projective_closure, |
| 78 | + "algebraic-geometry", |
| 79 | + "projective-closure", |
| 80 | + "exact", |
| 81 | + examples=( |
| 82 | + example( |
| 83 | + "circle_closure", |
| 84 | + "Projective closure of x^2 + y^2 - 1.", |
| 85 | + { |
| 86 | + "variables": ["x", "y"], |
| 87 | + "polynomial": "x**2 + y**2 - 1", |
| 88 | + }, |
| 89 | + ), |
| 90 | + ), |
| 91 | + ), |
| 92 | + _op( |
| 93 | + "algebraic_geometry.projective_curve.affine_chart.compute", |
| 94 | + "Extract an affine chart from a projective curve", |
| 95 | + "Dehomogenize a projective curve at the given chart variable by " |
| 96 | + "setting that variable to 1.", |
| 97 | + AffineChartRequest, |
| 98 | + AffineChartResult, |
| 99 | + compute_affine_chart, |
| 100 | + "algebraic-geometry", |
| 101 | + "affine-chart", |
| 102 | + "exact", |
| 103 | + examples=( |
| 104 | + example( |
| 105 | + "chart_z", |
| 106 | + "Extract the z=1 chart of x^2 + y^2 - z^2.", |
| 107 | + { |
| 108 | + "variables": ["x", "y", "z"], |
| 109 | + "polynomial": "x**2 + y**2 - z**2", |
| 110 | + "chart_variable": "z", |
| 111 | + }, |
| 112 | + ), |
| 113 | + ), |
| 114 | + ), |
| 115 | +) |
| 116 | + |
| 117 | +__all__ = ["TOOLS"] |
0 commit comments