# Path: pyDEA/core/utils/dea_utils.py
# def calculate_nb_pages(nb_data_rows, nb_table_rows):
#     ''' Calculates number of pages given number of data rows and number of rows
#         in the table.
# 
#         Note:
#             first row is reserved for categories.
# 
#         Args:
#             nb_data_rows (int): number of data rows.
# 
#                 Warning:
#                     It must be a positive number. Otherwise the function
#                     will return incorrect value.
# 
#             nb_table_rows (int): number of rows in the table.
# 
#                 Warning:
#                     It must be a positive number. Otherwise the function
#                     will return incorrect value.
# 
#         Returns:
#             int: number of pages
# 
#         Example:
#             >>> calculate_nb_pages(100, 10)
#             >>> 12
#             >>> calculate_nb_pages(25, 20)
#             >>> 2
#             >>> calculate_nb_pages(0, 20)
#             >>> 1
#             >>> calculate_nb_pages(10, 25):
#             >>> 1
# 
#     '''
#     if nb_table_rows:
#         base = int(nb_data_rows / (nb_table_rows - 1))
#         if nb_data_rows % (nb_table_rows - 1) != 0:
#             base += 1
#         return max(base, 1)
#     return 0
# 
# def calculate_start_row_index(curr_page, nb_table_rows):
#     ''' Calculates row index of data that will be displayed given
#         current page and number of rows in the table.
# 
#         Note:
#             The first row of the table is reserved for displaying categories.
# 
#         Args:
#             curr_page (int): current page number. Pages start from 1.
#             nb_table_rows (int): number of rows in the table.
# 
#         Returns:
#             int: data row index
#     '''
#     if (curr_page == 0):
#         return 0
#     return (curr_page - 1) * (nb_table_rows - 1)


from tkinter import E, N, W, Spinbox, StringVar
from tkinter.ttk import Frame, Button
from pyDEA.core.utils.dea_utils import calculate_nb_pages, calculate_start_row_index
        except ValueError:
            nb_values = 1
        str_var.set(nb_values)
        return nb_values

    def remove_rows(self):
        ''' Removes rows that are checked in checkboxes for removal.
            First row cannot be removed.
        '''
        if self.table.nb_rows > 0:
            row_index = 1
            prev_nb_rows = self.table.nb_rows
            while row_index < self.table.nb_rows:
                box, var = self.table.row_checkboxes[row_index]
                if var is not None and var.get() == 1:
                    if self.table.remove_row(row_index) is False:
                        row_index += 1
                else:
                    row_index += 1

            # when rows are removed number of pages to display data might change
            if len(self.table.cells) > 1:
                start_row = self.table.cells[1][0].data_row
                if start_row != -1:
                    nb_pages = calculate_nb_pages(len(self.table.data),
                                                  self.table.nb_rows)
                    self.set_navigation(nb_pages, False)
                    # + 2 for index and first row is for categories
                    page_number = calculate_nb_pages(start_row + 2,
                                                  self.table.nb_rows)

# Path: pyDEA/core/utils/dea_utils.py
# def calculate_nb_pages(nb_data_rows, nb_table_rows):
#     ''' Calculates number of pages given number of data rows and number of rows
#         in the table.
# 
#         Note:
#             first row is reserved for categories.
# 
#         Args:
#             nb_data_rows (int): number of data rows.
# 
#                 Warning:
#                     It must be a positive number. Otherwise the function
#                     will return incorrect value.
# 
#             nb_table_rows (int): number of rows in the table.
# 
#                 Warning:
#                     It must be a positive number. Otherwise the function
#                     will return incorrect value.
# 
#         Returns:
#             int: number of pages
# 
#         Example:
#             >>> calculate_nb_pages(100, 10)
#             >>> 12
#             >>> calculate_nb_pages(25, 20)
#             >>> 2
#             >>> calculate_nb_pages(0, 20)
#             >>> 1
#             >>> calculate_nb_pages(10, 25):
#             >>> 1
# 
#     '''
#     if nb_table_rows:
#         base = int(nb_data_rows / (nb_table_rows - 1))
#         if nb_data_rows % (nb_table_rows - 1) != 0:
#             base += 1
#         return max(base, 1)
#     return 0
# 
# def calculate_start_row_index(curr_page, nb_table_rows):
#     ''' Calculates row index of data that will be displayed given
#         current page and number of rows in the table.
# 
#         Note:
#             The first row of the table is reserved for displaying categories.
# 
#         Args:
#             curr_page (int): current page number. Pages start from 1.
#             nb_table_rows (int): number of rows in the table.
# 
#         Returns:
#             int: data row index
#     '''
#     if (curr_page == 0):
#         return 0
#     return (curr_page - 1) * (nb_table_rows - 1)


# Path: pyDEA/core/gui_modules/table_modifier_gui.py
from tkinter import E, N, W, Spinbox, StringVar
from tkinter.ttk import Frame, Button
from pyDEA.core.utils.dea_utils import calculate_nb_pages, calculate_start_row_index

        except ValueError:
            nb_values = 1
        str_var.set(nb_values)
        return nb_values

    def remove_rows(self):
        ''' Removes rows that are checked in checkboxes for removal.
            First row cannot be removed.
        '''
        if self.table.nb_rows > 0:
            row_index = 1
            prev_nb_rows = self.table.nb_rows
            while row_index < self.table.nb_rows:
                box, var = self.table.row_checkboxes[row_index]
                if var is not None and var.get() == 1:
                    if self.table.remove_row(row_index) is False:
                        row_index += 1
                else:
                    row_index += 1

            # when rows are removed number of pages to display data might change
            if len(self.table.cells) > 1:
                start_row = self.table.cells[1][0].data_row
                if start_row != -1:
                    nb_pages = calculate_nb_pages(len(self.table.data),
                                                  self.table.nb_rows)
                    self.set_navigation(nb_pages, False)
                    # + 2 for index and first row is for categories
                    page_number = calculate_nb_pages(start_row + 2,
                                                  self.table.nb_rows)

                    new_start_row = calculate_start_row_index(