Skip to content

Commit

Permalink
style: rename tsv/csv reading function in tests, tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
Lopa10ko committed Sep 23, 2024
1 parent 4fd8bde commit cb22381
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions fedot_ind/tools/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def read_train_test_files(self, data_path, dataset_name: str, shuffle: bool = Tr
return is_multivariate, (x_train, y_train), (x_test, y_test)

@staticmethod
def predict_encoding(file_path: Path, n_lines: int = 20) -> str:
def predict_encoding(file_path: str, n_lines: int = 20) -> str:
with Path(file_path).open('rb') as f:
rawdata = b''.join([f.readline() for _ in range(n_lines)])
return chardet.detect(rawdata)['encoding']
Expand Down Expand Up @@ -835,8 +835,8 @@ def load_process_data(path_to_dataset, sep):
if mode not in ['tsv', 'csv']:
raise ValueError(f'Invalid mode {mode}. Should be one of "tsv" or "csv"')
separator = '/t' if mode == 'tsv' else ','
x_train, y_train = load_process_data(dataset_dir + f'{dataset_name}_TRAIN.{mode}', separator)
x_test, y_test = load_process_data(dataset_dir + f'{dataset_name}_TEST.{mode}', separator)
x_train, y_train = load_process_data(dataset_dir + f'/{dataset_name}_TRAIN.{mode}', separator)
x_test, y_test = load_process_data(dataset_dir + f'/{dataset_name}_TEST.{mode}', separator)

return x_train, y_train, x_test, y_test

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/tools/test_load_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_read_tsv():
path = '.'
loader = DataLoader(dataset_name=ds_name, folder=path)
path = os.path.join(PROJECT_PATH, 'tests', 'data', 'datasets')
x_train, y_train, x_test, y_test = loader.read_tsv(
x_train, y_train, x_test, y_test = loader.read_tsv_or_csv(
dataset_name='ItalyPowerDemand_tsv', data_path=path)

for i in [x_train, y_train, x_test, y_test]:
Expand Down

0 comments on commit cb22381

Please sign in to comment.