# Path: feemodel/tests/config.py
# def tmpdatadir_context():
# def load_obj(filename):
# def mk_tmpdatadir():
# def rm_tmpdatadir():
#     README = ("This is a temporary directory for feemodel unit tests,\n"
#               "and is meant to be removed after every test. Feel free\n"
#               "to delete it if it failed to be removed.\n")
# 
# Path: feemodel/util.py
# def cumsum_gen(iterable, base=0, mapfn=lambda x: x):
#     """Cumulative sum generator.
# 
#     Returns a generator that yields the cumulative sum of a given iterable.
# 
#     base is the object that you begin summing from.
# 
#     mapfn is a function that is applied to each element of the iterable prior
#     to the summation.
#     """
#     cumsum = base
#     for item in iterable:
#         cumsum += mapfn(item)
#         yield cumsum


import unittest
from operator import attrgetter
from collections import defaultdict
from copy import deepcopy
from feemodel.tests.config import poolsref, txref
from feemodel.simul.simul import Simul, UTILIZATION_THRESH
from feemodel.util import cumsum_gen
    stable_byterate = sim.cap.txbyteratefn(sim.stablefeerate)
    print("The stable feerate is {}.".format(sim.stablefeerate))
    print("The stable/total byterate is {}/{}.".
          format(stable_byterate, sim.cap.txbyteratefn(0)))

    for idx, simblock in enumerate(sim.run()):
        bytecounter[simblock.pool.minfeerate] += simblock.size
        if not idx % 10000:
            print(idx)
        if idx == NUMITERS:
            break

    mempool_entries = sim.mempool.get_entries()
    mempool_size = sum(map(attrgetter("size"), mempool_entries.values()))
    print("final mempool len/size: {}/{}".
          format(len(mempool_entries), mempool_size))

    for feerate in bytecounter:
        bytecounter[feerate] /= sim.simtime

    feerates, procrates = zip(*sorted(bytecounter.items()))
    cumprocrates = list(cumsum_gen(procrates))
    try:
        loweststablemfr = sim.cap.procratesfn._x[0]
    except IndexError:
        loweststablemfr = float("inf")

    for feerate, cumprocrate in zip(feerates, cumprocrates):
        if feerate < loweststablemfr:
            continue

# Path: feemodel/tests/config.py
# def tmpdatadir_context():
# def load_obj(filename):
# def mk_tmpdatadir():
# def rm_tmpdatadir():
#     README = ("This is a temporary directory for feemodel unit tests,\n"
#               "and is meant to be removed after every test. Feel free\n"
#               "to delete it if it failed to be removed.\n")
# 
# Path: feemodel/util.py
# def cumsum_gen(iterable, base=0, mapfn=lambda x: x):
#     """Cumulative sum generator.
# 
#     Returns a generator that yields the cumulative sum of a given iterable.
# 
#     base is the object that you begin summing from.
# 
#     mapfn is a function that is applied to each element of the iterable prior
#     to the summation.
#     """
#     cumsum = base
#     for item in iterable:
#         cumsum += mapfn(item)
#         yield cumsum


# Path: feemodel/tests/test_capacity.py
import unittest
from operator import attrgetter
from collections import defaultdict
from copy import deepcopy
from feemodel.tests.config import poolsref, txref
from feemodel.simul.simul import Simul, UTILIZATION_THRESH
from feemodel.util import cumsum_gen

    stable_byterate = sim.cap.txbyteratefn(sim.stablefeerate)
    print("The stable feerate is {}.".format(sim.stablefeerate))
    print("The stable/total byterate is {}/{}.".
          format(stable_byterate, sim.cap.txbyteratefn(0)))

    for idx, simblock in enumerate(sim.run()):
        bytecounter[simblock.pool.minfeerate] += simblock.size
        if not idx % 10000:
            print(idx)
        if idx == NUMITERS:
            break

    mempool_entries = sim.mempool.get_entries()
    mempool_size = sum(map(attrgetter("size"), mempool_entries.values()))
    print("final mempool len/size: {}/{}".
          format(len(mempool_entries), mempool_size))

    for feerate in bytecounter:
        bytecounter[feerate] /= sim.simtime

    feerates, procrates = zip(*sorted(bytecounter.items()))
    cumprocrates = list(cumsum_gen(procrates))
    try:
        loweststablemfr = sim.cap.procratesfn._x[0]
    except IndexError:
        loweststablemfr = float("inf")

    for feerate, cumprocrate in zip(feerates, cumprocrates):
        if feerate < loweststablemfr:
            continue

        lowercumprocrate = sum(