Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,17 @@ addons:
update: true

before_script:
- echo "OSX related"
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then nvm get head || true; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_prepare_osx.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./.travis/travis_prepare_linux.sh; fi


before_script:
- echo "OSX related"
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then nvm get head || true; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_prepare_osx.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./.travis/travis_prepare_linux.sh;
fi
script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./.travis/travis_prepare_linux.sh; fi

- python2 -m compileall -q . || echo "Python2 not found"
- if type python3 > /dev/null; then python3 -m compileall -q . ; fi
script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_build_osx.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.travis/travis_build_linux.sh; fi

Expand Down
36 changes: 36 additions & 0 deletions .travis/run_pylint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -e
python3 -m pip install pylint --user
PYLINT="python3 -m pylint -E \
--disable=no-member --disable=no-name-in-module \
--disable=invalid-unary-operand-type \
--disable=import-error \
"
function do_pylint() {
echo "Checking $1"
DIR=$(dirname $1)
SNAME=$(basename $1)
(
cd $DIR
$PYLINT $@ $SNAME
)
}

FILES=$(find . -type f -name "*.py" | shuf)
N=4
i=0
for f in $FILES; do
#i=$((i+1))
#if [ $i -eq $N ]; then
# i=0
# wait;
#fi
# do_pylint "$f"
echo "Checking $f"
DIR=$(dirname $f)
SNAME=$(basename $f)
(
cd $DIR
$PYLINT $@ $SNAME
)
done
10 changes: 8 additions & 2 deletions .travis/travis_build_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ set -e
# NOTE: On travis, don't enable -j`nproc` option. It may not compile properly.

(

# Make sure not to pick up python from /opt.
PATH=/usr/bin:/usr/local/bin:$PATH
PATH=/usr/local/bin:/usr/bin:$PATH

# Get pylint
python -m pip install pylint --user
python -m pip install python-libsbml --user
python -m pip install pyneuroml --user

mkdir -p _GSL_BUILD && cd _GSL_BUILD \
&& cmake -DDEBUG=ON \
-DPYTHON_EXECUTABLE=`which python` ..
make pylint -j3
make && ctest --output-on-failure

cd .. # Now with boost.
Expand Down
2 changes: 2 additions & 0 deletions .travis/travis_prepare_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ apt-get install -qq python-numpy python-matplotlib python-networkx python-pip
apt-get install -qq python3-lxml python-lxml
apt-get install -qq python3-numpy python3-matplotlib python3-dev
apt-get install -qq python-pip python3-pip
apt-get install -qq python-tk python3-tk
apt-get install -qq libgraphviz-dev

# Gsl
Expand All @@ -42,3 +43,4 @@ apt-get install -qq python-setuptools python3-setuptools
apt-get install -qq python-tornado python3-tornado
python2 -m pip install pyNeuroML libNeuroML
python3 -m pip install pyNeuroML libNeuroML

22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -518,5 +518,27 @@ foreach( _test_script ${PY_TEST_SCRIPTS} )
)
endforeach( )

