def getShapeOfKey(key): ch = db.getChunkstore() data = db.getLatestRow(ch, key) data[key] = data[key].apply( db.decodeObject) #decode it because we encode numpy arrays val = data[key].values[-1] #get the latest item return val.shape
def test_labels(): lib = db.getChunkstore() #get the whole history of the course course = db.loadData(lib, db.dbKeys['tick'], None, None, False) filename = "data/dataset_test.pickle" start = None end = None #generate a sample dataset ds.run("matrix", "openPrice,closePrice,gasPrice", start, end, filename, "boolean", '1', False) sleep(1) #delay between saving and reading with open(filename, 'rb') as f: res = pickle.load(f) #load the result i = 0 indices = course.index.values for j, date in enumerate(res['dates']): # i = course.index[course['date'] == date] #while course.get_value(indices[i], 'date') != date: # i+=1 currPrice = course.get_value(i[0], 'close') nextPrice = course.get_value(i[0] + 1, 'close') #print("Checking prices %s %s with value of label %s" % (currPrice, nextPrice, res['labels'][j])) if res['labels'][j] != (nextPrice > currPrice): print( "Debug info: Date %s at course index %s (len=%s). Curr / next prices are %s and %s." % (date, i, len(course), currPrice, nextPrice)) assert False assert True
from propertyGasPrice import PropertyGasPrice from propertyGasUsed import PropertyGasUsed from propertyHighPrice import PropertyHighPrice from propertyLowPrice import PropertyLowPrice from propertyNetworkHashrate import PropertyNetworkHashrate from propertyOpenPrice import PropertyOpenPrice #from propertyQuoteVolume import PropertyQuoteVolume from propertyStickPrice import PropertyStickPrice from propertyTransactionCount import PropertyTransactionCount from propertyUniqueAccounts import PropertyUniqueAccounts #from propertyVolume import PropertyVolume from propertyVolumeFrom import PropertyVolumeFrom from propertyVolumeTo import PropertyVolumeTo #from propertyWeightedAverage import PropertyWeightedAverage chunkStore = db.getChunkstore() globalProperties = [ PropertyAccountBalanceDistribution(), PropertyBalanceLastSeenDistribution(), PropertyBlockDifficulty(), PropertyBlockSize(), PropertyClosePrice(), PropertyGasLimit(), PropertyGasPrice(), PropertyGasUsed(), PropertyHighPrice(), PropertyLowPrice(), PropertyNetworkHashrate(), PropertyOpenPrice(), PropertyStickPrice(),
default=None, help='The end date. YYYY-MM-DD-HH') args, _ = parser.parse_known_args() start = dateutil.parser.parse( args.start) if args.start is not None else None end = dateutil.parser.parse(args.end) if args.end is not None else None if args.type == 'file': with open(args.data, 'rb') as f: data = pickle.load(f) if type(data) != list: data = [data] #turn to single element list for dataset in data: values = dataset['dataset'][:, -1, args.index] dates = dataset['dates'] print(values, dates) plot(values, dates, 'Value of ' + args.data) plot(dataset['labels'], dataset['dates'], 'Correct labels') elif args.type == 'key': data = db.loadData(db.getChunkstore(), args.data, start, end, True) values = data[args.data].values dates = data['date'].values plot(values, dates, 'Value of ' + args.data)
frame = dataset['dataset'][ -1, -1, :, :] #shape is samples, layers, width, height print(frame) print(dataset['dataset'].shape) print(dataset['dates'][-1]) plotImage(frame) if args.target: plot(dataset['labels'], dataset['dates'], 'Correct labels') elif args.type == 'key': prop = args.data data = db.loadData(db.getChunkstore(), prop, start, end, True) if type( data.iloc[0][prop] ) == str: #if the property values have been encoded, decode them print("Running numpy array Arctic workaround for prop %s..." % prop) data[prop] = data[prop].apply(lambda x: db.decodeObject(x)) values = data[prop].values dates = data['date'].values if type(values[0]) != np.ndarray: plot(values, dates, 'Value of ' + prop) else: #if we are dealing with complex property, visualize it if args.renderTimelapse is not None:
def test_connection(): lib = db.getChunkstore() assert lib
def __init__(self): super().__init__() self.name = 'blockchain' self.store = db.getChunkstore() self.id_cache = None