Ticket #10052: trac_10052-steenrod.delta3to4.patch

File trac_10052-steenrod.delta3to4.patch, 2.7 KB (added by jhpalmieri, 10 years ago)

Diff between v3 and v4 (for reference only)

  • sage/algebras/steenrod/steenrod_algebra_misc.py

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1299898020 28800
    # Node ID e791515a4dbbc38ade760caa0a01932cef096cda
    # Parent  21b3641531b7c8f924587e0d500d5ddaaa62dade
    #9370: delta from v3 to v4
    
    diff -r 21b3641531b7 -r e791515a4dbb sage/algebras/steenrod/steenrod_algebra_misc.py
    a b def is_valid_profile(profile, truncation 
    246246        # p odd:
    247247        e = list(profile[0]) + [truncation_type]*len(profile[0])
    248248        k = list(profile[1])
     249        if not set(k).issubset(set([1,2])):
     250            return False
    249251        if truncation_type > 0:
    250252            k = k + [2]
    251253        else:
    def normalize_profile(profile, precision 
    391393        sage: normalize_profile(([2,1], [2,2,2]), precision=84, p=13)
    392394        (((2, 1), (2, 2, 2)), 0)
    393395        sage: normalize_profile((lambda n: 0, lambda n: 2), precision=4, p=11)
    394         (((0, 0, 0), (2, 2, 2)), +Infinity)
     396        (((0, 0, 0), ()), +Infinity)
    395397
    396398    As at the prime 2, negative numbers in the first component are
    397     converted to zeroes.  Numbers in the second component are forced
    398     to lie between 1 and 2: numbers larger than 2 get converted to 2,
    399     etc. ::
     399    converted to zeroes.  Numbers in the second component must be
     400    either 1 and 2, or else an error is raised::
    400401
    401         sage: normalize_profile((lambda n: -n, lambda n: 2+n), precision=4, p=11)
    402         (((0, 0, 0), (2, 2, 2)), +Infinity)
     402        sage: normalize_profile((lambda n: -n, lambda n: 1), precision=4, p=11)
     403        (((0, 0, 0), (1, 1, 1)), +Infinity)
     404        sage: normalize_profile([[0,0,0], [1,2,3,2,1]], p=11)
     405        Traceback (most recent call last):
     406        ...
     407        ValueError: Invalid profile
    403408    """
    404409    from inspect import isfunction
    405410    from sage.rings.infinity import Infinity
    def normalize_profile(profile, precision 
    488493                k = tuple(k)
    489494            elif isfunction(k):
    490495                # k is a function: turn it into a tuple.
    491                 k = [max(1, min(2, k(i))) for i in range(precision-1)]
    492                 k = tuple(k)
     496                k = tuple([k(i) for i in range(precision-1)])
     497            # Remove trailing ones from k if truncation_type is 'zero',
     498            # remove trailing twos if truncation_type is 'Infinity'.
     499            if truncation_type == 0:
     500                while len(k) > 0 and k[-1] == 1:
     501                    k = k[:-1]
     502            else:
     503                while len(k) > 0 and k[-1] == 2:
     504                    k = k[:-1]
    493505            new_profile = (e, k)
    494506        if is_valid_profile(new_profile, truncation_type, p):
    495507            return new_profile, truncation_type