Debugging Sage using Eric4
June 18, 2009 | Filed Under sage | Leave a Comment
This is just a short note on how to use the Eric4 program to debug a Sage script (a .py file). It’s a slightly updated version of a post on some Sage mailing list that I can’t find right now.
On Ubuntu 9.04, install Eric4:
sudo apt-get install eric
Save the following to a file:
#!/bin/bash
x=`pwd`
export SAGE_ROOT=/path_to_your_sage_installation
cd $SAGE_ROOT
source local/bin/sage-env
cd $x
sage-python ${*}
Start Eric4 and go to Settings, Preferences, Debugger/Python, and set the Custom Python Interpreter to the file that you just saved.
Using File, Open you can debug a Python file that uses the Sage libraries, e.g.:
from sage.all import * r=MPolynomialRing(GF(127),2,'x') print r.gens()
To set a breakpoint in the Sage library itself use the ? sign to find out where a file is located. For example
sage: PolynomialRing?
shows us that PolynomialRing comes from
$SAGE_ROOT/local/lib/python2.5/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py
If you open that file (File, Open) you can set breakpoints and so on.
A note to netbook users: Eric4’s default window is quite large and did not display properly on my Asus EEE PC. The solution is to remove most of the toolbar entries (these are accessible from the menu anyway) and also change the window mode to detached windows so that you can alt-tab between the various components of Eric4 instead of having them all in one giant window.
Open access
May 11, 2009 | Filed Under Uncategorized | Leave a Comment
A while ago I got a paper published in a Springer journal. While finishing up the publishing process I got the option of having “Open Access”, but at a price:
Authors opting for Open Access in the Springer Open Choice program,
agree to pay the article processing fee. The standard fee is US$3000.
Customers in the Americas will be charged in US dollars, and customers
in Europe, Asia, and Africa will be charged the equivalent fee in Euros.
VAT and other applicable taxes are not included in the standard fee of
US$3000, and will be added according to the requirements of the country
where the order is placed.
$US3000 seems a bit much for open access to a little maths paper. I put a more up to date version on the arXiv anyway. It’s no wonder that the general public doesn’t quite know what scientists get up to when so much of their output is in non-open journals. Walk-in access is diminishing too since libraries are switching to electronic subscriptions and you sometimes need a student/staff login to use a computer in a library (I think that’s the case at UQ these days).
DD-WRT on the Asus WL-500gP
April 23, 2009 | Filed Under Uncategorized | Leave a Comment
Notes: When flashing using tftp, you really need to wait a few minutes after the file transfer finishes.
my local copy of the DD-WRT files: dd-wrt
sshfs is an excellent alternative to NFS: sshfs on DD-WRT wiki
Hello world with pydesign - STS(13) and STS(15)
March 25, 2009 | Filed Under Uncategorized | 1 Comment
I wanted a listing of the blocks of the 2 nonisomorphic STS (Steiner Triple System) on 13 points and the 80 nonisomorphic STS on 15 points. Over at designtheory.org there is a database of t-designs. An STS(13) corresponds to a t-design t=2, v=13, b=26, r=6, k=3, L=1 and an STS(15) corresponds to a t-design t=2, v=15, b=35, r=7, k=3, L1. Here is some code that uses pydesign to read the blocks from DTRS external representation files:
from pydesign import ext_rep
from pydesign import block_design
STS = {}
def save_blocks(t):
b = block_design.BaseBlockDesign(ext_rep.XTree(t))
if not STS.has_key(b.v): STS[b.v] = []
STS[b.v].append(b.blocks)
proc = ext_rep.XTreeProcessor()
proc.block_design_proc = save_blocks
f = ext_rep.open_extrep_file('t2-v13-b26-r6-k3-L1.icgsa.txt.bz2')
proc.parse(f)
f.close()
f = ext_rep.open_extrep_file('t2-v15-b35-r7-k3-L1.icgsa.txt.bz2')
proc.parse(f)
f.close()
assert len(STS[13]) == 2
assert len(STS[15]) == 80
print "An STS(13):", STS[13][0]
Here’s the source: STS_13_15.py.
Sunset in Libeň
March 10, 2009 | Filed Under Uncategorized | 1 Comment
![[photo]](/blogdata/medium/2009-03-08++18-27-14.jpg)
Turn an Asus WL-500gP into a PC
February 24, 2009 | Filed Under Uncategorized | 1 Comment
Update (2009-04-23): after a reboot my WL-500gP no longer booted Debian. Nothing appeared in the logs, so it really had be stumped. I ended up installing DD-WRT and all is well.
Here are my notes for installing Debian on an Asus WL-500gP (Premium v1). I basically followed this guide. I’m using the WL-500gP as a PC, not a router, so I have no information here about how to configure the VLAN stuff using robocfg.
Flash the kernel image
Install tftp on your PC, download the kernel openwrt-brcm47xx-2.6-jffs2-128k.trx and Debian image debian-mipsel-2007-Apr-17.tar.bz2 from here (or try my local copy but be sure to check the md5sums).
Set your PC to static IP 192.168.1.3 with gateway 192.168.1.1
Turn off the router. Hold down the “restore” button on the back, and turn on the power. Hold the button until the power LED on the front of the router flashes slowly.
The router is now in diag mode. Upload the image:
$ tftp 192.168.1.1
tftp> binary
tftp> trace
Packet tracing on.
tftp> put openwrt-brcm-2.6-jffs2-128k.trx
Prepare your USB disk on your PC
I assume that your USB disk is /dev/sda but it’s likely to be something else, so adjust accordingly. Partition your USB disk so that /dev/sda1 is ext3, /dev/sda2 is swap. It is essential to make sure that the USB drive is not checked by e2fsck:
$ tune2fs -c0 -i0 /dev/sda1
Uncompress debian-mipsel-2007-Apr-17.tar.bz2 in the /dev/sda1 partition so that /bin, /etc are at the top level.
Run mkswap on /dev/sda2
Configure the network.
My home network (via ADSL modem) is 192.168.1.x so my /etc/network/interfaces is:
auto lo
iface lo inet loopback
#auto eth0
#iface eth0 inet dhcp
auto eth0.100
iface eth0.100 inet dhcp
auto eth0
iface eth0 inet static
address 192.168.1.66
netmask 255.255.255.0
gateway 192.168.1.1
#auto eth0.100
#iface eth0.100 inet static
#address 192.168.1.25
#netmask 255.255.255.0
#network 192.168.1.128
#broadcast 192.168.1.191
#gateway 192.168.1.1
# wireless doesn’t work yet
#auto eth1
#iface eth1 inet static
# address 192.168.5.1
# netmask 255.255.255.0
# gateway 192.168.x.x
# wireless-essid networkname
# wireless-key 00000000000000000
My home router provides DNS so my /etc/resolv.conf looks like:
nameserver 192.168.1.1
/etc/hostname:
asusbox
Unmount the USB drive, plug it into the Asus.
For ethernet, I found that the LAN1 port worked (I thought that the WAN port would but it didn’t). Connect the Asus to your main router via the LAN1 port as if it was a normal PC.
Power it up. It should respond to ping,and ssh. The default root password is toor, and it should be changed as soon as possible.
I have an old laptop hard drive attached to my WL-500gP using an IDE to USB cable:
![[photo]](/blogdata/medium/2009-02-21++19-55-48.jpg)
Nice little silent PC:
![[photo]](/blogdata/medium/2009-02-21++19-56-26.jpg)
Some system info:
carlo@lothlorien:~$ cat /proc/cpuinfo
system type : Broadcom BCM47xx
processor : 0
cpu model : Broadcom BCM3302 V0.6
BogoMIPS : 263.16
wait instruction : no
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : no
hardware watchpoint : no
ASEs implemented :
VCED exceptions : not available
VCEI exceptions : not available
carlo@lothlorien:~$ free -m
total used free shared buffers cached
Mem: 29 28 1 0 0 16
-/+ buffers/cache: 11 18
Swap: 729 5 724
carlo@lothlorien:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 147G 103G 37G 74% /
tmpfs 15M 0 15M 0% /lib/init/rw
udev 10M 20K 10M 1% /dev
tmpfs 15M 4.0K 15M 1% /dev/shm
none 15M 0 15M 0% /tmp
lothlorien:~# lspci
00:00.0 Host bridge: Broadcom Corporation BCM4704 PCI to SB Bridge (rev 09)
00:02.0 Network controller: Broadcom Corporation BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller (rev 02)
00:03.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 62)
00:03.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 62)
00:03.2 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 65)
It can handle rtorrent but uses a few Mb of swap and so it’s not too quick to respond sometimes in an ssh terminal.
Cython vs. C++, improved
November 9, 2008 | Filed Under sage | 2 Comments
In a recent post I compared my Cython and C++ implementations of a depth first search algorithm. The Cython code was quite slow, and Robert Bradshaw commented:
This graph looked pretty depressing, so I made some optimizations to your code (basically the ones suggested above, and a couple of other glaring things that stood out). The algorithm is still completely the same, and I didn’t do any code re-factoring other than __getitem__/__setitem__, just mostly typing things here and there. It’s now faster than c++ on my machine for the whole range graphed above (and much faster for small inputs).
Code and diff up at http://sage.math.washington.edu/home/robertwb/cython-latin/
I applied Robert’s patch and re-ran the tests on my laptop:

