diff --git a/pysd/builders/python/subscripts.py b/pysd/builders/python/subscripts.py index ce83b8b6..51f0b321 100644 --- a/pysd/builders/python/subscripts.py +++ b/pysd/builders/python/subscripts.py @@ -59,7 +59,7 @@ def subscripts(self, abstract_subscripts: List[AbstractSubscriptRange]): # subscript from file self._subscripts[sub.name] = ExtSubscript( file_name=sub.subscripts["file"], - sheet=sub.subscripts["tab"], + tab=sub.subscripts["tab"], firstcell=sub.subscripts["firstcell"], lastcell=sub.subscripts["lastcell"], prefix=sub.subscripts["prefix"], diff --git a/pysd/py_backend/external.py b/pysd/py_backend/external.py index 997e0532..bd64bdcb 100644 --- a/pysd/py_backend/external.py +++ b/pysd/py_backend/external.py @@ -22,23 +22,27 @@ class Excels(): _Excels, _Excels_opyxl = {}, {} @classmethod - def read(cls, file_name, sheet_name): + def read(cls, file_name, tab): """ Read the Excel file or return the previously read one """ - if file_name.joinpath(sheet_name) in cls._Excels: - return cls._Excels[file_name.joinpath(sheet_name)] + if file_name.joinpath(tab) in cls._Excels: + return cls._Excels[file_name.joinpath(tab)] else: # get the function to read the data based on its extension read_kwargs = {} ext = file_name.suffix.lower() if ext in ['.xls', '.xlsx', '.xlsm', 'xlsb', 'odf', 'ods', 'odt']: read_func = pd.read_excel - read_kwargs['sheet_name'] = sheet_name + read_kwargs['sheet_name'] = tab elif ext == '.csv': read_func = pd.read_csv + if tab and not tab[0].isalnum(): + read_kwargs['sep'] = tab else: read_func = pd.read_table + if tab and not tab[0].isalnum(): + read_kwargs['sep'] = tab # read the data excel = np.array([ pd.to_numeric(ex, errors='coerce') @@ -46,7 +50,7 @@ def read(cls, file_name, sheet_name): read_func(file_name, header=None, **read_kwargs).values ]) # save data for future retrievals - cls._Excels[file_name.joinpath(sheet_name)] = excel + cls._Excels[file_name.joinpath(tab)] = excel return excel @classmethod @@ -99,7 +103,7 @@ class External(object): def __init__(self, py_name): self.py_name = py_name self.file = None - self.sheet = None + self.tab = None def __str__(self): return self.py_name @@ -124,7 +128,7 @@ def _get_data_from_file(self, rows, cols): # read data data = Excels.read( self.file, - self.sheet)[rows[0]:rows[1], cols[0]:cols[1]].copy() + self.tab)[rows[0]:rows[1], cols[0]:cols[1]].copy() shape = data.shape @@ -167,7 +171,7 @@ def _get_data_from_file_opyxl(self, cellname): local_cellranges = None # need to lower the sheetnames as Vensim has no case sensitivity for sheet in excel.sheetnames: - if sheet.lower() == self.sheet.lower(): + if sheet.lower() == self.tab.lower(): local_cellranges = excel[sheet].defined_names break @@ -184,8 +188,8 @@ def _get_data_from_file_opyxl(self, cellname): or global_cellranges.get(cellname) sheet, cells = next(cellrange.destinations) - assert sheet.lower() == self.sheet.lower() - self.sheet = sheet # case insensitivity in sheet name + assert sheet.lower() == self.tab.lower() + self.tab = sheet # case insensitivity in sheet name # Get the cells where the cellrange is defined cells = re.split(r":|\$", cells) @@ -578,7 +582,7 @@ def _file_sheet(self): Returns file and sheet name in a string """ return "\tFile name:\t'{}'\n".format(self.file)\ - + "\tSheet name:\t'{}'\n".format(self.sheet) + + "\tSheet name:\t'{}'\n".format(self.tab) @staticmethod def _col_to_num(col): @@ -709,11 +713,11 @@ class ExtData(External, Data): Class for Vensim GET XLS DATA/GET DIRECT DATA """ - def __init__(self, file_name, sheet, time_row_or_col, cell, + def __init__(self, file_name, tab, time_row_or_col, cell, interp, coords, root, final_coords, py_name): super().__init__(py_name) self.files = [file_name] - self.sheets = [sheet] + self.tabs = [tab] self.time_row_or_cols = [time_row_or_col] self.cells = [cell] self.coordss = [coords] @@ -730,13 +734,12 @@ def __init__(self, file_name, sheet, time_row_or_col, cell, + "'raw', 'interpolate', " + "'look_forward' or 'hold_backward'") - def add(self, file_name, sheet, time_row_or_col, cell, - interp, coords): + def add(self, file_name, tab, time_row_or_col, cell, interp, coords): """ Add information to retrieve new dimension in an already declared object """ self.files.append(file_name) - self.sheets.append(sheet) + self.tabs.append(tab) self.time_row_or_cols.append(time_row_or_col) self.cells.append(cell) self.coordss.append(coords) @@ -758,9 +761,9 @@ def initialize(self): """ if not self.coordss[0]: # Just load one value (no add) - for self.file, self.sheet, self.x_row_or_col, \ + for self.file, self.tab, self.x_row_or_col, \ self.cell, self.coords\ - in zip(self.files, self.sheets, self.time_row_or_cols, + in zip(self.files, self.tabs, self.time_row_or_cols, self.cells, self.coordss): self.data = self._initialize_data("data") else: @@ -768,9 +771,9 @@ def initialize(self): self.data = xr.DataArray( np.nan, self.final_coords, list(self.final_coords)) - for self.file, self.sheet, self.x_row_or_col, \ + for self.file, self.tab, self.x_row_or_col, \ self.cell, self.coords\ - in zip(self.files, self.sheets, self.time_row_or_cols, + in zip(self.files, self.tabs, self.time_row_or_cols, self.cells, self.coordss): values = self._initialize_data("data") @@ -794,11 +797,11 @@ class ExtLookup(External, Lookups): Class for Vensim GET XLS LOOKUPS/GET DIRECT LOOKUPS """ - def __init__(self, file_name, sheet, x_row_or_col, cell, coords, + def __init__(self, file_name, tab, x_row_or_col, cell, coords, root, final_coords, py_name): super().__init__(py_name) self.files = [file_name] - self.sheets = [sheet] + self.tabs = [tab] self.x_row_or_cols = [x_row_or_col] self.cells = [cell] self.coordss = [coords] @@ -807,12 +810,12 @@ def __init__(self, file_name, sheet, x_row_or_col, cell, coords, self.interp = "interpolate" self.is_float = not bool(coords) - def add(self, file_name, sheet, x_row_or_col, cell, coords): + def add(self, file_name, tab, x_row_or_col, cell, coords): """ Add information to retrieve new dimension in an already declared object """ self.files.append(file_name) - self.sheets.append(sheet) + self.tabs.append(tab) self.x_row_or_cols.append(x_row_or_col) self.cells.append(cell) self.coordss.append(coords) @@ -827,9 +830,9 @@ def initialize(self): """ if not self.coordss[0]: # Just loag one value (no add) - for self.file, self.sheet, self.x_row_or_col, \ + for self.file, self.tab, self.x_row_or_col, \ self.cell, self.coords\ - in zip(self.files, self.sheets, self.x_row_or_cols, + in zip(self.files, self.tabs, self.x_row_or_cols, self.cells, self.coordss): self.data = self._initialize_data("lookup") else: @@ -837,9 +840,9 @@ def initialize(self): self.data = xr.DataArray( np.nan, self.final_coords, list(self.final_coords)) - for self.file, self.sheet, self.x_row_or_col, \ + for self.file, self.tab, self.x_row_or_col, \ self.cell, self.coords\ - in zip(self.files, self.sheets, self.x_row_or_cols, + in zip(self.files, self.tabs, self.x_row_or_cols, self.cells, self.coordss): values = self._initialize_data("lookup") @@ -859,11 +862,11 @@ class ExtConstant(External): Class for Vensim GET XLS CONSTANTS/GET DIRECT CONSTANTS """ - def __init__(self, file_name, sheet, cell, coords, + def __init__(self, file_name, tab, cell, coords, root, final_coords, py_name): super().__init__(py_name) self.files = [file_name] - self.sheets = [sheet] + self.tabs = [tab] self.transposes = [ cell[-1] == '*' and np.prod(utils.compute_shape(coords)) > 1] self.cells = [cell.strip('*')] @@ -871,12 +874,12 @@ def __init__(self, file_name, sheet, cell, coords, self.root = root self.final_coords = final_coords - def add(self, file_name, sheet, cell, coords): + def add(self, file_name, tab, cell, coords): """ Add information to retrieve new dimension in an already declared object """ self.files.append(file_name) - self.sheets.append(sheet) + self.tabs.append(tab) self.transposes.append( cell[-1] == '*' and np.prod(utils.compute_shape(coords)) > 1) self.cells.append(cell.strip('*')) @@ -892,8 +895,8 @@ def initialize(self): """ if not self.coordss[0]: # Just loag one value (no add) - for self.file, self.sheet, self.transpose, self.cell, self.coords\ - in zip(self.files, self.sheets, self.transposes, + for self.file, self.tab, self.transpose, self.cell, self.coords\ + in zip(self.files, self.tabs, self.transposes, self.cells, self.coordss): self.data = self._initialize() else: @@ -902,8 +905,8 @@ def initialize(self): self.data = xr.DataArray( np.nan, self.final_coords, list(self.final_coords)) - for self.file, self.sheet, self.transpose, self.cell, self.coords\ - in zip(self.files, self.sheets, self.transposes, + for self.file, self.tab, self.transpose, self.cell, self.coords\ + in zip(self.files, self.tabs, self.transposes, self.cells, self.coordss): self.data.loc[self.coords] = self._initialize().values @@ -1017,10 +1020,10 @@ class ExtSubscript(External): Class for Vensim GET XLS SUBSCRIPT/GET DIRECT SUBSCRIPT """ - def __init__(self, file_name, sheet, firstcell, lastcell, prefix, root): + def __init__(self, file_name, tab, firstcell, lastcell, prefix, root): super().__init__("Hardcoded external subscript") self.file = file_name - self.sheet = sheet + self.tab = tab self.prefix = prefix self._resolve_file(root=root) split = self._split_excel_cell(firstcell) @@ -1063,11 +1066,15 @@ def get_subscripts_cell(self, row_first, col_first, lastcell): ext = self.file.suffix.lower() if ext in ['.xls', '.xlsx', '.xlsm', 'xlsb', 'odf', 'ods', 'odt']: read_func = pd.read_excel - read_kwargs['sheet_name'] = self.sheet + read_kwargs['sheet_name'] = self.tab elif ext == '.csv': read_func = pd.read_csv + if self.tab and not self.tab[0].isalnum(): + read_kwargs['sep'] = self.tab else: read_func = pd.read_table + if self.tab and not self.tab[0].isalnum(): + read_kwargs['sep'] = self.tab # read the data data = read_func( @@ -1091,7 +1098,7 @@ def get_subscripts_name(self, cellname): local_cellranges = None # need to lower the sheetnames as Vensim has no case sensitivity for sheet in excel.sheetnames: - if sheet.lower() == self.sheet.lower(): + if sheet.lower() == self.tab.lower(): local_cellranges = excel[sheet].defined_names break @@ -1108,8 +1115,8 @@ def get_subscripts_name(self, cellname): or global_cellranges.get(cellname) sheet, cells = next(cellrange.destinations) - assert sheet.lower() == self.sheet.lower() - self.sheet = sheet # case insensitivity in sheet name + assert sheet.lower() == self.tab.lower() + self.tab = sheet # case insensitivity in sheet name # Get the cells where the cellrange is defined first_cell, last_cell = cells.replace("$", '').split(":") diff --git a/tests/pytest_types/external/pytest_external.py b/tests/pytest_types/external/pytest_external.py index 2cf092de..60ee5772 100644 --- a/tests/pytest_types/external/pytest_external.py +++ b/tests/pytest_types/external/pytest_external.py @@ -275,7 +275,7 @@ def test_read_empty_cells_openpyxl(self, _root): ext = External("external") ext.file = "data/input.xlsx" - ext.sheet = "Horizontal missing" + ext.tab = "Horizontal missing" ext._resolve_file(root=_root) error_message = r"external\nThe cells are empty\.\n"\ @@ -294,7 +294,7 @@ def test_read_empty_cells_pandas(self, _root): ext = External("external") ext.file = "data/input.xlsx" - ext.sheet = "Horizontal missing" + ext.tab = "Horizontal missing" ext._resolve_file(root=_root) error_message = r"external\nThe cells are empty\.\n" @@ -339,7 +339,7 @@ def test_data_interp_h1d_1(self, _root): py_name = "test_data_interp_h1d_1" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -372,7 +372,7 @@ def test_data_interp_hn1d_1(self, _root): py_name = "test_data_interp_h1d_1" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -402,7 +402,7 @@ def test_data_interp_h1d(self, _root, _exp): py_name = "test_data_interp_h1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -432,7 +432,7 @@ def test_data_interp_v1d(self, _root, _exp): py_name = "test_data_interp_v1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -462,7 +462,7 @@ def test_data_interp_hn1d(self, _root, _exp): py_name = "test_data_interp_h1nd" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -492,7 +492,7 @@ def test_data_interp_vn1d(self, _root, _exp): py_name = "test_data_interp_vn1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -522,7 +522,7 @@ def test_data_forward_h1d(self, _root, _exp): py_name = "test_data_forward_h1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -552,7 +552,7 @@ def test_data_forward_v1d(self, _root, _exp): py_name = "test_data_forward_v1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -582,7 +582,7 @@ def test_data_forward_hn1d(self, _root, _exp): py_name = "test_data_forward_hn1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -612,7 +612,7 @@ def test_data_forward_vn1d(self, _root, _exp): py_name = "test_data_forward_vn1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -642,7 +642,7 @@ def test_data_backward_h1d(self, _root, _exp): py_name = "test_data_backward_h1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -672,7 +672,7 @@ def test_data_backward_v1d(self, _root, _exp): py_name = "test_data_backward_v1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -702,7 +702,7 @@ def test_data_backward_hn1d(self, _root, _exp): py_name = "test_data_backward_hn1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -732,7 +732,7 @@ def test_data_backward_vn1d(self, _root, _exp): py_name = "test_data_backward_vn1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -762,7 +762,7 @@ def test_data_interp_vn2d(self, _root, _exp): py_name = "test_data_interp_vn2d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -791,7 +791,7 @@ def test_data_forward_hn2d(self, _root, _exp): py_name = "test_data_forward_hn2d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -820,7 +820,7 @@ def test_data_backward_v2d(self, _root, _exp): py_name = "test_data_backward_v2d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -853,7 +853,7 @@ def test_data_interp_h3d(self, _root, _exp): py_name = "test_data_interp_h3d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell_1, @@ -863,7 +863,7 @@ def test_data_interp_h3d(self, _root, _exp): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, cell=cell_2, coords=coords_2, @@ -893,7 +893,7 @@ def test_data_forward_v3d(self, _root, _exp): py_name = "test_data_forward_v3d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell_1, @@ -903,7 +903,7 @@ def test_data_forward_v3d(self, _root, _exp): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, cell=cell_2, coords=coords_2, @@ -933,7 +933,7 @@ def test_data_backward_hn3d(self, _root, _exp): py_name = "test_data_backward_hn3d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell_1, @@ -943,7 +943,7 @@ def test_data_backward_hn3d(self, _root, _exp): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, cell=cell_2, coords=coords_2, @@ -970,7 +970,7 @@ def test_data_raw_h1d(self, _root, _exp): py_name = "test_data_forward_h1d" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -1013,7 +1013,7 @@ def test_lookup_h1d(self, _root, _exp): py_name = "test_lookup_h1d" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell, @@ -1041,7 +1041,7 @@ def test_lookup_v1d(self, _root, _exp): py_name = "test_lookup_v1d" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell, @@ -1069,7 +1069,7 @@ def test_lookup_hn1d(self, _root, _exp): py_name = "test_lookup_h1nd" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell, @@ -1097,7 +1097,7 @@ def test_lookup_vn1d(self, _root, _exp): py_name = "test_lookup_vn1d" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell, @@ -1125,7 +1125,7 @@ def test_lookup_h2d(self, _root, _exp): py_name = "test_lookup_h2d" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell, @@ -1156,7 +1156,7 @@ def test_lookup_vn3d(self, _root, _exp): py_name = "test_lookup_vn3d" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell_1, @@ -1165,7 +1165,7 @@ def test_lookup_vn3d(self, _root, _exp): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, cell=cell_2, coords=coords_2) @@ -1194,7 +1194,7 @@ def test_lookup_vn3d_shape0(self, _root, _exp): py_name = "test_lookup_vn3d_shape0" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell_1, @@ -1203,7 +1203,7 @@ def test_lookup_vn3d_shape0(self, _root, _exp): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, cell=cell_2, coords=coords_2) @@ -1230,7 +1230,7 @@ def test_lookup_vn2d_xarray(self, _root): py_name = "test_lookup_vn2d_xarray" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell_1, @@ -1293,7 +1293,7 @@ def test_lookup_vn3d_xarray(self, _root): py_name = "test_lookup_vn3d_xarray" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell_1, @@ -1302,7 +1302,7 @@ def test_lookup_vn3d_xarray(self, _root): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, cell=cell_2, coords=coords_2) @@ -1364,7 +1364,7 @@ def test_constant_0d(self, _root): py_name = "test_constant_0d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1372,7 +1372,7 @@ def test_constant_0d(self, _root): py_name=py_name) data2 = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell2, coords=coords, @@ -1398,7 +1398,7 @@ def test_constant_n0d(self, _root): py_name = "test_constant_0d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1406,7 +1406,7 @@ def test_constant_n0d(self, _root): py_name=py_name) data2 = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell2, coords=coords, @@ -1431,7 +1431,7 @@ def test_constant_h1d(self, _root, _exp): py_name = "test_constant_h1d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1454,7 +1454,7 @@ def test_constant_v1d(self, _root, _exp): py_name = "test_constant_v1d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1477,7 +1477,7 @@ def test_constant_hn1d(self, _root, _exp): py_name = "test_constant_hn1d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1500,7 +1500,7 @@ def test_constant_vn1d(self, _root, _exp): py_name = "test_constant_vn1d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1523,7 +1523,7 @@ def test_constant_h2d(self, _root, _exp): py_name = "test_constant_h2d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1546,7 +1546,7 @@ def test_constant_v2d(self, _root, _exp): py_name = "test_constant_v2d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1569,7 +1569,7 @@ def test_constant_hn2d(self, _root, _exp): py_name = "test_constant_hn2d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1592,7 +1592,7 @@ def test_constant_vn2d(self, _root, _exp): py_name = "test_constant_vn2d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1624,7 +1624,7 @@ def test_constant_h3d(self, _root, _exp): py_name = "test_constant_h3d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1632,7 +1632,7 @@ def test_constant_h3d(self, _root, _exp): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, cell=cell2, coords=coords2) @@ -1662,7 +1662,7 @@ def test_constant_v3d(self, _root, _exp): py_name = "test_constant_v3d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1670,7 +1670,7 @@ def test_constant_v3d(self, _root, _exp): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, cell=cell2, coords=coords2) @@ -1700,7 +1700,7 @@ def test_constant_hn3d(self, _root, _exp): py_name = "test_constant_hn3d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1708,7 +1708,7 @@ def test_constant_hn3d(self, _root, _exp): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, cell=cell2, coords=coords2) @@ -1738,7 +1738,7 @@ def test_constant_vn3d(self, _root, _exp): py_name = "test_constant_vn2d" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -1746,7 +1746,7 @@ def test_constant_vn3d(self, _root, _exp): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, cell=cell2, coords=coords2) @@ -1776,7 +1776,7 @@ def test_subscript_h(self, _root): 'val5', 'val6', 'val7', 'val8'] data = pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -1799,7 +1799,7 @@ def test_subscript_h2(self, _root): 'v5', 'v6', 'v7', 'v8'] data = pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -1822,7 +1822,7 @@ def test_subscript_h_csv(self, _root): 'h6', 'h7', 'h8', 'h9', 'h10'] data = pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -1844,7 +1844,7 @@ def test_subscript_v(self, _root): expected = ['A', 'B', 'C'] data = pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -1866,7 +1866,7 @@ def test_subscript_v2(self, _root): expected = ['A', 'B', 'C', '4', '5'] data = pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -1888,7 +1888,7 @@ def test_subscript_d(self, _root): expected = ['X', 'A', 'B', 'C', 'Y', 'A', 'B', 'C'] data = pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -1910,7 +1910,7 @@ def test_subscript_d2(self, _root): expected = ['j3', 'j2', 'j1', 'j6', 'j4', 'j8', 'j-1', 'j3', 'j2'] data = pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -1933,7 +1933,7 @@ def test_subscript_name_h(self, _root): 'l5', 'l6', 'l7', 'l8'] data = pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -1955,7 +1955,7 @@ def test_subscript_name_v(self, _root): expected = ['pA', 'pB', 'pC'] data = pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -1977,7 +1977,7 @@ def test_subscript_name_d(self, _root): expected = ['X', 'A', '0', 'B', '0', 'C', '1'] data = pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -2006,7 +2006,7 @@ def test_non_existent_file(self, _root): py_name = "test_non_existent_file" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2033,7 +2033,7 @@ def test_non_existent_sheet_pyxl(self, _root): py_name = "test_non_existent_sheet_pyxl" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2061,7 +2061,7 @@ def test_non_existent_cellrange_name_pyxl(self, _root): py_name = "test_non_existent_cellrange_name_pyxl" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2087,7 +2087,7 @@ def test_non_existent_cellrange_name_in_sheet_pyxl(self, _root): py_name = "est_non_existent_cellrange_name_in_sheet_pyxl" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -2118,7 +2118,7 @@ def test_data_interp_h1dm_row(self, _root): pysd.external.External.missing = "warning" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2156,7 +2156,7 @@ def test_data_interp_h1dm_row2(self, _root): pysd.external.External.missing = "warning" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2196,7 +2196,7 @@ def test_data_interp_h1dm(self, _root, _exp): pysd.external.External.missing = "warning" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2232,7 +2232,7 @@ def test_data_interp_h1dm_ignore(self, _root, _exp): pysd.external.External.missing = "ignore" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2267,7 +2267,7 @@ def test_data_interp_h1dm_raise(self, _root): pysd.external.External.missing = "raise" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2298,7 +2298,7 @@ def test_data_interp_v1dm(self, _root, _exp): pysd.external.External.missing = "warning" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2334,7 +2334,7 @@ def test_data_interp_v1dm_ignore(self, _root, _exp): pysd.external.External.missing = "ignore" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2369,7 +2369,7 @@ def test_data_interp_v1dm_raise(self, _root): pysd.external.External.missing = "raise" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2400,7 +2400,7 @@ def test_data_interp_hn1dm(self, _root, _exp): pysd.external.External.missing = "warning" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2436,7 +2436,7 @@ def test_data_interp_hn1dm_ignore(self, _root, _exp): pysd.external.External.missing = "ignore" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2471,7 +2471,7 @@ def test_data_interp_hn1dm_raise(self, _root): pysd.external.External.missing = "raise" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2505,7 +2505,7 @@ def test_data_interp_hn3dmd(self, _root, _exp): pysd.external.External.missing = "warning" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell_1, @@ -2515,7 +2515,7 @@ def test_data_interp_hn3dmd(self, _root, _exp): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, cell=cell_2, interp=interp, @@ -2551,7 +2551,7 @@ def test_data_interp_hn3dmd_raw(self, _root): pysd.external.External.missing = "warning" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell_1, @@ -2561,7 +2561,7 @@ def test_data_interp_hn3dmd_raw(self, _root): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, cell=cell_2, interp=interp, @@ -2589,7 +2589,7 @@ def test_lookup_hn3dmd_raise(self, _root): pysd.external.External.missing = "raise" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell_1, @@ -2598,7 +2598,7 @@ def test_lookup_hn3dmd_raise(self, _root): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, cell=cell_2, coords=coords_2) @@ -2626,7 +2626,7 @@ def test_lookup_hn3dmd_ignore(self, _root, _exp): pysd.external.External.missing = "ignore" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell_1, @@ -2635,7 +2635,7 @@ def test_lookup_hn3dmd_ignore(self, _root, _exp): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, cell=cell_2, coords=coords_2) @@ -2669,7 +2669,7 @@ def test_constant_h3dm(self, _root): pysd.external.External.missing = "warning" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell_1, coords=coords_1, @@ -2677,7 +2677,7 @@ def test_constant_h3dm(self, _root): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, cell=cell_2, coords=coords_2) @@ -2705,7 +2705,7 @@ def test_constant_h3dm_ignore(self, _root): pysd.external.External.missing = "ignore" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell_1, coords=coords_1, @@ -2713,7 +2713,7 @@ def test_constant_h3dm_ignore(self, _root): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, cell=cell_2, coords=coords_2) @@ -2739,7 +2739,7 @@ def test_constant_h3dm_raise(self, _root): pysd.external.External.missing = "raise" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell_1, coords=coords_1, @@ -2747,7 +2747,7 @@ def test_constant_h3dm_raise(self, _root): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, cell=cell_2, coords=coords_2) @@ -2776,7 +2776,7 @@ def test_constant_hn3dm_raise(self, _root): pysd.external.External.missing = "raise" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell_1, coords=coords_1, @@ -2784,7 +2784,7 @@ def test_constant_hn3dm_raise(self, _root): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, cell=cell_2, coords=coords_2) @@ -2807,7 +2807,7 @@ def test_data_interp_h1d0(self, _root): py_name = "test_data_interp_h1d0" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2835,7 +2835,7 @@ def test_data_interp_v1d0(self, _root): py_name = "test_data_interp_v1d0" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2865,7 +2865,7 @@ def test_data_interp_hn1d0(self, _root): pysd.external.External.missing = "warning" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2894,7 +2894,7 @@ def test_data_interp_hn1dt(self, _root): py_name = "test_data_interp_h1dt" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2923,7 +2923,7 @@ def test_data_interp_hns(self, _root): py_name = "test_data_interp_hns" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2952,7 +2952,7 @@ def test_data_interp_vnss(self, _root): py_name = "test_data_interp_vnss" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -2982,7 +2982,7 @@ def test_data_interp_hnnwd(self, _root): py_name = "test_data_interp_hnnwd" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -3009,7 +3009,7 @@ def test_data_raw_hnnm(self, _root): py_name = "test_data_interp_hnnm" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -3032,7 +3032,7 @@ def test_data_raw_hnnm(self, _root): py_name = "test_data_interp_hnnnm2" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -3069,7 +3069,7 @@ def test_data_h3d_interpnv(self, _root): r"'raw', 'interpolate', 'look_forward' or 'hold_backward'" with pytest.raises(ValueError, match=error_message): pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -3097,7 +3097,7 @@ def test_data_h3d_interp(self, _root): py_name = "test_data_h3d_interp" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell_1, @@ -3110,7 +3110,7 @@ def test_data_h3d_interp(self, _root): "previously defined one" with pytest.raises(ValueError, match=error_message): data.add(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, cell=cell_2, coords=coords_2, @@ -3134,7 +3134,7 @@ def test_data_h3d_add(self, _root): py_name = "test_data_h3d_add" data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell_1, @@ -3146,7 +3146,7 @@ def test_data_h3d_add(self, _root): error_message = "Error matching dimensions with previous data" with pytest.raises(ValueError, match=error_message): data.add(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, cell=cell_2, coords=coords_2, @@ -3169,7 +3169,7 @@ def test_lookup_h3d_add(self, _root): py_name = "test_lookup_h3d_add" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell_1, @@ -3180,7 +3180,7 @@ def test_lookup_h3d_add(self, _root): error_message = "Error matching dimensions with previous data" with pytest.raises(ValueError, match=error_message): data.add(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, cell=cell_2, coords=coords_2) @@ -3206,7 +3206,7 @@ def test_constant_h3d_add(self, _root): py_name = "test_constant_h3d_add" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -3216,7 +3216,7 @@ def test_constant_h3d_add(self, _root): error_message = "Error matching dimensions with previous data" with pytest.raises(ValueError, match=error_message): data.add(file_name=file_name, - sheet=sheet, + tab=sheet, cell=cell2, coords=coords2) @@ -3234,7 +3234,7 @@ def test_constant_hns(self, _root): py_name = "test_constant_hns" data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -3261,7 +3261,7 @@ def text_openpyxl_str(self, _root): py_name = "test_openpyxl_str" data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell, @@ -3282,7 +3282,7 @@ def text_openpyxl_str(self, _root): sheet = "caSE anD NON V" # test case insensitivity data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell, coords=coords, @@ -3308,7 +3308,7 @@ def test_subscript_name_non_existent_sheet(self, _root): error_message = r"The sheet doesn't exist\.\.\." with pytest.raises(ValueError, match=error_message): pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -3329,7 +3329,7 @@ def test_subscript_name_non_existent_cellrange_name(self, _root): error_message = "The cellrange name 'fake-cell'\nDoesn't exist in" with pytest.raises(AttributeError, match=error_message): pysd.external.ExtSubscript(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, firstcell=firstcell, lastcell=lastcell, @@ -3374,7 +3374,7 @@ def test_constant_hn3dm_keep(self, _root): ['XY', 'ABC', 'val']) data = pysd.external.ExtConstant(file_name=file_name, - sheet=sheet, + tab=sheet, root=_root, cell=cell_1, coords=coords_1, @@ -3382,7 +3382,7 @@ def test_constant_hn3dm_keep(self, _root): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, cell=cell_2, coords=coords_2) @@ -3430,7 +3430,7 @@ def test_lookup_hn3dmd_keep(self, _root): ['lookup_dim', 'XY', 'ABC']) data = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, root=_root, cell=cell_1, @@ -3439,7 +3439,7 @@ def test_lookup_hn3dmd_keep(self, _root): py_name=py_name) data.add(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=x_row_or_col, cell=cell_2, coords=coords_2) @@ -3471,7 +3471,7 @@ def test_data_interp_v1dm_keep(self, _root): ['time']) data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -3507,7 +3507,7 @@ def test_data_interp_hnnm_keep(self, _root): ['time']) data = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -3536,7 +3536,7 @@ def test_lookup_data_attr(self, _root): py_name = "test_data_interp_hnnm" datD = pysd.external.ExtData(file_name=file_name, - sheet=sheet, + tab=sheet, time_row_or_col=time_row_or_col, root=_root, cell=cell, @@ -3546,7 +3546,7 @@ def test_lookup_data_attr(self, _root): py_name=py_name) datL = pysd.external.ExtLookup(file_name=file_name, - sheet=sheet, + tab=sheet, x_row_or_col=time_row_or_col, root=_root, cell=cell,