There will be maintenance performed on git.ligo.org, chat.ligo.org, containers.lig.org, and docs.ligo.org starting at 9am PDT on Tuesday 18th August 2020. There will be an extremely small period of downtime at the start of the maintenance window as various services are restarted. Please address any comments, questions, or concerns to computing-help@igwn.org.

Commit 23907247 authored by Karl Wette's avatar Karl Wette Committed by Adam Mercer

lalsuite_swig.m4: require SWIG >= 3.0.9 if Python >= 3.0.0

- Revert changes to SWIGTestLALPython.py from commit
  bd0474c650edcd6b7d6ff5c974a95a41edea95f4
- Ref #5735
Original: 7e71dcb5ec4ac78dea377b2ed3c213cde0e522d4
parent 87ef9802
......@@ -2,7 +2,7 @@
# lalsuite_swig.m4 - SWIG configuration
# Author: Karl Wette, 2011--2017
#
# serial 101
# serial 102
AC_DEFUN([_LALSUITE_CHECK_SWIG_VERSION],[
# $0: check the version of $1, and store it in ${swig_version}
......@@ -418,6 +418,19 @@ AC_DEFUN([LALSUITE_USE_SWIG_PYTHON],[
# $0: configure SWIG Python bindings
LALSUITE_USE_SWIG_LANGUAGE([Python],[C],[
# check Python version
AC_MSG_CHECKING([${PYTHON} version])
AS_IF([test "x${PYTHON_VERSION}" = x],[
AC_MSG_ERROR([could not determine ${PYTHON} version])
])
AC_MSG_RESULT([${PYTHON_VERSION}])
LALSUITE_VERSION_COMPARE([${PYTHON_VERSION}],[>=],[3.0.0],[
LALSUITE_VERSION_COMPARE([${swig_min_version}],[<],[3.0.9],[
swig_min_version=3.0.9
swig_min_version_info="for Python version ${PYTHON_VERSION}"
])
])
# check for distutils
AC_MSG_CHECKING([for distutils])
cat <<EOD | ${PYTHON} - 2>/dev/null
......
......@@ -23,10 +23,6 @@ lal_c_si = lal.C_SI
lal_180_pi = lal.LAL_180_PI
print("PASSED module load")
# FIXME: delete this when we can depend on swig >= 3.0.9,
# which fixed https://github.com/swig/swig/pull/617
swig_division_coercion_works = sys.version_info.major <= 2 or lal.swig_version >= 0x030009
# check memory allocation
print("checking memory allocation ...")
if not lal.NoDebug:
......@@ -1054,25 +1050,21 @@ assert(t2 + 5.5 >= t1 and t2 + 3 != t2)
assert(is_value_and_type(t2 - 5, t0, LIGOTimeGPS))
assert(is_value_and_type(t1 * 3, 31.5, LIGOTimeGPS))
assert(is_value_and_type(3 * t1, 31.5, LIGOTimeGPS))
if swig_division_coercion_works: # FIXME: https://github.com/swig/swig/pull/617
assert(is_value_and_type(t2 / 2.5, 2, LIGOTimeGPS))
assert(is_value_and_type(21 / t1, 2, LIGOTimeGPS))
assert(is_value_and_type(t2 / 2.5, 2, LIGOTimeGPS))
assert(is_value_and_type(21 / t1, 2, LIGOTimeGPS))
assert(is_value_and_type(t1 + t2, 15.5, LIGOTimeGPS))
assert(is_value_and_type(t1 - t2, 5.5, LIGOTimeGPS))
assert(is_value_and_type(t1 * t2, 52.5, LIGOTimeGPS))
assert(is_value_and_type(t2 * t1, 52.5, LIGOTimeGPS))
if swig_division_coercion_works: # FIXME: https://github.com/swig/swig/pull/617
assert(is_value_and_type(t1 / t2, 2.1, LIGOTimeGPS))
assert(is_value_and_type(t1 / t2, 2.1, LIGOTimeGPS))
assert(is_value_and_type(t1 % t2, 0.5, LIGOTimeGPS))
assert(t1 > t2 and t2 < t1 and t1 >= t2 and t2 <= t1)
if swig_division_coercion_works: # FIXME: https://github.com/swig/swig/pull/617
assert(LIGOTimeGPS(333333333,333333333) == LIGOTimeGPS(1000000000) / 3)
assert(LIGOTimeGPS(666666666,666666667) == LIGOTimeGPS(2000000000) / 3)
assert(LIGOTimeGPS(333333333,333333333) == LIGOTimeGPS(1000000000) / 3)
assert(LIGOTimeGPS(666666666,666666667) == LIGOTimeGPS(2000000000) / 3)
assert(LIGOTimeGPS("-62997760.825036067") == LIGOTimeGPS("-47044285.062262587") - LIGOTimeGPS("15953475.76277348"))
assert(LIGOTimeGPS("-6542354.389038577") == LIGOTimeGPS("-914984.929117316") * 7.1502318572066237)
assert(LIGOTimeGPS("-6542354.389038577") == 7.1502318572066237 * LIGOTimeGPS("-914984.929117316"))
if swig_division_coercion_works: # FIXME: https://github.com/swig/swig/pull/617
assert(LIGOTimeGPS("-127965.770535834") == LIGOTimeGPS("-914984.929117316") / 7.1502318572066237)
assert(LIGOTimeGPS("-127965.770535834") == LIGOTimeGPS("-914984.929117316") / 7.1502318572066237)
t1 += 812345667.75
assert(str(t1) == "812345678.25")
assert(type(eval(repr(t1))) is type(t1))
......@@ -1124,9 +1116,8 @@ assert(is_value_and_type(tsw - tmy, tsw - tsw, LIGOTimeGPS))
assert(is_value_and_type(tmy - tsw, tsw - tsw, LIGOTimeGPS))
assert(is_value_and_type(tsw * tmy, tsw * tsw, LIGOTimeGPS))
assert(is_value_and_type(tmy * tsw, tsw * tsw, LIGOTimeGPS))
if swig_division_coercion_works: # FIXME: https://github.com/swig/swig/pull/617
assert(is_value_and_type(tsw / tmy, tsw / tsw, LIGOTimeGPS))
assert(is_value_and_type(tmy / tsw, tsw / tsw, LIGOTimeGPS))
assert(is_value_and_type(tsw / tmy, tsw / tsw, LIGOTimeGPS))
assert(is_value_and_type(tmy / tsw, tsw / tsw, LIGOTimeGPS))
assert(lal.swig_lal_test_noptrgps(tmy) == lal.swig_lal_test_noptrgps(tsw))
del tsw
lal.CheckMemoryLeaks()
......@@ -1138,9 +1129,8 @@ u1 = lal.Unit("kg m s^-2")
assert(type(lal.Unit(u1)) is lal.Unit)
assert(is_value_and_type(u1, lal.NewtonUnit, lal.Unit))
assert(str(u1) == "m kg s^-2")
if swig_division_coercion_works: # FIXME: https://github.com/swig/swig/pull/617
u2 = lal.MeterUnit * lal.KiloGramUnit / lal.SecondUnit ** 2
assert(is_value_and_type(u2, u1, lal.Unit))
u2 = lal.MeterUnit * lal.KiloGramUnit / lal.SecondUnit ** 2
assert(is_value_and_type(u2, u1, lal.Unit))
u2 = lal.MeterUnit**(1,2) * lal.KiloGramUnit**(1,2) * lal.SecondUnit ** -1
assert(is_value_and_type(u2, u1**(1,2), lal.Unit))
try:
......@@ -1152,25 +1142,24 @@ assert(not expected_exception)
u1 *= lal.MeterUnit
assert(is_value_and_type(u1, lal.JouleUnit, lal.Unit))
assert(repr(u1) == "m^2 kg s^-2")
if swig_division_coercion_works: # FIXME: https://github.com/swig/swig/pull/617
u1 /= lal.SecondUnit
assert(is_value_and_type(u1, lal.WattUnit, lal.Unit))
assert(u1 == "m^2 kg s^-3")
u1 *= 1000
assert(u1 == lal.KiloUnit * lal.WattUnit)
assert(u1 == 1000 * lal.WattUnit)
assert(u1 == lal.WattUnit * 1000)
assert(u1 == lal.MegaUnit / 1000 * lal.WattUnit)
assert(int(u1) == 1000)
u1 /= 10000
assert(u1 == 100 * lal.MilliUnit * lal.WattUnit)
try:
u1 *= 1.234
expected_exception = True
except:
pass
assert(not expected_exception)
assert(u1.norm() == u1)
u1 /= lal.SecondUnit
assert(is_value_and_type(u1, lal.WattUnit, lal.Unit))
assert(u1 == "m^2 kg s^-3")
u1 *= 1000
assert(u1 == lal.KiloUnit * lal.WattUnit)
assert(u1 == 1000 * lal.WattUnit)
assert(u1 == lal.WattUnit * 1000)
assert(u1 == lal.MegaUnit / 1000 * lal.WattUnit)
assert(int(u1) == 1000)
u1 /= 10000
assert(u1 == 100 * lal.MilliUnit * lal.WattUnit)
try:
u1 *= 1.234
expected_exception = True
except:
pass
assert(not expected_exception)
assert(u1.norm() == u1)
del u1
del u2
lal.CheckMemoryLeaks()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment