id	summary	reporter	owner	description	type	status	priority	milestone	component	resolution	keywords	cc	work_issues	upstream	reviewer	author	merged	dependencies	stopgaps
11832	bug fixes for profile functions for the Steenrod algebra	jhpalmieri	AlexGhitza	"Profile functions for the Steenrod algebra, especially at odd primes, are a little buggy: 
{{{
sage: P3 = SteenrodAlgebra(p=3, profile=(lambda n: Infinity, lambda n: 1))
sage: P3._has_nontrivial_profile()
False
}}}
This should be `True`.
{{{
sage: P3._profile
((+Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity, +Infinity), (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1))
}}}
All of the ""Infinity""s should be omitted.
{{{
sage: SteenrodAlgebra(p=3, profile=((3,2,1), lambda n: 1))
Traceback (most recent call last)
...
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'
}}}
This error shouldn't happen.

These bugs are in the function `steenrod_algebra_misc.normalize_profile_function` and in the method `_has_nontrivial_profile` in `steenrod_algebra.SteenrodAlgebra_generic`.  The attached patch fixes these, and it also speeds up `steenrod_algebra_misc.is_valid_profile:
{{{
sage: sage: from sage.algebras.steenrod.steenrod_algebra_misc import is_valid_profile, normalize_profile
sage: pro = normalize_profile(lambda n: n)
sage: timeit('is_valid_profile(pro[0], pro[1], p=2)') # before
5 loops, best of 3: 334 ms per loop

sage: timeit('is_valid_profile(pro[0], pro[1], p=2)') # after
125 loops, best of 3: 3.99 ms per loop
}}}
"	defect	closed	critical	sage-5.0	algebra	fixed				N/A	William Stein	John Palmieri	sage-5.0.beta12		#12700
