aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2016-12-25 23:36:35 -0800
committerbnewbold <bnewbold@robocracy.org>2016-12-25 23:36:39 -0800
commit4bdf3106e13576e1b46a1d5e2e841ebc61045ee1 (patch)
tree8796266af0f1555feafad5720ede6a83dbfd54a5
parent3e3f933595f64083e41433075e66aa275af66c6c (diff)
downloadmodelthing-4bdf3106e13576e1b46a1d5e2e841ebc61045ee1.tar.gz
modelthing-4bdf3106e13576e1b46a1d5e2e841ebc61045ee1.zip
remove variables from metadata files
Plan here is to make these examples only.
-rw-r--r--examples/classic_gravitation/metadata.toml29
-rw-r--r--examples/lotka_volterra/metadata.toml31
-rw-r--r--src/lib.rs26
-rw-r--r--tests/lib.rs2
4 files changed, 0 insertions, 88 deletions
diff --git a/examples/classic_gravitation/metadata.toml b/examples/classic_gravitation/metadata.toml
index 9d61b3b..9f43ae7 100644
--- a/examples/classic_gravitation/metadata.toml
+++ b/examples/classic_gravitation/metadata.toml
@@ -3,35 +3,6 @@
name-en = "Classic Gravitation"
description-en = "Newtonian"
-[variables]
-
- [variables.G]
- type = "constant"
- name-en = "Gravitational Constant"
- value_si = 6.674e-11
-
- [variables.F]
- type = 'dependent'
- name-en = "force"
- units_si = "unit"
-
- [variables.r]
- type = 'independent'
- name-en = "distance"
- units_si = "meter"
-
- [variables.m1]
- type = 'independent'
- latex = 'm_1'
- name = "mass #1"
- units_si = "kilogram"
-
- [variables.m2]
- type = 'independent'
- latex = 'm_2'
- name = "mass #2"
- units_si = "kilogram"
-
[examples]
[examples.earth_surface]
diff --git a/examples/lotka_volterra/metadata.toml b/examples/lotka_volterra/metadata.toml
index 7ebc215..9753537 100644
--- a/examples/lotka_volterra/metadata.toml
+++ b/examples/lotka_volterra/metadata.toml
@@ -3,37 +3,6 @@
name-en = "Lotka–Volterra equations"
description-en = "Predator-Prey Model"
-[variables]
-
- [variables.t]
- type = 'time' # or "independent"?
-
- [variables.x]
- type = 'state'
-
- [variables.y]
- type = 'state'
-
- [variables.alpha]
- type = 'parameter'
- latex = '\alpha'
- unicode = 'α'
-
- [variables.beta]
- type = 'parameter'
- latex = '\beta'
- unicode = 'β'
-
- [variables.delta]
- type = 'parameter'
- latex = '\delta'
- unicode = 'δ'
-
- [variables.gamma]
- type = 'parameter'
- latex = '\gamma'
- unicode = 'γ'
-
[examples]
[examples.mathworld]
diff --git a/src/lib.rs b/src/lib.rs
index e20c8fb..07bc0b3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -18,7 +18,6 @@ use std::fs::File;
pub struct ModelMetadata {
pub name_en: String,
pub description_en: Option<String>,
- pub vars: Vec<ModelVar>,
}
#[derive(Debug, PartialEq)]
@@ -53,34 +52,9 @@ pub fn parse_metadata(raw: String) -> Result<ModelMetadata, String> {
.expect("missing 'model' section")
.as_table()
.unwrap();
- let variables = root.get("variables")
- .expect("missing 'variables' section")
- .as_table()
- .unwrap();
- let mut vars = vec![];
- for (slug, info) in variables {
- let info = info.as_table().unwrap();
- let vtype = match info.get("type").unwrap().as_str().unwrap() {
- "independent" => ModelVarType::Independent,
- "dependent" => ModelVarType::Dependent,
- "constant" => ModelVarType::Constant,
- "time" => ModelVarType::Time,
- "state" => ModelVarType::State,
- "parameter" => ModelVarType::Parameter,
- other => return Err(format!("Unknown variable type: {}", other)),
- };
- vars.push(ModelVar {
- slug: slug.to_string(),
- name_en: info.get("name-en").map(|x| x.as_str().unwrap().to_string()),
- vtype: vtype,
- latex: info.get("latex").map(|x| x.as_str().unwrap().to_string()),
- units_si: info.get("units-si").map(|x| x.as_str().unwrap().to_string()),
- });
- }
Ok(ModelMetadata {
name_en: model.get("name-en").unwrap().as_str().unwrap().to_string(),
description_en: model.get("description-en").map(|x| x.as_str().unwrap().to_string()),
- vars: vars,
})
}
diff --git a/tests/lib.rs b/tests/lib.rs
index 77359de..914064d 100644
--- a/tests/lib.rs
+++ b/tests/lib.rs
@@ -13,13 +13,11 @@ fn test_parse_metadata() {
r#"
[model]
name-en = "Bogus Dummy Model"
-[variables]
"#.to_string();
assert_eq!(parse_metadata(raw).unwrap(),
ModelMetadata {
name_en: "Bogus Dummy Model".to_string(),
description_en: None,
- vars: vec![],
});
}