Skip to content

Commit

Permalink
pyflakes (static code analysis) error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dilawar Singh committed Jun 14, 2019
1 parent 54a6515 commit 534e0a6
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 37 deletions.
4 changes: 1 addition & 3 deletions Brent_minimization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or
Expand Down Expand Up @@ -40,12 +40,10 @@
'''

from __future__ import print_function
import numpy
from scipy import optimize
import argparse
import os
import sys
import argparse
import findSim
from multiprocessing import Pool

Expand Down
2 changes: 0 additions & 2 deletions basicParameterSweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@
'''

from __future__ import print_function
import numpy
import argparse
import os
import sys
import argparse
import findSim
from multiprocessing import Pool

Expand Down
51 changes: 25 additions & 26 deletions findSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import time
import imp # This is apparently deprecated in Python 3.4 and up
import matplotlib.pyplot as pyplot
import mpld3

#mpld3 hack
# suggested: https://github.com/mpld3/mpld3/issues/434
Expand Down Expand Up @@ -378,14 +377,14 @@ def doScore( self, scoringFormula ):
assert( len(self.data) == len( self.simData ) )
score = 0.0
numScore = 0.0
dvals = [i[1] for i in self.data]
datarange = max( dvals ) - min( dvals )
# dvals = [i[1] for i in self.data]
# datarange = max( dvals ) - min( dvals )
for i,sim in zip( self.data, self.simData ):
t = i[0]
expt = i[1]
sem = i[2]
#print t, expt, sem, sim, datarange
#print "Formula = ", scoringFormula, eval( scoringFormula )
# t = i[0]
# expt = i[1]
# sem = i[2]
# print t, expt, sem, sim, datarange
# print "Formula = ", scoringFormula, eval( scoringFormula )
score += eval( scoringFormula )
numScore += 1.0

Expand All @@ -399,16 +398,16 @@ def directParamScore( readouts, modelLookup, scoringFormula ):
for rd in readouts:
for d in rd.data:
entity = d[0]
expt = d[1]*rd.quantityScale
sem = d[2]*rd.quantityScale
# expt = d[1]*rd.quantityScale
# sem = d[2]*rd.quantityScale
if not entity in modelLookup:
raise SimError( "Readout::directParamScore: Entity {} not found".format( entity ) )
elmList = modelLookup[entity]
if len( elmList ) != 1:
raise SimError( "Readout::directParamScore: Should only have 1 object, found {} ".format( len( elmList ) ) )
# We use a utility function because findSim may permit
# parameters like Kd that need to be evaluated.
sim = getObjParam( elmList[0], rd.field )
# sim = getObjParam( elmList[0], rd.field )
#sim = elmList[0].getField( rd.field )
score += eval( scoringFormula )
numScore += 1.0
Expand Down Expand Up @@ -717,15 +716,15 @@ def isNotDescendant( elm, ancestorSet ):
def getObjParam( elm, field ):
if field == 'Kd':
if not elm.isA['ReacBase']:
raise SimError( "getObjParam: can only get Kd on a Reac, was: '{}'".format( obj.className ) )
raise SimError( "getObjParam: can only get Kd on a Reac, was: '{}'".format( elm.className ) )
return elm.Kb/elm.Kf
elif field == 'tau':
# This is a little dubious, because order 1 reac has 1/conc.time
# units. Suppose Kf = x / mM.sec. Then Kf = 0.001x/uM.sec
# This latter is the Kf we want to use, assuming typical concs are
# around 1 uM.
if not elm.isA['ReacBase']:
raise SimError( "getObjParam: can only get tau on a Reac, was: '{}'".format( obj.className ) )
raise SimError( "getObjParam: can only get tau on a Reac, was: '{}'".format( elm.className ) )
scaleKf = 0.001 ** (elm.numSubstrates-1)
scaleKb = 0.001 ** (elm.numProducts-1)
#print( "scaleKf={}; scaleKb={}, numsu ={}, numPrd={},Kb={},Kf={}".format( scaleKf, scaleKb, elm.numSubstrates, elm.numProducts, elm.Kb, elm.Kf ) )
Expand Down Expand Up @@ -867,7 +866,7 @@ def pruneDanglingObj( kinpath, erSPlist):
for i in erlist:
isub = i.neighbors["sub"]
iprd = i.neighbors["prd"]
tobedelete = False
# tobedelete = False
if moose.exists(i.path):
if len(isub) == 0 or len(iprd) == 0 :
subprdNotfound = True
Expand Down Expand Up @@ -954,8 +953,8 @@ def makeReadoutPlots( readouts, modelLookup ):
moose.connect( plot, 'requestOut', elm, fieldname )

def putReadoutsInQ( q, readouts, pauseHsolve ):
stdError = []
plotLookup = {}
# stdError = []
# plotLookup = {}
for i in readouts:
if i.field in (epspFields + epscFields):
for j in range( len( i.data ) ):
Expand Down Expand Up @@ -1016,7 +1015,7 @@ def doReadout( qe, model ):
'''
readout = qe.entry
val = int(round( ( qe.val ) ) )
ratioReference = 0.0
# ratioReference = 0.0
if readout.field in (epspFields + epscFields):
doEpspReadout( readout, model.modelLookup )
elif val == -1: # This is a special event to get RatioReferenceValue
Expand Down Expand Up @@ -1109,7 +1108,7 @@ def parseAndRunDoser( model, stims, readouts, modelId ):
exactly one stimulus block, {} defined".format( len(stims)) )
if len( readouts ) != 1:
raise SimError( "parseAndRunDoser: Dose response run needs \
exactly one readout block, {} defined".format( len(readout) ) )
exactly one readout block, {} defined".format( len(readouts) ) )
numLevels = len( readouts[0].data )

if numLevels == 0:
Expand All @@ -1131,10 +1130,10 @@ def parseAndRunDoser( model, stims, readouts, modelId ):

##########################################################################
def runDoser( model, stim, readout, doseMol ):
responseScale = readout.quantityScale
# responseScale = readout.quantityScale
doseScale = stim.quantityScale
referenceDose = readout.ratioReferenceDose * stim.quantityScale
sim = 0.0
# sim = 0.0
for dose, response, sem in readout.data:
doseMol.concInit = dose * doseScale
moose.reinit()
Expand Down Expand Up @@ -1164,7 +1163,7 @@ def doBarChartStim( multiStimLine, doseMol, dose, field ):

def doBarChartReference( readout, stim, modelLookup ):
if readout.useRatio and readout.ratioReferenceTime >= 0.0:
responseScale = readout.quantityScale
# responseScale = readout.quantityScale
referenceDose = readout.ratioReferenceDose * stim.quantityScale
referenceMol = modelLookup[readout.ratioReferenceEntities[0] ]

Expand Down Expand Up @@ -1206,7 +1205,7 @@ def parseAndRunBarChart( model, stims, readouts, modelId ):
one stimulus block, {} defined".format( len( stims ) ) )
if len( readouts ) != 1:
raise SimError( "parseAndRunBarChart: BarChart run needs exactly \
one readout block, {} defined".format( len( readout ) ) )
one readout block, {} defined".format( len( readouts ) ) )
numLevels = len( readouts[0].data )

if numLevels == 0:
Expand Down Expand Up @@ -1268,9 +1267,9 @@ def convertBarChartLabels( self, readout, stim ):

def plotbar( self, readout, stim, scriptName ):
barpos = np.arange( len( self.sim ) )
width = 0.35 # A reasonable looking bar width
exptBar = pyplot.bar(barpos - width/2, self.expt, width, yerr=self.yerror, color='SkyBlue', label='Experiment')
simBar = pyplot.bar(barpos + width/2, self.sim, width, color='IndianRed', label='Simulation')
# width = 0.35 # A reasonable looking bar width
# exptBar = pyplot.bar(barpos - width/2, self.expt, width, yerr=self.yerror, color='SkyBlue', label='Experiment')
# simBar = pyplot.bar(barpos + width/2, self.sim, width, color='IndianRed', label='Simulation')
pyplot.xlabel( "Stimulus combinations" )
pyplot.ylabel( self.ylabel )
pyplot.title(scriptName)
Expand Down Expand Up @@ -1480,7 +1479,7 @@ def innerMain( script, modelFile = "model/synSynth7.g", dumpFname = "", paramFna
'''

global pause
solver = "gsl" # Pick any of gsl, gssa, ee..
# solver = "gsl" # Pick any of gsl, gssa, ee..
modelWarning = ""
modelId = ""
expt, stims, readouts, model = loadTsv( script )
Expand Down
1 change: 0 additions & 1 deletion models/loadhh.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import moose
import rdesigneur as rd
def load():
rdes = rd.rdesigneur(
Expand Down
1 change: 0 additions & 1 deletion multi_param_minimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from __future__ import print_function
import numpy as np
from scipy import optimize
import argparse
import os
import sys
import argparse
Expand Down
2 changes: 0 additions & 2 deletions runAllParallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@
'''
from __future__ import print_function, division

import numpy
import argparse
import os
import sys
import argparse
import time
from multiprocessing import Pool

Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
__maintainer__ = "Dilawar Singh"
__email__ = "[email protected]"

import os
import sys
import setuptools

with open("README.md") as f:
Expand Down

0 comments on commit 534e0a6

Please sign in to comment.