Source code for idaes.core.util.var_test

##############################################################################
# Institute for the Design of Advanced Energy Systems Process Systems
# Engineering Framework (IDAES PSE Framework) Copyright (c) 2018, by the
# software owners: The Regents of the University of California, through
# Lawrence Berkeley National Laboratory,  National Technology & Engineering
# Solutions of Sandia, LLC, Carnegie Mellon University, West Virginia
# University Research Corporation, et al. All rights reserved.
# 
# Please see the files COPYRIGHT.txt and LICENSE.txt for full copyright and
# license information, respectively. Both files are also available online
# at the URL "https://github.com/IDAES/idaes".
##############################################################################
from __future__ import division
from pyomo.environ import value

__author__ = "Qi Chen <qichen@andrew.cmu.edu>"

[docs]def assert_var_equal(test_case, var, expected_val, tolerance): test_case.assertIs( abs(value(var) - expected_val) <= tolerance, True, msg="Value {} not within {} of expected value {}".format( value(var), tolerance, expected_val))
[docs]def value_correct(var, expected_val, tolerance): return abs(value(var) - expected_val) <= tolerance