def test_new_args_num(self): series = Series('1', '2', '3') self.assertEquals(series.keys(), ['_1', '_2', '_3']) self.assertEquals(series._1, []) self.assertEquals(series._2, []) self.assertEquals(series._3, []) self.assertEquals(series.values(), [])
def test_clear_series(self): values = [[0, 'yhoo', 23.0], [1, 'goog', 200]] series = Series('bar', 'symbol', 'close') series.from_values(values) self.assertEquals(len(series), 2) series.clear() self.assertEquals(len(series), 0)
def test_lol_single(self): values = [[0, 'yhoo', 23.0]] series = Series('0', '1', '2') series.from_values(values) self.assertEquals(series._0, [0]) self.assertEquals(series._1, ['yhoo']) self.assertEquals(series._2, [23.0]) self.assertEquals(len(series), 1)
def test_lol_multi(self): series = Series('0', '1', '2') values = [[0, 'yhoo', 23.0], [1, 'goog', 200]] series.from_values(values) self.assertEquals(series._0, [0, 1]) self.assertEquals(series._1, ['yhoo', 'goog']) self.assertEquals(series._2, [23.0, 200]) self.assertEquals(len(series), 2)
def test_appendcol_valuesbad(self): values = [dict(bar=0, symbol='yhoo', close=23.0)] series = Series('bar', 'symbol', 'close') series.from_values(values) values = dict(bar=1, symbol='goog', close=200) series.append(values) self.assertRaises(ValueError, series.appendcol, 'open', [22.0])
def test_lol_kwargs_all(self): series = Series('bar', 'symbol', 'close') values = [[0, 'yhoo', 23.0], [1, 'goog', 200]] series.from_values(values, 'bar', 'symbol') self.assertEquals(series.bar, [0, 1]) self.assertEquals(series.symbol, ['yhoo', 'goog']) self.assertEquals(series.close, [None, None]) self.assertEquals(len(series), 2)
def test_lod_single(self): values = [dict(bar=0, symbol='yhoo', close=23.0)] series = Series('bar', 'symbol', 'close') series.from_values(values) self.assertEquals(series.keys(), ['bar', 'symbol', 'close']) self.assertEquals(series.bar, [0]) self.assertEquals(series.symbol, ['yhoo']) self.assertEquals(series.close, [23.0]) self.assertEquals(len(series), 1)
def test_lol_args_extra(self): series = Series('bar', 'symbol', 'close', 'open') values = [[0, 'yhoo', 23.0], [1, 'goog', 200]] series.from_values(values) self.assertEquals(series.bar, [0, 1]) self.assertEquals(series.symbol, ['yhoo', 'goog']) self.assertEquals(series.close, [23.0, 200]) self.assertEquals(series.open, [None, None]) self.assertEquals(len(series), 2)
def test_index_access(self): values = [dict(bar=0, symbol='yhoo', close=23.0)] series = Series('bar', 'symbol', 'close') series.from_values(values) values = dict(bar=1, symbol='goog', close=200) series.append(values) self.assertEquals(series[0], (0, 'yhoo', 23.0)) self.assertEquals(series[1], (1, 'goog', 200)) self.assertEquals(len(series), 2)
def test_sort_descending(self): series = Series('bar', 'symbol', 'close') values = [[0, 'yhoo', 23.0], [1, 'goog', 200]] series.from_values(values) series.sort('close', order='d') self.assertEquals(series.bar, [1, 0]) self.assertEquals(series.symbol, ['goog', 'yhoo']) self.assertEquals(series.close, [200, 23.0]) self.assertEquals(len(series), 2)
def test_append_dict_args_none(self): values = [dict(bar=0, symbol='yhoo', close=23.0)] series = Series('bar', 'symbol', 'close') series.from_values(values) series.append(dict(bar=1, symbol='goog', close=200)) self.assertEquals(series.bar, [0, 1]) self.assertEquals(series.symbol, ['yhoo', 'goog']) self.assertEquals(series.close, [23.0, 200]) self.assertEquals(len(series), 2)
def test_append_list_args_none(self): values = [[0, 'yhoo', 23.0]] series = Series('bar', 'symbol', 'close') series.from_values(values) series.append([1, 'goog', 200]) self.assertEquals(series.bar, [0, 1]) self.assertEquals(series.symbol, ['yhoo', 'goog']) self.assertEquals(series.close, [23.0, 200]) self.assertEquals(len(series), 2)
def test_lod_kwargs(self): values = [dict(bar=0, symbol='yhoo', close=23.0)] values.append(dict(bar=1, symbol='goog', close=200)) series = Series('bar', 'symbol', 'close') series.from_values(values, bar='bar', close='close') self.assertEquals(series.keys(), ['bar', 'symbol', 'close']) self.assertEquals(series.bar, [0, 1]) self.assertEquals(series.symbol, [None, None]) self.assertEquals(series.close, [23.0, 200]) self.assertEquals(len(series), 2)
def test_append_generator(self): values = [[0, 'yhoo', 23.0], [1, 'goog', 200]] newvalues = (x for x in values) series = Series('bar', 'symbol', 'close') series.from_values(values) self.assertEquals(series.keys(), ['bar', 'symbol', 'close']) self.assertEquals(series[0], (0, 'yhoo', 23.0)) self.assertEquals(series[1], (1, 'goog', 200)) self.assertEquals(len(series), 2)
def test_iter(self): values = [dict(bar=0, symbol='yhoo', close=23.0)] series = Series('bar', 'symbol', 'close') series.from_values(values) values = dict(bar=1, symbol='goog', close=200) series.append(values) results = [] for bar in series: results.append(bar) self.assertEquals(results, [0, 1])
def test_initcol_existing_0(self): values = [dict(bar=0, symbol='yhoo', close=23.0)] series = Series('bar', 'symbol', 'close') series.from_values(values) values = dict(bar=1, symbol='goog', close=200) series.append(values) series.initcol('close', 0.0) self.assertEquals(series.keys(), ['bar', 'symbol', 'close']) self.assertEquals(series[0], (0, 'yhoo', 0.0)) self.assertEquals(series[1], (1, 'goog', 0.0)) self.assertEquals(len(series), 2)
def test_appendcol_values(self): values = [dict(bar=0, symbol='yhoo', close=23.0)] series = Series('bar', 'symbol', 'close') series.from_values(values) values = dict(bar=1, symbol='goog', close=200) series.append(values) series.appendcol('open', [22.0, 21.0]) self.assertEquals(series.keys(), ['bar', 'symbol', 'close', 'open']) self.assertEquals(series[0], (0, 'yhoo', 23.0, 22.0)) self.assertEquals(series[1], (1, 'goog', 200, 21.0)) self.assertEquals(len(series), 2)
def test_format_int(self): values = [[0, 'yhoo', 23.0], [1, 'goog', 200]] series = Series('bar', 'symbol', 'close') series.from_values(values) series.format('close', int) self.assertEquals(series.close, [23, 200])
def test_format_str(self): values = [[0, 'yhoo', 23.0], [1, 'goog', 200]] series = Series('bar', 'symbol', 'close') series.from_values(values) series.format('close', str) self.assertEquals(series.close, ['23.0', '200'])
parser.add_argument( '--tree-branch', default='master', help='the branch or commit to use as a base for applying patches') parser.add_argument('--result-dir', default=results_dir, help='the directory where results will be generated') args = parser.parse_args() args.mdir = os.path.abspath(args.mdir) args.tree = os.path.abspath(args.tree) core.log_open_sec("Loading patches") try: files = [os.path.join(args.mdir, f) for f in sorted(os.listdir(args.mdir))] series = Series() for f in files: with open(f, 'r') as fp: data = fp.read() if re.search(r"\[.* 0+/\d.*\]", data) and \ not re.search(r"\n@@ -\d", data): series.set_cover_letter(data) else: series.add_patch(Patch(data)) finally: core.log_end_sec() tree = Tree(args.tree_name, args.tree_name, args.tree, branch=args.tree_branch) tester = Tester(args.result_dir)
def test_new_args(self): series = Series('row1', 'row2', 'row3') self.assertEquals(series.keys(), ['row1', 'row2', 'row3']) self.assertEquals(series.values(), [])