Skip to content

Commit ebfb5dc

Browse files
author
Dilawar Singh
committed
2 parents 45216b3 + 526c5b0 commit ebfb5dc

File tree

274 files changed

+5912
-31942
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+5912
-31942
lines changed

.travis.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ sudo: required
33

44
matrix:
55
include:
6-
- os : linux
7-
dist: xenial
8-
- os : osx
9-
osx_image: xcode10.1
6+
- os: linux
7+
dist: xenial
8+
- os: osx
9+
osx_image: xcode10.2
1010

1111
notifications:
1212
email:
@@ -26,12 +26,6 @@ before_script:
2626
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_prepare_osx.sh; fi
2727
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./.travis/travis_prepare_linux.sh; fi
2828

29-
30-
before_script:
31-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then nvm get head || true; fi
32-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_prepare_osx.sh; fi
33-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./.travis/travis_prepare_linux.sh; fi
34-
3529
script:
3630
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_build_osx.sh; fi
3731
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.travis/travis_build_linux.sh; fi

.travis/travis_build_osx.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,26 @@ set -e
2626
# Make sure not to pick up python from /opt.
2727
PATH=/usr/local/bin:/usr/bin:$PATH
2828

29+
PYTHON3=$(which python3)
30+
2931
# Get pylint
30-
python -m pip install pylint --user
31-
python -m pip install python-libsbml --user
32-
python -m pip install pyneuroml --user
32+
$PYTHON3 -m pip install pylint --user
33+
$PYTHON3 -m pip install python-libsbml --user
34+
$PYTHON3 -m pip install pyneuroml --user
3335

3436
mkdir -p _GSL_BUILD && cd _GSL_BUILD \
3537
&& cmake -DDEBUG=ON \
36-
-DPYTHON_EXECUTABLE=`which python` ..
38+
-DPYTHON_EXECUTABLE=$PYTHON3 \
39+
..
3740
make pylint -j3
38-
make && ctest --output-on-failure -E ".*socket_streamer.*"
41+
make && ctest --output-on-failure
3942

4043
cd .. # Now with boost.
4144
mkdir -p _BOOST_BUILD && cd _BOOST_BUILD \
4245
&& cmake -DWITH_BOOST_ODE=ON -DDEBUG=ON \
43-
-DPYTHON_EXECUTABLE=`which python` ..
46+
-DPYTHON_EXECUTABLE=`which python3` ..
4447

45-
make && ctest --output-on-failure -E ".*socket_streamer.*"
48+
make -j4 && ctest --output-on-failure
4649
cd ..
4750
set +e
4851

.travis/travis_prepare_osx.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,20 @@ brew install python
2828
brew install numpy
2929
brew install boost
3030

31+
PYTHON3=$(which python3)
32+
3133
#brew outdated python || brew install python
3234
#brew outdated numpy || brew install homebrew/python/numpy
3335
brew unlink numpy && brew link numpy || echo "Failed to link numpy"
3436
# Numpy caveats
35-
mkdir -p $HOME/Library/Python/2.7/lib/python/site-packages
36-
echo 'import sys; sys.path.insert(1, "/usr/local/lib/python2.7/site-packages")' >> $HOME/Library/Python/2.7/lib/python/site-packages/homebrew.pth
37+
#mkdir -p $HOME/Library/Python/2.7/lib/python/site-packages
38+
#echo 'import sys; sys.path.insert(1, "/usr/local/lib/python2.7/site-packages")' >> $HOME/Library/Python/2.7/lib/python/site-packages/homebrew.pth
3739

3840
# To make sure that we do not pick python from /opt etc.
3941
PATH=/usr/local/bin:/usr/bin:$PATH
4042
# ensurepip
41-
python -m ensurepip
42-
python -m pip install matplotlib --user --upgrade
43-
python -m pip install pyNeuroML libNeuroML --user
44-
python -m pip install scipy --user
43+
$PYTHON3 -m ensurepip
44+
$PYTHON3 -m pip install matplotlib --user --upgrade
45+
$PYTHON3 -m pip install pyNeuroML libNeuroML --user
46+
$PYTHON3 -m pip install scipy --user
47+
$PYTHON3 -m pip install pylint --user

CMakeLists.txt

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ project(pymoose)
44
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules")
55
include(CheckCXXCompiler.cmake)
66
include(CheckIncludeFileCXX)
7-
include(FindPkgConfig)
87

98
# getgit revision number
109
find_program( GIT_EXEC git )
@@ -78,6 +77,7 @@ option(WITH_BOOST_ODE "Use boost library ode2 library instead of GSL" OFF)
7877
option(WITH_GSL "Use gsl-library. Alternative is WITH_BOOST" ON)
7978
option(PARALLELIZED_CLOCK "High level parallelization of moose::Clock (alpha)" OFF )
8079
option(USE_PRIVATE_RNG "Stochastic Objects use their private RNG" ON)
80+
option(WITH_ASAN "Use AddressSanitizer in DEBUG mode." OFF)
8181

8282

