def test_get_start_index_error_raised2(): """ Test discerner.get_start_index for case where an error is raised by get_start_index function """ data = [0, 1, 2, NARealType()] get_start_index(data, 3)
def test_get_start_index(): """ Test discerner.get_start_index for success cases """ data = [0, 1, 2, 3, 4, 5] start = get_start_index(data, 3) eq_(data[start], 4) data = [0, 1, 2, NARealType(), 4] start = get_start_index(data, 2) eq_(data[start], 4)
def test_get_start_index_with_negative_indexing(): """ Test discerner.cruncher.get_start_index with negative indexing """ data = range(15) start = get_start_index(data, 14, index=-13) eq_(start, 1)
def get_pre_and_post_returns(args, day, prices): """ Append pre and post return data """ try: pre_start = cruncher.get_end_index( prices, day, index=-1 * args.interval ) pre_end = cruncher.get_end_index( prices, pre_start, index=args.interval - 1 ) post_start = cruncher.get_start_index(prices, day, index=1) post_end = cruncher.get_end_index( prices, post_start, index=args.interval - 1 ) except SkipEvaluationError: logger.debug( "The day {} does not support being evaluated".format(day) ) else: logger.debug("Appending to returns") pre_rets.append( (prices[pre_end] - prices[pre_start]) / prices[pre_start] ) post_rets.append( (prices[post_end] - prices[post_start]) / prices[post_start] )