simon-git: spigot (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Tue Oct 24 19:41:27 BST 2017


TL;DR:
  5d880c5 Python testenv: canonicalise the build-base pathname.
  867d4e4 Buildscr: run sphinx-build in warnings-as-errors mode.
  752b4ef Python: make BASE_NEG and BASE_DIGITS comparable for equality.
  98a968c Python: add an iterator-style to_digits() method.
  437a3a9 Python: add methods that generate IEEE hex strings.
  9f500ce Python: provide short names for the rounding modes.

Repository:     https://git.tartarus.org/simon/spigot.git
On the web:     https://git.tartarus.org/?p=simon/spigot.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2017-10-24 19:41:27

commit 5d880c5744e73decbe380a457ee726e8ba9a75e0
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=5d880c5744e73decbe380a457ee726e8ba9a75e0;hp=53426105a41f45cfb4ed25f53474ce99a05ddca5
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Oct 24 18:40:29 2017 +0100

    Python testenv: canonicalise the build-base pathname.
    
    Turned out that the testenv commands in Buildscr, of the form 'testenv
    --build-base=<relative path> --exec make -C <subdir>', were ending up
    with the wrong PYTHONPATH because the relative path provided via the
    --build-base option stopped being useful when make changed its cwd.
    
    Now we feed the build-base directory to os.path.abspath before setting
    PYTHONPATH based on it.

 python-module/testenv | 1 +
 1 file changed, 1 insertion(+)

commit 867d4e41abdd5c184478b9f965744c098108550f
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=867d4e41abdd5c184478b9f965744c098108550f;hp=5d880c5744e73decbe380a457ee726e8ba9a75e0
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Oct 24 18:45:54 2017 +0100

    Buildscr: run sphinx-build in warnings-as-errors mode.
    
    If I do something like citing a method in api.rst that doesn't
    actually exist, sphinx-build will give a mere warning. Not good
    enough! I want that to be a build-breaking error, so I'll notice it
    and fix it.

 Buildscr | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

commit 752b4ef0789a7f76a77206323f1a4cc7e5dfa4b1
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=752b4ef0789a7f76a77206323f1a4cc7e5dfa4b1;hp=867d4e41abdd5c184478b9f965744c098108550f
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Oct 24 19:35:24 2017 +0100

    Python: make BASE_NEG and BASE_DIGITS comparable for equality.
    
    I have no idea whether this will be useful to end users, but it's
    about to be useful to the test suite, which will now be able to
    assertEqual() two lists that include a BASE_NEG without getting
    confused.

 python-module/__init__.py | 6 ++++++
 1 file changed, 6 insertions(+)

commit 98a968c0252c1adb2a968466f0dd2563ce2127b1
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=98a968c0252c1adb2a968466f0dd2563ce2127b1;hp=752b4ef0789a7f76a77206323f1a4cc7e5dfa4b1
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Oct 23 20:43:30 2017 +0100

    Python: add an iterator-style to_digits() method.
    
    This gives the infinite decimal (or other base) expansion of a number
    in the form of an iterator delivering successive digits as Python
    integers, which I expect will be more useful to automated processing
    than the printable-text representation produced by base_format().
    Also, this system doesn't have the annoying limit of 36 on the base,
    because there's no difficulty with finding a good representation for
    digit values larger than that.
    
    The returned iterator is actually a class I made up, and in addition
    to the iterator protocol it also provides an explicit get_digit
    function to which you can pass an override base.
    
    Just as with from_digits(), the question arises of how you represent a
    negative number without getting confused by the inability to
    distinguish "+0" from "-0". I decided the nicest approach was to
    generate a BASE_NEG object on output of the same kind that from_digits
    accepts on input, so that the two functions look more or less
    consistent.
    
    (However, I decided _not_ to have get_digit() with an explicit base
    return a BASE_DIGIT object, because if you've just passed in the base
    value by hand, you surely don't need to be told again what it was, and
    it's a pointless extra faff to unwrap the object to get the actual
    digit value back out.)
    
    On the implementation side, this is done by exposing a Python
    interface to a StaticGenerator rather than using any kind of more
    fully cooked base-output generator, so that I can manually premultiply
    in each digit-extraction matrix and therefore vary it for base
    overrides.
    
    In fact I ended up - for the first time in this project's history -
    finding it was easier to separate the digit-extraction matrix into two
    separate transformations. The first subtracts off the just-extracted
    digit, and I do it immediately after extraction while I can trivially
    remember what that digit _was_; the second scales up by the base of
    the next digit, and I defer that half of the transform until I find
    out what the base is _going to be_!

 python-demos/demo          |  33 +++++++++--
 python-doc/api.rst         |   2 +
 python-module/__init__.py  | 134 +++++++++++++++++++++++++++++++++++++++++++++
 python-module/internal.cpp |  76 ++++++++++++++++++++++++-
 python-module/testsuite    |  20 +++++++
 5 files changed, 260 insertions(+), 5 deletions(-)

commit 437a3a9110792ba007433a50fa31bbdf0304b277
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=437a3a9110792ba007433a50fa31bbdf0304b277;hp=98a968c0252c1adb2a968466f0dd2563ce2127b1
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Oct 24 19:33:44 2017 +0100

    Python: add methods that generate IEEE hex strings.
    
    This is one output mode of CLI spigot that was under-represented in
    Python spigot - the C++ internal.Spigot object has always been able to
    deliver text output formatted like that, but it wasn't exposed in the
    user-facing API until now.

 python-doc/api.rst        |  10 +++
 python-module/__init__.py | 161 ++++++++++++++++++++++++++++++++++++++++++++++
 python-module/testsuite   |  33 ++++++++++
 3 files changed, 204 insertions(+)

commit 9f500cefdd18d35e7472dae9eb57db8e543c283f
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=9f500cefdd18d35e7472dae9eb57db8e543c283f;hp=437a3a9110792ba007433a50fa31bbdf0304b277
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Oct 24 19:33:46 2017 +0100

    Python: provide short names for the rounding modes.
    
    The long names like ROUND_TO_NEAREST_AWAY_FROM_ZERO are taken directly
    from the internal enum in the C++ code. I don't think I want to
    actually get rid of them - or even remove them from primacy in the
    documentation - but it seems worth at least _providing_ a set of nice
    short identifiers, to save typing. The obvious choice of abbreviation
    scheme is the same set of strings I used in the __format__ syntax,
    only in upper case this time because they're module constants.

 python-module/__init__.py | 93 +++++++++++++++++++++++++----------------------
 python-module/testsuite   |  7 ++++
 2 files changed, 57 insertions(+), 43 deletions(-)



More information about the tartarus-commits mailing list