8383
############################ BUILD CONFIGURATION #################################
@@ -87,7 +87,7 @@ add_definitions(-DUSE_GENESIS_PARSER)
8787

8888
if(DEBUG OR "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
8989
message(STATUS "Building for Debug/Unit testing")
90-
add_definitions(-DDO_UNIT_TESTS)
90+
add_definitions(-DDO_UNIT_TESTS -O)
9191
set(CMAKE_BUILD_TYPE Debug)
9292
elseif(ENABLE_UNIT_TESTS)
9393
MESSAGE(STATUS "Enabled Unit tests")
@@ -109,8 +109,14 @@ if(GPROF AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
109109
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-pg")
110110
endif()
111111

112-
find_package(Threads)
113-
112+
if(WITH_ASAN AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
113+
message(STATUS "Compiling with ASAN")
114+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} \
115+
-fno-omit-frame-pointer -fsanitize=leak -fsanitize=address")
116+
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} \
117+
-fno-omit-frame-pointer -fsanitize=leak -fsanitize=address")
118+
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address")
119+
endif()
114120

115121
################################### TARGETS ####################################
116122

@@ -132,8 +138,6 @@ if(WITH_BOOST_ODE)
132138
set(WITH_GSL OFF)
133139
endif(WITH_BOOST_ODE)
134140

135-
include_directories(msg basecode)
136-
137141
set_target_properties(libmoose PROPERTIES COMPILE_DEFINITIONS "MOOSE_LIB")
138142
set_target_properties(libmoose PROPERTIES PREFIX "")
139143

@@ -143,11 +147,10 @@ set(STATIC_LIBRARIES "" )
143147
set(SYSTEM_SHARED_LIBS ${LibXML2_LIBRARIES})
144148

145149
# BOOST ode library performs better than GSL and ideally should be made default.
146-
# Making boost default means that we get rid of gsl. Boost does not have a very
147-
# good matrix library; it has ublas which is not well maintained and emit a lot
150+
# Unfortunately Boost does not have a very good matrix library; it has ublas
151+
# which is not well maintained and emit a lot
148152
# of warning during compilation. Nonetheless, WITH_BOOST_ODE works fine and
149-
# produce results quicker than GSL. Both boost ode and ublas are in moose source
150-
# tree ./external/odeint-v2 and ./external/boost-numeric-bindings
153+
# produce results quicker than GSL.
151154
if(WITH_GSL)
152155
find_package(GSL 1.16 REQUIRED)
153156
if(NOT GSL_FOUND)
@@ -172,13 +175,14 @@ if(WITH_GSL)
172175
# top level.
173176
include_directories( ${GSL_INCLUDE_DIRS} )
174177
elseif(WITH_BOOST_ODE)
175-
find_package(Boost 1.44 REQUIRED)
176-
find_package( LAPACK REQUIRED )
178+
find_package(Boost 1.53 REQUIRED)
179+
find_package(LAPACK REQUIRED)
177180
endif()
178181

179182
# if boost ode is being used, don't use GSL.
180183
if(WITH_BOOST_ODE)
181184
add_definitions(-DUSE_BOOST_ODE -UUSE_GSL)
185+
include_directories(${Boost_INCLUDE_DIRS})
182186
endif()
183187

184188
# Openmpi
@@ -202,6 +206,7 @@ if(WITH_BOOST_ODE)
202206
list(APPEND SYSTEM_SHARED_LIBS ${Boost_LIBRARIES})
203207
endif(WITH_BOOST_ODE)
204208

209+
find_package( Threads )
205210
list(APPEND SYSTEM_SHARED_LIBS ${CMAKE_THREAD_LIBS_INIT})
206211

207212
# These libraries could be static of dynamic. We need to discrimate between
@@ -265,6 +270,7 @@ list(APPEND MOOSE_LIBRARIES
265270
msg
266271
benchmarks
267272
shell
273+
randnum
268274
scheduling
269275
moose_mpi
270276
biophysics
@@ -441,6 +447,7 @@ set(PYMOOSE_TEST_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/python)
441447
# Collect all python script in tests folder and run them.
442448
file(GLOB PY_TEST_SCRIPTS "${PYMOOSE_TEST_DIRECTORY}/test_*.py" )
443449

450+
444451
# Run python tests.
445452
foreach( _test_script ${PY_TEST_SCRIPTS} )
446453
get_filename_component( _test_name ${_test_script} NAME_WE)
@@ -453,6 +460,36 @@ foreach( _test_script ${PY_TEST_SCRIPTS} )
453460
)
454461
endforeach( )
455462

463+
# Alpha tests. These should not run by default.
464+
set(MOOSE_ALPHA_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/alpha)
465+
file(GLOB PY_ALPHA_TEST_SCRIPTS "${PYMOOSE_ALPHA_TEST_DIRECTORY}/*.py" )
466+
foreach( _test_script ${PY_ALPHA_TEST_SCRIPTS} )
467+
get_filename_component( _test_name ${_test_script} NAME_WE)
468+
add_test( NAME ${_test_name}
469+
COMMAND ${PYTHON_EXECUTABLE} ${_test_script}
470+
CONFIGURATIONS Devel
471+
WORKING_DIRECTORY ${PYMOOSE_ALPHA_TEST_DIRECTORY}
472+
)
473+
set_tests_properties( ${_test_name}
474+
PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/python"
475+
)
476+
endforeach( )
477+
478+
# Regression and github issues. These should not run by default.
479+
set(PYMOOSE_ISSUES_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/issues)
480+
file(GLOB PY_ISSUES_SCRIPTS "${PYMOOSE_ISSUES_DIRECTORY}/*.py" )
481+
foreach( _test_script ${PY_ISSUES_SCRIPTS} )
482+
get_filename_component( _test_name ${_test_script} NAME_WE)
483+
add_test( NAME ${_test_name}
484+
COMMAND ${PYTHON_EXECUTABLE} ${_test_script}
485+
CONFIGURATIONS Devel
486+
WORKING_DIRECTORY ${PYMOOSE_ISSUES_DIRECTORY}
487+
)
488+
set_tests_properties( ${_test_name}
489+
PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/python"
490+
)
491+
endforeach( )
492+
456493
# add pylint target.
457494
set(PYSCRIPTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/python )
458495
file(GLOB_RECURSE PY_SCRIPTS "python/*.py")
@@ -476,4 +513,5 @@ foreach( _py_script ${PY_SCRIPTS} )
476513
endforeach( )
477514

478515
############################ CPACK ######################################
516+
# This is not maintained anymore since packaging is done using OpenBuildService
479517
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_moose_cpack.cmake)

