相关疑难解决方法(0)

迭代过程中Python字典的顺序是否得到保证?

我目前正在使用SciPy.integrate.ode在Python中实现复杂的微生物食品网.我需要能够轻松地将物种和反应添加到系统中,所以我必须编写一些非常通用的代码.我的方案看起来像这样:

class Reaction(object):
    def __init__(self):
        #stuff common to all reactions
    def __getReactionRate(self, **kwargs):
        raise NotImplementedError

... Reaction subclasses that 
... implement specific types of reactions


class Species(object):
    def __init__(self, reactionsDict):
        self.reactionsDict = reactionsDict
        #reactionsDict looks like {'ReactionName':reactionObject, ...}
        #stuff common to all species

    def sumOverAllReactionsForThisSpecies(self, **kwargs):
        #loop over all the reactions and return the 
        #cumulative change in the concentrations of all solutes

...Species subclasses where for each species
... are defined and passed to the superclass constructor

class …
Run Code Online (Sandbox Code Playgroud)

python dictionary numpy scientific-computing scipy

34
推荐指数
6
解决办法
2万
查看次数

标签 统计

dictionary ×1

numpy ×1

python ×1

scientific-computing ×1

scipy ×1