Skip to content

Commit

Permalink
Merge pull request symengine#289 from isuruf/int
Browse files Browse the repository at this point in the history
Fix converting large Integers to python ints
  • Loading branch information
isuruf authored Aug 4, 2019
2 parents 13cedfa + 61e3b69 commit d21ec88
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 22 deletions.
25 changes: 12 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ addons:
- g++-4.7

env:
global:
- secure: "gdcw4nEd06q+E8yZkaqtgexX4kHgKqFuTRHKyx5QJBW/q+vL94ntbFft7jZssXEmFtijyjjNbhTucwcSaXIAP1X4tct5kHcuBH5LVvCxi7r4NfhERJDE/EAOS4xbQJ9IUHjdBWCWTCCiXpg0bG/1YcCVsppcKi2Z864CBDpa8DPuDUtyxFpkHW7PdALitLWDIIkIJU817JqYlJKcnR62OYGdVlHiUHhSGI6JKnqou7gf6fgXLsXNnUDUeWS+9vElOTV6OU7vHbG1Ka2N2vwpLIoBoSrw80EDAyP+QqqBRP1B2CyPGvEu9lTyqxUVkb0DAjsltn1bt36UVIb+l55B1JWPSriI3xiVstXa9D2Xb1uth9h712c0cwXw9LJ7YsXEcwdAfCRF/Zywt9IdwCWlnRkiGD2fOHPBkjpXVAV+2xFSD8WLuV6hc3xZjFLvzRxiDZ1CYSY+Wh6IxOp7411GT3BgtH0kEXb5+cg55cjPxgWAWOsU1WkrrWMl9DngeiWNwGZQCU+UkPB1WaITtA6JbFdEZPinZFWtYPMj6ZdA+ARkmwQnG6Y6sg37Zq76n8mDjLb5ECLXq22uRLaATl8lRLOaNDStg9PSxtVGON65NeesPMRFRC7+2ySQ/8KqsZZubHk7SoSY8APP+5mqzBuMbt2bnBVLmf04TI7RnVPSZ6A="

## All these variables are sent into the bin/test_travis.sh script. See this
## script to know how they are used. Most of them are just passed to cmake,
## so if they are not set, cmake will use a default value. For the rest, the
Expand All @@ -27,7 +24,7 @@ env:
## executed.
matrix:
# Debug builds:
- BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="2.7" TRIGGER_FEEDSTOCK="yes" TEST_SYMPY="yes"
- BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="2.7" TEST_SYMPY="yes"
- BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="3.6" TEST_SYMPY="yes"

# Release builds:
Expand All @@ -53,24 +50,26 @@ matrix:
packages:
- binutils-dev
- g++-4.8
- env: BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="3.5" WITH_LLVM="3.8" WITH_SCIPY="yes" BUILD_SHARED_LIBS="yes"
- env: BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="3.5" BUILD_SHARED_LIBS="yes"
compiler: clang
os: linux
- env: BUILD_TYPE="Release" PYTHON_VERSION="2.7" WITH_NUMPY="no"
compiler: clang
os: linux
- 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"
compiler: gcc
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-8
packages:
- clang
- g++-4.8
- libstdc++-4.8-dev
- binutils-dev
- env: BUILD_TYPE="Release" PYTHON_VERSION="2.7" WITH_NUMPY="no"
compiler: clang
os: linux
- env: BUILD_TYPE="Debug" PYTHON_VERSION="3.6" WITH_SYMPY="no"
compiler: gcc
os: linux
- env: BUILD_TYPE="Debug" PYTHON_VERSION="2.7"
- llvm-8-dev
- env: BUILD_TYPE="Debug" PYTHON_VERSION="2.7" WITH_LLVM="5.0" WITH_SCIPY="yes"
compiler: clang
os: osx
- env: BUILD_TYPE="Release" PYTHON_VERSION="3.5" WITH_NUMPY="no"
Expand Down
3 changes: 1 addition & 2 deletions bin/install_travis.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env bash

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

export conda_pkgs="python=${PYTHON_VERSION} pip cython nose pytest"
export conda_pkgs="python=${PYTHON_VERSION} pip cython pytest gmp mpfr"

if [[ "${WITH_SYMPY}" != "no" ]]; then
export conda_pkgs="${conda_pkgs} sympy";
Expand Down
4 changes: 1 addition & 3 deletions bin/test_travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ set -x
python setup.py install build_ext --inplace --symengine-dir=$our_install_dir

# Test python wrappers
nosetests -v
# If switching to py.test, the following collects correct tests:
#py.test -v $PYTHON_SOURCE_DIR/symengine/tests/test_*.py
py.test -s -v $PYTHON_SOURCE_DIR/symengine/tests/test_*.py
mkdir -p empty && cd empty
python $PYTHON_SOURCE_DIR/bin/test_python.py
cd ..
Expand Down
2 changes: 1 addition & 1 deletion symengine/lib/symengine_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ class Integer(Rational):
return sage.Integer(str(self))

def __int__(Basic self):
return symengine.mp_get_si(deref(symengine.rcp_static_cast_Integer(self.thisptr)).as_integer_class())
return int(str(self))

@property
def p(self):
Expand Down
6 changes: 4 additions & 2 deletions symengine/tests/test_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ def test_integer():


def test_integer_long():
i = Integer(123434444444444444444)
assert str(i) == "123434444444444444444"
py_int = 123434444444444444444
i = Integer(py_int)
assert str(i) == str(py_int)
assert int(i) == py_int


def test_integer_string():
Expand Down
2 changes: 1 addition & 1 deletion symengine_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.4.0
c66b8c50bb481c51ce128b768b056454aa6dc67a

0 comments on commit d21ec88

Please sign in to comment.