basecode/FuncOrder.h

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,31 @@
1313

1414
class FuncOrder
1515
{
16-
public:
17-
FuncOrder()
18-
: func_( 0 ), index_( 0 )
19-
{;}
16+
public:
17+
FuncOrder()
18+
: func_( 0 ), index_( 0 )
19+
{;}
2020

21-
const OpFunc* func() const {
22-
return func_;
23-
}
24-
unsigned int index() const {
25-
return index_;
26-
}
21+
const OpFunc* func() const
22+
{
23+
return func_;
24+
}
25+
unsigned int index() const
26+
{
27+
return index_;
28+
}
2729

28-
void set( const OpFunc* func, unsigned int index ) {
29-
func_ = func;
30-
index_ = index;
31-
}
30+
void set( const OpFunc* func, unsigned int index )
31+
{
32+
func_ = func;
33+
index_ = index;
34+
}
3235

33-
bool operator<( const FuncOrder& other ) const
34-
{
35-
return func_ < other.func_;
36-
}
37-
private:
38-
const OpFunc* func_;
39-
unsigned int index_;
36+
bool operator<( const FuncOrder& other ) const
37+
{
38+
return func_ < other.func_;
39+
}
40+
private:
41+
const OpFunc* func_;
42+
unsigned int index_;
4043
};

basecode/global.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace moose {
4949
{ "HSolve", {0.0, 0} }
5050
};
5151

52-
moose::RNG<double> rng;
52+
moose::RNG rng;
5353

5454
/* Check if path is OK */
5555
int checkPath( const string& path )
@@ -104,6 +104,11 @@ namespace moose {
104104
return moose::rng.uniform( );
105105
}
106106

107+
double mtrand( double a, double b )
108+
{
109+
return (b-a) * mtrand() + a;
110+
}
111+
107112
// MOOSE suffixes [0] to all elements to path. Remove [0] with null
108113
// character whenever possible. For n > 0, [n] should not be touched. Its
109114
// the user job to take the pain and write the correct path.

basecode/global.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extern unsigned int totalTests;
5656
namespace moose
5757
{
5858

59-
extern moose::RNG<double> rng;
59+
extern moose::RNG rng;
6060

6161
extern map<string, valarray<double>> solverProfMap;
6262

@@ -114,6 +114,18 @@ namespace moose
114114
*/
115115
double mtrand( void );
116116

117+
/* --------------------------------------------------------------------------*/
118+
/**
119+
* @Synopsis Overloaded function. Random number between a and b
120+
*
121+
* @Param a lower limit.
122+
* @Param b Upper limit.
123+
*
124+
* @Returns
125+
*/
126+
/* ----------------------------------------------------------------------------*/
127+
double mtrand( double a, double b );
128+
117129
/**
118130
* @brief Create a POSIX compatible path from a given string.
119131
* Remove/replace bad characters.

basecode/header.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class Neutral;
9999
#include "SharedFinfo.h"
100100
#include "FieldElementFinfo.h"
101101
#include "FieldElement.h"
102-
#include "../builtins/Streamer.h"
103102
#include "../shell/Neutral.h"
104103

105104

biophysics/Compartment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void Compartment::vRandInject( const Eref& e, double prob, double current)
268268

269269
#ifdef DO_UNIT_TESTS
270270

271-
#include "header.h"
271+
#include "../basecode/header.h"
272272
#include "../shell/Shell.h"
273273
//#include "../randnum/randnum.h"
274274

0 commit comments

Comments
 (0)