Example #1
0
    def test_compound(self):
        s = t.amount.mean()
        r = compute(s, data)
        assert isinstance(r, float)

        expr = cos(s) ** 2 + sin(s) ** 2
        result = compute(expr, data)
        expected = math.cos(r) ** 2 + math.sin(r) ** 2
        assert result == expected
Example #2
0
    def test_compound(self):
        s = t.amount.mean()
        r = compute(s, data)
        assert isinstance(r, float)

        expr = cos(s)**2 + sin(s)**2
        result = compute(expr, data)
        expected = math.cos(r)**2 + math.sin(r)**2
        assert result == expected
 def distance(lat1, lon1, lat2, lon2, R=3959):
     # http://andrew.hedges.name/experiments/haversine/
     dlon = radians(lon2 - lon1)
     dlat = radians(lat2 - lat1)
     a = sin(dlat / 2.0) ** 2 + cos(lat1) * cos(lat2) * sin(dlon / 2.0) ** 2
     return R * 2 * atan2(sqrt(a), sqrt(1 - a))
 def distance(lat1, lon1, lat2, lon2, R=3959):
     # http://andrew.hedges.name/experiments/haversine/
     dlon = radians(lon2 - lon1)
     dlat = radians(lat2 - lat1)
     a = sin(dlat / 2.0) ** 2 + cos(lat1) * cos(lat2) * sin(dlon / 2.0) ** 2
     return R * 2 * atan2(sqrt(a), sqrt(1 - a))
Example #5
0
 def myfunc(x):
     return myother((cos(x) + sin(x)) ** 2 / math.pi)
Example #6
0
 def myfunc(x):
     return (cos(x) + sin(x)) ** 2 / math.pi
Example #7
0
 def myfunc(x):
     return myother((cos(x) + sin(x))**2 / math.pi)
Example #8
0
 def myfunc(x):
     return (cos(x) + sin(x))**2 / math.pi
Example #9
0
 def test_cos(self):
     a = blaze.array([0, math.pi/6, math.pi/3, 0.5*math.pi,
                      math.pi, 1.5*math.pi, 2*math.pi])
     b = blaze.array([1, 0.5*blaze.sqrt(3), 0.5, 0, -1, 0, 1])
     assert_allclose(blaze.cos(a), b, rtol=1e-15, atol=1e-15)
     assert_allclose(blaze.cos(-a), b, rtol=1e-15, atol=1e-15)