# 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

    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(
            [procrate for _feerate, procrate
             in sim.cap.procratesfn if _feerate > feerate])
        upper_byterate = stable_byterate - lowercumprocrate
        caprate = sim.cap.capfn(feerate)
        print("feerate/actual byterate/upperbound byterate/cap: {}/{}/{}/{}".
              format(feerate, cumprocrate, upper_byterate, caprate))
        assert cumprocrate < upper_byterate*1.01
        assert upper_byterate < caprate*UTILIZATION_THRESH


class CapacityTests(unittest.TestCase):

    def setUp(self):
        self.poolsref = deepcopy(poolsref)
        self.txref = deepcopy(txref)

    def test_A(self):
        """Default ref tests."""

# 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


    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(
            [procrate for _feerate, procrate
             in sim.cap.procratesfn if _feerate > feerate])
        upper_byterate = stable_byterate - lowercumprocrate
        caprate = sim.cap.capfn(feerate)
        print("feerate/actual byterate/upperbound byterate/cap: {}/{}/{}/{}".
              format(feerate, cumprocrate, upper_byterate, caprate))
        assert cumprocrate < upper_byterate*1.01
        assert upper_byterate < caprate*UTILIZATION_THRESH


class CapacityTests(unittest.TestCase):

    def setUp(self):
        self.poolsref = deepcopy(poolsref)
        self.txref = deepcopy(txref)

    def test_A(self):
        """Default ref tests."""

        sim = Simul(self.poolsref, self.txref)