Skip to content

Commit

Permalink
Clean up printfs.
Browse files Browse the repository at this point in the history
  • Loading branch information
upibhalla committed Mar 13, 2024
1 parent f58b126 commit 303990d
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions simWrapHillTau.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import os
import json
import numpy as np
from datetime import datetime

# from simWrap import SimWrap
# from simError import SimError
Expand Down Expand Up @@ -129,6 +130,15 @@ def _scaleOneParam( self, params ):

def deleteItems( self, itemsToDelete ):
self.modifiedModelDict = dict( self.jsonDict )
# Update the Description and Author fields to reflect subsetting.
description = self.modifiedModelDict.get("Description")
if not description:
description = ""
self.modifiedModelDict["Description"] = description + ": Original model modified by findSim for subset calculations."
author = self.modifiedModelDict.get("Author")
if not author:
author = ""
self.modifiedModelDict["Author"] = author + ": Programmatic modification by findSim at " + datetime.today().strftime('%Y-%m-%d %H:%M:%S')
# This accumulates a list of objects to delete, which is then
# applied to the model once it is built.
# Note that we silently ignore requests to delete nonexistent
Expand Down Expand Up @@ -207,24 +217,21 @@ def extObjLinkedToGroup( self, grp ):
for rr in groupVal['Reacs']:
mySpecies.add( rr )

print( grp, "NUM MY SPECIES = ", len( mySpecies ) )
print( "MY SPECIES = ", mySpecies )
#print( "MY SPECIES = ", mySpecies )
# Scan for reagent species of eqns and reacs, add if outside group.
ret = set()
if groupVal.get( 'Eqns' ):
for eqnName, eqnVal in groupVal['Eqns'].items():
subs, cs = hillTau.extractSubs( eqnVal, consts )
for ss in subs:
print( "SS in Eqns = ", ss )
if ss not in mySpecies:
ret.add( ss )
if groupVal.get( 'Reacs' ):
for rname, rval in groupVal['Reacs'].items():
for ss in rval['subs']:
print( "SS = ", ss )
if ss not in mySpecies:
ret.add( ss )
print( grp, "NUM Ext Obj= ", len( ret ) )
#print( grp, "NUM Ext Obj= ", len( ret ) )
return ret

def allObjLinkedToObj( self, obj ):
Expand Down Expand Up @@ -296,7 +303,6 @@ def subsetItems( self, _modelSubset ):
entry = self.findDictOfObj( oo )
if not entry[0] in subsettedGroups:
extEntries.append( entry )
print( "ENTRY = ", entry )

# Now we have all the lists. Now march through and rebuild
# Here are the entire subsetted groups, just copied over.
Expand All @@ -307,9 +313,17 @@ def subsetItems( self, _modelSubset ):
for [grp, objType, objName, objVal] in extEntries:
if not grp in gdict:
gdict[grp] = {}
if not objType in gdict[grp]:
gdict[grp][objType] = {}
gdict[grp][objType][objName] = objVal
if not "Species" in gdict[grp]:
gdict[grp]["Species"] = {}
if objType == "Species":
gdict[grp][objType][objName] = objVal
if objType == "Reacs":
baseline = objVal.get( "baseline" )
if not baseline:
baseline = 0.0
gdict[grp]["Species"][objName] = baseline
if objType == "Eqns":
gdict[grp]["Species"][objName] = 0.0

# Finally, wrap it up
subsetDict['Groups'] = gdict
Expand Down Expand Up @@ -423,7 +437,7 @@ def loadModelFile( self, fname, modifyFunc, scaleParam, dumpFname, paramFname ):
modelWarning = "Warning in subsetting from: " + fname
modifyFunc( {}, modelWarning ) # Callback.
t0 = time.time()
#self.model = hillTau.parseModel( self.jsonDict )
self.model = hillTau.parseModel( self.jsonDict )
#print( "loadModelFile: scaling parms {}".format( scaleParam ) )
#self.model.modifySched( saveList = self.saveList, deleteList = self.deleteList )
#self.trimModelLookup()
Expand Down

0 comments on commit 303990d

Please sign in to comment.