¡@

Home 

python Programming Glossary: assert

How can I profile a SQLAlchemy powered application?

http://stackoverflow.com/questions/1171166/how-can-i-profile-a-sqlalchemy-powered-application

aaa_profiling . There we have tests using decorators that assert a maximum number of method calls being used for particular operations..

Using property() on classmethods

http://stackoverflow.com/questions/128573/using-property-on-classmethods

setvar classmethod setvar var ClassProperty getvar setvar assert foo.getvar 5 foo.setvar 4 assert foo.getvar 4 assert foo.var.. getvar setvar assert foo.getvar 5 foo.setvar 4 assert foo.getvar 4 assert foo.var 4 foo.var 3 assert foo.var 3 However.. assert foo.getvar 5 foo.setvar 4 assert foo.getvar 4 assert foo.var 4 foo.var 3 assert foo.var 3 However the setters don't..

Fastest way to list all primes below N in python

http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python

p 83 # Info http en.wikipedia.org wiki Sieve_of_Atkin assert end 0 lng end 1 2 sieve False lng 1 x_max x2 xd int sqrt end.. n in python 3035188#3035188 Returns a array of primes p n assert n 2 sieve np.ones n 2 dtype np.bool for i in xrange 3 int n..

when does Python allocate new memory for identical strings?

http://stackoverflow.com/questions/2123925/when-does-python-allocate-new-memory-for-identical-strings

joinsplit n .join names .split # same as file mem again assert joinsplit names print d strings from a file s N nid joinsplit..

Inverse Distance Weighted (IDW) Interpolation with Python

http://stackoverflow.com/questions/3104781/inverse-distance-weighted-idw-interpolation-with-python

ndim 1 2 ndim def __init__ self X z leafsize 10 stat 0 assert len X len z len X d len z d len X len z self.tree KDTree X leafsize..

How to send Email Attachments with python

http://stackoverflow.com/questions/3362600/how-to-send-email-attachments-with-python

send_from send_to subject text files server localhost assert type send_to list assert type files list msg MIMEMultipart msg.. text files server localhost assert type send_to list assert type files list msg MIMEMultipart msg 'From' send_from msg 'To'..

How do I sort a list of strings in Python?

http://stackoverflow.com/questions/36139/how-do-i-sort-a-list-of-strings-in-python

'en_US.UTF 8' # vary depending on your lang locale assert sorted u'Ab' u'ad' u'aa' key cmp_to_key locale.strcoll u'aa'..

A weighted version of random.choice

http://stackoverflow.com/questions/3679694/a-weighted-version-of-random-choice

Increment a python floating point value by the smallest possible amount

http://stackoverflow.com/questions/6063755/increment-a-python-floating-point-value-by-the-smallest-possible-amount

after x in the direction of y. return _nextafter x y assert nextafter 0 1 nextafter 0 1 0 assert 0.0 nextafter 0 1 0.0 And.. return _nextafter x y assert nextafter 0 1 nextafter 0 1 0 assert 0.0 nextafter 0 1 0.0 And if you really really want a pure Python..

Creating a singleton in python

http://stackoverflow.com/questions/6760685/creating-a-singleton-in-python

should still inject your logger if you want your test to assert that something is getting logged but in general Loggers are..

Use numpy array in shared memory for multiprocessing

http://stackoverflow.com/questions/7894791/use-numpy-array-in-shared-memory-for-multiprocessing

# many processes access different slices of the same array assert M 2 # odd step N 10 p.map_async g slice i i step for i in range.. g slice i i step for i in range stop_f N step p.join assert np.allclose 1 M tonumpyarray shared_arr arr_orig def init shared_arr_..