Ejemplo n.º 1
0
    def testFile(self):
        testfile = io.StringIO("""#a
0
1 eins
2 "2"
3 x"x""")
        mydata = data.file(testfile, row=0, a="a", b=2)
        self.assertEqual(mydata.columns["row"], [1, 2, 3, 4])
        self.assertAlmostEqual(mydata.columns["a"][0], 0.0)
        self.assertAlmostEqual(mydata.columns["a"][1], 1.0)
        self.assertAlmostEqual(mydata.columns["a"][2], 2.0)
        self.assertAlmostEqual(mydata.columns["a"][3], 3.0)
        self.assertEqual(mydata.columns["b"][0], None)
        self.assertEqual(mydata.columns["b"][1], "eins")
        self.assertEqual(mydata.columns["b"][2], "2")
        self.assertEqual(mydata.columns["b"][3], "x\"x")
        testfile = io.StringIO("""#a
0
1
2
3
4
5
6
7
8
9""")
        mydata = data.file(testfile,
                           title="title",
                           skiphead=3,
                           skiptail=2,
                           every=2,
                           row=0)
        self.assertEqual(mydata.columns["row"], [4, 6, 8])
        self.assertEqual(mydata.title, "title")
Ejemplo n.º 2
0
    def testFile(self):
        testfile = io.StringIO("""#a
0
1 eins
2 "2"
3 x"x""")
        mydata = data.file(testfile, row=0, a="a", b=2)
        self.assertEqual(mydata.columns["row"], [1, 2, 3, 4])
        self.assertAlmostEqual(mydata.columns["a"][0], 0.0)
        self.assertAlmostEqual(mydata.columns["a"][1], 1.0)
        self.assertAlmostEqual(mydata.columns["a"][2], 2.0)
        self.assertAlmostEqual(mydata.columns["a"][3], 3.0)
        self.assertEqual(mydata.columns["b"][0], None)
        self.assertEqual(mydata.columns["b"][1], "eins")
        self.assertEqual(mydata.columns["b"][2], "2")
        self.assertEqual(mydata.columns["b"][3], "x\"x")
        testfile = io.StringIO("""#a
0
1
2
3
4
5
6
7
8
9""")
        mydata = data.file(testfile, title="title", skiphead=3, skiptail=2, every=2, row=0)
        self.assertEqual(mydata.columns["row"], [4, 6, 8])
        self.assertEqual(mydata.title, "title")
Ejemplo n.º 3
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")
Ejemplo n.º 4
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")