Ejemplo n.º 1
0
  def test_independence(self):
    Quantity.participantsAreIndepended = False
    # only add and mul are tested
    x = Quantity(1, 1)
    y = Quantity(1, 1)
    z = Quantity(1, 0)

    mul = lambda x, y: x * y
    add = lambda x, y: x + y


    # this should not raise an error
    try:
      a = x * 3
      a = x * z 
    except:
      self.assertTrue(False)

    # this should raise an error
    self.assertRaises(data.ParticipantsAreNotIndependend, mul, x, x)
    self.assertRaises(data.ParticipantsAreNotIndependend, add, x, x)
    self.assertRaises(data.ParticipantsAreNotIndependend, mul, x, y)
    self.assertRaises(data.ParticipantsAreNotIndependend, add, x, y)

    Quantity.yesIKnowTheDangersAndPromiseToBeCareful()
    # this should not raise an error
    mul(x, x)
    add(x, x)
    mul(x, y)
    add(x, y)
Ejemplo n.º 2
0
  def setUp(self):
    self.METER = [1] + [0]*7
    Quantity.yesIKnowTheDangersAndPromiseToBeCareful()

    self.x = np.arange(100)
    self.y = np.sqrt(np.arange(100))
    self.z = np.array( (4, 5, 6, 7) ) * math.e

    self.sx = np.zeros(100) + math.pi
    self.sy = np.cos(self.y)**2
    self.sz = np.array( (4, 5, 6, 7) ) / 13

    self.sym = ['s1', 's2', 's3', 's4']
    self.lab = ['Height', 'Width', 'Depth', 'Thickness']
    self.lat =  ['s_1', 's_2', 's_3', 's_4']

    ms  = data.enumstr('s', 100)