The code above will compute A1-degrees of endomorphisms of affine space.
The previous bug for the local degree computation has been fixed. Thanks to Irena Swanson for suggesting the fix, as well as to Kyle Ormsby for communicating the suggestion to us.