Opened 7 years ago

Closed 6 years ago

#19917 closed enhancement (fixed)

Libgap tab completion

Reported by: vbraun Owned by:
Priority: major Milestone: sage-7.1
Component: group theory Keywords:
Cc: dimpase Merged in:
Authors: Volker Braun Reviewers: Dima Pasechnik
Report Upstream: N/A Work issues:
Branch: 47bc138 (Commits, GitHub, GitLab) Commit: 47bc138c13530e553a22642be9de6efb8fdcd80c
Dependencies: Stopgaps:

Status badges

Description (last modified by vbraun)

This ticket fixes tab completion on the libgap object

sage: libgap.[TAB]
sage: n = libgap(123)
sage: n.[TAB]

Change History (30)

comment:1 Changed 7 years ago by vbraun

  • Branch set to u/vbraun/libgap_tab_completion

comment:2 Changed 7 years ago by vbraun

  • Authors set to Volker Braun
  • Commit set to ccc742ed7c0a3af2e9aa1de3897809bdaf46aead
  • Component changed from PLEASE CHANGE to group theory
  • Description modified (diff)
  • Type changed from PLEASE CHANGE to enhancement

New commits:

ccc742eFix libgap tab completion

comment:3 Changed 7 years ago by git

  • Commit changed from ccc742ed7c0a3af2e9aa1de3897809bdaf46aead to 807d1a578f9f7725c63f578eb9f961b5832683d2

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

807d1a5Improve tab completion on LibGAP elements

comment:4 Changed 7 years ago by vbraun

  • Cc dimpase added
  • Description modified (diff)
  • Status changed from new to needs_review

comment:5 Changed 7 years ago by dimpase

Still, the tab completion on objects obtained from libgap does not work; not sure if it was intended to be fixed by this ticket:

sage: g=libgap.GeneralLinearGroup(3,2)
sage: g.
g.N                     g.cartesian_product     g.is_bool               g.is_permutation        g.matrix                g.parent                g.save                  g.version
g.abs                   g.category              g.is_function           g.is_prime              g.multiplicative_order  g.powers                g.subs                  
g.additive_order        g.db                    g.is_list               g.is_record             g.n                     g.rename                g.substitute            
g.base_extend           g.dump                  g.is_nilpotent          g.is_string             g.numerical_approx      g.reset_name            g.trait_names           
g.base_ring             g.dumps                 g.is_one                g.is_zero               g.order                 g.sage                  g.vector                
sage: g.Order()  # this choice not offered, but works...
168

comment:6 follow-up: Changed 7 years ago by vbraun

Did you rebuild the Sage library? I get:

sage: g =libgap.GeneralLinearGroup(3,2)
sage: g.
Display all 727 possibilities? (y or n)
g.ANonReesCongruenceOfSemigroup                   g.IsReesMatrixSemigroup
g.AbelianGroupCons                                g.IsReesZeroMatrixSemigroup
g.AbelianInvariants                               g.IsRegular
g.AbelianInvariantsMultiplier                     g.IsRegularSemigroup
...

comment:7 in reply to: ↑ 6 Changed 7 years ago by dimpase

Replying to vbraun:

Did you rebuild the Sage library?

hmm, no I didn't. However, are all there 727 options relevant here? We only want functions which accept Group as the 1st parameter, no?

comment:8 Changed 7 years ago by vbraun

Its perhaps not too surprising that most GAP functions accept a group...

comment:9 Changed 7 years ago by vdelecroix

  • Status changed from needs_review to needs_work

Anyway

sage -t --long src/sage/libs/gap/element.pyx
**********************************************************************
File "src/sage/libs/gap/element.pyx", line 405, in sage.libs.gap.element.GapElement.__dir__
Failed example:
    'GeneratorsOfGroup' in dir(G)
Expected:
    True
Got:
    False
**********************************************************************
1 item had failures:
   1 of   5 in sage.libs.gap.element.GapElement.__dir__
    [356 tests, 1 failure, 1.97 s]

comment:10 Changed 7 years ago by dimpase

sage: from sage.libs.gap.all_documented_functions import *
sage: g=Group([ [ [ Z(3), 0*Z(3) ],[ Z(3), Z(3) ] ] ])
sage: g
Group([ [ [ Z(3), 0*Z(3) ], [ Z(3), Z(3) ] ] ])
sage: g.O
g.Omega                        g.OmegaOp                      g.OrbitLengthOp                g.OrbitOp                      g.Orbits                       
g.OmegaAndLowerPCentralSeries  g.OmegaSeries                  g.OrbitLengths                 g.OrbitStabilizerAlgorithm     g.OrbitsDomain                 
g.OmegaCons                    g.OneImmutable                 g.OrbitLengthsDomain           g.OrbitStabilizerOp            g.OrdinaryCharacterTable       
sage: g.Order()
6

