Opened 5 years ago

Closed 5 years ago

#20410 closed enhancement (fixed)

Tab completion for units

Reported by: nthiery Owned by:
Priority: major Milestone: sage-7.2
Component: symbolics Keywords:
Cc: Merged in:
Authors: Nicolas M. Thiéry Reviewers: Vincent Delecroix
Report Upstream: N/A Work issues:
Branch: e344fa5 (Commits, GitHub, GitLab) Commit: e344fa54a33c1f8da38cfd021e27e7f9f3be9992
Dependencies: Stopgaps:

Status badges

Description (last modified by nthiery)

The units library lacks tab completion. This would help discovering units, and typing them it more quickly.

Current:

sage: units
Collection of units: acceleration amount_of_substance ... volume
sage: units.mass
Collection of units of mass: amu assay_ton ... tonne wey
sage: units.m<tab>
*does nothing*

This implements:

sage: units.m<tab>
mass ...
sage: units.mass.p<tab>
units.mass.pennyweight  units.mass.pondus       units.mass.pound        units.mass.pound_troy   

(feature request from seing a friend using it).

Change History (8)

comment:1 Changed 5 years ago by nthiery

  • Branch set to u/nthiery/tab_completion_for_units

comment:2 Changed 5 years ago by nthiery

  • Authors set to Nicolas M. Thiéry
  • Commit set to fcabf36196a9b13be52074b40ca71882160a60cc
  • Component changed from user interface to symbolics
  • Description modified (diff)
  • Status changed from new to needs_review

New commits:

fcabf3620410: implement tab completion on 'units' and 'units.*'

comment:3 Changed 5 years ago by nthiery

  • Description modified (diff)

comment:4 Changed 5 years ago by vdelecroix

  • Reviewers set to Vincent Delecroix
  • Status changed from needs_review to needs_work

You should remove the method trait_names that was used for that before (see #19951).

Your solution break the completion of other methods

sage: units.__cmp__
<bound method Units.__cmp__ of ...>
sage: units.__<tab>
* nothing *

One solution would be to use the class sage.interfaces.tab_completion.ExtraTabCompletion (from #19923).

comment:5 Changed 5 years ago by git

  • Commit changed from fcabf36196a9b13be52074b40ca71882160a60cc to e344fa54a33c1f8da38cfd021e27e7f9f3be9992

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

2336cbb20410: reimplemented tab completion on top of ExtraTabCompletion, per suggestion of the reviewer
e344fa520410: misc docstring syntax fixes

comment:6 Changed 5 years ago by nthiery

  • Status changed from needs_work to needs_review

Thanks Vincent for the pointer!

comment:7 Changed 5 years ago by vdelecroix

  • Status changed from needs_review to positive_review

Good to go. Thanks for taking the time of fixing it.

comment:8 Changed 5 years ago by vbraun

  • Branch changed from u/nthiery/tab_completion_for_units to e344fa54a33c1f8da38cfd021e27e7f9f3be9992
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.