def calc(self, num_windows, width, height):
        """returns (rows, cols, orientation) tuple given input"""
        best_ratio = None
        best_rows_cols_orientation = None
        for rows, cols, orientation in self._possible_grids(num_windows):
            sample_width = width / cols
            sample_height = height / rows
            sample_ratio = sample_width / sample_height
            diff = abs(sample_ratio - self.ratio)
            if best_ratio is None or diff < best_ratio:
                best_ratio = diff
                best_rows_cols_orientation = (rows, cols, orientation)

        return best_rows_cols_orientation
returns (rows, cols, orientation) tuple given input
libqtile/layout/ratiotile.py