Opened 3 years ago

Closed 3 years ago

#27694 closed enhancement (fixed)

Make L.<x> syntax work for LazyLaurentSeriesRing

Reported by: slelievre Owned by:
Priority: major Milestone: sage-8.8
Component: algebra Keywords:
Cc: klee, slelievre, tscrim Merged in:
Authors: Kwankyu Lee Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: 3f28452 (Commits, GitHub, GitLab) Commit: 3f284520d005e9863381407dc58cd79015e464df
Dependencies: Stopgaps:

Status badges

Description

Following #27347, one can use

sage: from sage.rings.lazy_laurent_series_ring import LazyLaurentSeriesRing
sage: L = LazyLaurentSeriesRing(ZZ, 'z')
sage: x = L.gen()

It would be nice to have the syntactic sugar

sage: L.<x> = LazyLaurentSeriesRing(ZZ)

work, just as it does for non-lazy:

sage: L.<x> = LaurentSeriesRing(ZZ)

The Sage preparser actually transforms the L.<x> input as follows:

sage: preparse('L.<x> = LazyLaurentSeriesRing(ZZ)')
"L = LazyLaurentSeriesRing(ZZ, names=('x',)); (x,) = L._first_ngens(1)"

so methods gens and _first_ngens are needed for LazyLaurentSeriesRing.

Change History (15)

comment:1 Changed 3 years ago by tscrim

  • Cc tscrim added

comment:2 Changed 3 years ago by klee

Does your proposal include importing LazyLaurentSeriesRing at startup time?

comment:3 follow-up: Changed 3 years ago by slelievre

It is the case for LazyPowerSeriesRing, so that would be consistent.

comment:4 in reply to: ↑ 3 Changed 3 years ago by klee

Replying to slelievre:

It is the case for LazyPowerSeriesRing, so that would be consistent.

I fear that it increases startup time. Perhaps using lazy_import is necessary.

comment:5 Changed 3 years ago by slelievre

Maybe that is the case for LazyPowerSeriesRing too? I don't know how to check that...

comment:6 Changed 3 years ago by jhpalmieri

Doesn't look like it's lazily imported, see the third hit in the search:

sage: search_src('import', 'LazyPowerSeriesRing')
categories/highest_weight_crystals.py:378:                from sage.combinat.species.series import LazyPowerSeriesRing
categories/sets_with_grading.py:217:            from sage.combinat.species.series import LazyPowerSeriesRing
combinat/species/all.py:6:from .series import LazyPowerSeriesRing
combinat/species/generating_series.py:81:from .series import LazyPowerSeriesRing, LazyPowerSeries
combinat/species/series.py:51:            sage: from sage.combinat.species.series import LazyPowerSeriesRing

comment:7 Changed 3 years ago by klee

  • Authors set to Kwankyu Lee
  • Branch set to u/klee/27694
  • Commit set to bdfc88b534d4bf0fc6a77a6e1a67988b7f62cd2e

New commits:

bdfc88bMake L.<z> work

comment:8 Changed 3 years ago by klee

It's not lazily imported yet. Let's see how this affects the startup time first.

comment:9 Changed 3 years ago by tscrim

I would just lazily import it. There is no real harm in doing that. It just might take a moment to load when first using it in Sage. It is quite difficult to see how a single import changes startup time (unless it is really big); it is a "death by a 1000 needles" thing where it is the culmination of all the different modules.

comment:10 Changed 3 years ago by git

  • Commit changed from bdfc88b534d4bf0fc6a77a6e1a67988b7f62cd2e to 084c44f2c938dd192d9abd36f24b7ae1baf7a97f

Branch pushed to git repo; I updated commit sha1. New commits:

084c44fChange x to z

comment:11 Changed 3 years ago by git

  • Commit changed from 084c44f2c938dd192d9abd36f24b7ae1baf7a97f to 3f284520d005e9863381407dc58cd79015e464df

Branch pushed to git repo; I updated commit sha1. New commits:

3f28452Switch to lazy_import

comment:12 Changed 3 years ago by tscrim

Ready for review?

comment:13 Changed 3 years ago by klee

  • Status changed from new to needs_review

comment:14 Changed 3 years ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review

LGTM.

comment:15 Changed 3 years ago by vbraun

  • Branch changed from u/klee/27694 to 3f284520d005e9863381407dc58cd79015e464df
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.