def test_datasets_convert_thermochemical_string_values_producing_correct_value( datasets_db): """Strings where floats are expected should give correct answers for thermochemical datasets""" ds = clean_dataset(CU_MG_DATASET_THERMOCHEMICAL_STRING_VALUES) assert np.issubdtype(np.array(ds['values']).dtype, np.number) assert np.issubdtype(np.array(ds['conditions']['T']).dtype, np.number) assert np.issubdtype(np.array(ds['conditions']['P']).dtype, np.number)
def test_datasets_convert_zpf_string_values_producing_correct_value( datasets_db): """Strings where floats are expected should give correct answers for ZPF datasets""" ds = clean_dataset(CU_MG_DATASET_ZPF_STRING_VALUES) assert np.issubdtype( np.array([t[0][2] for t in ds['values']]).dtype, np.number) assert np.issubdtype(np.array(ds['conditions']['T']).dtype, np.number) assert np.issubdtype(np.array(ds['conditions']['P']).dtype, np.number)
def test_datasets_convert_zpf_string_values_producing_correct_value( datasets_db): """Strings where floats are expected should give correct answers for ZPF datasets""" datasets_db.insert(clean_dataset(CU_MG_DATASET_ZPF_STRING_VALUES)) dbf = Database(CU_MG_TDB) errors = calculate_zpf_error(dbf, ['CU', 'MG', 'VA'], list(dbf.phases.keys()), datasets_db, {}, {}, {}) assert np.isclose(-np.sum(np.square(errors)), -5741.61962949)
def test_datasets_convert_thermochemical_string_values_producing_correct_value( datasets_db): """Strings where floats are expected should give correct answers for thermochemical datasets""" datasets_db.insert( clean_dataset(CU_MG_DATASET_THERMOCHEMICAL_STRING_VALUES)) dbf = Database(CU_MG_TDB) error = calculate_thermochemical_error(dbf, ['CU', 'MG', 'VA'], list(dbf.phases.keys()), datasets_db) assert np.isclose(float(error), -3672.727272727273, atol=0.01)
def test_applying_tags(datasets_db): """Test that applying tags updates the appropriate values""" dataset = clean_dataset(CU_MG_DATASET_THERMOCHEMICAL_STRING_VALUES) # overwrite tags for this test dataset["tags"] = ["testtag"] datasets_db.insert(dataset) assert len(datasets_db.all()) == 1 assert "newkey_from_tag" not in datasets_db.all()[0] apply_tags(datasets_db, {"testtag": { "newkey_from_tag": ["tag", "values"] }}) assert len(datasets_db.all()) == 1 assert "newkey_from_tag" in datasets_db.all()[0] assert datasets_db.all()[0]["newkey_from_tag"] == ["tag", "values"]