The Cython implementation with Robert’s patch is now significantly faster than the C++ implementation on most of the range that I checked.
Deconstruction / graffiti
October 19, 2008 | Filed Under Uncategorized | Leave a Comment
Graffiti near Karlín:
![[photo]](/blogdata/medium/2008-08-30++09-53-50.jpg)
![[photo]](/blogdata/medium/2008-08-30++09-54-00.jpg)
![[photo]](/blogdata/medium/2008-08-30++09-56-23.jpg)
![[photo]](/blogdata/medium/2008-08-30++09-56-31.jpg)
![[photo]](/blogdata/medium/2008-08-30++09-56-55.jpg)
![[photo]](/blogdata/medium/2008-08-30++09-57-05.jpg)
August photo batch
October 19, 2008 | Filed Under Uncategorized | Leave a Comment
![[photo]](/blogdata/medium/2008-08-30++09-41-08.jpg)
![[photo]](/blogdata/medium/2008-08-30++09-41-29.jpg)
![[photo]](/blogdata/medium/2008-08-30++09-44-39.jpg)
![[photo]](/blogdata/medium/2008-08-30++09-44-53.jpg)
![[photo]](/blogdata/medium/2008-08-30++09-45-08.jpg)
![[photo]](/blogdata/medium/2008-08-30++09-47-49.jpg)
![[photo]](/blogdata/medium/2008-08-30++09-50-08.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-07-29.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-07-53.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-09-30.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-10-42.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-10-47.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-12-01.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-15-45.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-16-25.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-18-47.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-19-08.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-23-11.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-25-56.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-26-06.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-35-35.jpg)
![[photo]](/blogdata/medium/2008-08-30++10-50-12.jpg)
![[photo]](/blogdata/medium/2008-08-30++11-05-31.jpg)
![[photo]](/blogdata/medium/2008-08-30++11-06-33.jpg)
![[photo]](/blogdata/medium/2008-08-30++11-06-37.jpg)
Meat
October 19, 2008 | Filed Under Uncategorized | Leave a Comment
Why do our across-the-street neighbours have newspaper hanging from the top of their window?
![[photo]](/blogdata/medium/2008-10-04++13-24-21.jpg)
Oh right, they’re just hanging some meat out there.
![[photo]](/blogdata/medium/2008-10-04++13-22-04.jpg)
Not sure that I would air-cure meat outside in Prague. Mmm, diesel fumes!