def format(self, x, y, width):
        leftGap, rightGap = determineGaps(width, self.width)

        # Hook up the two sides if self is narrower than its stated width.
        Path(x, y).h(leftGap).addTo(self)
        Path(x + leftGap + self.width, y).h(rightGap).addTo(self)
        x += leftGap

        last = len(self.items) - 1
        innerWidth = self.width - (ARC_RADIUS * 4)

        # Do the elements that curve above
        above = self.items[:self.default]
        if above:
            distanceFromY = max(
                ARC_RADIUS * 2,
                self.items[self.default].up
                    + VERTICAL_SEPARATION
                    + self.items[self.default - 1].down)
        for i, item in list(enumerate(above))[::-1]:
            Path(x, y).arc('se').up(distanceFromY - (ARC_RADIUS * 2)).arc('wn').addTo(self)
            item.format(x + (ARC_RADIUS * 2), y - distanceFromY, innerWidth)
            Path(x + (ARC_RADIUS * 2) + innerWidth, y + item.yAdvance - distanceFromY).arc('ne') \
                .down(distanceFromY + self.yAdvance - item.yAdvance - (ARC_RADIUS * 2)).arc('ws').addTo(self)
            item.addTo(self)
            distanceFromY += max(
                ARC_RADIUS,
                item.up
                    + VERTICAL_SEPARATION
                    + (self.items[1 - i].down if i > 0 else 0))

        # Do the straight-line path.
        Path(x, y).right(ARC_RADIUS * 2).addTo(self)
        self.items[self.default].format(x + (ARC_RADIUS * 2), y, innerWidth)
        Path(x + (ARC_RADIUS * 2) + innerWidth, y + self.yAdvance).right(ARC_RADIUS * 2).addTo(self)
        self.items[self.default].addTo(self)

        # Do the elements that curve below
        below = self.items[self.default + 1:]
        for i, item in enumerate(below):
            if i == 0:
                distanceFromY = max(
                    ARC_RADIUS * 2,
                    self.items[self.default].down
                        + VERTICAL_SEPARATION
                        + item.up)
            Path(x, y).arc('ne').down(distanceFromY - (ARC_RADIUS * 2)).arc('ws').addTo(self)
            item.format(x + (ARC_RADIUS * 2), y + distanceFromY, innerWidth)
            Path(x + (ARC_RADIUS * 2) + innerWidth, y + distanceFromY + item.yAdvance).arc('se') \
                .up((distanceFromY + item.yAdvance) - self.yAdvance - (ARC_RADIUS * 2)).arc('wn').addTo(self)
            item.addTo(self)
            distanceFromY += max(
                ARC_RADIUS,
                item.down
                    + VERTICAL_SEPARATION
                    + (below[i + 1].up if i+1 < len(below) else 0))
        return self
dataset/ETHPy150Open tabatkins/bikeshed/bikeshed/railroaddiagrams.py/Choice.format/swapped operands of `-`