# add pylint target.
set(PYSCRIPTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/python )
file(GLOB_RECURSE PY_SCRIPTS "python/*.py")
add_custom_target( pylint )
foreach( _py_script ${PY_SCRIPTS} )
get_filename_component( _py_name ${_py_script} NAME_WE)
file( READ ${_py_script} pytext)
string(MD5 _md5 "${pytext}")
set(TGT_NAME "${_py_name}-${_md5}" )
set(PYLINT_OPTIONS --disable=no-member --disable=no-name-in-module
--disable=invalid-unary-operand-type
--disable=import-error
--disable=no-method-argument
)
add_custom_target( ${TGT_NAME}
COMMAND ${PYTHON_EXECUTABLE} -m pylint -E ${PYLINT_OPTIONS} ${_py_script}
COMMENT "Running pylint on ${_py_script}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies(pylint ${TGT_NAME} )
endforeach( )

############################ CPACK ######################################
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_moose_cpack.cmake)
2 changes: 2 additions & 0 deletions CheckCXXCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ add_definitions(-Wall
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_definitions( -Wno-unused-local-typedefs )
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
add_definitions( -Wno-unused-local-typedef )
endif()


Expand Down
1 change: 0 additions & 1 deletion python/moose/OrderedDict.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
except ImportError:
pass


class OrderedDict(dict):
'Dictionary that remembers insertion order'
# An inherited dict maps keys to values.
Expand Down
1 change: 1 addition & 0 deletions python/moose/SBML/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,6 @@ def validateModel(sbmlDoc):
# consistencyMessages)

if __name__ == '__main__':
import libsbml
sbmlDoc = libsbml.readSBML('00001-sbml-l3v1.xml')
validateModel(sbmlDoc)
25 changes: 11 additions & 14 deletions python/moose/SBML/writeSBML.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,12 @@
'''
import sys
import re
import os
import moose
from moose.SBML.validation import validateModel
from moose.chemUtil.chemConnectUtil import *
from moose.chemUtil.graphUtils import *


# ToDo:
# Table should be written
# boundary condition for buffer pool having assignment statment constant
# shd be false

foundLibSBML_ = False
try:
from libsbml import *
Expand Down Expand Up @@ -171,9 +166,10 @@ def mooseWriteSBML(modelpath, filename, sceneitems={}):
else:
return False, "Atleast one compartment should exist to write SBML"

def calPrime(x):
prime = int((20 * (float(x - cmin) / float(cmax - cmin))) - 10)
return prime
# This function does not make sense. Where is cmin, cmax?
#def calPrime(x):
# prime = int((20 * (float(x - cmin) / float(cmax - cmin))) - 10)
# return prime

def writeEnz(modelpath, cremodel_, sceneitems,groupInfo):
for enz in moose.wildcardFind(modelpath + '/##[ISA=EnzBase]'):
Expand Down Expand Up @@ -1060,11 +1056,12 @@ def writeSimulationAnnotation(modelpath):
modelAnno = modelAnno + "</moose:ModelAnnotation>"
return modelAnno

def xyPosition(objInfo,xory):
try:
return(float(moose.element(objInfo).getField(xory)))
except ValueError:
return (float(0))
## Already defined in chemConnectUtil from which this module is importing *
#def xyPosition(objInfo,xory):
# try:
# return(float(moose.element(objInfo).getField(xory)))
# except ValueError:
# return (float(0))

def recalculatecoordinates(modelpath, mObjlist,xcord,ycord):
positionInfoExist = not(len(np.nonzero(xcord)[0]) == 0 \
Expand Down
11 changes: 8 additions & 3 deletions python/moose/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function

# Bring moose.py functions into global namespace.

# Bring everything from moose.py to global namespace.
from moose.moose import *

__version__ = version( )
# Bring everything from c++ module to global namespace. Not everything is
# imported by the pervios import statement.
from moose._moose import *

# create a shorthand for version() call here.
__version__ = version()

10 changes: 0 additions & 10 deletions python/moose/chemMerge/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,17 +714,7 @@ def checkexist(spList,objB,objA):

return allexist

def findCompartment(element):
while not mooseIsInstance(element,["CubeMesh","CyclMesh"]):
element = element.parent
return element

def mooseIsInstance(element, classNames):
return moose.element(element).__class__.__name__ in classNames


if __name__ == "__main__":

try:
sys.argv[1]
except IndexError:
Expand Down
13 changes: 3 additions & 10 deletions python/moose/chemUtil/chemConnectUtil.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
""" ChemconnectUtil.py Some of the command function are written """

#Created : Friday May 27 12:19:00 2016(+0530)

__author__ = "Harsha Rani"
__copyright__ = "Copyright 2017, Harsha Rani and NCBS Bangalore"
__credits__ = ["NCBS Bangalore"]
Expand All @@ -13,16 +11,14 @@
__status__ = "Development"
__updated__ = "Aug 8 2017"

#Aug 8 : added findCompartment function here

import moose
import numpy as np

def xyPosition(objInfo,xory):
try:
return(float(moose.element(objInfo).getField(xory)))
except ValueError:
return (float(0))
return float(moose.element(objInfo).getField(xory))
except ValueError as e:
return float(0)

def setupMeshObj(modelRoot):
''' Setup compartment and its members pool,reaction,enz cplx under self.meshEntry dictionaries \
Expand Down Expand Up @@ -94,9 +90,6 @@ def setupMeshObj(modelRoot):
ymax = max(ycord)
return meshEntry,xmin,xmax,ymin,ymax,positionInfoExist,listOfitems

def sizeHint(self):
return QtCore.QSize(800,400)

def getxyCord(xcord,ycord,list1,listOfitems):
for item in list1:
# if isinstance(item,Function):
Expand Down
Loading