<commit_before>"""
desispec.io.params
===============

IO routines for parameter values
"""
from __future__ import print_function, absolute_import, division

import yaml

from pkg_resources import resource_filename


def read_params(filename=None):
    """Read parameter data from file
    """
    global params  # Caching

    # File
    if filename is None:
        filename = resource_filename('desispec','/data/params/desispec_param.yml')
    # Read yaml
    with open(filename, 'r') as infile:
        params = yaml.load(infile)
    # Return
    return params


<commit_msg>now properly cached [I think]<commit_after>"""
desispec.io.params
===============

IO routines for parameter values
"""
from __future__ import print_function, absolute_import, division

import yaml

from pkg_resources import resource_filename

# CACHE
params = {}


def read_params(filename=None, reload=False):
    """Read parameter data from file
    """
    global params  # Cache
    # Init
    if (len(params) == 0) or (reload is True):
        if filename is None:
            filename = resource_filename('desispec','/data/params/desispec_param.yml')
        # Read yaml
        with open(filename, 'r') as infile:
            params = yaml.load(infile)
    # Return
    return params



{'fraction_non_alphanumeric': 0.11547525530243519, 'fraction_numerical': 0.0007855459544383347, 'mean_word_length': 3.348122866894198, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4977465', 'n_tokens_mistral': 382, 'n_tokens_neox': 359, 'n_words': 110}