mirror of
https://github.com/codex-storage/das-research.git
synced 2025-02-23 08:18:14 +00:00
Compact code
This commit is contained in:
parent
1e4aefe261
commit
eb141deb5b
@ -45,13 +45,9 @@ class Simulator:
|
|||||||
self.proposerPublishToC = config.evalConf(self, config.proposerPublishToR, shape)
|
self.proposerPublishToC = config.evalConf(self, config.proposerPublishToR, shape)
|
||||||
|
|
||||||
def getNodeClass(self, nodeIdx):
|
def getNodeClass(self, nodeIdx):
|
||||||
nodeRatios = []
|
nodeRatios = [_v['ratio'] for _k, _v in self.shape.nodeTypes.items() if _k != "group"]
|
||||||
for _k, _v in self.shape.nodeTypes.items():
|
|
||||||
if _k != "group": nodeRatios.append(_v['ratio'])
|
|
||||||
nodeCounts = [int(self.shape.numberNodes * ratio / sum(nodeRatios)) for ratio in nodeRatios]
|
nodeCounts = [int(self.shape.numberNodes * ratio / sum(nodeRatios)) for ratio in nodeRatios]
|
||||||
commulativeSum = [nodeCounts[0]]
|
commulativeSum = [sum(nodeCounts[:i+1]) for i in range(len(nodeCounts))]
|
||||||
for count in nodeCounts[1: ]:
|
|
||||||
commulativeSum.append(commulativeSum[-1] + count)
|
|
||||||
commulativeSum[-1] = self.shape.numberNodes
|
commulativeSum[-1] = self.shape.numberNodes
|
||||||
for i, idx in enumerate(commulativeSum):
|
for i, idx in enumerate(commulativeSum):
|
||||||
if nodeIdx < idx:
|
if nodeIdx < idx:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user