Commit e21a98ca authored by eric pellegrini's avatar eric pellegrini

Relocated doc build to install stage

Remove Unittest class
parent baff7ea2
......@@ -140,7 +140,7 @@ ci:osx:
allow_failure: false
artifacts:
paths:
- ${CI_PROJECT_DIR}/BuildServer/Unix/Build_macOS
- ${CI_PROJECT_DIR}/build
expire_in: 1 hrs
tags:
- sci
......
......@@ -17,14 +17,14 @@ if sys.platform.startswith('darwin'):
u'LSApplicationCategoryType': u'public.app-category.science'
}
OPTIONS = {
'argv_emulation': False,# has to be False otherwise triggers problems zith wxPython which lose some events that are captured by OS
'argv_emulation': False,# has to be False otherwise triggers problems with wxPython which lose some events that are captured by OS
'iconfile': u'../../MDANSE/GUI/Icons/mdanse.icns',
'excludes': 'PyQt4',
'matplotlib_backends': '-',
'optimize': '1',
'plist': PLIST,
'bdist_base': './Build_macOS/build',
'dist_dir': './Build_macOS/dist',
'bdist_base': '../../../build',
'dist_dir': '../../../dist',
'graph': False,
'xref': False,
'packages' : ["MDANSE","MMTK","Scientific"]
......
......@@ -5,10 +5,6 @@
#############################
rm -rf build
# Create the temporary directory where ScientificPython, MMTK and MDANSE will be installed
rm -rf ${MDANSE_TEMPORARY_INSTALLATION_DIR}
mkdir ${MDANSE_TEMPORARY_INSTALLATION_DIR}
#############################
# BUILDING DEPENDENCIES
#############################
......@@ -61,20 +57,11 @@ echo -e "${BLUE}""Building MDANSE""${NORMAL}"
cd $MDANSE_SOURCE_DIR
# Now build last version and install it
${PYTHONEXE} setup.py build
${PYTHONEXE} setup.py build_api
${PYTHONEXE} setup.py build_help
${PYTHONEXE} setup.py build --build-platlib build/lib --build-scripts build/scripts
status=$?
if [ $status -ne 0 ]; then
echo -e "${RED}" "Failed to build MDANSE""${NORMAL}"
exit $status
fi
${PYTHONEXE} setup.py install --prefix=${MDANSE_TEMPORARY_INSTALLATION_DIR}
status=$?
if [ $status -ne 0 ]; then
echo -e "${RED}" "Failed to install MDANSE""${NORMAL}"
exit $status
fi
rm -rf build
......@@ -5,7 +5,7 @@ export PYTHONEXE=/usr/bin/python
# The sed -i"" is compulsory other crashes on macos
export SED_I_COMMAND='sed -i'
export MDANSE_SOURCE_DIR=$(pwd)
export MDANSE_TEMPORARY_INSTALLATION_DIR=${MDANSE_SOURCE_DIR}/BuildServer/Unix/Build_Debian
export MDANSE_TEMPORARY_INSTALLATION_DIR=${MDANSE_SOURCE_DIR}/build/mdanse
export PYTHONPATH=${MDANSE_TEMPORARY_INSTALLATION_DIR}/lib/python2.7/site-packages/:${PYTHONPATH}
export RED="\\033[1;31m"
export BLUE="\\033[1;34m"
......@@ -14,4 +14,4 @@ export NORMAL="\\033[0m"
# Get revision number from Git
export MDANSE_GIT_CURRENT_COMMIT=$(git rev-parse --short HEAD)
# Get commit branch from Gitlab
export MDANSE_GIT_BRANCH_NAME="$1"
\ No newline at end of file
export MDANSE_GIT_BRANCH_NAME="$1"
......@@ -5,7 +5,7 @@ export PYTHONEXE=/usr/bin/python
# The sed -i"" is compulsory other crashes on macos
export SED_I_COMMAND='sed -i ""'
export MDANSE_SOURCE_DIR=$(pwd)
export MDANSE_TEMPORARY_INSTALLATION_DIR=${MDANSE_SOURCE_DIR}/BuildServer/Unix/Build_macOS
export MDANSE_TEMPORARY_INSTALLATION_DIR=${MDANSE_SOURCE_DIR}/build/osx
export PYTHONPATH=${MDANSE_TEMPORARY_INSTALLATION_DIR}/lib/python2.7/site-packages/:${PYTHONPATH}
export MDANSE_DEPENDENCIES_DIR=/Users/ci/Projects/mdanse/dependencies
export RED="\\033[1;31m"
......@@ -15,4 +15,4 @@ export NORMAL="\\033[0m"
# Get revision number from Git
export MDANSE_GIT_CURRENT_COMMIT=$(git rev-parse --short HEAD)
# Get commit branch from Gitlab
export MDANSE_GIT_BRANCH_NAME=${CI_COMMIT_REF_NAME}
\ No newline at end of file
export MDANSE_GIT_BRANCH_NAME=${CI_COMMIT_REF_NAME}
......@@ -10,20 +10,19 @@ export DISTUTILS_DEBUG=0
# PREPARATION
#############################
cd ${MDANSE_SOURCE_DIR}
DEBIAN_ROOT_DIR=${MDANSE_SOURCE_DIR}/BuildServer/Build_Debian
DEBIAN_ROOT_DIR=${MDANSE_SOURCE_DIR}/dist/debian
rm -rf ${DEBIAN_ROOT_DIR}
mkdir ${DEBIAN_ROOT_DIR}
mkdir -p ${DEBIAN_ROOT_DIR}
#############################
# PACKAGING
#############################
echo -e "${BLUE}""Build debian tree""${NORMAL}"
# Set automatically the good version number for the Debian control file
sed -i "s/Version:.*/Version: ${VERSION_NAME}/g" BuildServer/Unix/Debian_resources/DEBIAN/control
# Copy all the debian files (e.g. control, copyright, md5sum ...) into DEBIAN directory
cp -r BuildServer/Unix/Debian_resources/DEBIAN ${DEBIAN_ROOT_DIR}/
# Set automatically the good version number for the Debian control file
sed -i "s/Version:.*/Version: ${VERSION_NAME}/g" ${DEBIAN_ROOT_DIR}/DEBIAN/control
chmod -R 755 ${DEBIAN_ROOT_DIR}/DEBIAN
# Build the /usr/share/applications directory inside the debian root directory and copy the mdanse desktop file inside
......@@ -46,6 +45,32 @@ dos2unix ${DEBIAN_BIN_DIR}/mdanse_*
DEBIAN_DIST_DIR=${DEBIAN_ROOT_DIR}/usr/local/lib/python2.7/dist-packages
mkdir -p ${DEBIAN_DIST_DIR}
${PYTHONEXE} setup.py build --build-platlib build/lib --build-scripts build/scripts build_api
status=$?
if [ $status -ne 0 ]; then
echo -e "${RED}" "Failed to build MDANSE API""${NORMAL}"
exit $status
fi
${PYTHONEXE} setup.py build --build-platlib build/lib --build-scripts build/scripts build_help
status=$?
if [ $status -ne 0 ]; then
echo -e "${RED}" "Failed to build MDANSE embedded documentation""${NORMAL}"
exit $status
fi
echo -e "${BLUE}""Installing MDANSE""${NORMAL}"
cd $MDANSE_SOURCE_DIR
${PYTHONEXE} setup.py build --build-platlib build/lib --build-scripts build/scripts install --prefix=${MDANSE_TEMPORARY_INSTALLATION_DIR}
status=$?
if [ $status -ne 0 ]; then
echo -e "${RED}" "Failed to install MDANSE""${NORMAL}"
exit $status
fi
# Copy the localy installed ScientificPython, MMTK and MDANSE
cp -r ${MDANSE_TEMPORARY_INSTALLATION_DIR}/lib/python2.7/site-packages/Scientific ${DEBIAN_DIST_DIR}
cp -r ${MDANSE_TEMPORARY_INSTALLATION_DIR}/lib/python2.7/site-packages/MMTK ${DEBIAN_DIST_DIR}
......@@ -63,4 +88,3 @@ if [ $status -ne 0 ]; then
exit $status
fi
rm -rf ${MDANSE_TEMPORARY_INSTALLATION_DIR}
\ No newline at end of file
......@@ -10,27 +10,23 @@ export DISTUTILS_DEBUG=0
# PREPARATION
#############################
cd ${MDANSE_SOURCE_DIR}
rm -rf ${MDANSE_TEMPORARY_INSTALLATION_DIR}/build
rm -rf ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist
#############################
# PACKAGING
#############################
echo -e "${BLUE}""Packaging MDANSE""${NORMAL}"
MDANSE_DMG=MDANSE-${VERSION_NAME}-${DISTRO}-${ARCH}.dmg
rm -f BuildServer/Unix/${MDANSE_DMG}
rm -f BuildServer/Unix/rw.${MDANSE_DMG}
cd BuildServer/Unix
${PYTHONEXE} MacOS_resources/build.py py2app
cd BuildServer/Unix/MacOS_resources
${PYTHONEXE} build.py py2app
status=$?
if [ $status -ne 0 ]; then
echo -e "${RED}" "Cannot build app.""${NORMAL}"
exit $status
fi
#Add MDANSE version file (should read the version from the bundle with pyobjc, but will figure that out later)
echo "${VERSION_NAME}" > ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/version
# Add MDANSE version file (should read the version from the bundle with pyobjc, but will figure that out later)
echo "${VERSION_NAME}" > ${MDANSE_SOURCE_DIR}/dist/MDANSE.app/Contents/Resources/version
#############################
# Copying Python
......@@ -39,21 +35,21 @@ echo "${VERSION_NAME}" > ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Co
### see http://joaoventura.net/blog/2016/embeddable-python-osx/ for technical details
### In our case we also want the user to be able to start directly python without launching the bundle executable (e.g. to run scripts in command line) which is the reason
### why we have to modify the python executable appropriately with the following commands
rm ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/MacOS/python
mkdir ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/bin
cp /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/bin/python
rm ${MDANSE_SOURCE_DIR}/dist/MDANSE.app/Contents/MacOS/python
mkdir ${MDANSE_SOURCE_DIR}/dist/MDANSE.app/Contents/Resources/bin
cp /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python ${MDANSE_SOURCE_DIR}/dist/MDANSE.app/Contents/Resources/bin/python
cp -r /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/* ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/lib/python2.7/
cp /System/Library/Frameworks/Python.framework/Versions/2.7/Python ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/lib/libpython2.7.dylib
chmod 777 ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/lib/libpython2.7.dylib
cp -r /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/* ${MDANSE_SOURCE_DIR}/dist/MDANSE.app/Contents/Resources/lib/python2.7/
cp /System/Library/Frameworks/Python.framework/Versions/2.7/Python ${MDANSE_SOURCE_DIR}/dist/MDANSE.app/Contents/Resources/lib/libpython2.7.dylib
chmod 777 ${MDANSE_SOURCE_DIR}/dist/MDANSE.app/Contents/Resources/lib/libpython2.7.dylib
install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python @executable_path/../lib/libpython2.7.dylib ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/bin/python
install_name_tool -id @loader_path/libpython2.7.dylib ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/lib/libpython2.7.dylib
install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python @executable_path/../lib/libpython2.7.dylib ${MDANSE_SOURCE_DIR}/dist/MDANSE.app/Contents/Resources/bin/python
install_name_tool -id @loader_path/libpython2.7.dylib ${MDANSE_SOURCE_DIR}/dist/MDANSE.app/Contents/Resources/lib/libpython2.7.dylib
ln -s ../Resources/bin/python ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/MacOS/python
ln -s ../Resources/bin/python ${MDANSE_SOURCE_DIR}/dist/MDANSE.app/Contents/MacOS/python
# Do some manual cleanup, e.g.
rm ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/lib/python2.7/MDANSE/__pkginfo__.py\"\"
rm ${MDANSE_SOURCE_DIR}/dist/MDANSE.app/Contents/Resources/lib/python2.7/MDANSE/__pkginfo__.py\"\"
# matplotlib/tests ==> 45.2 Mb
#rm -rf ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/lib/python2.7/matplotlib/tests
#rm -rf ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/mpl-data/sample_data
......@@ -80,8 +76,8 @@ rm ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Resources/lib/p
#cp ${MDANSE_SOURCE_DIR}/BuildServer/Unix/MacOS_resources/site.py ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist/MDANSE.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/.
chmod 777 ${MDANSE_SOURCE_DIR}/BuildServer/Unix/MacOS_resources//change_dylib_path.sh
${MDANSE_SOURCE_DIR}/BuildServer/Unix/MacOS_resources//change_dylib_path.sh
chmod 777 ${MDANSE_SOURCE_DIR}/BuildServer/Unix/MacOS_resources/change_dylib_path.sh
${MDANSE_SOURCE_DIR}/BuildServer/Unix/MacOS_resources/change_dylib_path.sh
#############################
# Create DMG
......@@ -89,7 +85,6 @@ ${MDANSE_SOURCE_DIR}/BuildServer/Unix/MacOS_resources//change_dylib_path.sh
hdiutil unmount /Volumes/MDANSE -force -quiet
sleep 5
${MDANSE_SOURCE_DIR}/BuildServer/Unix/MacOS_resources/dmg/create-dmg --background "${MDANSE_SOURCE_DIR}/BuildServer/Unix/MacOS_resources/dmg/dmg_background.jpg" --volname "MDANSE" --window-pos 200 120 --window-size 800 400 --icon MDANSE.app 200 190 --hide-extension MDANSE.app --app-drop-link 600 185 "${MDANSE_DMG}" ${MDANSE_TEMPORARY_INSTALLATION_DIR}/dist
mv ${MDANSE_SOURCE_DIR}/BuildServer/Unix/${MDANSE_DMG} ${MDANSE_SOURCE_DIR}
${MDANSE_SOURCE_DIR}/BuildServer/Unix/MacOS_resources/dmg/create-dmg --background "${MDANSE_SOURCE_DIR}/BuildServer/Unix/MacOS_resources/dmg/dmg_background.jpg" --volname "MDANSE" --window-pos 200 120 --window-size 800 400 --icon MDANSE.app 200 190 --hide-extension MDANSE.app --app-drop-link 600 185 "${MDANSE_DMG}" ${MDANSE_SOURCE_DIR}/dist
mv ${MDANSE_SOURCE_DIR}/dist/${MDANSE_DMG} ${MDANSE_SOURCE_DIR}
rm -rf ${MDANSE_TEMPORARY_INSTALLATION_DIR}
\ No newline at end of file
......@@ -5,6 +5,8 @@
#############################
cd ${MDANSE_SOURCE_DIR}
PYTHONPATH=${MDANSE_SOURCE_DIR}/build/lib:${PYTHONPATH}
#############################
# UNITARY TESTS
#############################
......@@ -44,4 +46,4 @@ if [ $status -ne 0 ]; then
echo -e "${RED}" "One or several functional tests failed"
exit $status
fi
cd ${MDANSE_SOURCE_DIR}
\ No newline at end of file
cd ${MDANSE_SOURCE_DIR}
......@@ -82,12 +82,5 @@ if %STATUS% neq 0 (
echo "Failed to build MDANSE"
exit %STATUS%
)
%PYTHON_EXE% setup.py install
rem Exit now if unable to install
if %STATUS% neq 0 (
echo "Failed to install MDANSE"
exit %STATUS%
)
rmdir /S /Q build
cd %MDANSE_SOURCE_DIR%
\ No newline at end of file
cd %MDANSE_SOURCE_DIR%
......@@ -5,6 +5,33 @@ rem BUILD_TARGET
rem MDANSE_DEPENDENCIES_DIR
rem MDANSE_TEMPORARY_INSTALLATION_DIR
cd "%MDANSE_SOURCE_DIR%"
%PYTHON_EXE% setup.py build_api
set STATUS=%ERRORLEVEL%
rem Exit now if unable to build
if %STATUS% neq 0 (
echo "Failed to build MDANSE API"
exit %STATUS%
)
%PYTHON_EXE% setup.py build_help
set STATUS=%ERRORLEVEL%
rem Exit now if unable to build
if %STATUS% neq 0 (
echo "Failed to build MDANSE embedded documentation"
exit %STATUS%
)
%PYTHON_EXE% setup.py install
rem Exit now if unable to install
if %STATUS% neq 0 (
echo "Failed to install MDANSE"
exit %STATUS%
)
cd "%MDANSE_SOURCE_DIR%\\BuildServer\\Windows"
rem copy LICENSE
......@@ -33,4 +60,5 @@ if %STATUS% neq 0 (
move %MDANSE_TEMPORARY_INSTALLATION_DIR%\\MDANSE*.exe %MDANSE_SOURCE_DIR%\\
rem Remove NSIS log file
del NSISlog.txt
cd %MDANSE_SOURCE_DIR%
......@@ -13,7 +13,10 @@ if "%1%"=="win32" (
set BUILD_TARGET=win-amd64
)
set PYTHONPATH=%MDANSE_SOURCE_DIR%/build/lib;%PYTHONPATH%
set MDANSE_SOURCE_DIR=%cd%
rem Set the site-packages of the temporary Python
set PYTHON_SCRIPT_DIR=%MDANSE_SOURCE_DIR%\\BuildServer\\Windows\\Build\\Scripts
rem Set the location where the temporary Python will be installed
......@@ -61,4 +64,4 @@ if %STATUS% neq 0 (
exit %STATUS%
)
cd %MDANSE_SOURCE_DIR%
\ No newline at end of file
cd %MDANSE_SOURCE_DIR%
......@@ -782,10 +782,10 @@ xdrfile_decompress_coord_float(float *ptr,
XDRFILE* xfp)
{
int minint[3], maxint[3], *lip;
int smallidx, minidx, maxidx;
int smallidx;
unsigned sizeint[3], sizesmall[3], bitsizeint[3], size3;
int k, *buf1, *buf2, lsize, flag;
int smallnum, smaller, larger, i, is_smaller, run;
int smallnum, smaller, i, is_smaller, run;
float *lfp, inv_precision;
int tmp, *thiscoord, prevcoord[3];
unsigned int bitsize;
......@@ -866,14 +866,11 @@ xdrfile_decompress_coord_float(float *ptr,
return 0; /* not sure what has happened here or why we return... */
}
tmp=smallidx+8;
maxidx = (LASTIDX<tmp) ? LASTIDX : tmp;
minidx = maxidx - 8; /* often this equal smallidx */
tmp = smallidx-1;
tmp = (FIRSTIDX>tmp) ? FIRSTIDX : tmp;
smaller = magicints[tmp] / 2;
smallnum = magicints[smallidx] / 2;
sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx] ;
larger = magicints[maxidx];
/* buf2[0] holds the length in bytes */
......@@ -1013,7 +1010,6 @@ xdrfile_compress_coord_float(float *ptr,
float *lfp, lf;
int tmp, tmpsum, *thiscoord, prevcoord[3];
unsigned int tmpcoord[30];
int errval=1;
unsigned int bitsize;
if(xfp==NULL)
......@@ -1074,7 +1070,6 @@ xdrfile_compress_coord_float(float *ptr,
{
/* scaling would cause overflow */
fprintf(stderr, "(xdrfile error) Internal overflow compressing coordinates.\n");
errval=0;
}
lint1 = lf;
if (lint1 < minint[0]) minint[0] = lint1;
......@@ -1089,7 +1084,6 @@ xdrfile_compress_coord_float(float *ptr,
{
/* scaling would cause overflow */
fprintf(stderr, "(xdrfile error) Internal overflow compressing coordinates.\n");
errval=0;
}
lint2 = lf;
if (lint2 < minint[1]) minint[1] = lint2;
......@@ -1100,10 +1094,6 @@ xdrfile_compress_coord_float(float *ptr,
lf = *lfp * precision + 0.5;
else
lf = *lfp * precision - 0.5;
if (fabs(lf) > INT_MAX-2)
{
errval=0;
}
lint3 = lf;
if (lint3 < minint[2]) minint[2] = lint3;
if (lint3 > maxint[2]) maxint[2] = lint3;
......@@ -1126,7 +1116,6 @@ xdrfile_compress_coord_float(float *ptr,
* would cause overflow
*/
fprintf(stderr, "(xdrfile error) Internal overflow compressing coordinates.\n");
errval=0;
}
sizeint[0] = maxint[0] - minint[0]+1;
sizeint[1] = maxint[1] - minint[1]+1;
......@@ -1299,10 +1288,10 @@ xdrfile_decompress_coord_double(double *ptr,
XDRFILE* xfp)
{
int minint[3], maxint[3], *lip;
int smallidx, minidx, maxidx;
int smallidx, maxidx;
unsigned sizeint[3], sizesmall[3], bitsizeint[3], size3;
int k, *buf1, *buf2, lsize, flag;
int smallnum, smaller, larger, i, is_smaller, run;
int smallnum, smaller, i, is_smaller, run;
double *lfp, inv_precision;
float float_prec, tmpdata[30];
int tmp, *thiscoord, prevcoord[3];
......@@ -1381,13 +1370,11 @@ xdrfile_decompress_coord_double(double *ptr,
return 0;
tmp=smallidx+8;
maxidx = (LASTIDX<tmp) ? LASTIDX : tmp;
minidx = maxidx - 8; /* often this equal smallidx */
tmp = smallidx-1;
tmp = (FIRSTIDX>tmp) ? FIRSTIDX : tmp;
smaller = magicints[tmp] / 2;
smallnum = magicints[smallidx] / 2;
sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx] ;
larger = magicints[maxidx];
/* buf2[0] holds the length in bytes */
......@@ -1506,7 +1493,6 @@ xdrfile_compress_coord_double(double *ptr,
float float_prec, lf,tmpdata[30];
int tmp, tmpsum, *thiscoord, prevcoord[3];
unsigned int tmpcoord[30];
int errval=1;
unsigned int bitsize;
bitsizeint[0] = 0;
......@@ -1563,7 +1549,6 @@ xdrfile_compress_coord_double(double *ptr,
if (fabs(lf) > INT_MAX-2) {
/* scaling would cause overflow */
fprintf(stderr, "(xdrfile error) Internal overflow compressing coordinates.\n");
errval=0;
}
lint1 = lf;
if (lint1 < minint[0]) minint[0] = lint1;
......@@ -1577,7 +1562,6 @@ xdrfile_compress_coord_double(double *ptr,
if (fabs(lf) > INT_MAX-2) {
/* scaling would cause overflow */
fprintf(stderr, "(xdrfile error) Internal overflow compressing coordinates.\n");
errval=0;
}
lint2 = lf;
if (lint2 < minint[1]) minint[1] = lint2;
......@@ -1588,9 +1572,6 @@ xdrfile_compress_coord_double(double *ptr,
lf = (float)*lfp * float_prec + 0.5;
else
lf = (float)*lfp * float_prec - 0.5;
if (fabs(lf) > INT_MAX-2) {
errval=0;
}
lint3 = lf;
if (lint3 < minint[2]) minint[2] = lint3;
if (lint3 > maxint[2]) maxint[2] = lint3;
......@@ -1613,7 +1594,6 @@ xdrfile_compress_coord_double(double *ptr,
* would cause overflow
*/
fprintf(stderr, "(xdrfile error) Internal overflow compressing coordinates.\n");
errval=0;
}
sizeint[0] = maxint[0] - minint[0]+1;
sizeint[1] = maxint[1] - minint[1]+1;
......
......@@ -63,7 +63,7 @@ static int xtc_header(XDRFILE *xd,int *natoms,int *step,float *time,mybool bRead
static int xtc_coord(XDRFILE *xd,int *natoms,matrix box,rvec *x,float *prec,
mybool bRead)
{
int i,j,result;
int result;
/* box */
result = xdrfile_read_float(box[0],DIM*DIM,xd);
......
......@@ -38,10 +38,9 @@ class JobFileGenerator():
# parameters (dict): optional. If not None, the parameters which the job file will be built with.
"""
array_of_python_dependancies_string = ['unittest', 'numpy', 'os']
array_of_mdanse_dependancies_string = ['from Tests.UnitTests.UnitTest import UnitTest',
'from MDANSE import REGISTRY']
array_of_mdanse_dependancies_string = ['from MDANSE import REGISTRY']
test_string = ''
test_string = test_string + 'class Test%s(UnitTest):\n\n' % self.job._type.upper()
test_string = test_string + 'class Test%s(unittest.TestCase):\n\n' % self.job._type.upper()
test_string = test_string + ' def test(self):\n'
# Writes the line that will initialize the |parameters| dictionary and create the job
if parameters is None:
......@@ -56,14 +55,14 @@ class JobFileGenerator():
# Launch the job in monoprocessor mode and copy output file
test_string = test_string + ' print "Launching job in monoprocessor mode"\n'
test_string = test_string + ' parameters["running_mode"] = ("monoprocessor",1)\n'
test_string = test_string + ' self.assertNotRaises(job.run, parameters, status=False)\n'
test_string = test_string + ' job.run(parameters, status=False)\n'
test_string = test_string + ' shutil.copy(output_path + ".nc", reference_data_path + "_mono" + ".nc")\n'
test_string = test_string + ' print "Monoprocessor execution completed"\n\n'
# Launch the job in multiprocessor mode if avalaible
if self.multiprocessor:
test_string = test_string + ' print "Launching job in multiprocessor mode"\n'
test_string = test_string + ' parameters["running_mode"] = ("multiprocessor",2)\n'
test_string = test_string + ' self.assertNotRaises(job.run,parameters,False)\n'
test_string = test_string + ' job.run(parameters,False)\n'
test_string = test_string + ' shutil.copy(output_path + ".nc", reference_data_path + "_multi" + ".nc")\n'
test_string = test_string + ' print "Multiprocessor execution completed"\n\n'
# Compare reference data with monoprocessor if reference data exists
......
......@@ -41,11 +41,10 @@ from MDANSE.Framework.Configurable import Configurable
from MDANSE.Framework.Configurators.IConfigurator import ConfiguratorError
from MDANSE.Framework.Projectors.IProjector import ProjectorError
from MDANSE.Framework.AtomSelectionParser import AtomSelectionParserError
from UnitTest import UnitTest
TRAJECTORIES_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),"UserData","Trajectories")
class TestConfigurator(UnitTest):
class TestConfigurator(unittest.TestCase):
'''
Unittest for the configurators used to setup an analysis in MDANSE
'''
......@@ -70,16 +69,16 @@ class TestConfigurator(UnitTest):
# Case of a valid integer
self._parameters["test_integer"] = 20
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
# Case of a float that will casted to an integer
self._parameters["test_integer"] = 20.2
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
self.assertEqual(self._configurable["test_integer"]["value"], 20)
# Case of a string that can be casted to an integer
self._parameters["test_integer"] = "30"
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
self.assertEqual(self._configurable["test_integer"]["value"], 30)
# Case of a string that cannot be casted to an integer
......@@ -99,17 +98,17 @@ class TestConfigurator(UnitTest):
# Case of an integer that will be casted to a float
self._parameters["test_float"] = 20
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
self.assertEqual(self._configurable["test_float"]["value"], 20.0)
# Case of a float
self._parameters["test_float"] = 20.2
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
self.assertEqual(self._configurable["test_float"]["value"], 20.2)
# Case of a string that can be casted to a float
self._parameters["test_float"] = "30.2"
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
self.assertEqual(self._configurable["test_float"]["value"], 30.2)
# Case of a string that cannot be casted to a float
......@@ -129,7 +128,7 @@ class TestConfigurator(UnitTest):
# Case of a valid trajectory
self._parameters["trajectory"] = self._validTrajectory.filename
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
# Case of an unknown trajectory
self._parameters["trajectory"] = 'fsfsdjkfjkfjs'
......@@ -162,12 +161,12 @@ class TestConfigurator(UnitTest):
# No projection
self._parameters["projection"] = None
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
proj = self._configurable["projection"]['projector'](data)
self.assertTrue(numpy.array_equal(data,proj))
self._parameters["projection"] = ('null',None)
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
proj = self._configurable["projection"]['projector'](data)
self.assertTrue(numpy.array_equal(data,proj))
......@@ -185,13 +184,13 @@ class TestConfigurator(UnitTest):
# Axial projection
self._parameters["projection"] = ('axial',(1,0,0))
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
proj = self._configurable["projection"]['projector'](data)
self.assertTrue(numpy.array_equal(data[:,0],proj[:,0]))
# Axial projection - wrong data
self._parameters["projection"] = ('axial',(1,0,0))
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
self.assertRaises(ProjectorError, self._configurable["projection"]['projector'].__call__,None)
self.assertRaises(ProjectorError, self._configurable["projection"]['projector'].__call__,[1])
......@@ -209,7 +208,7 @@ class TestConfigurator(UnitTest):
# Planar projection
self._parameters["projection"] = ('planar',(1,0,0))
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
proj = self._configurable["projection"]['projector'](data)
self.assertTrue(numpy.array_equal(numpy.zeros((data.shape[0],), dtype=numpy.float64),proj[:,0]))
self.assertTrue(numpy.array_equal(data[:,1],proj[:,1]))
......@@ -217,7 +216,7 @@ class TestConfigurator(UnitTest):
# Planar projection - wrong data
self._parameters["projection"] = ('planar',(1,0,0))
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
self.assertRaises(ProjectorError, self._configurable["projection"]['projector'].__call__,None)
self.assertRaises(ProjectorError, self._configurable["projection"]['projector'].__call__,[1])
......@@ -255,7 +254,7 @@ class TestConfigurator(UnitTest):
# Test a valid atom selection string
self._parameters["trajectory"] = self._validTrajectory.filename
self._parameters["atom_selection"] = 'atom_type carbon'
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
self.assertEqual(self._configurable['atom_selection']['selection_length'],sum([True for at in self._configurable['trajectory']['instance'].universe.atomList() if at.symbol=='C']))
def test_atom_transmutation(self):
......@@ -289,7 +288,7 @@ class TestConfigurator(UnitTest):
# Test a valid atom selection string
self._parameters["trajectory"] = self._validTrajectory.filename
self._parameters["atom_transmutation"] = None
self.assertNotRaises(self._configurable.setup,self._parameters)
self._configurable.setup(self._parameters)
def suite():
loader = unittest.TestLoader()
......
......@@ -32,12 +32,10 @@ Created on May 29, 2015
import unittest
from UnitTest import UnitTest
from MDANSE import ELEMENTS
from MDANSE.Data.ElementsDatabase import ElementsDatabaseError
class TestElementsDatabase(UnitTest):
class TestElementsDatabase(unittest.TestCase):
'''
Unittest for the configurators used to setup an analysis in MDANSE
'''
......@@ -57,26 +55,26 @@ class TestElementsDatabase(UnitTest):
for e in ELEMENTS.elements:
for p in ELEMENTS.properties:
self.assertNotRaises(ELEMENTS.__getitem__,(e,p))
_ = ELEMENTS[e,p]
def test_getelement(self):
for e in ELEMENTS.elements:
self.assertNotRaises(ELEMENTS.get_element,e)
_ = ELEMENTS.get_element(e)
def test_get_property(self):
for p in ELEMENTS.properties:
self.assertNotRaises(ELEMENTS.get_property,p)
_ = ELEMENTS.get_property(p)
def test___setitem__(self):
self.assertNotRaises(ELEMENTS.__setitem__,('C','atomic_weight'),20.0)
ELEMENTS['C','atomic_weight'] = 20.0
def test_add_element(self):
# Otherwise, everything should be OK
self.assertNotRaises(ELEMENTS.add_element, "element1")
ELEMENTS.add_element("element1")
def test_add_property(self):
......@@ -84,9 +82,9 @@ class TestElementsDatabase(UnitTest):
self.assertRaises(ElementsDatabaseError, ELEMENTS.add_property, "atomic_weight",0.0)
# Otherwise, everything should be OK
self.assertNotRaises(ELEMENTS.add_property, "prop1",'float')
self.assertNotRaises(ELEMENTS.add_property, "prop2",'int')
self.assertNotRaises(ELEMENTS.add_property, "prop3",'str')
ELEMENTS.add_property("prop1",'float')
ELEMENTS.add_property("prop2",'int')
ELEMENTS.add_property("prop3",'str')
def test_has_property(self):
......@@ -111,4 +109,4 @@ def suite():
if __name__ == '__main__':
unittest.main(verbosity=2)
\ No newline at end of file
......@@ -34,11 +34,9 @@ import unittest
import numpy
from UnitTest import UnitTest
from MDANSE.Mathematics.Geometry import center_of_mass
class TestGeometry(UnitTest):
class TestGeometry(unittest.TestCase):
'''
Unittest for the geometry-related functions
'''
......@@ -62,4 +60,4 @@ def suite():
if __name__ == '__main__':
unittest.main(verbosity=2)