def test_creates_table_with_given_domain_and_row_filter(self):
a, c, m = column_sizes(self.table)
order = ([random.randrange(a) for _ in self.domain.attributes] +
[random.randrange(a, a + c) for _ in self.domain.class_vars] +
[random.randrange(-m + 1, 0) for _ in self.domain.metas])
random.shuffle(order)
vars = list(self.domain.variables) + list(self.domain.metas[::-1])
vars = [vars[i] for i in order]
new_domain = self.create_domain(vars, vars, vars)
new_table = data.Table.from_table(new_domain, self.table, [0])
self.assert_table_with_filter_matches(
new_table, self.table[:1], xcols=order, ycols=order, mcols=order)
new_table = data.Table.from_table(new_domain, self.table, [2, 1, 0])
self.assert_table_with_filter_matches(
new_table, self.table[2::-1], xcols=order, ycols=order, mcols=order)
After Change
def test_creates_table_with_given_domain_and_row_filter(self):
a, c, m = column_sizes(self.table)
order = (list(range(a+c)) + list(range(-m+1, 0)))
random.shuffle(order)
vars = list(self.domain.variables) + list(self.domain.metas[::-1])
atrs = [vars[order[i]] for i in range(a)]
cv = [vars[order[i]] for i in range(a, a+c)]
metas = [vars[order[i]] for i in range(a+c, a+c+m-1)]
new_domain = self.create_domain(atrs, cv, metas)
new_table = data.Table.from_table(new_domain, self.table, [0])
self.assert_table_with_filter_matches(
new_table, self.table[:1], xcols=order[:a], ycols=order[a:a+c], mcols=order[a+c:])
new_table = data.Table.from_table(new_domain, self.table, [2, 1, 0])
self.assert_table_with_filter_matches(
new_table, self.table[2::-1], xcols=order[:a], ycols=order[a:a+c], mcols=order[a+c:])