Code Search for Developers
 
 
  

erathostenes_skel.py from matplotlib at Krugle


Show erathostenes_skel.py syntax highlighted

#!/usr/bin/env python
"""Simple example implementations of the Sieve of Erathostenes."""

import sys
import math

import numpy as N

def sieve(nmax):
    """Return a list of prime numbers up to nmax, using Erathostenes' sieve."""

    raise NotImplementedError

if __name__ == '__main__':
    # A simple test suite.
    import unittest

    # Make the generic test NOT be a subclass of unittest.TestCase, so that it
    # doesn't get picked up automatically.  Each subclass will specify an
    # actual sieve function to test.
    class sieveTestBase:

        def test2(self):
            self.assert_(self.sieve_func(2)==[2])

        def test100(self):
            primes100 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
                         43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
            self.assert_(self.sieve_func(100)==primes100)

    # These subclasses define the actual sieve function to test.  Note that it
    # must be set as a staticmethod, so that the 'self' instance is NOT passed
    # to the called sieve as first argument.
    class sieveTestCase(sieveTestBase,unittest.TestCase):
        sieve_func = staticmethod(sieve)

        
    # This must be called LAST, because no code after it will be seen.
    unittest.main()




See more files for this project here

matplotlib

Matplotlib is a pure python plotting library with the goal of making\r\npublication quality plots using a syntax familiar to matlab users. \r\nThe library uses Numeric for handling large\r\ndata sets and supports a variety of output backends

Project homepage: http://sourceforge.net/projects/matplotlib
Programming language(s): C,C++,Python
License: other

  faces/
    faces_skel0.tgz
    fmatch_skel1.py
  fortran_wrap/
    Makefile
    fib3.f
    test.py
  distributions_skel.py
  erathostenes_skel.py
  fft_imdenoise_skel.py
  fit_synapse_skel.py
  fitting_skel.py
  montecarlo_pi_skel.py
  polyroots1d_skel.py
  qsort_skel.py
  quad_newton_skel.py
  recarray_demo_skel.py
  regress_demo_skel.py
  scrape_key_stats_skel.py
  shoot_skel.py
  spline_demo_skel.py
  stats_descriptives_skel.py
  stats_distributions_skel.py
  trapezoid_skel.py
  wallis_pi_skel.py
  wordfreqs_skel.py