<commit_before>import io
import os
import xml.etree.ElementTree as ET

class BaseClock(object):

    def __init__(self, clock_config, global_config):

        self.config = global_config
        # By default, whether or not to estimate the rate is left up to
        # BEASTling.
        default_estimate_rate = None
        # But if the user specifies a rate, we assume they do not want it
        # estimated...
        if any([k in clock_config for k in ("mean", "rate")]):
            k = "mean" if "mean" in clock_config else "rate"
            self.initial_mean = clock_config[k]
            default_estimate_rate = False
        else:
            self.initial_mean = 1.0
        # ...but they can override this by explicitly saying so.
        self.estimate_rate = clock_config.get("estimate_rate",default_estimate_rate)
        self.calibrations = global_config.calibrations
        self.name = clock_config["name"] 
        self.mean_rate_id = "clockRate.c:%s" % self.name
        self.mean_rate_idref = "@%s" % self.mean_rate_id
        self.is_used = False

    def add_state(self, state):
        # Add mean clock rate
        parameter = ET.SubElement(state, "parameter", {
            "id": self.mean_rate_id,
            "name": "stateNode"
            })
        parameter.text=str(self.initial_mean)

    def add_prior(self, prior):<commit_msg>Restrict domain of mean clock rate to be <= 1000, which is already faster than reasonable.  This MAY help to control rare clock explosions.<commit_after>import io
import os
import xml.etree.ElementTree as ET

class BaseClock(object):

    def __init__(self, clock_config, global_config):

        self.config = global_config
        # By default, whether or not to estimate the rate is left up to
        # BEASTling.
        default_estimate_rate = None
        # But if the user specifies a rate, we assume they do not want it
        # estimated...
        if any([k in clock_config for k in ("mean", "rate")]):
            k = "mean" if "mean" in clock_config else "rate"
            self.initial_mean = clock_config[k]
            default_estimate_rate = False
        else:
            self.initial_mean = 1.0
        # ...but they can override this by explicitly saying so.
        self.estimate_rate = clock_config.get("estimate_rate",default_estimate_rate)
        self.calibrations = global_config.calibrations
        self.name = clock_config["name"] 
        self.mean_rate_id = "clockRate.c:%s" % self.name
        self.mean_rate_idref = "@%s" % self.mean_rate_id
        self.is_used = False

    def add_state(self, state):
        # Add mean clock rate
        parameter = ET.SubElement(state, "parameter", {
            "id": self.mean_rate_id,
            "upper": "1000.0",
            "name": "stateNode"
            })
        parameter.text=str(self.initial_mean)

    def add_prior(self, prior):
{'fraction_non_alphanumeric': 0.09378256339006599, 'fraction_numerical': 0.0045154567558179926, 'mean_word_length': 2.3488372093023258, 'pattern_counts': {'":': 5, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2108240', 'n_tokens_mistral': 857, 'n_tokens_neox': 831, 'n_words': 247}