jeffswt / pydatagen Goto Github PK
View Code? Open in Web Editor NEWCreate random data easier with pydatagen.
License: GNU Lesser General Public License v3.0
Create random data easier with pydatagen.
License: GNU Lesser General Public License v3.0
Now print_oi
directly sends the data to stdout. It would be nice if one could get the formatted string instead.
by the way,
>>> random.sample([1,2,3,4,5], 3)
[3, 4, 1]
the attributes are shared across instances in classmethods, causing unexpected bug.
for example,
>>> class Test:
... @classmethod
... def __init__(cls,x):
... cls.x=x
...
>>> a=Test(1)
>>> a.x
1
>>> b=Test(2)
>>> a.x
2
>>>
def possibility(rate):
return random.random()>rate
try this:
f=open('1.txt','w')
from contextlib import redirect_stdout
with redirect_stdout(f):
print('hello world')
or
f=open('1.txt','w')
print('hello world', file=f)
Using master
Python 3.4.3 (default, Jun 29 2015, 12:16:01)
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pydatagen import *
>>> def test():
... try:
... Graph(6, 12, connected=True, weighed=True, weight_range=range(10, 99))
... return True
... except:
... return False
...
>>> results = [test() for _ in range(20000)]
>>> results.count(True) / len(results)
0.18835
queue
is designed for multithreading uses and acquire a lock in every method call. in a word, it's really slow.
just use list instead. it's much (about 50x) faster.
>>> import timeit
>>> timeit.timeit('q.put(123)', 'import queue; q=queue.Queue()', number=10**6)
24.48412793993996
>>> timeit.timeit('q.append(123)', 'q=[]', number=10**6)
0.5576901608900329
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.