<s> from __future__ import absolute_import , division , print_function <EOL> import pandas as pd <EOL> import numpy as np <EOL> from . core import tokenize , DataFrame <EOL> from . . utils import different_seeds <EOL> __all__ = [ '<STR_LIT>' ] <EOL> def make_float ( n , rstate ) : <EOL> return rstate . rand ( n ) * <NUM_LIT:2> - <NUM_LIT:1> <EOL> def make_int ( n , rstate ) : <EOL> return rstate . poisson ( <NUM_LIT:1000> , size = n ) <EOL> names = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def make_string ( n , rstate ) : <EOL> return rstate . choice ( names , size = n ) <EOL> def make_categorical ( n , rstate ) : <EOL> return pd . Categorical . from_codes ( rstate . randint ( <NUM_LIT:0> , len ( names ) , size = n ) , <EOL> names ) <EOL> make = { float : make_float , <EOL> int : make_int , <EOL> str : make_string , <EOL> object : make_string , <EOL> '<STR_LIT>' : make_categorical } <EOL> def make_timeseries_part ( start , end , dtypes , freq , seed ) : <EOL> index = pd . DatetimeIndex ( start = start , end = end , freq = freq ) <EOL> state = np . random . RandomState ( seed ) <EOL> columns = dict ( ( k , make [ dt ] ( len ( index ) , state ) ) for k , dt in dtypes . items ( ) ) <EOL> df = pd . DataFrame ( columns , index = index , columns = sorted ( columns ) ) <EOL> if df . index [ - <NUM_LIT:1> ] == end : <EOL> df = df . iloc [ : - <NUM_LIT:1> ] <EOL> return df <EOL> def make_timeseries ( start , end , dtypes , freq , partition_freq , seed = None ) : <EOL> """<STR_LIT>""" <EOL> divisions = list ( pd . DatetimeIndex ( start = start , end = end , <EOL> freq = partition_freq ) ) <EOL> state = np . random . RandomState ( seed ) <EOL> seeds = different_seeds ( len ( divisions ) , state ) <EOL> name = '<STR_LIT>' + tokenize ( start , end , dtypes , freq , partition_freq ) <EOL> dsk = dict ( ( ( name , i ) , ( make_timeseries_part , divisions [ i ] , divisions [ i + <NUM_LIT:1> ] , <EOL> dtypes , freq , seeds [ i ] ) ) <EOL> for i in range ( len ( divisions ) - <NUM_LIT:1> ) ) <EOL> head = make_timeseries_part ( '<STR_LIT>' , '<STR_LIT>' , dtypes , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> return DataFrame ( dsk , name , head , divisions ) </s>
