Beispiel #1
0
    def testData(self):
        mydata = data.points([[1], [2]], a=1)
        mydata2 = data.data(mydata, a="2*a", b="2*$1*a", c="4*$(i)*a*$(-1)", context={"i":1})
        self.assertEqual(mydata.columns["a"], [1, 2])
        self.assertAlmostEqual(mydata2.columns["a"][0], 2.0)
        self.assertAlmostEqual(mydata2.columns["a"][1], 4.0)
        self.assertAlmostEqual(mydata2.columns["b"][0], 2.0)
        self.assertAlmostEqual(mydata2.columns["b"][1], 8.0)
        self.assertAlmostEqual(mydata2.columns["c"][0], 4.0)
        self.assertAlmostEqual(mydata2.columns["c"][1], 32.0)
        mydata3 = data.data(mydata2, a="b", b="2*c")
        self.assertEqual(mydata3.columns["a"], mydata2.columns["b"])
        self.assertAlmostEqual(mydata3.columns["b"][0], 2*mydata2.columns["c"][0])
        self.assertAlmostEqual(mydata3.columns["b"][1], 2*mydata2.columns["c"][1])

        a = "nothing"
        two = 2
        f = lambda x: x*x
        mydata = data.points([[1], [2]], a=1)
        mydata2 = data.data(mydata, b="two*a", c="two*$1*a", d="f($1)", context=locals())
        self.assertEqual(mydata.columndata[0], [1, 2])
        self.assertAlmostEqual(mydata2.columns["b"][0], 2.0)
        self.assertAlmostEqual(mydata2.columns["b"][1], 4.0)
        self.assertAlmostEqual(mydata2.columns["c"][0], 2.0)
        self.assertAlmostEqual(mydata2.columns["c"][1], 8.0)
        self.assertAlmostEqual(mydata2.columns["d"][0], 1.0)
        self.assertAlmostEqual(mydata2.columns["d"][1], 4.0)
Beispiel #2
0
    def testData(self):
        mydata = data.points([[1], [2]], a=1)
        mydata2 = data.data(mydata,
                            a="2*a",
                            b="2*$1*a",
                            c="4*$(i)*a*$(-1)",
                            context={"i": 1})
        self.assertEqual(mydata.columns["a"], [1, 2])
        self.assertAlmostEqual(mydata2.columns["a"][0], 2.0)
        self.assertAlmostEqual(mydata2.columns["a"][1], 4.0)
        self.assertAlmostEqual(mydata2.columns["b"][0], 2.0)
        self.assertAlmostEqual(mydata2.columns["b"][1], 8.0)
        self.assertAlmostEqual(mydata2.columns["c"][0], 4.0)
        self.assertAlmostEqual(mydata2.columns["c"][1], 32.0)
        mydata3 = data.data(mydata2, a="b", b="2*c")
        self.assertEqual(mydata3.columns["a"], mydata2.columns["b"])
        self.assertAlmostEqual(mydata3.columns["b"][0],
                               2 * mydata2.columns["c"][0])
        self.assertAlmostEqual(mydata3.columns["b"][1],
                               2 * mydata2.columns["c"][1])

        a = "nothing"
        two = 2
        f = lambda x: x * x
        mydata = data.points([[1], [2]], a=1)
        mydata2 = data.data(mydata,
                            b="two*a",
                            c="two*$1*a",
                            d="f($1)",
                            context=locals())
        self.assertEqual(mydata.columndata[0], [1, 2])
        self.assertAlmostEqual(mydata2.columns["b"][0], 2.0)
        self.assertAlmostEqual(mydata2.columns["b"][1], 4.0)
        self.assertAlmostEqual(mydata2.columns["c"][0], 2.0)
        self.assertAlmostEqual(mydata2.columns["c"][1], 8.0)
        self.assertAlmostEqual(mydata2.columns["d"][0], 1.0)
        self.assertAlmostEqual(mydata2.columns["d"][1], 4.0)
