Skip to content

Commit d21ec88

Browse files
authored
Merge pull request #289 from isuruf/int
Fix converting large Integers to python ints
2 parents 13cedfa + 61e3b69 commit d21ec88

File tree

6 files changed

+20
-22
lines changed

6 files changed

+20
-22
lines changed

.travis.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ addons:
1616
- g++-4.7
1717

1818
env:
19-
global:
20-
- secure: "gdcw4nEd06q+E8yZkaqtgexX4kHgKqFuTRHKyx5QJBW/q+vL94ntbFft7jZssXEmFtijyjjNbhTucwcSaXIAP1X4tct5kHcuBH5LVvCxi7r4NfhERJDE/EAOS4xbQJ9IUHjdBWCWTCCiXpg0bG/1YcCVsppcKi2Z864CBDpa8DPuDUtyxFpkHW7PdALitLWDIIkIJU817JqYlJKcnR62OYGdVlHiUHhSGI6JKnqou7gf6fgXLsXNnUDUeWS+9vElOTV6OU7vHbG1Ka2N2vwpLIoBoSrw80EDAyP+QqqBRP1B2CyPGvEu9lTyqxUVkb0DAjsltn1bt36UVIb+l55B1JWPSriI3xiVstXa9D2Xb1uth9h712c0cwXw9LJ7YsXEcwdAfCRF/Zywt9IdwCWlnRkiGD2fOHPBkjpXVAV+2xFSD8WLuV6hc3xZjFLvzRxiDZ1CYSY+Wh6IxOp7411GT3BgtH0kEXb5+cg55cjPxgWAWOsU1WkrrWMl9DngeiWNwGZQCU+UkPB1WaITtA6JbFdEZPinZFWtYPMj6ZdA+ARkmwQnG6Y6sg37Zq76n8mDjLb5ECLXq22uRLaATl8lRLOaNDStg9PSxtVGON65NeesPMRFRC7+2ySQ/8KqsZZubHk7SoSY8APP+5mqzBuMbt2bnBVLmf04TI7RnVPSZ6A="
21-
2219
## All these variables are sent into the bin/test_travis.sh script. See this
2320
## script to know how they are used. Most of them are just passed to cmake,
2421
## so if they are not set, cmake will use a default value. For the rest, the
@@ -27,7 +24,7 @@ env:
2724
## executed.
2825
matrix:
2926
# Debug builds:
30-
- BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="2.7" TRIGGER_FEEDSTOCK="yes" TEST_SYMPY="yes"
27+
- BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="2.7" TEST_SYMPY="yes"
3128
- BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="3.6" TEST_SYMPY="yes"
3229

3330
# Release builds:
@@ -53,24 +50,26 @@ matrix:
5350
packages:
5451
- binutils-dev
5552
- g++-4.8
56-
- env: BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="3.5" WITH_LLVM="3.8" WITH_SCIPY="yes" BUILD_SHARED_LIBS="yes"
53+
- env: BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="3.5" BUILD_SHARED_LIBS="yes"
54+
compiler: clang
55+
os: linux
56+
- env: BUILD_TYPE="Release" PYTHON_VERSION="2.7" WITH_NUMPY="no"
5757
compiler: clang
5858
os: linux
59+
- env: BUILD_TYPE="Debug" PYTHON_VERSION="3.6" WITH_SYMPY="no" WITH_LLVM="8.0" WITH_SCIPY="yes" CC="gcc-4.8" CXX="g++-4.8"
60+
compiler: gcc
61+
os: linux
5962
addons:
6063
apt:
6164
sources:
6265
- ubuntu-toolchain-r-test
66+
- llvm-toolchain-trusty-8
6367
packages:
64-
- clang
68+
- g++-4.8
6569
- libstdc++-4.8-dev
6670
- binutils-dev
67-
- env: BUILD_TYPE="Release" PYTHON_VERSION="2.7" WITH_NUMPY="no"
68-
compiler: clang
69-
os: linux
70-
- env: BUILD_TYPE="Debug" PYTHON_VERSION="3.6" WITH_SYMPY="no"
71-
compiler: gcc
72-
os: linux
73-
- env: BUILD_TYPE="Debug" PYTHON_VERSION="2.7"
71+
- llvm-8-dev
72+
- env: BUILD_TYPE="Debug" PYTHON_VERSION="2.7" WITH_LLVM="5.0" WITH_SCIPY="yes"
7473
compiler: clang
7574
os: osx
7675
- env: BUILD_TYPE="Release" PYTHON_VERSION="3.5" WITH_NUMPY="no"

bin/install_travis.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/usr/bin/env bash
22

33
# symengine's bin/install_travis.sh will install miniconda
4-
conda update -q -n root conda
54

6-
export conda_pkgs="python=${PYTHON_VERSION} pip cython nose pytest"
5+
export conda_pkgs="python=${PYTHON_VERSION} pip cython pytest gmp mpfr"
76

87
if [[ "${WITH_SYMPY}" != "no" ]]; then
98
export conda_pkgs="${conda_pkgs} sympy";

bin/test_travis.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ set -x
99
python setup.py install build_ext --inplace --symengine-dir=$our_install_dir
1010

1111
# Test python wrappers
12-
nosetests -v
13-
# If switching to py.test, the following collects correct tests:
14-
#py.test -v $PYTHON_SOURCE_DIR/symengine/tests/test_*.py
12+
py.test -s -v $PYTHON_SOURCE_DIR/symengine/tests/test_*.py
1513
mkdir -p empty && cd empty
1614
python $PYTHON_SOURCE_DIR/bin/test_python.py
1715
cd ..

symengine/lib/symengine_wrapper.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ class Integer(Rational):
17221722
return sage.Integer(str(self))
17231723

17241724
def __int__(Basic self):
1725-
return symengine.mp_get_si(deref(symengine.rcp_static_cast_Integer(self.thisptr)).as_integer_class())
1725+
return int(str(self))
17261726

17271727
@property
17281728
def p(self):

symengine/tests/test_number.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ def test_integer():
1515

1616

1717
def test_integer_long():
18-
i = Integer(123434444444444444444)
19-
assert str(i) == "123434444444444444444"
18+
py_int = 123434444444444444444
19+
i = Integer(py_int)
20+
assert str(i) == str(py_int)
21+
assert int(i) == py_int
2022

2123

2224
def test_integer_string():

symengine_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.4.0
1+
c66b8c50bb481c51ce128b768b056454aa6dc67a

0 commit comments

Comments
 (0)