passagemath-objects
raw JSON → 10.8.4 verified Fri May 01 auth: no python
Core library for mathematical object infrastructure in the passagemath ecosystem. Provides base classes for Sage-like elements, parents, categories, coercion framework, and metaclasses. Part of the passagemath distribution (successor to SageMath components). Current version 10.8.4, supports Python 3.11-3.14. Released as part of passagemath v10.8.x series.
pip install passagemath-objects Common errors
error ModuleNotFoundError: No module named 'sage' ↓
cause Code imports from old SageMath namespace (sage.structure) which is not present in passagemath.
fix
Change imports to passagemath.objects.*, e.g., 'from passagemath.objects.parent import Parent'
error ImportError: cannot import name 'CategoryInfinite' from 'passagemath.objects.category' ↓
cause CategoryInfinite was removed or renamed in recent versions.
fix
Use 'Category(is_finite=False)' instead of CategoryInfinite.
error ValueError: coercion model has not been initialized ↓
cause Attempting to use coercion without setting up the global coercion model.
fix
Ensure you create a Parent instance first (which initializes coercion) or call CoercionModel()._init_coercion().
Warnings
breaking All import paths changed from sage.* to passagemath.*. Code written for SageMath will not work. ↓
fix Replace sage structure imports with passagemath.objects.*
deprecated The class `CategoryInfinite` is deprecated; use `Category` with appropriate finiteness parameter. ↓
fix Replace `CategoryInfinite()` with `Category(is_finite=False)`
gotcha Coercion model initialization requires explicit setup; default model raises ValueError if used directly without configuration. ↓
fix Call `CoercionModel()._init_coercion()` after creation or use `from passagemath.objects.parent import Parent` which sets it up automatically.
gotcha Memory leaks may occur if elements are not properly garbage collected due to reference cycles in coercion caches. ↓
fix Use `gc.collect()` after cycles or call `Element._reset_cache()` periodically.
Install
pip install passagemath[objects] Imports
- Parent wrong
from sage.structure.parent import Parentcorrectfrom passagemath.objects.parent import Parent - Element wrong
from sage.structure.element import Elementcorrectfrom passagemath.objects.element import Element - Category wrong
from sage.categories.category import Categorycorrectfrom passagemath.objects.category import Category - CoercionModel
from passagemath.objects.coerce import CoercionModel
Quickstart
from passagemath.objects.parent import Parent
from passagemath.objects.element import Element
from passagemath.objects.category import Category
class MyParent(Parent):
def __init__(self):
super().__init__(category=Category())
p = MyParent()
print(isinstance(p, Parent)) # True