Articles tagged with 'numpy'

Blog: Caution with numpy float32 images

There is an interesting thread on the numpy discussion group about an unexpected result of taking the mean (or sum) of a large array of 32-bit floating point numbers.  If you exceed the 32-big float precision then you will get the wrong answer on some platforms.  Takeaway: use float64 or specify the precision of the accumulator.

Here are some examples:

In [1]: d = np.ones((1000, 1000), dtype ...

Posted by aldcroft

Blog: HPC examples with Python

AstroPython reader Moritz writes:

While looking for good way to define a banded matrix in Python I stumbled on the following tutorial:

HPC Techreport: A brief introduction to Python

After the standard introduction to basic Python concepts, I quite like the way different HPC solutions are built up in the end (numpy, scipy, weave, Cython) to lead to one example implemented with very different approaches.

In the end ...

Posted by aldcroft

Blog: Installing scientific Python on Ubuntu

Adam Klien wrote a detailed description of setting up a cutting-edge scientific Python environment on a fresh install of Ubuntu 11.10.  This shows all the steps and mostly installs the latest releases or dev versions from source.  It also demonstrates the great idea of using virtualenv to "isolate the Python distro from the carnage" in case something goes wrong or you change your mind.

Posted by aldcroft

Tutorial: Python Scientific Lecture Notes

Teaching material on the scientific Python ecosystem, a quick introduction to central tools and techniques. The different chapters each correspond to a 1 to 2 hours course with increasing level of expertise, from beginner to expert.

http://scipy-lectures.github.com/

1. Getting started with Python for science
1.1. Scientific computing with tools and workflow
1.2. The Python language
1.3. NumPy: creating and manipulating numerical data ...

Posted by aldcroft

Blog: High Performance Python tutorial v0.2 (from EuroPython 2011)

Ian Ozsvald has released an excellent High Performance Python tutorial (55 page PDF) which walks through different ways of making Python code run much faster.  Read more in the original blog post, look at the source on github, or watch the slides.

Topics covered:

  • Python profiling (cProfile, RunSnake, line_profiler) – find bottlenecks
  • PyPy – Python’s new Just In Time compiler, a note on the new numpy module
  • Cython ...

Posted by aldcroft