Opened 7 years ago

Closed 4 years ago

#13386 closed defect (duplicate)

comparison of Sage integer with Numpy integer

Reported by: vdelecroix Owned by: vdelecroix
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: basic arithmetic Keywords: integer, numpy, comparison
Cc: Merged in:
Authors: Reviewers: Jeroen Demeyer
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by vdelecroix)

We correct

sage: import numpy
sage: numpy.int32(123) == 123
True
sage: 123 == numpy.int32(123)
False

The change causes numpy to be loaded on startup. It may be hard to not do it as there are many integer comparisons on startup (see see nbruin comment).

Attachments (2)

trac_13386-integer_numpy_comparisons.patch (2.8 KB) - added by vdelecroix 7 years ago.
trac_13386-avoid_numpy_loading.patch (1.7 KB) - added by whuss 7 years ago.

Download all attachments as: .zip

Change History (14)

Changed 7 years ago by vdelecroix

comment:1 Changed 7 years ago by vdelecroix

  • Status changed from new to needs_review

comment:2 Changed 7 years ago by nbruin

Your patch causes numpy to be loaded upon sage startup. According to #11714 that isn't done.

comment:3 Changed 7 years ago by vdelecroix

  • Dependencies set to #11714
  • Description modified (diff)

comment:4 Changed 7 years ago by kcrisman

  • Status changed from needs_review to needs_info

I claim "needs info" since it isn't clear that we want to go back to importing numpy on startup if a lot of work went into that ticket.

Changed 7 years ago by whuss

comment:5 Changed 7 years ago by whuss

I just added a patch, which avoids the loading of numpy during startup.

Unfortunately comparison with numpy types fail for all rings:

sage: import numpy
sage: QQ(1) == numpy.int32(1)
False
sage: QQbar(1) == numpy.int32(1)
False
sage: AA(1) == numpy.int32(1)
False
sage: RR(1) == numpy.int32(1)
False
sage: RDF(1) == numpy.int32(1)
False
sage: RIF(1) == numpy.int32(1)
False
Last edited 7 years ago by whuss (previous) (diff)

comment:6 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:7 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:8 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:9 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:10 Changed 5 years ago by vdelecroix

  • Authors Vincent Delecroix deleted
  • Dependencies #11714 deleted
  • Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
  • Status changed from needs_info to needs_review

Hello,

I propose to close this as duplicate since #18076 fixes the issue

sage: import numpy
sage: 123 == numpy.int32(123)
True

Vincent

comment:11 Changed 4 years ago by jdemeyer

  • Reviewers set to Jeroen Demeyer
  • Status changed from needs_review to positive_review

comment:12 Changed 4 years ago by vbraun

  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.