Beispiel #3
0
 def testPoints(self):
     mydata = data.points([[1, 2, 3], [4, 5, 6]], a=1, b=2)
     self.assertEqual(mydata.columndata[0], [1, 2])
     self.assertEqual(mydata.columns["a"], [1, 4])
     self.assertEqual(mydata.columndata[2], [2, 5])
     self.assertEqual("c" in list(mydata.columns.keys()), 0)
            yaxisat=0,
            x=axis.linear(title="$x$",
                          min=0,
                          max=xrange,
                          painter=painter_x,
                          parter=None),
            y=axis.linear(title=r"$I(x)$",
                          max=1.2,
                          painter=painter_y,
                          parter=None)))

x2 = np.linspace(0, (0.93 * xrange)**2, 800)
factor = sqrt(0.5 * pi)
_, integral = fresnel(np.sqrt(x2) / factor)
integral = factor * integral
g1.plot(data.points(list(zip(np.sqrt(x2), integral)), x=1, y=2),
        lineproperties)

g2 = c.insert(
    graphxy(xpos=g1.xpos - g1.width,
            ypos=g1.ypos + g1.height + 0.5,
            width=10,
            height=2,
            xaxisat=0,
            yaxisat=0,
            x=axis.linear(title="$x$",
                          min=-xrange,
                          max=xrange,
                          painter=painter_x,
                          parter=None),
            y=axis.linear(title=r"$f(x)$",
Beispiel #5
0
 def testPoints(self):
     mydata = data.points([[1, 2, 3], [4, 5, 6]], a=1, b=2)
     self.assertEqual(mydata.columndata[0], [1, 2])
     self.assertEqual(mydata.columns["a"], [1, 4])
     self.assertEqual(mydata.columndata[2], [2, 5])
     self.assertEqual("c" in list(mydata.columns.keys()), 0)
Beispiel #6
0
#!/usr/bin/env python
import sys
sys.path[:0] = ["../.."]

import time
from pyx import *
from pyx.graph.axis import timeaxis
from pyx.graph import data

d = data.file("data/timedata", date=1, value=2)
d = data.points(
    [[datetime.datetime(*(time.strptime(date)[:6])), value]
     for date, value in zip(d.columns["date"], d.columns["value"])],
    x=1,
    y=2)

g = graph.graphxy(height=5,
                  x=timeaxis.timeaxis(manualticks=[
                      timeaxis.timetick(2003, 8, 12),
                      timeaxis.timetick(2003, 8, 13),
                      timeaxis.timetick(2003, 8, 14),
                      timeaxis.timetick(2003, 8, 15),
                      timeaxis.timetick(2003, 8, 16)
                  ],
                                      texter=timeaxis.timetexter("%d %b")))
g.plot(d)
g.writeEPSfile("test_timeaxis")
g.writePDFfile("test_timeaxis")
g.writeSVGfile("test_timeaxis")
Beispiel #7
0
#!/usr/bin/env python
import sys; sys.path[:0] = ["../.."]

import time
from pyx import *
from pyx.graph.axis import timeaxis
from pyx.graph import data

d = data.file("data/timedata", date=1, value=2)
d = data.points([[datetime.datetime(*(time.strptime(date)[:6])), value] for date, value in zip(d.columns["date"], d.columns["value"])], x=1, y=2)

g = graph.graphxy(height=5, x=timeaxis.timeaxis(manualticks=[timeaxis.timetick(2003, 8, 12),
                                                             timeaxis.timetick(2003, 8, 13),
                                                             timeaxis.timetick(2003, 8, 14),
                                                             timeaxis.timetick(2003, 8, 15),
                                                             timeaxis.timetick(2003, 8, 16)],
                                                texter=timeaxis.timetexter("%d %b")))
g.plot(d)
g.writeEPSfile("test_timeaxis")
g.writePDFfile("test_timeaxis")
g.writeSVGfile("test_timeaxis")