Ignore:
Timestamp:
09/28/15 20:45:46 (8 months ago)
Author:
mmckerns
Message:

add simplify to simplify equations for a single variable on the LHS;
use simplify in many examples where symbolic equations are given;
add comparator function, to determine the comparator ('<=', '=', etc);
add test_simplify to test_symbolic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mystic/tests/test_symbolic.py

    r781 r831  
    7676  assert (x[1] - x[0]) - 1.0 == mean(x[:-1]) 
    7777 
     78def test_simplify(): 
     79  constraints = """ 
     80  mean([x0, x1, x2]) <= 5.0 
     81  x0 <= x1 + x2""" 
     82 
     83  from mystic.math.measures import mean 
     84  _constraints = simplify(constraints) 
     85  solv = generate_solvers(_constraints) 
     86  constraint = generate_constraint(solv) 
     87  x = constraint([1.0, -2.0, -3.0]) 
     88  assert all(x) == all([-5.0, -2.0, -3.0]) 
     89  assert mean(x) <= 5.0 
     90  assert x[0] <= x[1] + x[2] 
     91 
    7892 
    7993if __name__ == '__main__': 
     
    8296  test_generate_constraint() 
    8397  test_solve_constraint() 
     98  test_simplify() 
    8499 
Note: See TracChangeset for help on using the changeset viewer.