diff --git a/src/sage/categories/map.pyi b/src/sage/categories/map.pyi new file mode 100644 index 00000000000..62e6700a076 --- /dev/null +++ b/src/sage/categories/map.pyi @@ -0,0 +1,114 @@ +from __future__ import annotations + +from typing import Any, Callable, Generic, Iterator, Mapping, Self, Sequence, TypeVar + +from sage.categories.category import Category +from sage.structure.element import Element +from sage.structure.parent import Parent + +DomainElementT_contra = TypeVar("DomainElementT_contra", contravariant=True) +CodomainElementT_co = TypeVar("CodomainElementT_co", covariant=True) +SectionDomainT = TypeVar("SectionDomainT") +SectionCodomainT = TypeVar("SectionCodomainT") +CompositeDomainT = TypeVar("CompositeDomainT") +CompositeCodomainT = TypeVar("CompositeCodomainT") + +class Map(Element, Generic[DomainElementT_contra, CodomainElementT_co]): + _coerce_cost: int + _is_coercion: bool + _repr_type_str: str | None + _category_for: Category | None + domain: Callable[[], Parent[Any] | None] + codomain: Callable[[], Parent[Any]] + _codomain: Parent[Any] + + def __init__(self, parent: Any, codomain: Parent[Any] | None = ...) -> None: ... + def __copy__(self) -> Self: ... + def parent(self) -> Any: ... + def _make_weak_references(self) -> None: ... + def _make_strong_references(self) -> None: ... + def _update_slots(self, slots: Mapping[str, Any]) -> None: ... + def _update_slots_test(self, _slots: Mapping[str, Any]) -> None: ... + def _extra_slots(self) -> dict[str, Any]: ... + def _extra_slots_test(self) -> dict[str, Any]: ... + def __reduce__(self) -> tuple[Any, tuple[Any, ...]]: ... + def _repr_type(self) -> str: ... + def _repr_defn(self) -> str: ... + def _repr_(self) -> str: ... + def _default_repr_(self) -> str: ... + def domains(self) -> Iterator[Parent[Any] | None]: ... + def category_for(self) -> Category: ... + def __call__( + self, x: DomainElementT_contra, *args: Any, **kwds: Any + ) -> CodomainElementT_co: ... + def _call_(self, x: DomainElementT_contra) -> CodomainElementT_co: ... + def _call_with_args( + self, + x: DomainElementT_contra, + args: Sequence[Any] = ..., + kwds: Mapping[str, Any] | None = ..., + ) -> CodomainElementT_co: ... + def __mul__(self, right: Map[Any, Any]) -> Map[Any, Any]: ... + def _composition(self, right: Map[Any, Any]) -> Map[Any, Any]: ... + def _composition_(self, right: Map[Any, Any], homset: Any) -> Map[Any, Any]: ... + def pre_compose(self, right: Map[Any, Any]) -> Map[Any, Any]: ... + def post_compose(self, left: Map[Any, Any]) -> Map[Any, Any]: ... + def extend_domain(self, new_domain: Any) -> Map[Any, Any]: ... + def extend_codomain(self, new_codomain: Any) -> Map[Any, Any]: ... + def is_surjective(self) -> bool: ... + def _pow_int(self, n: int) -> Map[Any, Any]: ... + def section(self) -> Map[Any, Any] | None: ... + def __hash__(self) -> int: ... + +class Section( + Map[SectionCodomainT, SectionDomainT], Generic[SectionDomainT, SectionCodomainT] +): + _inverse: Map[SectionDomainT, SectionCodomainT] + + def __init__(self, map: Map[SectionDomainT, SectionCodomainT]) -> None: ... + def _extra_slots(self) -> dict[str, Any]: ... + def _update_slots(self, slots: Mapping[str, Any]) -> None: ... + def _repr_type(self) -> str: ... + def inverse(self) -> Map[SectionDomainT, SectionCodomainT]: ... + +class FormalCompositeMap( + Map[CompositeDomainT, CompositeCodomainT], + Generic[CompositeDomainT, CompositeCodomainT], +): + __list: Sequence[Map[Any, Any]] + + def __init__( + self, + parent: Any, + first: Map[Any, Any] | Sequence[Map[Any, Any]], + second: Map[Any, Any] | None = ..., + ) -> None: ... + def __copy__(self) -> Self: ... + def _update_slots(self, slots: Mapping[str, Any]) -> None: ... + def _extra_slots(self) -> dict[str, Any]: ... + def __richcmp__(self, other: Any, op: int) -> bool: ... + def __hash__(self) -> int: ... + def __getitem__(self, i: int) -> Map[Any, Any]: ... + def _call_(self, x: CompositeDomainT) -> CompositeCodomainT: ... + def _call_with_args( + self, + x: CompositeDomainT, + args: Sequence[Any] = ..., + kwds: Mapping[str, Any] | None = ..., + ) -> CompositeCodomainT: ... + def _repr_type(self) -> str: ... + def _repr_defn(self) -> str: ... + def first(self) -> Map[Any, Any]: ... + def then(self) -> Map[Any, Any]: ... + def is_injective(self) -> bool: ... + def is_surjective(self) -> bool: ... + def domains(self) -> Iterator[Parent[Any] | None]: ... + def section(self) -> Map[Any, Any] | None: ... + +def unpickle_map( + _class: type[Map[Any, Any]], + parent: Any, + _dict: Mapping[str, Any], + _slots: Mapping[str, Any], +) -> Map[Any, Any]: ... +def is_Map(x: Any) -> bool: ... diff --git a/src/sage/rings/complex_conversion.pyi b/src/sage/rings/complex_conversion.pyi index f3a8fc4e422..bd798e09672 100644 --- a/src/sage/rings/complex_conversion.pyi +++ b/src/sage/rings/complex_conversion.pyi @@ -1,8 +1,6 @@ -from typing import Any - -from sage.structure.element import Element from sage.categories.map import Map +from sage.rings.complex_double import ComplexDoubleElement +from sage.rings.complex_mpfr import ComplexNumber -class CCtoCDF(Map): - def _call_(self, x: Element) -> Element: - ... +class CCtoCDF(Map[ComplexNumber, ComplexDoubleElement]): + def _call_(self, x: ComplexNumber) -> ComplexDoubleElement: ... diff --git a/src/sage/rings/complex_interval_field.py b/src/sage/rings/complex_interval_field.py index c090d6cdae2..026bdd6eb61 100644 --- a/src/sage/rings/complex_interval_field.py +++ b/src/sage/rings/complex_interval_field.py @@ -34,9 +34,10 @@ # (at your option) any later version. # https://www.gnu.org/licenses/ # **************************************************************************** - +from __future__ import annotations import weakref +from typing import Literal import sage.rings.abc from sage.misc.cachefunc import cached_method @@ -48,10 +49,10 @@ from sage.rings.ring import Field from sage.structure.parent import Parent -cache = {} +cache: dict[int, weakref.ReferenceType[ComplexIntervalField_class]] = {} -def ComplexIntervalField(prec=53, names=None): +def ComplexIntervalField(prec=53, names=None) -> ComplexIntervalField_class: """ Return the complex interval field with real and imaginary parts having ``prec`` *bits* of precision. @@ -180,9 +181,10 @@ class ComplexIntervalField_class(sage.rings.abc.ComplexIntervalField): - :class:`sage.rings.complex_arb.ComplexBallField` (alternative implementation of complex intervals, with more features) """ + Element = complex_interval.ComplexIntervalFieldElement - def __init__(self, prec=53): + def __init__(self, prec=53) -> None: """ Initialize ``self``. @@ -195,9 +197,11 @@ def __init__(self, prec=53): """ self._prec = int(prec) from sage.categories.fields import Fields - Field.__init__(self, self.real_field(), ("I",), False, - category=Fields().Infinite()) - self._populate_coercion_lists_(convert_method_name='_complex_mpfi_') + + Field.__init__( + self, self.real_field(), ("I",), False, category=Fields().Infinite() + ) + self._populate_coercion_lists_(convert_method_name="_complex_mpfi_") def __reduce__(self): """ @@ -208,7 +212,7 @@ def __reduce__(self): sage: loads(dumps(CIF)) == CIF True """ - return ComplexIntervalField, (self._prec, ) + return ComplexIntervalField, (self._prec,) def construction(self): """ @@ -241,9 +245,10 @@ def construction(self): Univariate Polynomial Ring in x over Complex Interval Field with 53 bits of precision """ from sage.categories.pushout import AlgebraicClosureFunctor + return (AlgebraicClosureFunctor(), self.real_field()) - def is_exact(self): + def is_exact(self) -> Literal[False]: """ The complex interval field is not exact. @@ -254,7 +259,7 @@ def is_exact(self): """ return False - def prec(self): + def prec(self) -> int: """ Return the precision of ``self`` (in bits). @@ -267,7 +272,7 @@ def prec(self): """ return self._prec - def to_prec(self, prec): + def to_prec(self, prec) -> ComplexIntervalField_class: """ Return a complex interval field with the given precision. @@ -282,7 +287,7 @@ def to_prec(self, prec): """ return ComplexIntervalField(prec) - def _magma_init_(self, magma): + def _magma_init_(self, magma) -> str: r""" Return a string representation of ``self`` in the Magma language. @@ -321,10 +326,10 @@ def _sage_input_(self, sib, coerce): {call: {atomic:ComplexIntervalField}({atomic:2})} """ if self.prec() == 53: - return sib.name('CIF') + return sib.name("CIF") - v = sib.name('ComplexIntervalField')(sib.int(self.prec())) - name = 'CIF%d' % self.prec() + v = sib.name("ComplexIntervalField")(sib.int(self.prec())) + name = "CIF%d" % self.prec() sib.cache(self, v, name) return v @@ -386,7 +391,7 @@ def __eq__(self, other): return False return self._prec == other._prec - def __hash__(self): + def __hash__(self) -> int: """ Return the hash. @@ -400,7 +405,7 @@ def __hash__(self): """ return hash((self.__class__, self._prec)) - def __ne__(self, other): + def __ne__(self, other) -> bool: """ Test whether ``self`` is not equal to ``other``. @@ -521,8 +526,7 @@ def _coerce_map_from_(self, S): # Direct and efficient conversions if S is ZZ or S is QQ or S is int: return True - if isinstance(S, (ComplexIntervalField_class, - RealIntervalField_class)): + if isinstance(S, (ComplexIntervalField_class, RealIntervalField_class)): return S.precision() >= self._prec # If coercion to CC is possible and there is a _complex_mpfi_ @@ -532,7 +536,7 @@ def _coerce_map_from_(self, S): if f is not None: return f - return self._coerce_map_via( (self.real_field(),), S) + return self._coerce_map_via((self.real_field(),), S) def _repr_(self): """ @@ -650,7 +654,7 @@ def ngens(self): """ return 1 - def zeta(self, n=2): + def zeta(self, n: int = 2): r""" Return a primitive `n`-th root of unity. @@ -673,6 +677,7 @@ def zeta(self, n=2): 0.309016994374948? + 0.9510565162951536?*I """ from .integer import Integer + n = Integer(n) if n == 1: x = self.element_class(self, 1) @@ -683,10 +688,10 @@ def zeta(self, n=2): # e^(2*pi*i/n) = cos(2pi/n) + i *sin(2pi/n) RIF = self.real_field() pi = RIF.pi() - z = 2*pi/n + z = 2 * pi / n x = self.element_class(self, z.cos(), z.sin()) # Uncomment after implemented - #x._set_multiplicative_order( n ) + # x._set_multiplicative_order( n ) return x def scientific_notation(self, status=None): diff --git a/src/sage/rings/morphism.pyi b/src/sage/rings/morphism.pyi index 393bfc42ebb..7f1d3b6e309 100644 --- a/src/sage/rings/morphism.pyi +++ b/src/sage/rings/morphism.pyi @@ -1,15 +1,16 @@ -from sage.rings.integer import Integer -from sage.structure.element import Element -from sage.structure.parent import Parent +from typing import Any + from sage.categories.map import Map from sage.categories.morphism import Morphism +from sage.rings.integer import Integer +from sage.structure.parent import Parent class RingMap(Morphism): pass class RingMap_lift(RingMap): - S: Parent - to_S: Map + S: Parent[Any] + to_S: Map[Any, Any] class RingHomomorphism(RingMap): _lift: Morphism diff --git a/src/sage/rings/ring.pyi b/src/sage/rings/ring.pyi new file mode 100644 index 00000000000..af6d4f3ef2d --- /dev/null +++ b/src/sage/rings/ring.pyi @@ -0,0 +1,83 @@ +from __future__ import annotations + +from typing import Any, Iterator, NoReturn + +from sage.categories.category import Category +from sage.categories.commutative_rings import CommutativeRings +from sage.categories.fields import Fields +from sage.categories.rings import Rings +from sage.structure.category_object import NameSpec +from sage.structure.parent import Parent +from sage.structure.parent_gens import ParentWithGens + +_Rings: Rings +_CommutativeRings: CommutativeRings +_Fields: Fields + +class Ring(ParentWithGens): + _default_category: Category + + def __init__( + self, + base: Parent[Any] | object, + names: NameSpec = ..., + normalize: bool = ..., + category: Category | None = ..., + ) -> None: ... + def __iter__(self) -> Iterator[Any]: ... + def __len__(self) -> int: ... + def __xor__(self, n: object) -> NoReturn: ... + def base_extend(self, X: Parent[Any]) -> Parent[Any]: ... + def category(self) -> Category: ... + def __mul__(self, x: object) -> object: ... + def zero(self) -> Any: ... + def one(self) -> Any: ... + def order(self) -> int: ... + +class CommutativeRing(Ring): + _default_category: Category + + def __init__( + self, + base_ring: Parent[Any] | object, + names: NameSpec = ..., + normalize: bool = ..., + category: Category | None = ..., + ) -> None: ... + def fraction_field(self) -> Ring: ... + def extension( + self, + poly: object, + name: str | None = ..., + names: NameSpec = ..., + **kwds: object, + ) -> Ring: ... + +class IntegralDomain(CommutativeRing): + _default_category: Category + +class NoetherianRing(CommutativeRing): + _default_category: Category + +class DedekindDomain(CommutativeRing): + _default_category: Category + +class PrincipalIdealDomain(CommutativeRing): + _default_category: Category + +def _is_Field(x: object) -> bool: ... + +class Field(CommutativeRing): + _default_category: Category + +class Algebra(Ring): + def __init__( + self, base_ring: Parent[Any] | object, *args: object, **kwds: object + ) -> None: ... + +class CommutativeAlgebra(CommutativeRing): + def __init__( + self, base_ring: Parent[Any] | object, *args: object, **kwds: object + ) -> None: ... + +def is_Ring(x: object) -> bool: ... diff --git a/src/sage/structure/category_object.pyi b/src/sage/structure/category_object.pyi index 5c629f92938..45c96ba5617 100644 --- a/src/sage/structure/category_object.pyi +++ b/src/sage/structure/category_object.pyi @@ -1,13 +1,25 @@ -from typing import Any +from typing import Any, Sequence -class CategoryObject: - def __init__(self, category: Any = None, base: Any = None) -> None: ... +from sage.categories.category import Category +from sage.rings.ring import Ring +from sage.structure.sage_object import SageObject + +NameSpec = str | Sequence[str] | None + +class CategoryObject(SageObject): + _names: tuple[str, ...] | None + + def __init__( + self, + category: Category | Sequence[Category] | None = None, + base: Ring | None = None, + ) -> None: ... def __cinit__(self) -> None: ... - def _init_category_(self, category: Any) -> None: ... - def _refine_category_(self, category: Any) -> None: ... + def _init_category_(self, category: Category | Sequence[Category]) -> None: ... + def _refine_category_(self, category: Category | Sequence[Category]) -> None: ... def _is_category_initialized(self) -> bool: ... - def category(self) -> Any: ... - def categories(self) -> Any: ... + def category(self) -> Category: ... + def categories(self) -> list[Category]: ... def _underlying_class(self) -> Any: ... def __gens_dict(self) -> dict[str, Any]: ... def gens_dict(self, copy: bool = True) -> dict[str, Any]: ... @@ -16,14 +28,16 @@ class CategoryObject: def objgen(self) -> tuple[Any, Any]: ... def _first_ngens(self, n: int) -> Any: ... def _defining_names(self) -> Any: ... - def _assign_names(self, names: Any = None, normalize: bool = True, ngens: int = None) -> None: ... + def _assign_names( + self, names: NameSpec = None, normalize: bool = True, ngens: int | None = None + ) -> None: ... def variable_names(self) -> tuple[str, ...]: ... def variable_name(self) -> str: ... def _temporarily_change_names(self, names: Any, latex_names: Any) -> Any: ... def inject_variables(self, scope: Any = None, verbose: bool = True) -> None: ... def base_ring(self) -> Any: ... def base(self) -> Any: ... - def Hom(self, codomain: Any, cat: Any = None) -> Any: ... + def Hom(self, codomain: Any, category: Any = None) -> Any: ... def latex_variable_names(self) -> Any: ... def latex_name(self) -> str: ... def __getstate__(self) -> dict[str, Any]: ... @@ -33,6 +47,5 @@ class CategoryObject: def getattr_from_category(self, name: str) -> Any: ... def __dir__(self) -> Any: ... -def normalize_names(ngens: int, names: Any) -> tuple[str, ...]: ... - +def normalize_names(ngens: int, names: NameSpec) -> tuple[str, ...]: ... def certify_names(names: Any) -> bool: ... diff --git a/src/sage/structure/parent.pyi b/src/sage/structure/parent.pyi new file mode 100644 index 00000000000..5df7f70f8dd --- /dev/null +++ b/src/sage/structure/parent.pyi @@ -0,0 +1,161 @@ +from __future__ import annotations + +from typing import Any, Callable, Generic, Literal, Mapping, Self, Sequence, TypeVar + +from sage.categories.category import Category +from sage.categories.map import Map +from sage.rings.ring import Ring +from sage.structure.category_object import ( + CategoryObject, + NameSpec, +) + +ElementT_co = TypeVar("ElementT_co", covariant=True) + +def is_Integer(x: Any) -> bool: ... +def is_Parent(x: Any) -> bool: ... +def good_as_coerce_domain(S: Any) -> bool: ... +def good_as_convert_domain(S: Any) -> bool: ... + +class Parent(CategoryObject, Generic[ElementT_co]): + _element_constructor: Callable[..., Any] | None + _element_init_pass_parent: bool + _convert_method_name: str | None + _initial_coerce_list: list[Any] + _initial_action_list: list[Any] + _initial_convert_list: list[Any] + _coercions_used: bool + flags: int + _coerce_from_list: list[Any] + _registered_domains: list[Any] + _coerce_from_hash: Any + _action_list: list[Any] + _convert_from_list: list[Any] + _convert_from_hash: Any + _embedding: Any + _action_hash: Any + _cache_an_element: Any + + def __init__( + self, + base: Ring | None = None, + *, + category: Category | Sequence[Category] | None = None, + names: NameSpec = ..., + normalize: bool = ..., + facade: Parent[Any] | tuple[Parent[Any], ...] | Literal[True] | None = None, + ) -> None: ... + def _init_category_( + self, category: Category | Sequence[Category] | None + ) -> None: ... + def _refine_category_(self, category: Category | Sequence[Category]) -> None: ... + def _unset_category(self) -> None: ... + @property + def _abstract_element_class(self) -> type[ElementT_co]: ... + @property + def element_class(self) -> type[ElementT_co] | Any: ... + def __make_element_class__( + self, + cls: type[ElementT_co], + name: str | None = ..., + module: str | None = ..., + inherit: bool | None = ..., + ) -> type[ElementT_co]: ... + def _set_element_constructor(self) -> None: ... + def category(self) -> Category: ... + def _test_category(self, **options: Any) -> None: ... + def _test_eq(self, **options: Any) -> None: ... + def init_coerce(self, warn: bool = ...) -> None: ... + def _introspect_coerce(self) -> dict[str, Any]: ... + def __getstate__(self) -> dict[str, Any]: ... + def __setstate__(self, d: Mapping[str, Any]) -> None: ... + def _repr_option(self, key: str) -> Any: ... + def __call__(self, x: Any = 0, *args: Any, **kwds: Any) -> ElementT_co: ... + def __mul__(self, x: Any) -> Any: ... + def __pow__(self, x: Any, mod: Any) -> Any: ... + def __contains__(self, x: Any) -> bool: ... + def coerce(self, x: Any) -> ElementT_co: ... + def __bool__(self) -> bool: ... + def __getitem__(self, n: int | slice) -> ElementT_co: ... + def _is_valid_homomorphism_( + self, codomain: Any, im_gens: Any, base_map: Any | None = ... + ) -> bool: ... + def Hom(self, codomain: Any, category: Category | None = ...) -> Any: ... + def hom( + self, + im_gens: Any, + codomain: Any | None = ..., + check: bool | None = ..., + base_map: Any | None = ..., + category: Category | None = ..., + **kwds: Any, + ) -> Any: ... + def _populate_coercion_lists_( + self, + coerce_list: Sequence[Any] | None = ..., + action_list: Sequence[Any] | None = ..., + convert_list: Sequence[Any] | None = ..., + embedding: Any | None = ..., + convert_method_name: str | None = ..., + element_constructor: Callable[..., Any] | None = ..., + init_no_parent: bool | None = ..., + unpickling: bool = ..., + ) -> None: ... + def _unset_coercions_used(self) -> None: ... + def _unset_embedding(self) -> None: ... + def _is_coercion_cached(self, domain: Any) -> bool: ... + def _is_conversion_cached(self, domain: Any) -> bool: ... + def _remove_from_coerce_cache(self, domain: Any) -> None: ... + def register_coercion(self, mor: Any) -> None: ... + def register_action(self, action: Any) -> None: ... + def register_conversion(self, mor: Any) -> None: ... + def register_embedding(self, embedding: Any) -> None: ... + def coerce_embedding(self) -> Any: ... + def _generic_coerce_map(self, S: Any) -> Map[Any, Any]: ... + def _generic_convert_map( + self, S: Any, category: Category | None = ... + ) -> Map[Any, Any]: ... + def _convert_method_map( + self, S: Any, method_name: str | None = ... + ) -> Map[Any, Any]: ... + def _coerce_map_via(self, v: Sequence[Any], S: Any) -> Map[Any, Any]: ... + def has_coerce_map_from(self, S: Any) -> bool: ... + def _coerce_map_from_(self, S: Any) -> Any: ... + def coerce_map_from(self, S: Any) -> Map[Any, Any] | None: ... + def _internal_coerce_map_from(self, S: Any) -> Map[Any, Any] | None: ... + def convert_map_from(self, S: Any) -> Map[Any, Any] | None: ... + def _internal_convert_map_from(self, S: Any) -> Map[Any, Any] | None: ... + def _convert_map_from_( + self, S: Any + ) -> Map[Any, Any] | Callable[..., Any] | bool | None: ... + def get_action( + self, + S: Any, + op: Callable[..., Any] = ..., + self_on_left: bool = ..., + self_el: Any = ..., + S_el: Any = ..., + ) -> Any: ... + def _get_action_( + self, S: Any, op: Callable[..., Any], self_on_left: bool + ) -> Any: ... + def an_element(self) -> ElementT_co: ... + def _an_element_(self) -> ElementT_co: ... + def is_exact(self) -> bool: ... + def _is_numerical(self) -> bool: ... + def _is_real_numerical(self) -> bool: ... + +class Set_generic(Parent[Any]): + def object(self) -> Self: ... + def __bool__(self) -> bool: ... + +class EltPair: + x: Any + y: Any + tag: Any + + def __init__(self, x: Any, y: Any, tag: Any) -> None: ... + def __richcmp__(self, other: EltPair, op: int) -> bool: ... + def __hash__(self) -> int: ... + def short_repr(self) -> tuple[Any, str, str]: ... + def __repr__(self) -> str: ... diff --git a/src/sage/structure/parent_gens.pyi b/src/sage/structure/parent_gens.pyi new file mode 100644 index 00000000000..f620e751319 --- /dev/null +++ b/src/sage/structure/parent_gens.pyi @@ -0,0 +1,57 @@ +from __future__ import annotations + +from types import TracebackType +from typing import Any, Mapping, Sequence + +from sage.structure.category_object import NameSpec +from sage.structure.parent_base import ParentWithBase + +class ParentWithGens(ParentWithBase): + _base: Any + _gens: tuple[Any, ...] | None + _names: tuple[str, ...] | None + _latex_names: tuple[str, ...] | None + _list: Any + + def __init__( + self, + base: Any, + names: NameSpec = ..., + normalize: bool = ..., + category: Any | None = ..., + ) -> None: ... + def ngens(self) -> int: ... + def gen(self, i: int = ...) -> Any: ... + def gens(self) -> tuple[Any, ...]: ... + def _assign_names(self, names: NameSpec = ..., normalize: bool = ...) -> None: ... + def __getstate__(self) -> dict[str, Any]: ... + def __setstate__(self, d: Mapping[str, Any]) -> None: ... + def hom( + self, + im_gens: Any, + codomain: Any | None = ..., + base_map: Any | None = ..., + category: Any | None = ..., + check: bool = ..., + ) -> Any: ... + +class localvars: + _obj: ParentWithGens + _names: Sequence[str] + _latex_names: Sequence[str] | None + _orig: tuple[Sequence[str] | None, Sequence[str] | None] | None + + def __init__( + self, + obj: ParentWithGens, + names: NameSpec, + latex_names: Sequence[str] | None = ..., + normalize: bool = ..., + ) -> None: ... + def __enter__(self) -> None: ... + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_value: BaseException | None, + traceback: TracebackType | None, + ) -> None: ... diff --git a/src/sage/structure/sage_object.pyi b/src/sage/structure/sage_object.pyi new file mode 100644 index 00000000000..2f12dfaec2f --- /dev/null +++ b/src/sage/structure/sage_object.pyi @@ -0,0 +1,83 @@ +from __future__ import annotations + +from typing import Any, Hashable, Self +from unittest import TestCase + +from sage.categories.category import Category +from sage.typeset.ascii_art import AsciiArt +from sage.typeset.unicode_art import UnicodeArt + +_interface_init_with_interface: set[str] + +load: Any +loads: Any +dumps: Any +save: Any +unpickle_all: Any +unpickle_global: Any +unpickle_override: Any + +CacheKey = Hashable | tuple[Any, ...] + +class SageObject: + _SageObject__custom_name: str | None + + def _test_new(self, **options: Any) -> None: ... + def rename(self, x: Any | None = None) -> None: ... + def reset_name(self) -> None: ... + def get_custom_name(self) -> str | None: ... + def __repr__(self) -> str: ... + def _ascii_art_(self) -> AsciiArt: ... + def _unicode_art_(self) -> UnicodeArt: ... + def __hash__(self) -> int: ... + def _cache_key(self) -> CacheKey: ... + def save(self, filename: str | None = ..., compress: bool = ...) -> None: ... + def dump(self, filename: str, compress: bool = ...) -> None: ... + def dumps(self, compress: bool = ...) -> bytes: ... + def category(self) -> Category: ... + def _test_category(self, **options: Any) -> None: ... + def parent(self) -> type[Any]: ... + def _tester(self, **options: Any) -> TestCase: ... + def _test_not_implemented_methods(self, **options: Any) -> None: ... + def _test_pickling(self, **options: Any) -> None: ... + def _sage_(self) -> Self: ... + def _interface_(self, I: Any) -> Any: ... + def _interface_init_(self, I: Any | None = ...) -> str: ... + def _interface_is_cached_(self) -> bool: ... + def _gap_(self, G: Any | None = ...) -> Any: ... + def _gap_init_(self) -> str: ... + def _libgap_(self) -> Any: ... + def _gp_(self, G: Any | None = ...) -> Any: ... + def _gp_init_(self) -> str: ... + def _kash_(self, G: Any | None = ...) -> Any: ... + def _kash_init_(self) -> str: ... + def _axiom_(self, G: Any | None = ...) -> Any: ... + def _axiom_init_(self) -> str: ... + def _fricas_(self, G: Any | None = ...) -> Any: ... + def _fricas_init_(self) -> str: ... + def _giac_(self, G: Any | None = ...) -> Any: ... + def _giac_init_(self) -> str: ... + def _maxima_(self, G: Any | None = ...) -> Any: ... + def _maxima_init_(self) -> str: ... + def _maxima_lib_(self, G: Any | None = ...) -> Any: ... + def _maxima_lib_init_(self) -> str: ... + def _magma_init_(self, magma: Any) -> str: ... + def _macaulay2_(self, G: Any | None = ...) -> Any: ... + def _macaulay2_init_(self, macaulay2: Any | None = ...) -> str: ... + def _maple_(self, G: Any | None = ...) -> Any: ... + def _maple_init_(self) -> str: ... + def _mathematica_(self, G: Any | None = ...) -> Any: ... + def _mathematica_init_(self) -> str: ... + def _mathics_(self, G: Any | None = ...) -> Any: ... + def _mathics_init_(self) -> str: ... + def _octave_(self, G: Any | None = ...) -> Any: ... + def _octave_init_(self) -> str: ... + def _polymake_(self, G: Any | None = ...) -> Any: ... + def _polymake_init_(self) -> str: ... + def _r_init_(self) -> str: ... + def _singular_(self, G: Any | None = ...) -> Any: ... + def _singular_init_(self) -> str: ... + def __pari__(self) -> Any: ... + def _pari_init_(self) -> str: ... + def _regina_(self, G: Any | None = ...) -> Any: ... + def _regina_init_(self) -> str: ...