GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Tests for what kind of an element something is should test the parent · Issue #803 · sagemath/sage

Tests for what kind of an element something is should test the parent #803

New issue
Copy link
New issue
Copy link
Closed
Closed
Tests for what kind of an element something is should test the parent#803
Copy link
Labels
c: basic arithmeticr: wontfixt: bug

Description

@roed314
roed314
opened on Oct 3, 2007
Issue body actions

Calls like:

algebras/algebra_order.py:        elif isinstance(x, RingElement) and x in self.base_ring():
algebras/algebra_order_ideal.py:        elif isinstance(x, RingElement) and x in self.base_ring():
algebras/free_algebra_quotient_element.py:        elif isinstance(x, RingElement) and not isinstance(x, AlgebraElement) and x in R:
rings/infinity.py:        elif isinstance(x, RingElement) or isinstance(x, (int,long,float,complex)):
rings/infinity.py:        elif isinstance(x, RingElement):

should actually be checking to see if the parents are of the appropriate type. The element types are not always reliable: parents more accurately reflect the mathematical structure (mostly because they can have multiple inheritance).

There may be more instances in addition to those above (I just ran search_src("isinstance(x, RingElement)"))

Component: basic arithmetic

Reviewer: Vincent Delecroix

Issue created by migration from https://trac.sagemath.org/ticket/803

Activity

  1. roed314
    added this to the sage-5.11 milestone on Oct 3, 2007
  2. roed314
    added
    c: basic arithmetic
    on Oct 3, 2007
  3. williamstein commented on Feb 25, 2008

    @williamstein
    williamstein
    on Feb 25, 2008
    Contributor
    More actions
    comment:1

    I'm dubious:

    My immediate thought when looking at #803 is that it is the wrong
    idea in the first place. If I had looked at #803 before
    now I would have considered marking it "invalid".

    There are individual instances that involve "isinstance" that were
    perhaps badly written. E.g., the first example:

            elif isinstance(x, RingElement) and x in self.base_ring():
                return True
    

    Here I think the original author (David Kohel) may have written
    this at a time when "in" could raise an exception if x isn't
    a RingElement. That's no longer the case, so in this particular
    example the right fix is I think to put:

            elif x in self.base_ring():
                return True
    

    In probably hundreds of other cases the use of isinstance in
    Sage is exactly right. In some cases it could be improved,
    but how will depend in each case on understanding the code.

  4. jdemeyer
    modified the milestones: sage-5.11, sage-5.12 on Aug 13, 2013
  5. sagetrac-vbraun-spam
    modified the milestones: sage-6.1, sage-6.2 on Jan 30, 2014
  6. sagetrac-vbraun-spam
    modified the milestones: sage-6.2, sage-6.3 on May 6, 2014
  7. sagetrac-vbraun-spam
    modified the milestones: sage-6.3, sage-6.4 on Aug 10, 2014
  8. mezzarobba
    added
    s: needs review
    on Apr 13, 2015
  9. mezzarobba
    removed this from the sage-6.4 milestone on Apr 13, 2015
  10. videlec commented on Apr 14, 2015

    @videlec
    videlec
    on Apr 14, 2015
    Contributor
    More actions

    Reviewer: Vincent Delecroix

  11. videlec
    added
    s: positive review
    and removed
    s: needs review
    on Apr 14, 2015
  12. vbraun
    added
    r: wontfix
    and removed
    p: minor / 4
    on Apr 14, 2015
  13. vbraun
    closed this as completedon Apr 14, 2015
  14. vbraun
    added 2 commits that reference this issue on Nov 10, 2026

    sagemathgh-43136: build(deps): bump softprops/action-gh-release from …

    5a69445

    89e7ac1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: basic arithmeticr: wontfixt: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.