### Navigation

- index
- modules |
- next |
- previous |
- Interpreter Interfaces »

# Interface to mwrank

`sage.interfaces.mwrank.``Mwrank`(options='', server=None, server_tmpdir=None)

  Create and return an mwrank interpreter, with given options.

  INPUT:

  - `options` - string; passed when starting mwrank. The format is:

        -h       help            prints this info and quits
        -q       quiet           turns OFF banner display and prompt
        -v n     verbosity       sets verbosity to n (default=1)
        -o       PARI/GP output  turns ON extra PARI/GP short output (default is OFF)
        -p n     precision       sets precision to n decimals (default=15)
        -b n     quartic bound   bound on quartic point search (default=10)
        -x n     n aux           number of aux primes used for sieving (default=6)
        -l       list            turns ON listing of points (default ON unless v=0)
        -s       selmer_only     if set, computes Selmer rank only (default: not set)
        -d       skip_2nd_descent        if set, skips the second descent for curves with 2-torsion (default: not set)
        -S n     sat_bd          upper bound on saturation primes (default=100, -1 for automatic)

  EXAMPLES:

      sage: M = Mwrank('-v 0 -l')
      sage: print M('0 0 1 -1 0')
      Curve [0,0,1,-1,0] :    Rank = 1
      Generator 1 is [0:-1:1]; height 0.0511114082399688
      Regulator = 0.0511114082399688

class `sage.interfaces.mwrank.``Mwrank_class`(options='', server=None, server_tmpdir=None)

  Bases: `sage.interfaces.expect.Expect`

  Interface to the Mwrank interpreter.

  `console`()

    Start the mwrank console.

    EXAMPLE:

        sage: mwrank.console() # not tested: expects console input
        Program mwrank: ...

  `eval`(s, **kwds)

    Return mwrank’s output for the given input.

    INPUT:

    - `s` (str) - a Sage object which when converted to a string gives valid input to `mwrank`. The conversion is done by `validate_mwrank_input()`. Possible formats are:
      - a string representing exactly five integers separated by whitespace, for example ‘1 2 3 4 5’
      - a string representing exactly five integers separated by commas, preceded by ‘[‘ and followed by ‘]’ (with arbitrary whitespace), for example ‘[1 2 3 4 5]’
      - a list or tuple of exactly 5 integers.

    Note

    If a RuntimeError exception is raised, then the mwrank interface is restarted and the command is retried once.

    EXAMPLES:

        sage: mwrank.eval('12 3 4 5 6')
        'Curve [12,3,4,5,6] :...'
        sage: mwrank.eval('[12, 3, 4, 5, 6]')
        'Curve [12,3,4,5,6] :...'
        sage: mwrank.eval([12, 3, 4, 5, 6])
        'Curve [12,3,4,5,6] :...'
        sage: mwrank.eval((12, 3, 4, 5, 6))
        'Curve [12,3,4,5,6] :...'

  `quit`(verbose=False)

    Quit the mwrank process using kill -9 (so exit doesn’t dump core, etc.).

    INPUT:

    - `verbose` – ignored

    EXAMPLES:

        sage: m = Mwrank()
        sage: e = m('1 2 3 4 5')
        sage: m.quit()

`sage.interfaces.mwrank.``mwrank_console`()

  Start the mwrank console.

  EXAMPLE:

      sage: mwrank_console() # not tested: expects console input
      Program mwrank: ...

`sage.interfaces.mwrank.``validate_mwrank_input`(s)

  Returns a string suitable for mwrank input, or raises an error.

  INPUT:

  - \(s\) – one of the following:

    > - a list or tuple of 5 integers [a1,a2,a3,a4,a6] or (a1,a2,a3,a4,a6)
    > - a string of the form ‘[a1,a2,a3,a4,a6]’ or ‘a1 a2 a3 a4 a6’ where a1, a2, a3, a4, a6 are integers

  OUTPUT:

  For valid input, a string of the form ‘[a1,a2,a3,a4,a6]’. For invalid input a ValueError is raised.

  EXAMPLES:

  A list or tuple of 5 integers:

      sage: from sage.interfaces.mwrank import validate_mwrank_input
      sage: validate_mwrank_input([1,2,3,4,5])
      '[1, 2, 3, 4, 5]'
      sage: validate_mwrank_input((-1,2,-3,4,-55))
      '[-1, 2, -3, 4, -55]'
      sage: validate_mwrank_input([1,2,3,4])
      Traceback (most recent call last):
      ...
      ValueError: [1, 2, 3, 4] is not valid input to mwrank (should have 5 entries)
      sage: validate_mwrank_input([1,2,3,4,i])
      Traceback (most recent call last):
      ...
      ValueError: [1, 2, 3, 4, I] is not valid input to mwrank (entries should be integers)

  A string of the form ‘[a1,a2,a3,a4,a6]’ with any whitespace and integers ai:

      sage: validate_mwrank_input('0 -1 1 -7 6')
      '[0,-1,1,-7,6]'
      sage: validate_mwrank_input("[0,-1,1,0,0]\n")
      '[0,-1,1,0,0]'
      sage: validate_mwrank_input('0\t -1\t 1\t 0\t 0\n')
      '[0,-1,1,0,0]'
      sage: validate_mwrank_input('0 -1 1 -7 ')
      Traceback (most recent call last):
      ...
      ValueError: 0 -1 1 -7  is not valid input to mwrank

### Navigation

- index
- modules |
- next |
- previous |
- Interpreter Interfaces »