def test_MyParser_parseFile(db, data_key, meta): data_file = db[data_key] parser = MyParser() parser.parseFile(data_file, meta=meta) if meta: for key, value in meta.items(): assert parser._meta[key] == value
def recipe(request): parser = MyParser() parser.parseFile(NI_GR) stru = request.param(NI_CIF) recipe = multi_phase([(F.sphericalCF, stru)], parser, fit_range=(2., 8.0, .1), values={ 'psize_G0': 200}, sg_params={'G0': 225}) return recipe
def test_MyParser_parsePDFGetter(db, data_key, meta): pdfgetter = db[data_key] parser = MyParser() parser.parsePDFGetter(pdfgetter, meta=meta) if meta: for key, value in meta.items(): assert parser._meta[key] == value
def test_MyParser_parseDict(db, meta): parser = MyParser() parser.parseDict(db['Ni_gr'], meta=meta) recipe = multi_phase([db['Ni_stru']], parser, fit_range=(0., 8., .1)) con = next(iter(recipe.contributions.values())) gen = next(iter(con.generators.values())) # if meta = None, generator will use the default values assert gen.getQmin() == parser._meta.get('qmin', 0.0) assert gen.getQmax() == parser._meta.get('qmax', 100. * np.pi) assert gen.qdamp.value == parser._meta.get('qdamp', 0.0) assert gen.qbroad.value == parser._meta.get('qbroad', 0.0)
def test_make_contribution(db): parser = MyParser() parser.parseFile(db['Ni_gr_file']) gen_config = GenConfig("G", db['Ni_stru']) fun_config = FunConfig("f", F.sphericalCF) con_config = ConConfig(name="test", parser=parser, fit_range=(0, 8, 0.01), eq="G + B", funconfigs=[fun_config], genconfigs=[gen_config], baselines=[GaussianGenerator("B")]) con = make_contribution(con_config) assert len(con.generators) == 2
def test_ConConfig(db, kwargs, expect): parser = MyParser() parser.parseFile(db['Ni_gr_file']) stru = db['Ni_stru'] con_config = ConConfig( name="con", parser=parser, fit_range=(0., 8., .1), genconfigs=[GenConfig('G0', stru)], eq="G0", **kwargs ) for key, value in expect.items(): assert getattr(con_config, key) == value
def data(db): parser = MyParser() parser.parseFile(db["Ni_gr_file"], {"qdamp": 0.04, "qbroad": 0.02}) return parser
def test_MyParser_parseDict_error(data): parser = MyParser() with pytest.raises(ValueError): parser.parseDict(data)