瀏覽代碼

Refactor project structure, move sources under src/, tests under tests/
and other commands under bin/.

Harshad Sharma 8 年之前
父節點
當前提交
0e5ec1a760
共有 6 個文件被更改,包括 43 次插入152 次删除
  1. 0 25
      count-bits
  2. 0 107
      gen-performance-graph
  3. 43 20
      setup.py
  4. 0 0
      src/drs_bloom_filter.py
  5. 0 0
      src/python2x3.py
  6. 0 0
      tests/test_bloom_filter.py

+ 0 - 25
count-bits

@@ -1,25 +0,0 @@
-#!/usr/local/pypy-1.6/bin/pypy
-
-import sys
-
-total_bits = 0
-bits_set = 0
-
-while True:
-	block = sys.stdin.read(2**19)
-	if not block:
-		break
-	total_bits += len(block) * 8
-	#print('got block of length %d' % len(block))
-	for char in block:
-		byte = ord(char)
-		#print('got char %d' % byte)
-		for exponent in range(8):
-			bitmask = 2**exponent
-			#print('checking mask %d' % bitmask)
-			if byte & bitmask != 0:
-				#print('adding 1 to count')
-				bits_set += 1
-
-print('%s set, %s present, %6.2f%%' % (bits_set, total_bits, bits_set * 100.0 / total_bits))
-

+ 0 - 107
gen-performance-graph

@@ -1,107 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import anydbm
-from pychart import *
-
-def get_timing(kind):
-    database = anydbm.open('performance-numbers', 'r')
-    list_ = []
-    for key in database.keys():
-        fields = key.split()
-        #print fields[0], kind
-        if fields[0] == kind:
-            set_size = float(fields[1])
-            duration = float(database[key])
-            list_.append( ( set_size, duration ) )
-    database.close()
-    list_.sort()
-    return list_
-
-#def get_timing(filename):
-#    file_ = open(filename, 'r')
-#    list_ = []
-#    for line in file_:
-#        fields = line.split()
-#        set_size = float(fields[0])
-#        duration = float(fields[1])
-#        list_.append( ( set_size, duration ) )
-#    file_.close()
-#    return list_
-
-def get_hybrid_timing():
-    return get_timing('hybrid')
-
-def get_array_timing():
-    return get_timing('array')
-
-def get_seek_timing():
-    return get_timing('seek')
-
-def get_mmap_timing():
-    return get_timing('mmap')
-
-def desired_y_max(*list_):
-    maximum = 0.0
-    for element in list_:
-        for set_size, duration in element:
-            maximum = max(duration, maximum)
-    return maximum
-
-def main():
-    theme.get_options()
-    theme.output_format = 'pdf'
-    theme.use_color = 1
-    theme.output_file = 'performance-graph.pdf'
-    theme.default_font_size = 15
-    theme.reinitialize()
-
-    width = 800
-    height = width * 4 // 5
-    size = (width, height)
-
-    hybrid_timing_data = get_hybrid_timing()
-    print 'hybrid', hybrid_timing_data
-    array_timing_data = get_array_timing()
-    print 'array', array_timing_data
-    seek_timing_data = get_seek_timing()
-    print 'seek', seek_timing_data
-    mmap_timing_data = get_mmap_timing()
-    print 'mmap', mmap_timing_data
-
-    y_max = desired_y_max(array_timing_data, seek_timing_data, hybrid_timing_data, mmap_timing_data)
-
-    can = canvas.default_canvas()
-
-    ar = area.T(
-        size = size,
-        legend=legend.T(),
-        x_range = (1, None),
-        y_range = (0.0001, y_max + 100),
-        #x_coord = log_coord.T(),
-        #y_coord = log_coord.T(),
-        x_coord = linear_coord.T(),
-        y_coord = linear_coord.T(),
-        x_axis = axis.X(format="%g", label="Number of elements in set"),
-        y_axis = axis.Y(format="%g", label="Seconds"),
-        )
-
-    lp = line_plot.T(data=array_timing_data, label="Array")
-    ar.add_plot(lp)
-                    
-    lp = line_plot.T(data=seek_timing_data, label="Seek")
-    ar.add_plot(lp)
-                    
-    lp = line_plot.T(data=hybrid_timing_data, label="Hybrid")
-    ar.add_plot(lp)
-                    
-    lp = line_plot.T(data=mmap_timing_data, label="mmap")
-    ar.add_plot(lp)
-                    
-    ar.draw()
-
-    #can.show(ar.x_pos(4), ar.y_pos(970), "/a50{}seek")
-
-main()
-
-

+ 43 - 20
setup.py

@@ -1,16 +1,40 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+from __future__ import absolute_import
+from __future__ import print_function
+
+import io
+import re
+from glob import glob
+from os.path import basename
+from os.path import dirname
+from os.path import join
+from os.path import splitext
+
+from setuptools import find_packages
+from setuptools import setup
+
+
+def read(*names, **kwargs):
+    return io.open(
+        join(dirname(__file__), *names),
+        encoding=kwargs.get('encoding', 'utf8')
+    ).read()
+
 
 
-from setuptools import setup, find_packages
 setup(
 setup(
-    name = "drs-bloom-filter",
-    version = "1.01",
-    packages = find_packages(),
-    scripts = ['drs_bloom_filter.py', 'python2x3.py' ],
+    name="drs-bloom-filter",
+    version="1.01",
+    packages=find_packages('src'),
+    package_dir={'': 'src'},
+    py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
+    # scripts=['drs_bloom_filter.py', 'python2x3.py'],
 
 
     # metadata for upload to PyPI
     # metadata for upload to PyPI
-    author = "Daniel Richard Stromberg",
-    author_email = "strombrg@gmail.com",
+    author="Daniel Richard Stromberg",
+    author_email="strombrg@gmail.com",
     description='Pure Python Bloom Filter module',
     description='Pure Python Bloom Filter module',
-    long_description='''
+    long_description="""
 A pure python bloom filter (low storage requirement, probabilistic
 A pure python bloom filter (low storage requirement, probabilistic
 set datastructure) is provided.  It is known to work on CPython 2.x,
 set datastructure) is provided.  It is known to work on CPython 2.x,
 CPython 3.x, Pypy and Jython.
 CPython 3.x, Pypy and Jython.
@@ -20,16 +44,15 @@ Includes mmap, in-memory and disk-seek backends.
 The user specifies the desired maximum number of elements and the
 The user specifies the desired maximum number of elements and the
 desired maximum false positive probability, and the module
 desired maximum false positive probability, and the module
 calculates the rest.
 calculates the rest.
-''',
-    license = "MIT",
-    keywords = "probabilistic set datastructure",
-	 url='http://stromberg.dnsalias.org/~strombrg/drs-bloom-filter/',
-	 platforms='Cross platform',
-	 classifiers=[
-		 "Development Status :: 5 - Production/Stable",
-		 "Intended Audience :: Developers",
-		 "Programming Language :: Python :: 2",
-		 "Programming Language :: Python :: 3",
-		 ],
+""",
+    license="MIT",
+    keywords="probabilistic set datastructure",
+    url='http://stromberg.dnsalias.org/~strombrg/drs-bloom-filter/',
+    platforms='Cross platform',
+    classifiers=[
+        "Development Status :: 5 - Production/Stable",
+        "Intended Audience :: Developers",
+        "Programming Language :: Python :: 2",
+        "Programming Language :: Python :: 3",
+    ],
 )
 )
-

drs_bloom_filter.py → src/drs_bloom_filter.py


python2x3.py → src/python2x3.py


test-bloom-filter.py → tests/test_bloom_filter.py