How to read Matlab files with Python and SciPy can be read here. Short:
import scipy.io
data = scipy.io.loadmat('test.mat')
This will create a dictionary called data containing all the variables of the Matlab file.
A collection of coding snippets, tips, hints and random thoughts.
How to read Matlab files with Python and SciPy can be read here. Short:
import scipy.io
data = scipy.io.loadmat('test.mat')
This will create a dictionary called data containing all the variables of the Matlab file.
The guys over at jabber.org are moving servers, and upgrading their software. However, it does not seem to work well. They mention the need to adjust settings for iChat and Kopete. However my IM+ does not work anymore either, Licq’s pre-alpha jabber Plugin also crashes (however erijo seems to be working on a fix), and Adium also chokes, and will connect only every couple of hours. It seems they should have done a bit more testing before!
I am currently trying out Apple’s Mobile Me service, which is free in the first two months. It seems relatively nice, but has some drawbacks. On the plus side, you get 20 GB of storage space, or 40 GB for the family pack. Also you can track your iPhone if you lose it. The mail service is useful, but on the downside: It does not support server side filtering! That’s a great, great bummer. Also it does not seem to support Apple’s notion of filtering, called “intelligent mailboxes”. If that were supported on the server, I would ditch my GMX ProMail account, and switch to using Mobile Me for mail services.
In Python I sometimes want to make a dictionary of lists. So usually I would write something like:
mydic = {}
for something in somethingelse:
mydic[somekey].append(something)
This however will not work, if somekey did not exist so far, because it will raise an exception. But there is help! You can use a collection:
import collections
mydic = collections.defaultdic(list)
for something in somethingelse:
mydic[somekey].append(something)
Here is a minimal example for PyQt4, to set up a main window and connect a simple action to some slot. The documentation on doing this is sparse to say the least. So I hope this is helpful for anyone trying something similar. I assume that you have created a ui_MainWindow.ui file with Qt Designer, which contains a form derived from QMainWindow.
import sys
from PyQt4 import QtCore, QtGui, uic
class MyMainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.ui = uic.loadUi("ui_MainWindow.ui", self)
self.connect(self.ui.actionOpen, QtCore.SIGNAL('triggered()'), self, QtCore.SLOT('open()'))
@QtCore.pyqtSlot()
def open(self):
fileDialog = QtGui.QFileDialog(self, "Open file")
fileDialog.show()
app = QtGui.QApplication(sys.argv)
mainWindow = MyMainWindow()
mainWindow.show()
sys.exit(app.exec_())
I really don’t get happy with Qt 4.6 on OS X 10.6. Nokia rates Qt on that platform as Tier 2. Which means, it is not fully supported. This results in stupid things happening. With Licq, I currently have the problem that the whole program crashes with the following message:
Good news: The Qt port of MacPorts is working again. The port was upgraded to Qt 4.6 and now it compiles again. Now all I need is a 64 bit CUDA package for Snow Leopard, and I’ll be happy.
This allows you to convert any preprocessor macro value to a string, e.g. for printing.
#include <iostream>
#define MEINMAKRO 1.3.4
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
int main()
{
std::cout << TOSTRING(MEINMAKRO) << std::endl;
return 0;
}
I am using the try-out version of Mobile Me for the iPhone. Syncing the device with the Macbook Pro. Whenever I go to my address book, all the contacts appear twice. Very strange, I though, until I noticed that I was in the Group “All contacts”, which will show the contacts synced from the Mac and from Mobile Me. What a stupid way to present things. Right now, I just need to switch to “All contacts from my Mac” to fix this, but when I were to add another address book (say a corporate one or the Google one), I would be in trouble. Not very clever, Apple…