Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make comparisons is_one, and is_zero consistent for polys #168

Merged
merged 1 commit into from
Jul 22, 2024

Commits on Jul 22, 2024

  1. Make comparisons is_one, and is_zero consistent for polys

    nmod_poly previously compared unequal to an integer e.g.
    
      >>> nmod_poly([1], 3) == 1
      False
    
    This was inconsistent with all other poly types and als with nmod. The
    change here makes it so that nmod_poly can compare equal with anything
    that can be coerced by the nmod constructor.
    
    Also renamed all __nonzero__ methods to __bool__ (Python 3 vs 2)
    
    Also added is_one and is_zero to all *_poly and *_mpoly types because
    this was inconsistent before.
    
    Currently fmpz_mod has both is_one and is_zero but other scalar types do
    not. I'm not sure whether it makes sense to add them just for overall
    consistency. No matrix types have is_zero or is_one.
    
    We currently have:
    
      >>> nmod(1, 3) == fmpz(1)
      False
    
      >>> nmod(1, 3) == 1
      True
    
    So an exception is made here for int but comparison with fmpz is not
    allowed. The change here does the same thing for nmod_poly. It will
    compare unequal to fmpz_poly but will compare equal to an int or an
    nmod with the same modulus.
    oscarbenjamin committed Jul 22, 2024
    Configuration menu
    Copy the full SHA
    f24f9aa View commit details
    Browse the repository at this point in the history