From 55a8078401e8b7348161f61f07f7d0dd6d0c5725 Mon Sep 17 00:00:00 2001 From: Guillaume Fraux Date: Wed, 29 Mar 2017 15:41:22 +0200 Subject: [PATCH 1/2] Update lumol-core dependencies --- src/core/Cargo.toml | 6 +- src/core/src/sys/cache.rs | 10 +-- src/core/src/types/arrays.rs | 134 ++++++++++++++--------------------- 3 files changed, 63 insertions(+), 87 deletions(-) diff --git a/src/core/Cargo.toml b/src/core/Cargo.toml index ae0896a65..5166f83d5 100644 --- a/src/core/Cargo.toml +++ b/src/core/Cargo.toml @@ -14,10 +14,10 @@ name = "lumol" chemfiles = "0.7" rand = "0.3" log = "0.3" -log-once = "0.1.1" +log-once = "0.1" special = "0.7" -bitflags = "0.7" -ndarray = "0.6" +bitflags = "0.8" +ndarray = "0.8" lazy_static = "0.2" num-traits = "0.1" diff --git a/src/core/src/sys/cache.rs b/src/core/src/sys/cache.rs index 099d03263..c7f4b5895 100644 --- a/src/core/src/sys/cache.rs +++ b/src/core/src/sys/cache.rs @@ -66,7 +66,7 @@ impl EnergyCache { /// Clear all values in the cache by setting them to 0 fn clear(&mut self) { - self.pairs_cache.assign(0.0); + self.pairs_cache.fill(0.0); self.pairs = 0.0; self.pairs_tail = 0.0; self.bonds = 0.0; @@ -248,9 +248,9 @@ impl EnergyCache { cache.coulomb += coulomb_delta; cache.global += global_delta; - let (n, m) = new_pairs.shape(); + let (n, m) = new_pairs.dim(); debug_assert_eq!(n, m); - debug_assert_eq!((n, m), cache.pairs_cache.shape()); + debug_assert_eq!((n, m), cache.pairs_cache.dim()); // only loop over the indices that actually changed for &i in &idxes { for j in 0..n { @@ -333,9 +333,9 @@ impl EnergyCache { cache.coulomb = new_coulomb; cache.global = new_global; - let (n, m) = new_pairs.shape(); + let (n, m) = new_pairs.dim(); debug_assert_eq!(n, m); - debug_assert_eq!((n, m), cache.pairs_cache.shape()); + debug_assert_eq!((n, m), cache.pairs_cache.dim()); for (i, mi) in system.molecules().iter().enumerate() { for mj in system.molecules().iter().skip(i + 1) { for pi in mi.iter() { diff --git a/src/core/src/types/arrays.rs b/src/core/src/types/arrays.rs index 49fd836f5..5649db9dc 100644 --- a/src/core/src/types/arrays.rs +++ b/src/core/src/types/arrays.rs @@ -2,9 +2,9 @@ // Copyright (C) 2015-2016 Lumol's contributors — BSD license //! Multi-dimensional arrays based on ndarray -use ndarray::{Array, Ix}; +use ndarray; -use std::ops::{Index, IndexMut}; +use std::ops::{Index, IndexMut, Deref, DerefMut}; use types::Zero; /// Two dimensional tensors, based on ndarray. @@ -23,21 +23,7 @@ use types::Zero; /// assert_eq!(a[(0, 4)], 7.0); /// ``` #[derive(Debug, Clone, PartialEq)] -pub struct Array2(Array); - -impl Array2 { - /// Get the shape of the array - /// # Examples - /// ``` - /// # use lumol::types::Array2; - /// let a: Array2 = Array2::zeros((3, 5)); - /// assert_eq!(a.shape(), (3, 5)); - /// ``` - pub fn shape(&self) -> (Ix, Ix) { - let shape = self.0.shape(); - (shape[0], shape[1]) - } -} +pub struct Array2(ndarray::Array2); impl Array2 { /// Create a new `Array2` of the specified `size` filled with the @@ -50,8 +36,8 @@ impl Array2 { /// let a: Array2 = Array2::zeros((8, 5)); /// assert_eq!(a[(6, 2)], 0.0); /// ``` - pub fn zeros(size: (Ix, Ix)) -> Array2 { - Array2(Array::::zeros(size)) + pub fn zeros(size: (usize, usize)) -> Array2 { + Array2(ndarray::Array2::zeros(size)) } /// Resize the array if the current size is not `size`, and fill the @@ -73,28 +59,13 @@ impl Array2 { /// a.resize_if_different((8, 9)); /// assert_eq!(a[(3, 3)], 0.0); /// ``` - pub fn resize_if_different(&mut self, size: (Ix, Ix)) { - if self.0.shape() != &[size.0, size.1] { + pub fn resize_if_different(&mut self, size: (usize, usize)) { + if self.dim() != size { *self = Array2::zeros(size); } } } -impl Array2 { - /// Assign the given scalar to all entries in this array - /// # Examples - /// ``` - /// # use lumol::types::Array2; - /// let mut a = Array2::zeros((8, 5)); - /// a.assign(33.0); - /// - /// assert_eq!(a[(3, 4)], 33.0); - /// ``` - pub fn assign(&mut self, value: T) { - self.0.assign_scalar(&value); - } -} - impl Array2 { /// Create a new `Array2` of the specified `size` filled with the /// `Default::default` return value. @@ -108,14 +79,14 @@ impl Array2 { /// /// assert_eq!(a, b); /// ``` - pub fn default(size: (Ix, Ix)) -> Array2 { - Array2(Array::::default(size)) + pub fn default(size: (usize, usize)) -> Array2 { + Array2(ndarray::Array2::default(size)) } } -impl Index<(Ix, Ix)> for Array2 { +impl Index<(usize, usize)> for Array2 { type Output = T; - fn index(&self, index: (Ix, Ix)) -> &T { + fn index(&self, index: (usize, usize)) -> &T { unsafe { // ndarray does the check for us in debug builds self.0.uget(index) @@ -123,8 +94,8 @@ impl Index<(Ix, Ix)> for Array2 { } } -impl IndexMut<(Ix, Ix)> for Array2 { - fn index_mut(&mut self, index: (Ix, Ix)) -> &mut T { +impl IndexMut<(usize, usize)> for Array2 { + fn index_mut(&mut self, index: (usize, usize)) -> &mut T { unsafe { // ndarray does the check for us in debug builds self.0.uget_mut(index) @@ -132,6 +103,20 @@ impl IndexMut<(Ix, Ix)> for Array2 { } } +impl Deref for Array2 { + type Target = ndarray::Array2; + + fn deref(&self) -> &ndarray::Array2 { + &self.0 + } +} + +impl DerefMut for Array2 { + fn deref_mut(&mut self) -> &mut ndarray::Array2 { + &mut self.0 + } +} + /******************************************************************************/ /// Three dimensional tensors, based on ndarray @@ -150,23 +135,9 @@ impl IndexMut<(Ix, Ix)> for Array2 { /// assert_eq!(a[(0, 4, 1)], 7.0); /// ``` #[derive(Debug, Clone, PartialEq)] -pub struct Array3(Array); +pub struct Array3(ndarray::Array3); impl Array3 { - /// Get the shape of the array. - /// # Examples - /// ``` - /// # use lumol::types::Array3; - /// let a: Array3 = Array3::zeros((3, 5, 7)); - /// assert_eq!(a.shape(), (3, 5, 7)); - /// ``` - pub fn shape(&self) -> (Ix, Ix, Ix) { - let shape = self.0.shape(); - (shape[0], shape[1], shape[2]) - } -} - -impl Array3 { /// Create a new `Array3` of the specified `size` filled with the /// `Zero::zero` return value. /// @@ -177,8 +148,8 @@ impl Array3 { /// let a: Array3 = Array3::zeros((8, 5, 2)); /// assert_eq!(a[(6, 2, 0)], 0.0); /// ``` - pub fn zeros(size: (Ix, Ix, Ix)) -> Array3 { - Array3(Array::::zeros(size)) + pub fn zeros(size: (usize, usize, usize)) -> Array3 where T: Zero + Clone { + Array3(ndarray::Array3::zeros(size)) } /// Resize the array if the current size is not `size`, and fill the @@ -200,21 +171,12 @@ impl Array3 { /// a.resize_if_different((8, 5, 6)); /// assert_eq!(a[(3, 3, 3)], 0.0); /// ``` - pub fn resize_if_different(&mut self, size: (Ix, Ix, Ix)) { + pub fn resize_if_different(&mut self, size: (usize, usize, usize)) where T: Zero + Clone { if self.0.shape() != &[size.0, size.1, size.2] { *self = Array3::zeros(size); } } -} - -impl Array3 { - /// Assign the given scalar to all entries in this array - pub fn assign(&mut self, value: T) { - self.0.assign_scalar(&value); - } -} -impl Array3 { /// Create a new `Array3` of the specified `size` filled with the /// `Default::default` return value. /// `Default::default` return value. @@ -228,14 +190,14 @@ impl Array3 { /// /// assert_eq!(a, b); /// ``` - pub fn default(size: (Ix, Ix, Ix)) -> Array3{ - Array3(Array::::default(size)) + pub fn default(size: (usize, usize, usize)) -> Array3 where T: Default{ + Array3(ndarray::Array3::default(size)) } } -impl Index<(Ix, Ix, Ix)> for Array3 { +impl Index<(usize, usize, usize)> for Array3 { type Output = T; - fn index(&self, index: (Ix, Ix, Ix)) -> &T { + fn index(&self, index: (usize, usize, usize)) -> &T { unsafe { // ndarray does the check for us in debug builds self.0.uget(index) @@ -243,8 +205,8 @@ impl Index<(Ix, Ix, Ix)> for Array3 { } } -impl IndexMut<(Ix, Ix, Ix)> for Array3 { - fn index_mut(&mut self, index: (Ix, Ix, Ix)) -> &mut T { +impl IndexMut<(usize, usize, usize)> for Array3 { + fn index_mut(&mut self, index: (usize, usize, usize)) -> &mut T { unsafe { // ndarray does the check for us in debug builds self.0.uget_mut(index) @@ -252,6 +214,20 @@ impl IndexMut<(Ix, Ix, Ix)> for Array3 { } } +impl Deref for Array3 { + type Target = ndarray::Array3; + + fn deref(&self) -> &ndarray::Array3 { + &self.0 + } +} + +impl DerefMut for Array3 { + fn deref_mut(&mut self) -> &mut ndarray::Array3 { + &mut self.0 + } +} + #[cfg(test)] mod tests { mod array2 { @@ -283,11 +259,11 @@ mod tests { #[test] fn resize() { let mut a: Array2 = Array2::zeros((3, 4)); - assert_eq!(a.shape(), (3, 4)); + assert_eq!(a.dim(), (3, 4)); a[(1, 1)] = 42.0; a.resize_if_different((7, 90)); - assert_eq!(a.shape(), (7, 90)); + assert_eq!(a.dim(), (7, 90)); assert_eq!(a[(1, 1)], 0.0); a[(1, 1)] = 42.0; @@ -355,11 +331,11 @@ mod tests { #[test] fn resize() { let mut a: Array3 = Array3::zeros((3, 4, 5)); - assert_eq!(a.shape(), (3, 4, 5)); + assert_eq!(a.dim(), (3, 4, 5)); a[(1, 1, 1)] = 42.0; a.resize_if_different((7, 90, 8)); - assert_eq!(a.shape(), (7, 90, 8)); + assert_eq!(a.dim(), (7, 90, 8)); assert_eq!(a[(1, 1, 1)], 0.0); a[(1, 1, 1)] = 42.0; From d5cb582cb8dac302e8c0444d94b0794398ffa181 Mon Sep 17 00:00:00 2001 From: Guillaume Fraux Date: Wed, 29 Mar 2017 16:19:24 +0200 Subject: [PATCH 2/2] Update TOML to 0.3 --- src/input/Cargo.toml | 2 +- src/input/src/error.rs | 30 +++++++++--------------- src/input/src/extract.rs | 7 +++--- src/input/src/interactions/angles.rs | 6 ++--- src/input/src/interactions/mod.rs | 14 +++++------ src/input/src/interactions/pairs.rs | 6 ++--- src/input/src/interactions/toml.rs | 2 +- src/input/src/lib.rs | 4 ++-- src/input/src/simulations/mc.rs | 2 +- src/input/src/simulations/md.rs | 4 ++-- src/input/src/simulations/min.rs | 2 +- src/input/src/simulations/mod.rs | 16 ++++++------- src/input/src/simulations/outputs.rs | 4 ++-- src/input/src/simulations/simulations.rs | 2 +- src/input/src/simulations/system.rs | 2 +- 15 files changed, 46 insertions(+), 57 deletions(-) diff --git a/src/input/Cargo.toml b/src/input/Cargo.toml index 86efce606..7ed185df8 100644 --- a/src/input/Cargo.toml +++ b/src/input/Cargo.toml @@ -9,7 +9,7 @@ license = "BSD-3-Clause" [dependencies] lumol-core = {path = "../core"} -toml = "0.2" +toml = "0.3" log = "0.3" chemfiles = "0.7" diff --git a/src/input/src/error.rs b/src/input/src/error.rs index 20e8fdb3a..2731fdaca 100644 --- a/src/input/src/error.rs +++ b/src/input/src/error.rs @@ -6,7 +6,6 @@ use std::fmt; use std::result; use std::path::PathBuf; -use toml::Parser; use chemfiles; use lumol::units::ParseError; @@ -19,7 +18,7 @@ pub type Result = result::Result; #[derive(Debug)] pub enum Error { /// Error in the TOML input file - TOML(String), + TOML(Box), /// IO error, and associated file path Io(io::Error, PathBuf), /// Error while reading a trajectory file @@ -63,23 +62,25 @@ impl From for Error { impl fmt::Display for Error { fn fmt(&self, fmt: &mut fmt::Formatter) -> result::Result<(), fmt::Error> { use std::error::Error as StdError; - let message = match *self { + match *self { Error::Io(ref err, ref path) => { match err.kind() { io::ErrorKind::NotFound => { - format!("can not find '{}'", path.display()) + try!(write!(fmt, "can not find '{}'", path.display())) } io::ErrorKind::PermissionDenied => { - format!("permission to access '{}' denied", path.display()) + try!(write!(fmt, "permission to access '{}' denied", path.display())) } _ => { - format!("error with '{}': {}", path.display(), self.description()) + try!(write!(fmt, "error with '{}': {}", path.display(), self.description())) } } } - _ => String::from(self.description()) + Error::Trajectory(ref err) => try!(write!(fmt, "{}", err)), + Error::TOML(ref err) => try!(write!(fmt, "{}", err)), + Error::Config(ref err) => try!(write!(fmt, "{}", err)), + Error::Unit(ref err) => try!(write!(fmt, "{}", err)), }; - try!(write!(fmt, "{}", message)); Ok(()) } } @@ -87,7 +88,8 @@ impl fmt::Display for Error { impl error::Error for Error { fn description(&self) -> &str { match *self { - Error::TOML(ref err) | Error::Config(ref err) => err, + Error::Config(ref err) => err, + Error::TOML(ref err) => err.description(), Error::Io(ref err, _) => err.description(), Error::Trajectory(ref err) => err.description(), Error::Unit(ref err) => err.description(), @@ -103,13 +105,3 @@ impl error::Error for Error { } } } - -pub fn toml_error_to_string(parser: &Parser) -> String { - let errors = parser.errors.iter().map(|error|{ - let (line, _) = parser.to_linecol(error.lo); - format!("{} at line {}", error.desc, line + 1) - }).collect::>().join("\n "); - - let plural = if errors.len() == 1 {""} else {"s"}; - return format!("TOML parsing error{}: {}", plural, errors); -} diff --git a/src/input/src/extract.rs b/src/input/src/extract.rs index 54808a497..21e8a5c8d 100644 --- a/src/input/src/extract.rs +++ b/src/input/src/extract.rs @@ -1,6 +1,6 @@ // Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license -use toml::{Table, Value}; +use toml::value::{Table, Value}; use error::{Error, Result}; @@ -68,9 +68,10 @@ pub fn slice<'a>(key: &str, config: &'a Table, context: &str) -> Result<&'a [Val let array = try!(config.get(key).ok_or(Error::from( format!("Missing '{}' key in {}", key, context) ))); - return array.as_slice().ok_or(Error::from( + let array = array.as_array().ok_or(Error::from( format!("'{}' must be an array in {}", key, context) - )) + )); + return array.map(|arr| arr.as_slice()); } /// Extract the string 'type' key in a TOML table diff --git a/src/input/src/interactions/angles.rs b/src/input/src/interactions/angles.rs index fb1546309..c21b222fa 100644 --- a/src/input/src/interactions/angles.rs +++ b/src/input/src/interactions/angles.rs @@ -1,6 +1,6 @@ // Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license -use toml::{Value, Table}; +use toml::value::{Value, Table}; use lumol::sys::System; use lumol::energy::{Harmonic, CosineHarmonic, Torsion, NullPotential}; @@ -22,7 +22,7 @@ impl InteractionsInput { None => return Ok(()) }; - let angles = try!(angles.as_slice().ok_or( + let angles = try!(angles.as_array().ok_or( Error::from("The 'angles' section must be an array") )); @@ -58,7 +58,7 @@ impl InteractionsInput { None => return Ok(()) }; - let dihedrals = try!(dihedrals.as_slice().ok_or( + let dihedrals = try!(dihedrals.as_array().ok_or( Error::from("The 'dihedrals' section must be an array") )); diff --git a/src/input/src/interactions/mod.rs b/src/input/src/interactions/mod.rs index 1c756cf74..9207ddebb 100644 --- a/src/input/src/interactions/mod.rs +++ b/src/input/src/interactions/mod.rs @@ -1,6 +1,7 @@ // Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license -use toml::{Parser, Table, Value}; +use toml::de::from_str as parse; +use toml::value::{Table, Value}; use std::io::prelude::*; use std::fs::File; @@ -11,7 +12,6 @@ use lumol::energy::PairRestriction; use {Error, Result}; use validate; -use error::toml_error_to_string; mod toml; mod pairs; @@ -38,13 +38,11 @@ impl InteractionsInput { // TODO: use restricted privacy here #[doc(hidden)] pub fn from_string(string: &str) -> Result { - let mut parser = Parser::new(string); - let config = try!(parser.parse().ok_or( - Error::TOML(toml_error_to_string(&parser)) - )); - + let config = try!(parse(string).map_err(|err| { + Error::TOML(Box::new(err)) + })); try!(validate(&config)); - return InteractionsInput::from_toml(config); + return InteractionsInput::from_toml(config.clone()); } /// Read the interactions from a TOML table. This is an internal function, diff --git a/src/input/src/interactions/pairs.rs b/src/input/src/interactions/pairs.rs index 4c9bb9e71..09b368b0a 100644 --- a/src/input/src/interactions/pairs.rs +++ b/src/input/src/interactions/pairs.rs @@ -1,6 +1,6 @@ // Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license -use toml::{Value, Table}; +use toml::value::{Value, Table}; use lumol::sys::System; use lumol::units; @@ -62,7 +62,7 @@ impl InteractionsInput { None => return Ok(()) }; - let pairs = try!(pairs.as_slice().ok_or( + let pairs = try!(pairs.as_array().ok_or( Error::from("The 'pairs' section must be an array") )); @@ -157,7 +157,7 @@ impl InteractionsInput { None => return Ok(()) }; - let bonds = try!(bonds.as_slice().ok_or( + let bonds = try!(bonds.as_array().ok_or( Error::from("The 'bonds' section must be an array") )); diff --git a/src/input/src/interactions/toml.rs b/src/input/src/interactions/toml.rs index e18aef746..30f629384 100644 --- a/src/input/src/interactions/toml.rs +++ b/src/input/src/interactions/toml.rs @@ -2,7 +2,7 @@ // Copyright (C) 2015-2016 Lumol's contributors — BSD license //! Convert TOML values to Lumol types. -use toml::Table; +use toml::value::Table; use error::{Error, Result}; use FromToml; diff --git a/src/input/src/lib.rs b/src/input/src/lib.rs index 5e65f13c8..94f40e79e 100644 --- a/src/input/src/lib.rs +++ b/src/input/src/lib.rs @@ -67,7 +67,7 @@ extern crate toml; extern crate chemfiles; extern crate lumol; -use toml::Table; +use toml::value::Table; macro_rules! try_io { ($expr: expr, $path: expr) => ( @@ -108,7 +108,7 @@ fn validate(config: &Table) -> Result<()> { Error::from("Missing 'input' table") )); - let version = try!(input.lookup("version").ok_or( + let version = try!(input.get("version").ok_or( Error::from("Missing 'version' key in 'input' table") )); diff --git a/src/input/src/simulations/mc.rs b/src/input/src/simulations/mc.rs index 993c6c8f8..f67723ec6 100644 --- a/src/input/src/simulations/mc.rs +++ b/src/input/src/simulations/mc.rs @@ -1,6 +1,6 @@ // Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license -use toml::Table; +use toml::value::Table; use std::path::PathBuf; use lumol::sys::{read_molecule, molecule_type}; diff --git a/src/input/src/simulations/md.rs b/src/input/src/simulations/md.rs index 0d69fc7d6..8a6d616d4 100644 --- a/src/input/src/simulations/md.rs +++ b/src/input/src/simulations/md.rs @@ -1,6 +1,6 @@ // Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license -use toml::Table; +use toml::value::Table; use lumol::sim::md::*; use lumol::units; @@ -68,7 +68,7 @@ impl FromToml for MolecularDynamics { } if let Some(controls) = config.get("controls") { - let controls = try!(controls.as_slice().ok_or(Error::from( + let controls = try!(controls.as_array().ok_or(Error::from( "'controls' must be an array of tables in molecular dynamics" ))); diff --git a/src/input/src/simulations/min.rs b/src/input/src/simulations/min.rs index 27fcac91c..41e46a80c 100644 --- a/src/input/src/simulations/min.rs +++ b/src/input/src/simulations/min.rs @@ -1,6 +1,6 @@ // Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license -use toml::Table; +use toml::value::Table; use lumol::sim::min::*; use lumol::units; diff --git a/src/input/src/simulations/mod.rs b/src/input/src/simulations/mod.rs index 825fe22fc..53d23638f 100644 --- a/src/input/src/simulations/mod.rs +++ b/src/input/src/simulations/mod.rs @@ -1,6 +1,7 @@ // Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license -use toml::{Parser, Table}; +use toml::de::from_str as parse; +use toml::value::Table; use std::io::prelude::*; use std::path::{Path, PathBuf}; @@ -8,7 +9,6 @@ use std::fs::File; use validate; use error::{Error, Result}; -use error::toml_error_to_string; use lumol::sim::Simulation; use lumol::sys::System; @@ -54,14 +54,12 @@ impl Input { /// Read the `Input` from a TOML formatted string. // TODO: use restricted privacy here #[doc(hidden)] - pub fn from_str(path: PathBuf, buffer: &str) -> Result { - let mut parser = Parser::new(buffer); - let config = try!(parser.parse().ok_or( - Error::TOML(toml_error_to_string(&parser)) - )); - + pub fn from_str(path: PathBuf, string: &str) -> Result { + let config = try!(parse(string).map_err(|err| { + Error::TOML(Box::new(err)) + })); try!(validate(&config)); - Ok(Input{path: path, config: config}) + Ok(Input{path: path, config: config.clone()}) } /// Read input file and get the corresponding `Config` diff --git a/src/input/src/simulations/outputs.rs b/src/input/src/simulations/outputs.rs index 3a4c496f5..7d28f3787 100644 --- a/src/input/src/simulations/outputs.rs +++ b/src/input/src/simulations/outputs.rs @@ -1,6 +1,6 @@ // Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license -use toml::Table; +use toml::value::Table; use std::path::PathBuf; use lumol::out::Output; @@ -19,7 +19,7 @@ impl Input { pub fn read_outputs(&self) -> Result, u64)>> { let config = try!(self.simulation_table()); if let Some(outputs) = config.get("outputs") { - let outputs = try!(outputs.as_slice().ok_or( + let outputs = try!(outputs.as_array().ok_or( Error::from("'outputs' must be an array of tables in simulation") )); diff --git a/src/input/src/simulations/simulations.rs b/src/input/src/simulations/simulations.rs index 08e9e03ef..cd5b86b8f 100644 --- a/src/input/src/simulations/simulations.rs +++ b/src/input/src/simulations/simulations.rs @@ -1,6 +1,6 @@ // Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license -use toml::Table; +use toml::value::Table; use lumol::sim::Simulation; use error::{Error, Result}; diff --git a/src/input/src/simulations/system.rs b/src/input/src/simulations/system.rs index e394da151..b4ba946e1 100644 --- a/src/input/src/simulations/system.rs +++ b/src/input/src/simulations/system.rs @@ -1,6 +1,6 @@ // Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license -use toml::{Table, Value}; +use toml::value::{Table, Value}; use lumol::units; use lumol::sys::*;