~ubuntu-branches/ubuntu/raring/ffc/raring

« back to all changes in this revision

Viewing changes to test/regression/test.py

  • Committer: Package Import Robot
  • Author(s): Johannes Ring
  • Date: 2011-10-26 17:52:20 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20111026175220-ope1dzqv4jn2b8pq
Tags: 1.0-beta2-1
* New upstream release. This release includes some performance
  improvements for evaluating basis functions. It also adds support
  for Bessel functions and error functions.
* debian/control: Bump version numbers for python-ufc, python-fiat,
  python-instant, and python-ufl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
# FIXME: and DOLFIN wrappers.
36
36
 
37
37
import os, sys, shutil, difflib
38
 
from numpy import array, shape, abs, max
 
38
from numpy import array, shape, abs, max, isnan
39
39
from ffc.log import begin, end, info, info_red, info_green, info_blue
40
40
from ufctest import generate_test_code
41
41
from instant.output import get_status_output
175
175
    # Get UFC flags
176
176
    ufc_cflags = get_status_output("pkg-config --cflags ufc-1")[1].strip()
177
177
 
 
178
    # Get Boost dir (code copied from ufc/src/utils/python/ufc_utils/build.py)
 
179
    # Set a default directory for the boost installation
 
180
    if sys.platform == "darwin":
 
181
        # Use MacPorts as default
 
182
        default = os.path.join(os.path.sep, "opt", "local")
 
183
    else:
 
184
        default = os.path.join(os.path.sep, "usr")
 
185
 
 
186
    # If BOOST_DIR is not set use default directory
 
187
    boost_inc_dir = ""
 
188
    boost_lib_dir = ""
 
189
    boost_dir = os.getenv("BOOST_DIR", default)
 
190
    boost_is_found = False
 
191
    for inc_dir in ["", "include"]:
 
192
        if os.path.isfile(os.path.join(boost_dir, inc_dir, "boost", "version.hpp")):
 
193
            boost_inc_dir = os.path.join(boost_dir, inc_dir)
 
194
            break
 
195
    for lib_dir in ["", "lib"]:
 
196
        if os.path.isfile(os.path.join(boost_dir, lib_dir, "libboost_math_tr1.so")) or\
 
197
           os.path.isfile(os.path.join(boost_dir, lib_dir, "libboost_math_tr1.dylib")):
 
198
            boost_lib_dir = os.path.join(boost_dir, lib_dir)
 
199
            break
 
200
    if boost_inc_dir != "" and boost_lib_dir != "":
 
201
        boost_is_found = True
 
202
 
 
203
    if not boost_is_found:
 
204
        raise OSError, """The Boost library was not found.
 
205
If Boost is installed in a nonstandard location,
 
206
set the environment variable BOOST_DIR.
 
207
"""
 
208
 
 
209
    ufc_cflags += " -I%s -L%s" % (boost_inc_dir, boost_lib_dir)
 
210
 
178
211
    # Set compiler options
179
212
    if bench > 0:
180
213
        info("Benchmarking activated")
193
226
 
194
227
        # Compile test code
195
228
        prefix = f.split(".h")[0]
196
 
        command = "g++ %s -o %s.bin %s.cpp" % (compiler_options, prefix, prefix)
 
229
        command = "g++ %s -o %s.bin %s.cpp -lboost_math_tr1" % (compiler_options, prefix, prefix)
197
230
        ok = run_command(command)
198
231
 
199
232
        # Check status
283
316
 
284
317
            # Check that values match to within tolerance
285
318
            diff = max(abs(old_values - new_values))
286
 
            if diff > tolerance:
 
319
            if diff > tolerance or isnan(diff):
287
320
                if ok: log_error("\n" + header + "\n" + len(header)*"-")
288
321
                log_error("%s: values differ, error = %g (tolerance = %g)" % (key, diff, tolerance))
289
322
                log_error("  old = " + " ".join("%.16g" % v for v in old_values))