def interval_succession(self): """Return Friedmann (1985) CIS, a series which indicates the order of Contour Intervals in a given CC (normal form cseg here).""" subsets = self.subsets_adj(2) return [auxiliary.interval([x[0], x[-1]]) for x in subsets]
def interval_array(self): """Return Friedmann (1985) CIA, an ordered series of numbers that indicates the multiplicity of each Contour Interval type in a given CC (normal form cseg here). For cseg < 0 1 3 2 >, there are 2 instances of type +1 CI, 2 type +2 CI, 1. CIA = ([2, 2, 1], [1, 0, 0]) 'up_intervals' and 'down_intervals' store the contour intervals that the method counts. The loop appends positive elements in ups_list and negative in downs_list. 'ups' and 'downs' stores contour intervals counting for all types of positive and negative intervals in the cseg. >>> Contour([0, 1, 3, 2]).interval_array() ([2, 2, 1], [1, 0, 0]) """ up_intervals = range(1, len(self)) down_intervals = [-x for x in up_intervals] ups_list = [] downs_list = [] for x in itertools.combinations(self, 2): y = auxiliary.interval(x) if y > 0: ups_list.append(y) elif y < 0: downs_list.append(y) ups = [ups_list.count(x) for x in up_intervals] downs = [downs_list.count(x) for x in down_intervals] return ups, downs
def test_interval(self): self.assertEqual(auxiliary.interval([4, 0]), -4)