File: test.py

package info (click to toggle)
spigot 0.2017-01-15.gdad1bbc6-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, stretch, trixie
  • size: 904 kB
  • ctags: 1,521
  • sloc: cpp: 9,516; sh: 1,225; python: 643; makefile: 24
file content (34 lines) | stat: -rw-r--r-- 756 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sys, itertools
from spigot import Spigot

def spigprint(spig):
    s = ""
    spig.sp.base()
    while len(s) < 40:
        s = s + spig.sp.readfmt()
    print s

pi = Spigot("pi")

def funcscope(name):
    if name == "y":
        return pi
    return None
pisquared = Spigot("x^2", [{'x':pi}, funcscope])
spigprint(pisquared)
pisquared = Spigot("y^2", [{'x':pi}, funcscope])
spigprint(pisquared)

test = Spigot("pi^e - exp(pi)")
print test.sp.sign()

test = Spigot("tan(1e100)")
print float(test)

test = Spigot("e")
print ",".join(["%d" % n for n in
                itertools.islice(test.continued_fraction(), 0, 30)])

test = Spigot("pi")
print ",".join(["%d/%d" % (n,d) for (n,d) in
                itertools.islice(test.convergents(), 0, 10)])