although g.Size() does work.

sage: g.Si                    
g.Sigma                  g.SingleCollector        g.SingleValuedHashTable  g.Size

comment:11 Changed 7 years ago by dimpase

indeed, with g as above:

sage: 'Order' in dir(g)
False
sage: 'Size' in dir(g)
True

I'll ask GAP people...

comment:12 follow-up: Changed 7 years ago by vbraun

Thats because Order is not a function

gap> IsFunction("Order");
false
gap> Order;
<Attribute "Order">

I guess we should treat attribute as function...

comment:13 Changed 7 years ago by vbraun

And the name of GeneratorsOfGroup is also susprising

gap> NameFunction(GeneratorsOfGroup);
"GeneratorsOfMagmaWithInverses"

comment:14 Changed 7 years ago by vbraun

The gap (not: libgap) tab completion also doesn't have GeneratorsOfGroup:

sage: G = gap.SymmetricGroup(3)
sage: G.GeneratorsOf[TAB]
G.GeneratorsOfDomain             G.GeneratorsOfMagmaWithInverses  
G.GeneratorsOfMagma              G.GeneratorsOfMagmaWithOne       
sage: G.GeneratorsOfMagmaWithInverses()
[ (1,2,3), (1,2) ]

comment:15 Changed 7 years ago by vbraun

Improving tab completion beyond what the gap interface currently does should go into a separate ticket.

comment:16 Changed 7 years ago by git

  • Commit changed from 807d1a578f9f7725c63f578eb9f961b5832683d2 to 0dccd8dec0ec7ff7d56674a367aaafb875d3ee7c

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

0dccd8dFix doctest

comment:17 Changed 7 years ago by vbraun

  • Status changed from needs_work to needs_review

comment:18 in reply to: ↑ 12 Changed 7 years ago by dimpase

Replying to vbraun:

Thats because Order is not a function

gap> IsFunction("Order");

it must be IsFunction(Order); then you get true

comment:19 Changed 6 years ago by vbraun

Bump... tab completion is still borked

comment:20 Changed 6 years ago by dimpase

Aren't we GAP 4.8-based here, and waiting for it to be released?

comment:21 Changed 6 years ago by vbraun

This ticket is independent of the gap 4.8 update

comment:22 Changed 6 years ago by dimpase

Is the caching of keywords, etc done in sync with the updates of stored GAP workspaces? (this is how it looks from reading the code, but perhaps I am missing something)

And what does happen if a GAP package is loaded? (e.g. Graph would only be available after LoadPackage("grape"))

comment:23 Changed 6 years ago by vbraun

Caching is done on first use. Testing whether a function is documented is slow enough that we can't do it whenever tab completion is requested. Packages loaded by hand lateron will not be in the tab completion, just as when tab completion worked last time.

comment:24 Changed 6 years ago by dimpase

  • Status changed from needs_review to needs_work

I think it is quite convoluted solution, also making it hard to hook up docs of GAP packages.

Namely, the documentation does not magically change once a workspace is updated, but only when libGAP and GAP packages/databases are (re)installed. I'd rather see the corresponding cache built at libGAP (and eventually at GAP packages/GAP database) installation time, and not updated at runtime. This would not be a big rewrite, basically all the functionality for this is already implemented.

I don't have a clear idea how to handle loadable packages, this can be postponed for another ticket.

comment:25 Changed 6 years ago by vbraun

  • Status changed from needs_work to needs_review

I agree that there should be better handling of caches (including the workspace), but it should be a separate ticket.

comment:26 Changed 6 years ago by dimpase

could you add a description of what sage/libs/gap/operations.py is for in the top part of this file? Is it meant to help with tab completion? How? Something else?

comment:27 Changed 6 years ago by git

  • Commit changed from 0dccd8dec0ec7ff7d56674a367aaafb875d3ee7c to 47bc138c13530e553a22642be9de6efb8fdcd80c

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

47bc138Add explanation to the operations.py module docstring

comment:28 Changed 6 years ago by vbraun

Done

comment:29 Changed 6 years ago by dimpase

  • Reviewers set to Dima Pasechnik
  • Status changed from needs_review to positive_review

great, thanks!

comment:30 Changed 6 years ago by vbraun

  • Branch changed from u/vbraun/libgap_tab_completion to 47bc138c13530e553a22642be9de6efb8fdcd80c
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.