<s> from random import randrange as rr <EOL> from random import choice <EOL> from string import ascii_uppercase <EOL> from faker import Factory <EOL> faker = Factory . create ( ) <EOL> def random_node ( vals , nums , max_edges ) : <EOL> return { <EOL> '<STR_LIT>' : [ choice ( nums ) for _ in range ( rr ( <NUM_LIT:0> , max_edges ) ) ] , <EOL> '<STR_LIT>' : choice ( vals ) <EOL> } <EOL> def random_graph ( max_edges = <NUM_LIT:10> ) : <EOL> letters = [ choice ( ascii_uppercase ) for _ in range ( max_edges ) ] <EOL> dag = { } <EOL> nums = range ( max_edges ) <EOL> for k , letter in enumerate ( letters ) : <EOL> dag [ k ] = random_node ( letter , nums , max_edges ) <EOL> return dag <EOL> def random_person ( ) : <EOL> return { <EOL> '<STR_LIT:name>' : faker . name ( ) , <EOL> '<STR_LIT:email>' : faker . email ( ) , <EOL> '<STR_LIT:address>' : faker . address ( ) , <EOL> '<STR_LIT:url>' : faker . url ( ) <EOL> } <EOL> def random_person_full ( ) : <EOL> return { <EOL> '<STR_LIT>' : faker . first_name ( ) , <EOL> '<STR_LIT>' : faker . last_name ( ) , <EOL> '<STR_LIT:email>' : faker . email ( ) , <EOL> '<STR_LIT:address>' : faker . address ( ) , <EOL> '<STR_LIT:url>' : faker . url ( ) <EOL> } <EOL> def subnet_mask ( ) : <EOL> op1 = '<STR_LIT>' <EOL> op2 = '<STR_LIT>' <EOL> op3 = '<STR_LIT>' . format ( <EOL> choice ( range ( <NUM_LIT:1> , <NUM_LIT:2> ) ) , choice ( range ( <NUM_LIT:0> , <NUM_LIT:9> ) ) , choice ( range ( <NUM_LIT:0> , <NUM_LIT:9> ) ) ) <EOL> return choice ( [ op1 , op2 , op3 ] ) <EOL> def random_dna ( max = <NUM_LIT:4> ) : <EOL> """<STR_LIT>""" <EOL> dna = '<STR_LIT>' <EOL> acids = [ '<STR_LIT:T>' , '<STR_LIT>' , '<STR_LIT:A>' , '<STR_LIT:C>' ] <EOL> for x in range ( max ) : <EOL> dna += choice ( acids ) <EOL> return dna <EOL> def random_inverse_binary_matrix ( ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if kwargs is None : <EOL> kwargs = { } <EOL> kwargs . update ( { '<STR_LIT>' : [ <NUM_LIT:0> , <NUM_LIT:1> , - <NUM_LIT:1> ] } ) <EOL> return random_matrix ( ** kwargs ) <EOL> def random_binary_matrix ( ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if kwargs is None : <EOL> kwargs = { } <EOL> kwargs . update ( { '<STR_LIT>' : [ <NUM_LIT:0> , <NUM_LIT:1> ] } ) <EOL> return random_matrix ( ** kwargs ) <EOL> def random_matrix ( rows = <NUM_LIT:4> , columns = <NUM_LIT:4> , min = <NUM_LIT:1> , max = <NUM_LIT:100> , choices = None ) : <EOL> """<STR_LIT>""" <EOL> matrix = [ ] <EOL> for row in range ( rows ) : <EOL> _row = [ ] <EOL> for _ in range ( columns ) : <EOL> if choices is not None : <EOL> _row . append ( choice ( choices ) ) <EOL> else : <EOL> _row . append ( rr ( min , max ) ) <EOL> matrix . append ( _row ) <EOL> return matrix <EOL> def random_uniform_matrix ( size , ** kwargs ) : <EOL> return random_matrix ( rows = size , columns = size , ** kwargs ) <EOL> def make_sparselist ( vals , total , filler = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if len ( vals . keys ( ) ) > <NUM_LIT:0> : <EOL> if total < max ( vals . keys ( ) ) : <EOL> raise ValueError ( <EOL> '<STR_LIT>' ) <EOL> _sparselist = [ filler for _ in range ( total ) ] <EOL> for index , value in vals . iteritems ( ) : <EOL> _sparselist [ index ] = value <EOL> return _sparselist <EOL> def make_sparsematrix ( vals , total , rows = <NUM_LIT:4> , cols = <NUM_LIT:4> ) : <EOL> _sparsematrix = [ ] <EOL> for col in range ( cols ) : <EOL> _sparsematrix . append ( make_sparselist ( { } , cols ) ) <EOL> for coords , data in vals . iteritems ( ) : <EOL> row , col = coords <EOL> _sparsematrix [ row ] [ col ] = data <EOL> return _sparsematrix </s>
