Esempio n. 1
0
 def test_init(self):
     """Test initialization via both operator overloading and __init__"""
     x = Variable('x')
     y = Variable('y')
     mono = y**2/x
     # operator overloading
     mec = (x == y**2)
     # __init__
     mec2 = MonomialEquality(x, "=", y**2)
     self.assertTrue(mono in mec.as_posyslt1())
     self.assertTrue(mono in mec2.as_posyslt1())
Esempio n. 2
0
 def test_init(self):
     """Test initialization via both operator overloading and __init__"""
     x = Variable('x')
     y = Variable('y')
     mono = y**2 / x
     # operator overloading
     mec = (x == y**2)
     # __init__
     mec2 = MonomialEquality(x, "=", y**2)
     self.assertTrue(mono in mec.as_posyslt1())
     self.assertTrue(mono in mec2.as_posyslt1())
     x = Variable("x", "ft")
     y = Variable("y")
     if gpkit.units:
         self.assertRaises(ValueError, MonomialEquality, x, "=", y)
         self.assertRaises(ValueError, MonomialEquality, y, "=", x)
Esempio n. 3
0
 def test_init(self):
     """Test initialization via both operator overloading and __init__"""
     x = Variable('x')
     y = Variable('y')
     mono = y**2/x
     # operator overloading
     mec = (x == y**2)
     # __init__
     mec2 = MonomialEquality(x, "=", y**2)
     self.assertTrue(mono in mec.as_posyslt1())
     self.assertTrue(mono in mec2.as_posyslt1())
     x = Variable("x", "ft")
     y = Variable("y")
     if gpkit.units:
         self.assertRaises(ValueError, MonomialEquality, x, "=", y)
         self.assertRaises(ValueError, MonomialEquality, y, "=", x)
Esempio n. 4
0
 def test_init(self):
     "Test initialization via both operator overloading and __init__"
     x = Variable('x')
     y = Variable('y')
     mono = y**2 / x
     # operator overloading
     mec = (x == y**2)
     # __init__
     mec2 = MonomialEquality(x, y**2)
     self.assertTrue(mono.hmap in mec.as_hmapslt1({}))
     self.assertTrue(mono.hmap in mec2.as_hmapslt1({}))
     x = Variable("x", "ft")
     y = Variable("y")
     if gpkit.units:
         self.assertRaises(DimensionalityError, MonomialEquality, x, y)
         self.assertRaises(DimensionalityError, MonomialEquality, y, x)
Esempio n. 5
0
 def constr():
     """method that should raise a TypeError"""
     MonomialEquality(x * y, "=", x + y)
Esempio n. 6
0
 def test_united_dimensionless(self):
     "Check dimensionless unit-ed variables work"
     x = Variable('x')
     y = Variable('y', 'hr/day')
     c = MonomialEquality(x, "=", y)
     self.assertTrue(isinstance(c, MonomialEquality))