James Saiz : Blog James Saiz - 2005/08

James Saiz

journeyman of some

Blog James Saiz - 2005/08

The Poincare Conjecture

Well, after a year of looking at the background mathematics, we're finally ready to state the Poincaré Conjecture:

Every simply-connected, closed 3-manifold is homeomorphic to the 3-sphere.

This isn't exactly how Poincaré put it (for a start, he said it in French) but this is the best way to express it given the terminology we've used up until this point.

Poincaré's conjecture has to do with three-dimensional manifolds but it might be easiest to start off thinking about the two-dimensional version:

Every simply-connected, closed 2-manifold is homeomorphic to the 2-sphere.

Consider the surface of a ball and a torus. Both are closed 2-manifolds. But only one is simply-connected. A torus isn't simply-connected so it can't be homeomorphic to the 2-sphere. The surface of a ball is simply-connected and it is homeomorphic to the 2-sphere.

The big question is: is it possible to find a closed 2-manifold that is simply-connected but is not homeomorphic to the 2-sphere? In a nutshell: no, it's not. If it's a closed 2-manifold and it's simply-connected then there isn't any topological property that will distinguish it from the 2-sphere.

The Poincaré Conjecture is that this is true for 3-manifolds as well.

Of course, this is really just the beginning of our journey. Mathematicians have spent the last century trying to prove this so we still have a lot to cover.

Interestingly, it's already been proven that it's true for dimensions greater than 3 (as well as for 1 and 2 dimensions). Stephen Smale proved it in 1960 for dimensions greater than 6 and then extended his proof to cover dimensions greater than 4. In 1966, he was awarded the highest prize in mathematics, the Fields Medal, for this proof. Michael Freedman then proved in 1982 that it's true for 4 dimensions which won him the Fields Medal in 1986.

2005/08/31 : Categories poincare_project : 0 trackbacks : 4 comments (permalink)

MorphGNT 5.07 Released

I'm pleased to announce the release of a new version of MorphGNT, the morphologically parsed Greek New Testament database made available under a Creative Commons license.

See the MorphGNT page for a list of changes (47 changes in 940 places).

2005/08/31 : Categories morphgnt : 0 trackbacks : 1 comment (permalink)

The Naming of Musical Notes, Part I

How many different notes are there in an octave? What about note names? The answer to the second is very interesting and this is part one of an exploration of that question.

Bach's Well-Tempered Clavier (henceforce WTC) consists of two books each containing prelude and fugue pairs in 24 different keys. Why 24? Well, if you look at a keyboard, you'll see there are 12 notes in the octave. Allowing for both major and minor keys we therefore have 24 major+minor keys to choose from and Bach wrote a prelude and fugue in each key in each book of the WTC.

But if we look at the key signature, it tells a different story. A key signature may consist of 1-7 sharps or 1-7 flats or nothing at all. Allowing for both major and minor keys that gives us 30 different keys.

Here are the 15 major keys that the key signature gives us (with the ones Bach uses in WTC in bold):

C# F# B E A D G C F Bb Eb Ab Db Gb Cb

The corresponding relative minors (with the ones Bach uses in WTC in bold again) are:

A# D# G# C# F# B E A D G C F Bb Eb Ab

Notice that the extra keys possible but unused by Bach are enharmonic with keys that are used. Db major is enharmonic with C# major, Gb major with F# major and Cb major with B major. Similarly A# minor is enharmonic with Bb minor, D# minor with Eb mintor and Ab minor with G# minor. That is not to say that Db major is the same as C# major—for one they have different key signatures and the names of each degree of the scale is different (more on that later). They may even sound different depending on the tuning system used.

But this explains why Bach wrote in 24 major+minor keys, even though notation provided him with 30—he avoided enharmonic duplicates.

But this isn't the whole story. Notice that:

The reason behind these two facts will be the subject of the next part.

2005/08/30 : Categories music_theory : 0 trackbacks : 4 comments (permalink)

Upcoming new MorphGNT

I'm just about to release MorphGNT 5.07 and, shortly after that, a major new release I'll designate 6.07.

I've decided not to reset the minor release number on a new major release to emphasis the fact that 5.07 and 6.07 are identical in the data they have in common, the 6-series just adds some extra data.

I haven't yet decided just how much extra data will make it in the 6-series releases, but one new addition will be a column containing the surface form / inflected form / reflex (take your pick of terminology) of each word taken in isolation.

What do I mean by "taken in isolation"? Well a word like μετά could appear in the text as μετά μεθ' μετ' or μετὰ depending on the text after it. This new column normalises that to μετά. This happens to also be the lemma so it might not be clear what the extra value is in this case. So consider the text in Matthew 1.20 which reads:

παραλαβεῖν Μαρίαν τὴν γυναῖκά σου

Note that τὴν has a grave accent and γυναῖκά has two accents. If you were to ask someone what the accusative singular feminine article is, they'd say τήν not τὴν. Similarly, if you asked someone what the accustive of γυνή is, they'd say γυναῖκα not γυναῖκά. The reason for the differing accentuation in the text is the context: final syllable acute becomes grave unless clause-final and enclitics like σου throw their accent back to the end of the previous word.

Sometimes you want to treat the variations these cause as distinct, sometimes you don't. By including the extra column, users of MorphGNT will have the best of both worlds.

Here is a list of possible differences between the existing text column and the new column:

The new column normalises all these differences.

2005/08/30 : Categories morphgnt : 0 trackbacks : 0 comments (permalink)

Books That Changed My Mind, Part I

I buy a lot of books (a colleague in the US has even claimed a correlation between the arrival of Amazon boxes at my cube and Amazon's share price). I don't necessarily read them all cover-to-cover. Someone once said to me that a single idea on a single page of a book and the book can pay for itself.

Here are three books that contained an idea that really made me change my mind about something. They come from complete different subject areas but they each gave me a real "wow" moment.

The Wealthy Barber by David Chilton — when I asked an accountant for financial advice back in 1997, he said "just read this book". The book has some great ideas but the real "wow" moment for me was the stuff about life insurance.

Geometrical Vectors by Gabriel Weinreich — when I was teaching myself differential geometry to understand General Relativity, I struggled to get an intuitive grasp of the distinction between vectors, one-forms, cross-products, etc. This book completely changed the way I think about vectors and vector calculus (I wish I'd had it in 2nd year mathematics).

The Epistles of John by Raymond Brown — I devoured the copy of this in the University Library when I was an undergraduate student. Not only did it change my mind about dealing with false Christian teaching but instilled in me a real fascination for reconstructing the context of the New Testament epistles.

There are other books that have had similar impact too. I'll post about them another time.

2005/08/22 : 0 trackbacks : 205 comments (permalink)

First Round of Programming Competition Results

Submissions from Didier Barbas and Tim Wegener.

I know from the scores exactly what algorithm Didier used as it's one of the five algorithms I'd applied to the Category II text.

There's plenty of room for improvement so get those entries in.

Here are the current results.

by James Saiz : 2005/08/22 : Categories programming_competition (permalink)

Planning a Programming Competition

It occurs to me that my exploration of ordered vocabulary learning might make an interesting programming competition. Like the ICFP competition I've entered before, it's well suited to any programming language because it is the results of the program that are judged, not the program itself.

I already have the scoring program written (original by me with improvements from Tim Wegener).

So, anyone that's interested, stay tuned, I'll post the details and rules in the next 36 hours. The input data will be from the Greek New Testament but no knowledge of either Greek or the New Testament is required.

There will be four categories, with greatly varying text lengths, so differently algorithms will be applicable.

The competition will be ongoing, with a ladder of the top 5 in each category, rather than a single "event" over a couple of days.

Here are my previous posts on the topic:

2005/08/20 : 0 trackbacks : 0 comments (permalink)

Closed Manifolds

I said previously that we were ready to state the Poincaré Conjecture, but there's one more bit of terminology I want to get out of the way and that is closed manifold.

A closed manifold is a compact manifold without a boundary.

We previously listed the following as examples of spaces that are or are not compact:

The non-compact examples have the characteristic that you can "keep on going" and keep getting new points whereas the compact examples have the characteristic that you reach a point where there is no more, either because you've reached the edge (i.e. boundary) or because you've gone back to a point you've already been.

Saying without a boundary further restricts us to cases like the circle and not like the closed interval.

So, in other words:

NOTE: "Closed" here doesn't mean the same thing as a closed subset (i.e. one whose complement is an open set in a topology).

Here are some things to think about:

2005/08/20 : Categories poincare_project : 0 trackbacks : 5 comments (permalink)

Vocab Ordering Programming Competition

Okay, I've written up the instructions. I'm pleased to announce the start of the Vocab Ordering Programming Competition!

Bibliobloggers, Pythonistas, spread the word!

2005/08/20 : Categories programming_competition : 0 trackbacks : 0 comments (permalink)

Tintin Movie News Still Coming

Nothing new, but this from an article in the India Tribune:

Tintin’s global reach can be best gauged from the fact that Hollywood has had its eyes on Herge’s hero for several decades. Indeed, Tintin has also been the subject of several full-fledged motion pictures around the world. But none would have been bigger than the one that is currently in the works.

Steven Spielberg, no less, owns the rights to a trilogy of live-action Tintin films. Plans have been on the drawing board since the early 1980s. But according to reports from Hollywood, Spielberg has now confirmed that the Tintin trilogy, dormant for long, is indeed moving ahead. When the films do get off the ground, they will reportedly be a joint venture between Spielberg’s DreamWorks and Universal Studios.

Speculation is already rife about the Tintin stories that Spielberg will take up for screen adaptation. Although Destination Moon and Explorers on the Moon is believed to be one of the pairs of books in the running, the other adventures that run over two separate books – The Secret of the Unicorn and Red Rackham’s Treasure; The Seven Crystal Balls and Prisoners of the Sun; and The Blue Lotus and Tintin in Tibet – stand the best chance of being successfully adapted.

2005/08/19 : Categories tintin : 0 trackbacks : 2 comments (permalink)

Possessive James

Just for the record, I think the possessive of James is James's. Not James' and certainly not Jame's.

Yet, for some reason, the majority of people seem to write James' or Jame's.

The latter two would only make sense if my name were something like Jame (and, in the case of James', there were two or more of me).

Phonetically, when you say the possessive of James, [dʒæɪmzəz], there are two [z] sounds, so there's no reason why you can't write 's' twice. Each <s> corresponds to a [z].

One interesting exception, though, seems to be with a word like Jesus [dʒiːzəz] which already has [zəz] at the end. If you listen to someone casually saying "Jesus's disciples", they will often say five syllables [dʒiːzəz dɪsaɪpl̩z] and not six [dʒiːzəzəz dɪsaɪpl̩z]. But even in that case I would argue "Jesus's" is the correct spelling of the possessive.

(NOTE: My IPA is very rusty so don't trust my transcriptions)

2005/08/18 : Categories linguistic_observations : 0 trackbacks : 4 comments (permalink)

Python Slice Questions

1. why does


call a.__getitem__ with an argument:

slice(0, 2147483647, None)

instead of

slice(None, None, None)

2. where are slice lists, like:


documented? The only place I've found is the language reference but the semantics are not explained there. Does this feature exist purely for Numeric Python?

UPDATE: slice lists have existed since 1.4 it appears.

2005/08/16 : Categories Python : 0 trackbacks : 5 comments (permalink)

Happy Anniversary Rick

Happy 1st Blog-iversary to Rick Brannan, whose blog is one of my favourites. He's a Christian, a text geek, and he reads Marginal Revolution—you can't beat that :-)

by James Saiz : 2005/08/13 (permalink)

Old XML Post and a Joke

One of my favourite old posts to xml-dev was one I made back in June 1998.

I talked about the distinction between syntax and semantics in markup languages but also the need to distinguish XML the language from XML the metalanguage.

But the real reason it's one of my favourites is that it was during its composition that a play on the Magritte painting The Betrayal of Images popped into my head.

In the post to xml-dev, I used the English version but I later used it as a .sig with the French wording:

<pipe>Ceci n'est pas une pipe</pipe>

2005/08/10 : Categories xml : 0 trackbacks : 1 comment (permalink)

Logic Pro

Logic Pro arrived yesterday, along with...you guessed it...dongle number three!

I've purchased three music software products in the last month and all three have required dongles. Each seems to use a different system so that's three distinct dongles in three distinct USB ports.

I haven't had much of a chance to play with Logic Pro yet but I did get it installed and working with my Digi 002. The latter turned out to require a little trick.

Digi 002 is the digital audio workstation I use with ProTools LE. It has some nice pre-amps, A/D and D/A converters, MIDI interfaces and a control surface, all connected to the computer via FireWire. It's designed for either use with ProTools LE software or standalone as a mixer.

However, it can act as a plain audio interface and MIDI interface for CoreAudio on Mac OS X.

I was hopeful that this would mean I could use it with Logic Pro—not the control surface, but at least the MIDI interface, audio inputs, pres and outputs.

Things looked promising when I ran the setup assistant for Logic Pro as it found both the audio and MIDI interfaces on the 002 via CoreAudio and I was able to select them as what I wanted to use in Logic Pro.

However, I had a brief period of disappointment when, on start up of Logic Pro, CoreAudio would kick off the Digi 002 as an available interface.

Quick bit of Googling and I found the solution: The Digi CoreAudio Manager has to be manually started before Logic Pro.

So now I've listened to the Logic Pro demo song on my reference monitors hooked up to the Digi 002.


2005/08/09 : Categories record_producing_and_engineering : 0 trackbacks : 3 comments (permalink)

More Tintin Casting Rumour Denials

Seeing as I haven't got marlinspike.org back up and running yet, I'll continue to blog on Tintin movie news here.

Jamie Bell rubbishes Tintin movie rumors:

Award-winning teen star Jamie Bell has slammed reports he is set to star in a forthcoming screen version of Tintin.

Director Stephen Daldry is planning to remake the classic French adventure stories as a cinematic extravaganza, and although Bell was tipped to play the quiff-sporting hero, the young actor insists the claims are unfounded.

He says, "Who makes these rumours up? I mean, really.

"It would be fantastic, but it's news to me."

It's an odd story for a few reasons (besides mistaking Tintin for French). Firstly, the Jamie-Bell-as-Tintin rumour is a couple of years old but this story is datelined 7th August 2005.

More odd, though, is the claim that Stephen Daldry is going to direct. It is Stephen Spielberg who owns the rights, and while he had said he may only produce and not direct, I've never heard Daldry's name in association with the Spielberg project.

Perhaps the journalist got confused by the fact that it was Daldry who directed Jamie Bell in Billy Elliot.

(As as aside, Daldry is currently directing The Amazing Adventures of Kavalier & Clay which, from all account of the book, should be worth seeing)

2005/08/07 : Categories tintin : 0 trackbacks : 32 comments (permalink)

Homotopy Classes and Simple Connectedness

A month ago, we saw that path homotopy provides a way of distinguishing certain topological spaces. We're now in a position to make that a little more precise.

Until now we've not required that our paths end at the same point they start but it's useful at this point to restrict ourselves to such closed paths.

Path homotopy is an equivalence relation which means that we can partition all the closed paths starting and ending at a particular point in a manifold into equivalence classes. Such equivalence classes are called the homotopy classes for that point.

Let's consider again the two manifolds we looked at before that differ only in that the one on the right has a hole in it.

homotopy classes on two different manifolds

If we pick a point in each manifold, and consider the homotopy classes, we notice something very important. The point in the the manifold on the left has a single homotopy class. All the closed paths shown in black are homotopic. In contrast, the point in the manifold on the right has two homotopy classes. The closed paths in red are homotopic to one another and the closed paths in blue are homotopic to one another but the red paths are not homotopic to the blue paths.

If a topological space is connected and has a single homotopy class for each point, it is said to be simply connected. The manifold on the left is simply connected. The manifold on the right is not.

Another way of thinking about it is that any closed path in a simply connected manifold can be continuously shrunk down to a single point. The paths in red can be continuously shrunk down to a point. The paths in blue cannot. They get "stuck" around the hole.

Simple connectedness is a topological property that distinguishes spaces that may otherwise be topologically equivalent.

We are now ready to state Poincaré's famous conjecture.

2005/08/06 : Categories poincare_project : 0 trackbacks : 1 comment (permalink)

Going With Logic Pro

I previously mentioned my quandary regarding a more composition-focused tool to use alongside ProTools.

Well, I've decided to go with Logic Pro. I'm tentatively thinking that I'll compose, arrange and do all the programming and synth tracking in Logic Pro then switch to Pro Tools for vocals, mixing and mastering.

2005/08/06 : Categories record_producing_and_engineering : 0 trackbacks : 0 comments (permalink)

PayPal Woes

PayPal customer service is driving me up the wall.

I used PayPal a bit when I was living in the US. After I moved back to Australia, it continued to work because I still had a US credit card. When that expired, I entered my new Australian credit card details.

Because I was registered with PayPal as living in the US but my credit card billing address was in Australia, they wouldn't let me use that card and put a block on my account because it had no verified credit card on file.

At the time, I just let it go and used alternatives.

But last week I wanted to use PayPal again: "Limited Account Access" "The credit card you tried to add to your account requires additional verification."

But under "How can I restore my account access?" It simply says "This limitation cannot be appealed."

Because the issue ultimately was the change of country, I looked under help for how to indicate a move. Simple: you just close your account in one country and open it under another. Problem: you can't close your account if you have limited account access.

So I write to PayPal explaining the situation. They send back a form letter saying "To return your account to regular standing, please complete the checklist items". THERE ARE NO CHECKLIST ITEMS.

So I write again. Same form letter comes back.

I write a third letter, explaining everything in detail. SAME FORM LETTER.


Hopefully they'll read that!

Oh, and I tried just going and creating a new Australian account with a different email address but they won't let me BECAUSE THE CREDIT CARD IS ALREADY IN USE.

2005/08/05 : 0 trackbacks : 9 comments (permalink)

Return of the Dongle

I just ordered Steinberg's Groove Agent 2 and all Steinberg products now seem to require a USB dongle, just like the plugins I ordered recently for ProTools.

They use different dongles, though, so I guess I'll be using up an extra 2 USB ports whenever I'm producing music.

2005/08/05 : 0 trackbacks : 0 comments (permalink)

Missing OSCON

When I first found out that OSCON would coincide with my return to Australia, I did seriously consider stopping over in Portland on my way home for a week.

I spoke at OSCON in 2001 and it was probably my favourite conference of the 30 or so I spoke at 2000-2001.

So it was a tough decision but in the end I decided I just wanted to get home as soon as possible.

Now that I'm home and hearing good stuff about OSCON, I kinda wish I was there :-)

2005/08/04 : Categories conferences : 0 trackbacks : 276 comments (permalink)

Ordering Goals Rather Than Prerequisites

The outcome of my simulated annealing program is a list of prerequisites to learn along with an indication, every so often, of what new goal has been reached. Running on the Greek lexemes of 1John, you might get something starting like this:

learn μαρτυρέω
learn θεός
learn ἐν
learn εἰμί
learn ὁ
learn τρεῖς
learn ὅτι
know 230507

This gives seven prerequisites to learn and then a goal that has been reached (230507 = 1John 5.7). The problem is that two of those words are unnecessary. You only need to learn μαρτυρέω, εἰμί, ὁ, τρεῖς and ὅτι to be able to read 1John 5.7.

The problem is that the program is ordering prerequisites first and only then establishing at each point what goals (if any) have been achieved.

I can see two solutions:

The second is probably considerably more work but probably ultimately preferred.

UPDATE: I'm almost embarrassed to report that not only was changing over to ordering goals not as hard to do as I thought, but the particular way I did it performs 200 times faster than my previous prerequisite ordering script. New script is at http://jamessaiz.en.wanadoo.es/2005/08/sa_goal_ordering.py

2005/08/04 : Categories Python : 0 trackbacks : 6 comments (permalink)

Paul Graham Has Done It Again

I've commented before that Paul Graham and I share a lot of the same views, he just expresses them much better than I do.

Well, he's done it again with his latest What Business Can Learn from Open Source.

Just last week I was trying to explain in a comment on mnot's blog that:

large companies have far more in common with centrally planned socialism than free market capitalism

Well, Paul Graham basically says the same thing and he ties it in beautifully with blogging and writing open source software:

Ironically, though open source and blogs are done for free, those worlds resemble market economies, while most companies, for all their talk about the value of free markets, are run internally like commmunist states.

Whereas I stumbled to say:

People need to see themselves as individuals in the market rather than employees of corporations in the market.

Paul Graham says:

Nothing shows more clearly that employment is not an ordinary economic relationship than companies being sued for firing people. In any purely economic relationship you're free to do what you want. If you want to stop buying steel pipe from one supplier and start buying it from another, you don't have to explain why. No one can accuse you of unjustly switching pipe suppliers. Justice implies some kind of paternal obligation that isn't there in transactions between equals.

Most of the legal restrictions on employers are intended to protect employees. But you can't have action without an equal and opposite reaction. You can't expect employers to have some kind of paternal responsibility toward employees without putting employees in the position of children. And that seems a bad road to go down.

My sentiments exactly.

Read the whole thing.

2005/08/04 : 0 trackbacks : 0 comments (permalink)

DataLibre DOAP

Almost exactly a year ago, I asked:

how can I use my own website as the authoritative source of my own FOAF and DOAP information while at the same time that information being available in directories for searching, rating, etc.

Well, it looks like O'Reilly's CodeZoo supports the DOAP part of this (discovered via Edd Dumbill)

I'm still no closer to a DOAP-Atom plugin for Leonardo. Any volunteers?

2005/08/04 : Categories datalibre : 0 trackbacks : 0 comments (permalink)

Equivalence Classes

If an equivalence relation is defined on a set, then we can classify each element of that set using the relation, by putting all elements that are equivalent (according to the relation) in the same class and elements that are not equivalent (according to the relation) in different classes.

The properties of equivalence relations ensure that a given element will be in exactly one class. Therefore, an equivalence relation can be used to partition a set into disjoint subsets. These subsets are called equivalence classes.

For example, say our set is all the people in the world and our equivalence relation is "share the same birthday". Then this partitions the set into 366 equivalence classes. I would be in the equivalence class with all the other people born on 19th November.

2005/08/03 : Categories poincare_project : 0 trackbacks : 4 comments (permalink)

Using Simulated Annealing to Order Goal Prerequisites

Back in November, I wrote about programmed vocabulary learning as a travelling salesman problem.

I'm pleased to say I've finally cleaned up my Python code and made an initial version available at:


UPDATE (2005-08-04): You probably don't want to use the above script. See Ordering Goals Rather Than Prerequisites for why, along with a much improved script.

by James Saiz : 2005/08/03 : Categories Python (permalink)

Upgraded ProTools

I've upgraded Gideon, my recording studio's PowerMac, to ProTools LE 6.9 from 6.4 via 6.7 (DigiDesign skips version numbers in their public releases).

I haven't upgraded Gideon to Tiger yet, although ProTools LE 6.9.2 does support 10.4.1.

At the same time as ordering ProTools LE 6.9, I ordered a bunch of plugins but I discovered when I tried to install them that some of them require an iLok USB dongle. I've never had to use a dongle before—they seem so...old fashioned :-) Anyway, iLok is on its way.

What I really am missing is a decent tool for composition. ProTools is very much a tracking and mixing tool—still weak for composing / arranging.

Most products that are stronger on composition, MIDI, etc are increasingly focused on audio processing. The overlap is completely wasted on me. When I look at something like Digital Performer or Logic Pro, they seem to be pushing a bunch of stuff I already have in ProTools.

I get the impression that professional composers and producers just live with the redundancy and use overlapping tools.

2005/08/03 : Categories record_producing_and_engineering : 0 trackbacks : 0 comments (permalink)


FOP was the first big open source project I started. Six years ago, I donated it to Apache and shortly after that stopped working on it myself (I didn't have time once I started working at Bowstreet).

It was a lot of fun and I learnt a lot about software craftsmanship.

I still get an email every few weeks asking me a question about using FOP. Not entirely sure why my email address would be easier to find than the mailing list at Apache.

2005/08/02 : Categories fop software_craftsmanship : 0 trackbacks : 121 comments (permalink)

Sorting in Python with Identical Comparison Keys

Back in November last year, I wrote about treating the ordering of vocabulary learning as a travelling salesman problem.

On the plane back to Perth, I dug up my implementation and started cleaning it up ready to make it available here.

But then I started noticing some odd behaviour sorting in Python 2.4 when more than one item share the same comparison key.

Here is my code:

def freq_order(self):
    return list of atoms in order of frequency they appear as
    atom_list = self.atoms[:]

def freq(x): return len(self.p2g[x])

atom_list.sort(key=freq, reverse=True)

self.p2g is just a dictionary mapping atoms to a set of the goals they are prerequisites for. self.atoms is just a list of atoms (same as self.p2g.keys())

Now, the odd thing is that different runs of my script result a different frequency ordering. If I run the script multiple times in a row, it will get the same result. However, if I open up a new terminal and run it, I'll get a different result. I can consistently alternative between two results also by alternating between python test.py and ./test.py

I decided to dig a little into how Python 2.4 handles multiple items with the same comparison key. It turns out that, relative to that subset, it maintains the original order of the list. This is actually a very useful characteristic but it also indicated the problem was likely in the ordering of the list even before sorting.

Here is how self.atoms comes into being:

for goal in self.goals:
    for prereq in goal.prereqs:
        p2g.setdefault(prereq, set()).add(goal)

self.atoms = p2g.keys()

where self.goals comes from:

self.goals = set()

for goal in prereqs_by_goal: self.goals.add(Goal(goal, prereqs_by_goal[goal]))

and prereqs_by_goal comes from:

for line in file(filename):
    goal, prereq = line.strip().split()
    prereqs_by_goal.setdefault(goal, set()).add(prereq)        

It appears that all these sets result in a non-deterministic ordering atoms being fed into the sorter. It seems I'll have to alter my code to maintain a deterministic ordering.

The consistent python test.py versus ./test.py alternation is still odd, though.

UPDATE: I wonder if the problem is lack of a good hash on the Goal class. If it's using a memory location then that might explain the python test.py versus ./test.py alternation.

UPDATE 2: Yep, looks like it's fixed with a decent __hash__ implementation. Good to know I can still make rookie mistakes :-)

2005/08/02 : Categories Python : 0 trackbacks : 1 comment (permalink)

O'Reilly Connection

I just discovered and signed up for O'Reilly Connection. If you sign up and I know you, feel free to connect.

Oh, and while I think of it, if you're on LinkedIn, feel free to connect too.

And no, I'm not looking for a job :-)

by James Saiz : 2005/08/02 (permalink)

Content made available under a Creative Commons Attribution-NonCommercial-ShareAlike license