Skip to content
Snippets Groups Projects
Commit 04f112f8 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

PyCore tests: configure path in CMake, not in Py

parent 4e5c7cb2
No related branches found
No related tags found
No related merge requests found
...@@ -5,18 +5,17 @@ ...@@ -5,18 +5,17 @@
set(OUTPUT_DIR ${TEST_OUTPUT_DIR_PY_CORE}) set(OUTPUT_DIR ${TEST_OUTPUT_DIR_PY_CORE})
file(MAKE_DIRECTORY ${OUTPUT_DIR}) file(MAKE_DIRECTORY ${OUTPUT_DIR})
file(GLOB sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.py") file(GLOB tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.py")
list(REMOVE_ITEM tests utils.py)
if(NOT BORNAGAIN_TIFF_SUPPORT) if(NOT BORNAGAIN_TIFF_SUPPORT)
list(REMOVE_ITEM sources "intensitydata_io_tiff.py") list(REMOVE_ITEM tests "intensitydata_io_tiff.py")
endif() endif()
foreach(_src ${sources}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/utils.py ${OUTPUT_DIR}/utils.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${_src} ${OUTPUT_DIR}/${_src} @ONLY)
endforeach()
set(tests ${sources})
list(REMOVE_ITEM tests utils.py)
foreach(_test ${tests}) foreach(_test ${tests})
add_test(PyCore.${_test} ${Python3_EXECUTABLE} ${OUTPUT_DIR}/${_test}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${_test} ${OUTPUT_DIR}/${_test} COPYONLY)
add_test(PyCore.${_test}
env PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
${Python3_EXECUTABLE} ${OUTPUT_DIR}/${_test})
endforeach() endforeach()
import numpy, os, sys, unittest import numpy, os, sys, unittest
sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
import bornagain as ba import bornagain as ba
......
# Functional test: tests of IntensityData object # Functional test: tests of IntensityData object
import numpy, os, sys, unittest import numpy, os, sys, unittest
sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
import bornagain as ba import bornagain as ba
......
# Functional test: tests of IO operations with the IntensityData object # Functional test: tests of IO operations with the IntensityData object
import math, numpy, os, sys, time, unittest import math, numpy, os, sys, time, unittest
sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
import bornagain as ba import bornagain as ba
from bornagain import deg, deg2rad, rad2deg from bornagain import deg, deg2rad, rad2deg
......
# Functional test: tests of IO operations with the IntensityData object # Functional test: tests of IO operations with the IntensityData object
import math, numpy, os, sys, time, unittest import math, numpy, os, sys, time, unittest
sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
import bornagain as ba import bornagain as ba
......
import numpy, os, sys, unittest import numpy, os, sys, unittest
sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
import bornagain as ba import bornagain as ba
from bornagain import nm from bornagain import nm
......
import sys, unittest, ctypes import sys, unittest, ctypes
import inspect import inspect
sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
import bornagain as ba import bornagain as ba
initial_width = 42 initial_width = 42
......
import numpy, os, sys, unittest import numpy, os, sys, unittest
sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
import bornagain as ba import bornagain as ba
......
...@@ -3,8 +3,6 @@ Collection of utils for testing ...@@ -3,8 +3,6 @@ Collection of utils for testing
""" """
import gzip, numpy, sys, os import gzip, numpy, sys, os
sys.path.append("@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
import bornagain as ba import bornagain as ba
from bornagain import deg, angstrom from bornagain import deg, angstrom
...@@ -42,39 +40,7 @@ def get_reference_data(filename): ...@@ -42,39 +40,7 @@ def get_reference_data(filename):
os.path.join(REFERENCE_DIR, filename)) os.path.join(REFERENCE_DIR, filename))
def get_simulation_MiniGISAS(sample=None): def get_simulation_MiniGISAS(sample):
simulation = ba.GISASSimulation() detector = ba.SphericalDetector(25, -2*deg, 2*deg, 25, 0*deg, 2*deg)
simulation.setDetectorParameters(25, -2.0*deg, 2.0*deg, 25, 0.0*deg, beam = ba.Beam(1., 1*angstrom, ba.Direction(0.2*deg, 0))
2.0*deg) return ba.GISASSimulation(beam, sample, detector)
simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg)
if sample:
simulation.setSample(sample)
return simulation
def get_simulation_BasicGISAS(sample=None):
simulation = ba.GISASSimulation()
simulation.setDetectorParameters(100, 0.0*deg, 2.0*deg, 100, 0.0*deg,
2.0*deg)
simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg)
if sample:
simulation.setSample(sample)
return simulation
def plot_int(intensity):
import matplotlib, pylab
data = intensity.getArray() + 1
# data = numpy.abs(intensity.getArray())
phi_min = rad2deg(intensity.axis(0).lowerBound())
phi_max = rad2deg(intensity.axis(0).upperBound())
alpha_min = rad2deg(intensity.axis(1).lowerBound())
alpha_max = rad2deg(intensity.axis(1).upperBound())
im = pylab.imshow(data,
norm=matplotlib.colors.LogNorm(),
extent=[phi_min, phi_max, alpha_min, alpha_max])
cb = pylab.colorbar(im)
cb.set_label(r'Intensity (arb. u.)', size=16)
pylab.xlabel(r'$\phi_f (^{\circ})$', fontsize=16)
pylab.ylabel(r'$\alpha_f (^{\circ})$', fontsize=16)
pylab.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment