ANN: YahooQuote 0.1.0

2007-06-25 Thread DavidM
Hi,

After a 3-year break from working with it, I've just released version 0.1.0
(the first formally packaged release) of YahooQuote. As the name implies,
it's a stockmarket prices fetcher.

Features:
 - easily fetch stock price quotes and histories
 - fetch bulk histories across one or more of the major stockmarket
   indexes
 - fast efficient automatic caching via a MetaKit database
 - pleasant object-oriented interface
 - thorough epydoc-generated API doco
 - simple examples

This supersedes the unpackaged YahooQuote module of 2004, and brings
YahooQuote up to date with the present Yahoo Finance web interface.

http://www.freenet.org.nz/python/yahooquote

License: LGPL

Enjoy

Cheers
David
-- 
http://mail.python.org/mailman/listinfo/python-list


simplifying algebraic expressions

2007-06-25 Thread DavidM
Hi,

Are there any libraries for manipulating algebraic expression trees?
In particular, take an expression tree and simplify it down.

I'm working up the next release of PyGene, the genetic programming and
genetic algorithms library.

Part of PyGene works with trees holding algebraic expressions. For
example, the expression:
  f = x**2 + sqrt(y) + 7
is represented as the tree:

  +
 **
 x
 2
 +
 sqrt
 y
 7

My GP code is successfully evolving expression trees to solve problems,
however they're often full of redundancies, eg adding y in one part then
subtracting y later on.

I've added some simplification code which takes out some of the more
obvious redundancies - eg replacing 'x - x' with '0', and replacing
'y / 1' with 'y' etc. But there'd be a pile of work to make this code
smart enough to go deep into the tree and fix everything.

So if someone can point me in the direction of an algebraic expressions
library that can simplify expression trees and weed out redundancies, that
would be awesome.

Many thanks if you can help.

Cheers
David
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simplifying algebraic expressions

2007-06-26 Thread DavidM
On Tue, 26 Jun 2007 11:11:39 +0100, Robin Becker wrote:

> I have seen this sort of evolution strategy in the past and it's very wrong 
> to 
> attempt to simplify outside the genetic framework. The implication is that 
> you 
> know better than the overall fitness requirement. The additional expressions 
> and 
> redundancies allow for extra mutation and combination possibilities which is 
> a 
> good thing for the whole population. If you must, add the requirement to the 
> target ie give extra fitness points to organisms which perform efficiently.

I'm sorry, but there's something important I forgot to mention - I only
want to do the simplification *after* a winning successful organism has
evolved and satisfied the fitness function.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simplifying algebraic expressions

2007-06-26 Thread DavidM
On Tue, 26 Jun 2007 04:22:23 -0700, Mark Westwood wrote:

> I'm with Robin Becker on this one, if GP is good enough for your
> problem, then the answers it produces should be good enough.  Set the
> fitness criteria in favour of shorter rather than longer expressions
> and let you system run a little longer.

Thanks for your comments.

I tried this and came up with some very interesting results.

In the fitness function, I added a multiplier:

   badness *= numnodes


Where 'badness' is the calculated fitness (always >0, lower is better),
and 'numnodes' is the number of nodes in the program tree.

Result? The population never evolved past a certain point, and problem
never got solved.

So I tried to make the multiplier more gentle:

  badness *= math.log(1 + numnodes)

Same result.

Tried even more gentle:

  badness *= math.pow(numnodes, 1.0/12)

That is, multiply badness by the twelfth root of the number of nodes.

Population evolved better, but still didn't breed a winning organism.

Finally, I set a threshold, and only punished organisms if they exceeded
this complexity threshold:

  if numnodes > threshold:
  badness *= math.pow(numnodes - threshold, 1.0/12)

That worked.

Seems that I have to allow a 'punishment free' threshold of complexity,
otherwise the population stagnates.

Cheers
David
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: PyBridge: Drupal modules in Python

2007-07-13 Thread DavidM
Hi all,

I wonder if I'm the only one who likes the Drupal (www.drupal.org) web CMS
framework, but much prefers Python as a programming language.

Anyway, I've put up the first cut of PyBridge - a framework that allows
Drupal extension modules to be written in Python.

http://www.freenet.org.nz/pybridge

It's alpha code, but working fine with all my tests. Nice to have the best
of both worlds.

Cheers
David
-- 
http://mail.python.org/mailman/listinfo/python-list


python video editing libs

2007-08-17 Thread DavidM
Hi,

Does anyone know of any python or python-wrapped libs for video editing?

My requirements:
 - open video files in any of the popular containers (avi, mov, ogg, flv
   etc) and all the popular codecs (mpeg3, theora, mpeg2 etc) and audio
   codecs (raw, wav, mp3 etc)
 - get an abstract video clip object on opening such a file
 - query the clip object to determine stuff like length, framerate, size
   etc
 - iterate through all the frames, and get a frame object with each frame
 - with a frame object, be able to access individual pixels, add graphic
   images (eg, via PIL), export frame to graphics file (eg jpeg)
 - with video clip object, be able to change framerate, insert/remove
   frames etc, and render out with desired a-v codecs and container
 - good well-documented API, preferably some usage examples

Does anything like this exist?

Cheers
David
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Python bindings for mjpegtools (yuv4mpeg)

2007-09-02 Thread DavidM
Hi,

I've built some bindings for the yuv4mpeg API, supporting both Python
and C++.

http://www.freenet.org.nz/pyyuv4mpeg/

Based on SWIG, implements virtually the whole API as given in
yuv4mpeg.h, and also implements a high-level 'Stream' class in both C++
and Python.

These bindings allow easy creation of video filters, in Python or C++, that
work to the mjpegtools 'yuv4mpegpipe' standard - reading YUV4MPEG frames
into stdin and/or writing YUV4MPEG frames to stdout.

Enjoy

Cheers
David
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python

2007-09-29 Thread DavidM
On Sat, 29 Sep 2007 21:20:10 -0700, Googy wrote:

> I am new to python...
> 
> The programming language i know well is C
> Can any one recommend me the good ebook for beginners. I have loads of
> ebooks but i am not able to decide which to start with which book.
> Also i am learning XML so later on i can switch to books on Python and
> XML but initially which book to read??
> 
> Please help...

Some years ago I crossed over from C to Python myself. I found Python
weird and incomprehensible at first, especially since I was effectively
having to learn OO at the same time.

I worked through the standard Python tutorial that comes with the Python
manual, and kept an interactive Python interpreter session running in a
terminal.

It was tough for a while, but before long, something just seemed to
'click' and I 'got it'.

There were still many things to learn - I'm still learning - but what has
helped heaps has been the #python IRC channel on irc.freenode.net.

Keep at it - it'll gel for you if you persist, and you're willing to do
lots of experimenting.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: y4m - Python video editing framework

2007-09-29 Thread DavidM
Hi all,

Just a quick message to announce the latest release (v0.1.1) of the
'y4m' framework. www.freenet.org.nz/y4m

What is 'y4m'?

y4m is a python framework for manipulating yuv4mpeg video streams.

Young but growing rapidly.

It offers an intuitive Python API for:

 - opening yuv4mpeg streams for reading from stdin or a file (or
   auto-converting from any other video format ffmpeg can cope with)

 - opening yuv4mpeg streams for writing to stdout or a file (or
   autoconverting to any other video format ffmpeg can handle)

 - reading/changing stream and frame attributes

 - manipulating frames at any level - as rows/columns, or as pixels,
   or as Y,Cb,Cr planes

 - performing basic editing operations, such as:
- scaling
- cropping
- clipping (eg taking 15 secs of a stream after the first minute)
- flipping
- overlaying
- cross-fading (also known as 'dissolve')
- transparency
- polygon fill
- arbitrary rotation

 - simple keyframe interpolation

It also features a plugin architecture, whereby you can overcome the
performance penalties of python by invoking fast plugins written in C. 

The plugin interface offers a simple and powerful framework to support
writing your own plugins easily, and comes with several working example
plugins).

y4m is a toolkit you can use for writing your own yuv4mpeg stdio
filters, or even building your own video editing software.

y4m is still in alpha, but works quite well on 32-bit architecture.

(I can't guarantee it on 64-bit just yet - at least not till I've pulled
out all the remaining (sizeof)int==(sizeof)(*) assumptions.  Anyone with
64-bit architecture is welcome to try it - I'd love to hear how you get
on with it.)

All feedback, suggestions, patches, bouquets, brickbats etc welcome.

Cheers
David
-- 
http://mail.python.org/mailman/listinfo/python-list


pre-ANN: DVEdit - Video Editing the Python Way

2007-11-22 Thread DavidM
Hi fellow pythonistas,

I've put up an initial pre-alpha release of DVEdit - a highly pythonic
free/opensource framework for scripted video editing and production.

http://www.freenet.org.nz/dvedit

It's in very early stages, mainly proof of concept, but I feel pretty
happy with the core classes and concepts. Needs a lot of work to flesh out.
If there's enough interest, I'll make a Sourceforge project for it and
open it up for community participation. Contact details are on the front
page.

Cheers
David
-- 
http://mail.python.org/mailman/listinfo/python-list


weird embedding problem

2007-12-06 Thread DavidM
Hi all,

I'm embedding python in a C prog which is built as a linux shared lib.

The prog is linked against libpython, and on startup, it calls
Py_Initialize().

The prog imports a pure-python script. The script starts up ok, but when
it imports the 'math' module, the import fails with:

Traceback (most recent call last):
  File "/home/david/work/video/myprogs/dvedit/test/frei0rfx1.py", line 10, in 

import math
ImportError: /usr/lib/python2.5/lib-dynload/math.so: undefined symbol: 
PyExc_ValueError
Failed to import math

Any ideas of how to work around this?

Please note - the program I'm writing *must* be built as a shared lib, so
the usual practice of 'extend, don't embed' is just not an option here.

Thoughts?

Cheers
D
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: weird embedding problem

2007-12-07 Thread DavidM
On Fri, 07 Dec 2007 00:53:15 -0800, Graham Dumpleton wrote:

> Are you actually linking your C program against the Python library?

Yes. Refer OP:

>> I'm embedding python in a C prog which is built as a linux shared lib.
>> The prog is linked against libpython, and on startup, it calls
>> Py_Initialize().
-- 
http://mail.python.org/mailman/listinfo/python-list