How to use the quantecon.tests.get_h5_data_file function in quantecon

To help you get started, we’ve selected a few quantecon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github QuantEcon / QuantEcon.lectures.code / odu / test_odu.py View on Github external
def _get_data(sp, force_new=False):
    "get solution data from file, or create if necessary"
    with get_h5_data_file() as f:
        existed, grp = get_h5_data_group("odu")

        if force_new or not existed:
            if existed:
                grp.v._f_remove()
                grp.phi_vfi._f_remove()
                grp.phi_pfi._f_remove()
                grp.new_v._f_remove()
            v, phi_vfi, phi_pfi, new_v = _new_solution(sp, f, grp)

            return v, phi_vfi, phi_pfi, new_v

        # if we made it here, the group exists and we should try to read
        # existing solutions
        try:
            # Try reading data
github QuantEcon / QuantEcon.lectures.code / ifp / test_ifp.py View on Github external
def _get_vfi_pfi_guesses(cp, force_new=False):
    """
    load precomputed vfi/pfi solutions, or compute them if requested
    or we can't find old ones
    """
    # open the data file
    with get_h5_data_file() as f:

        # See if the ifp group already exists
        group_existed = True
        try:
            ifp_group = f.getNode("/ifp")
        except:
            # doesn't exist
            group_existed = False
            ifp_group = f.create_group("/", "ifp", "data for ifp.py tests")

        if force_new or not group_existed:
            # group doesn't exist, or forced to create new data.
            # This function updates f in place and returns v_vfi, c_vfi, c_pfi
            v_vfi, c_vfi, c_pfi = _new_solutions(cp, f, ifp_group)

            # We have what we need, so return
github QuantEcon / QuantEcon.lectures.code / jv / test_jv.py View on Github external
def _get_vf_guess(jv, force_new=False):
    with get_h5_data_file() as f:

        # See if the jv group already exists
        group_existed = True
        try:
            jv_group = f.getNode("/jv")
        except:
            # doesn't exist
            group_existed = False
            jv_group = f.create_group("/", "jv", "data for jv.py tests")

        if force_new or not group_existed:
            # group doesn't exist, or forced to create new data.
            # This function updates f in place and returns v_vfi, c_vfi, c_pfi
            V = _new_solution(jv, f, jv_group)

            return V
github QuantEcon / QuantEcon.lectures.code / lucas_model / test_lucastree.py View on Github external
def _get_price_data(tree, force_new=False):
    "get price data from file, or create if necessary"
    with get_h5_data_file() as f:
        existed, grp = get_h5_data_group("lucastree")

        if force_new or not existed:
            if existed:
                grp.prices._f_remove()
            prices = _new_solution(tree, f, grp)

            return prices

        # if we made it here, the group exists and we should try to read
        # existing solutions
        try:
            # Try reading vfi
            prices = grp.prices[:]

        except: