<commit_before>#!/usr/bin/env python
"""
Test fitting the velocity dispersion.
"""

import numpy as np
import pylab as plt
import logging

import dsphsim.instruments
import dsphsim.dwarf

import dsphsim.vdisp
import dsphsim.simulator

# More verbose output...
logging.getLogger().setLevel(logging.DEBUG)

def test_vdisp():
    np.random.seed(0)
     
    # Is the output independent of richness? 
    # It should be, but doesn't look like it is...
    kwargs = dict(distance_modulus=17.5,extension=0.1,rs=1.0,richness=1e5)
    kwargs.update(vmax=50)
     
    dwarf = dsphsim.dwarf.Dwarf(**kwargs)
    tac   = dsphsim.tactician.ObstimeTactician(instrument='M2FS')
     
    simulator = dsphsim.simulator.Simulator()
    data = simulator.simulate(dwarf,tac)
     
    peaks = []
    for i in range(10):
        samples = dsphsim.vdisp.mcmc(data['VTRUE'],data['VERR'])
        peaks.append(dsphsim.vdisp.kde_peak(samples['sigma']))
        print peaks[-1]
     
    assert np.allclose(peaks,3.3,atol=0.1)

if __name__ == "__main__":
    test_vdisp()
<commit_msg>Updating test to new output from mcmc call<commit_after>#!/usr/bin/env python
"""
Test fitting the velocity dispersion.
"""

import numpy as np
import pylab as plt
import logging

import dsphsim.instruments
import dsphsim.dwarf

import dsphsim.vdisp
import dsphsim.simulator

# More verbose output...
logging.getLogger().setLevel(logging.DEBUG)

def test_vdisp():
    np.random.seed(0)
     
    # Is the output independent of richness? 
    # It should be, but doesn't look like it is...
    kwargs = dict(distance_modulus=17.5,extension=0.1,rs=1.0,richness=1e5)
    kwargs.update(vmax=50)
     
    dwarf = dsphsim.dwarf.Dwarf(**kwargs)
    tac   = dsphsim.tactician.ObstimeTactician(instrument='M2FS')
     
    simulator = dsphsim.simulator.Simulator()
    data = simulator.simulate(dwarf,tac)
     
    peaks = []
    for i in range(10):
        samples,sampler = dsphsim.vdisp.mcmc(data['VTRUE'],data['VERR'])
        peaks.append(dsphsim.vdisp.kde_peak(samples['sigma']))
        print peaks[-1]
     
    assert np.allclose(peaks,3.3,atol=0.1)

if __name__ == "__main__":
    test_vdisp()

{'fraction_non_alphanumeric': 0.12656467315716272, 'fraction_numerical': 0.01854427445526194, 'mean_word_length': 3.386178861788618, 'pattern_counts': {'":': 2, '<': 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': '6137136', 'n_tokens_mistral': 796, 'n_tokens_neox': 777, 'n_words': 155}