.pkg: _optional_hooks> python "C:\Program Files\Python311\Lib\site-packages\pyproject_api\_backend.py" True setuptools.build_meta .pkg: get_requires_for_build_sdist> python "C:\Program Files\Python311\Lib\site-packages\pyproject_api\_backend.py" True setuptools.build_meta .pkg: get_requires_for_build_wheel> python "C:\Program Files\Python311\Lib\site-packages\pyproject_api\_backend.py" True setuptools.build_meta .pkg: prepare_metadata_for_build_wheel> python "C:\Program Files\Python311\Lib\site-packages\pyproject_api\_backend.py" True setuptools.build_meta .pkg: build_sdist> python "C:\Program Files\Python311\Lib\site-packages\pyproject_api\_backend.py" True setuptools.build_meta default: install_package> python -I -m pip install --force-reinstall --no-deps C:\Users\Olex\Documents\MANRID\ResLab\Playground\otoole-review\otoole\.tox\.tmp\package\4\otoole-1.1.0.post1.dev30+gbf43d3b.tar.gz default: commands[0]> pytest ================================================= test session starts ================================================= platform win32 -- Python 3.11.1, pytest-7.4.2, pluggy-1.3.0 -- C:\Users\Olex\Documents\MANRID\ResLab\Playground\otoole-review\otoole\.tox\default\Scripts\python.EXE cachedir: .tox\default\.pytest_cache rootdir: C:\Users\Olex\Documents\MANRID\ResLab\Playground\otoole-review\otoole configfile: setup.cfg testpaths: tests plugins: cov-4.1.0 collecting ... collected 210 items tests/test_cli.py::TestResults::test_convert_results PASSED tests/test_cli.py::TestConvert::test_version PASSED tests/test_cli.py::TestConvert::test_convert_commands[help] otoole -v convert --help PASSED tests/test_cli.py::TestConvert::test_convert_commands[excel] otoole -v convert datafile excel tests\fixtures\simplicity.txt C:\Users\Olex\AppData\Local\Temp\tmpp_6_i7ax.xlsx tests\fixtures\config.yaml b'' FAILED tests/test_cli.py::TestConvert::test_convert_commands[datafile] otoole -v convert datafile datafile tests\fixtures\simplicity.txt C:\Users\Olex\AppData\Local\Temp\tmp43bw7ctq.dat tests\fixtures\config.yaml b'' FAILED tests/test_cli.py::TestConvert::test_convert_error[invalid] PASSED tests/test_cli.py::TestConvert::test_convert_datafile_datafile_no_user_config PASSED tests/test_cli.py::TestConvert::test_convert_datafile_datafile_with_user_config FAILED tests/test_cli.py::TestConvert::test_convert_datafile_datafile_with_default_flag FAILED tests/test_cli.py::TestSetup::test_setup_commands[setup] otoole -v setup config C:\Users\Olex\AppData\Local\Temp\tmp9qer5gnl.yaml PASSED tests/test_cli.py::TestSetup::test_setup_commands[setup_with_overwrite] otoole -v setup config C:\Users\Olex\AppData\Local\Temp\tmp43t8rjik.yaml --overwrite b'' FAILED tests/test_cli.py::TestSetup::test_setup_error[setup_fails] PASSED tests/test_convert.py::TestRead::test_read_datafile PASSED tests/test_convert.py::TestRead::test_read_excel PASSED tests/test_convert.py::TestRead::test_read_csv PASSED tests/test_convert.py::TestWrite::test_write_datafile FAILED tests/test_convert.py::TestWrite::test_write_excel FAILED tests/test_convert.py::TestWrite::test_write_csv PASSED tests/test_convert.py::TestConvert::test_convert_excel_to_datafile FAILED tests/test_convert.py::TestConvert::test_convert_excel_to_csv PASSED tests/test_convert.py::TestReadResults::test_read_results FAILED tests/test_convert.py::TestConvertResults::test_convert_results_cbc_csv PASSED tests/test_convert.py::TestConvertResults::test_convert_results_cbc_csv_datafile PASSED tests/test_convert.py::TestConvertResults::test_convert_results_cbc_csv_raises PASSED tests/test_convert.py::TestGetReadResultsStrategy::test_read_results_glpk_raises PASSED tests/test_input.py::TestExpandDefaults::test_expand_parameters_defaults[multi_index_no_defaluts] PASSED tests/test_input.py::TestExpandDefaults::test_expand_parameters_defaults[multi_index] PASSED tests/test_input.py::TestExpandDefaults::test_expand_parameters_defaults[multi_index_empty] PASSED tests/test_input.py::TestExpandDefaults::test_expand_parameters_defaults[single_index] PASSED tests/test_input.py::TestExpandDefaults::test_expand_parameters_defaults[single_index_empty] PASSED tests/test_input.py::TestExpandDefaults::test_expand_result_defaults PASSED tests/test_input.py::TestReadStrategy::test_get_missing_input_dataframes[param] PASSED tests/test_input.py::TestReadStrategy::test_get_missing_input_dataframes[set] PASSED tests/test_input.py::TestReadStrategy::test_get_missing_input_dataframes_excpetion PASSED tests/test_input.py::TestReadStrategy::test_check_index[param] FAILED tests/test_input.py::TestReadStrategy::test_check_index[set] FAILED tests/test_input.py::TestReadStrategy::test_check_index_dtype[param] FAILED tests/test_input.py::TestReadStrategy::test_check_index_dtype[set] FAILED tests/test_input.py::TestReadStrategy::test_check_index_header[param] PASSED tests/test_input.py::TestReadStrategy::test_check_index_header[set] PASSED tests/test_input.py::TestReadStrategy::test_check_index_config PASSED tests/test_input.py::TestReadStrategy::test_check_dtypes[param] FAILED tests/test_input.py::TestReadStrategy::test_check_dtypes[set] FAILED tests/test_input.py::TestReadStrategy::test_check_param_index_name_passes PASSED tests/test_input.py::TestReadStrategy::test_check_param_index_name_fails PASSED tests/test_input.py::TestReadStrategy::test_check_set_index_name_passes PASSED tests/test_input.py::TestReadStrategy::test_check_set_index_name_fails PASSED tests/test_input.py::TestReadStrategy::test_compare_read_to_expected[full_name] PASSED tests/test_input.py::TestReadStrategy::test_compare_read_to_expected[short_name] PASSED tests/test_input.py::TestReadStrategy::test_compare_read_to_expected_exception[missing_value] PASSED tests/test_input.py::TestReadStrategy::test_compare_read_to_expected_exception[extra_value] PASSED tests/test_read_strategies.py::TestReadCplex::test_convert_to_dataframe PASSED tests/test_read_strategies.py::TestReadCplex::test_solution_to_dataframe PASSED tests/test_read_strategies.py::TestReadGurobi::test_convert_to_dataframe PASSED tests/test_read_strategies.py::TestReadGurobi::test_solution_to_dataframe PASSED tests/test_read_strategies.py::TestReadCbc::test_read_cbc_to_otoole_dataframe[0 Trade(Globe,Globe,IP,L_AGR,2015) -0.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2016) -1.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2017) -2.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2018) -3.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2019) -4.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2020) -5.0 0\n-expected0] FAILED tests/test_read_strategies.py::TestReadCbc::test_read_cbc_dataframe_to_otoole_dataframe FAILED tests/test_read_strategies.py::TestReadCbc::test_handle_duplicate_indices[data0-True] PASSED tests/test_read_strategies.py::TestReadCbc::test_handle_duplicate_indices[data1-False] PASSED tests/test_read_strategies.py::TestReadCbc::test_handle_duplicate_indices[data2-False] PASSED tests/test_read_strategies.py::TestReadCbc::test_identify_duplicate[data0-1] PASSED tests/test_read_strategies.py::TestReadCbc::test_identify_duplicate[data1-False] PASSED tests/test_read_strategies.py::TestReadCbc::test_identify_duplicate[data2-False] PASSED tests/test_read_strategies.py::TestReadCbc::test_rename_duplicate_column PASSED tests/test_read_strategies.py::TestReadCbc::test_read_cbc_to_dataframe[TotalDiscountedCost] PASSED tests/test_read_strategies.py::TestReadCbc::test_convert_cbc_to_csv_long[TotalDiscountedCost] FAILED tests/test_read_strategies.py::TestReadCbc::test_convert_cbc_to_csv_long[AnnualEmissions1] FAILED tests/test_read_strategies.py::TestReadCbc::test_convert_cbc_to_csv_long_read[TotalDiscountedCost] FAILED tests/test_read_strategies.py::TestReadCbc::test_calculate_results PASSED tests/test_read_strategies.py::TestReadCbc::test_solution_to_dataframe FAILED tests/test_read_strategies.py::TestReadCbc::test_manage_infeasible_variables PASSED tests/test_read_strategies.py::TestReadGlpk::test_read_model FAILED tests/test_read_strategies.py::TestReadGlpk::test_read_solution FAILED tests/test_read_strategies.py::TestReadGlpk::test_merge_model_sol PASSED tests/test_read_strategies.py::TestReadGlpk::test_convert_to_dataframe PASSED tests/test_read_strategies.py::TestReadGlpk::test_convert_to_dataframe_error PASSED tests/test_read_strategies.py::TestReadGlpk::test_read_model_error PASSED tests/test_read_strategies.py::TestCleanOnRead::test_index_dtypes_available PASSED tests/test_read_strategies.py::TestCleanOnRead::test_remove_empty_lines PASSED tests/test_read_strategies.py::TestCleanOnRead::test_change_types PASSED tests/test_read_strategies.py::TestReadMemoryStrategy::test_read_memory FAILED tests/test_read_strategies.py::TestReadMemoryStrategy::test_read_memory_user_config FAILED tests/test_read_strategies.py::TestConfig::test_read_config PASSED tests/test_read_strategies.py::TestReadDatafile::test_amply PASSED tests/test_read_strategies.py::TestReadDatafile::test_convert_amply_to_dataframe PASSED tests/test_read_strategies.py::TestReadDatafile::test_convert_amply_data_to_list_of_lists PASSED tests/test_read_strategies.py::TestReadDatafile::test_load_parameters PASSED tests/test_read_strategies.py::TestReadDatafile::test_load_sets PASSED tests/test_read_strategies.py::TestReadDatafile::test_catch_error_no_parameter PASSED tests/test_read_strategies.py::TestReadExcel::test_read_excel_yearsplit PASSED tests/test_read_strategies.py::TestReadExcel::test_narrow_parameters PASSED tests/test_read_strategies.py::TestReadExcel::test_invalid_column_name PASSED tests/test_read_strategies.py::TestReadExcel::test_check_index FAILED tests/test_read_strategies.py::TestReadCSV::test_get_input_data_empty[full] PASSED tests/test_read_strategies.py::TestReadCSV::test_get_input_data_empty[empty] PASSED tests/test_read_strategies.py::TestReadCSV::test_read_default_values_csv_fails PASSED tests/test_read_strategies.py::TestReadCSV::test_read_default_values_csv PASSED tests/test_read_strategies.py::TestReadTabular::test_whitespace_converter[create_empty] PASSED tests/test_read_strategies.py::TestReadTabular::test_whitespace_converter[create_full] PASSED tests/test_read_strategies.py::TestLongifyData::test_check_datatypes_valid PASSED tests/test_read_strategies.py::TestLongifyData::test_check_datatypes_invalid PASSED tests/test_setup.py::test_get_csv_setup_data FAILED tests/test_utils.py::TestCreateNameMappings::test_create_name_mappings PASSED tests/test_utils.py::TestCreateNameMappings::test_create_name_mappings_reversed PASSED tests/test_utils.py::test_excel_name_length_error[full_name_error] FAILED tests/test_utils.py::test_excel_name_length_error[short_name_error] FAILED tests/test_utils.py::TestYamlUniqueKeyReader::test_valid_yaml PASSED tests/test_utils.py::TestYamlUniqueKeyReader::test_invalid_yaml[invalid_yaml_1] PASSED tests/test_utils.py::TestYamlUniqueKeyReader::test_invalid_yaml[invalid_yaml_2] PASSED tests/test_utils.py::test_successful_read_deprecated_datapackage PASSED tests/test_utils.py::test_unsuccessful_read_deprecated_datapackage PASSED tests/test_validate.py::test_validate_fuel_code_true[DZAETH-True] PASSED tests/test_validate.py::test_validate_fuel_code_true[AGOCR1-True] PASSED tests/test_validate.py::test_validate_fuel_code_true[CO1AGO-False] PASSED tests/test_validate.py::test_validate_fuel_code_true[AGOETHETH-False] PASSED tests/test_validate.py::test_validate_fuel_code_true[ ETH-False] PASSED tests/test_validate.py::test_validate_fuel_code_true[DVA-False] PASSED tests/test_validate.py::test_validate_fuel_code_true_multi[DZAETH-True] PASSED tests/test_validate.py::test_validate_fuel_code_true_multi[AGOCR1-True] PASSED tests/test_validate.py::test_validate_fuel_code_true_multi[CO1AGO-True] PASSED tests/test_validate.py::test_validate_fuel_code_true_multi[AGOETHETH-False] PASSED tests/test_validate.py::test_validate_fuel_code_true_multi[ ETH-False] PASSED tests/test_validate.py::test_validate_fuel_code_true_multi[DVA-False] PASSED tests/test_validate.py::test_compose_expression PASSED tests/test_validate.py::test_compose_multi_expression PASSED tests/test_validate.py::test_read_packaged_validation PASSED tests/test_validate.py::test_create_schema PASSED tests/test_validate.py::test_create_schema_two_items PASSED tests/test_validate.py::test_create_schema_duplicate_raises PASSED tests/test_validate_config.py::TestValidConfigs::test_valid_configs[valid_set] PASSED tests/test_validate_config.py::TestValidConfigs::test_valid_configs[valid_parameter_1] PASSED tests/test_validate_config.py::TestValidConfigs::test_valid_configs[valid_parameter_2] PASSED tests/test_validate_config.py::TestValidConfigs::test_valid_configs[valid_result_1] PASSED tests/test_validate_config.py::TestValidConfigs::test_valid_configs[valid_result_2] PASSED tests/test_validate_config.py::TestInvalidConfigs::test_invalid_config_multi_defs[invalid_duplicate_set_names] PASSED tests/test_validate_config.py::TestInvalidConfigs::test_invalid_config_multi_defs[invalid_duplicate_param_names] PASSED tests/test_validate_config.py::TestInvalidConfigs::test_invalid_config_multi_defs[invalid_duplicate_result_names] PASSED tests/test_validate_config.py::TestInvalidConfigs::test_invalid_config_multi_defs[invalid_duplicate_names_diff_types_1] PASSED tests/test_validate_config.py::TestInvalidConfigs::test_invalid_config_multi_defs[invalid_duplicate_names_diff_types_2] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_set_type] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_parameter_type] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_result_type] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_name_spaces] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_name_numbers] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_name_special_chars] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_name_length] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_short_name_spaces] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_short_name_numbers] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_short_name_special_chars] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_short_name_length_1] PASSED tests/test_validate_config.py::TestUserDefinedValue::test_invalid_configs[invalid_short_name_length_2] PASSED tests/test_validate_config.py::TestUserDefinedSet::test_invalid_config_sets[invalid_dtype] PASSED tests/test_validate_config.py::TestUserDefinedSet::test_invalid_config_sets[invalid_unexpected_field] PASSED tests/test_validate_config.py::TestUserDefinedSet::test_invalid_config_sets[invalid_missing_field] PASSED tests/test_validate_config.py::TestUserDefinedParameter::test_invalid_config_params[invalid_dtype] PASSED tests/test_validate_config.py::TestUserDefinedParameter::test_invalid_config_params[invalid_unexpected_field] PASSED tests/test_validate_config.py::TestUserDefinedParameter::test_invalid_config_params[invalid_missing_field] PASSED tests/test_validate_config.py::TestUserDefinedParameter::test_invalid_config_params[invalid_missing_index] PASSED tests/test_validate_config.py::TestUserDefinedParameter::test_invalid_config_params[invalid_default] PASSED tests/test_validate_config.py::TestInvalidConfigResults::test_invalid_config_results[invalid_dtype] PASSED tests/test_validate_config.py::TestInvalidConfigResults::test_invalid_config_results[invalid_unexpected_field] PASSED tests/test_validate_config.py::TestInvalidConfigResults::test_invalid_config_results[invalid_missing_field] PASSED tests/test_validate_config.py::TestInvalidConfigResults::test_invalid_config_results[invalid_missing_index] PASSED tests/test_validate_config.py::TestInvalidConfigResults::test_invalid_config_results[invalid_default] PASSED tests/test_visualise.py::test_create_res SKIPPED (pydot deprecated, requires replacement with pygraphviz (ht...) tests/test_write_strategies.py::TestWriteExcel::test_form_empty_parameter_with_defaults PASSED tests/test_write_strategies.py::TestWriteExcel::test_form_empty_two_index_param_with_defaults PASSED tests/test_write_strategies.py::TestWriteExcel::test_form_two_index_param PASSED tests/test_write_strategies.py::TestWriteExcel::test_form_one_columns PASSED tests/test_write_strategies.py::TestWriteExcel::test_form_template_paramter PASSED tests/test_write_strategies.py::TestWriteExcel::test_form_three_columns PASSED tests/test_write_strategies.py::TestWriteExcel::test_form_no_pivot PASSED tests/test_write_strategies.py::TestWriteExcel::test_write_out_empty_dataframe FAILED tests/test_write_strategies.py::TestWriteDatafile::test_write_empty_parameter_with_defaults PASSED tests/test_write_strategies.py::TestWriteDatafile::test_write_parameter_as_tabbing_format FAILED tests/test_write_strategies.py::TestWriteDatafile::test_write_parameter_skip_defaults FAILED tests/test_write_strategies.py::TestWriteDatafile::test_write_set FAILED tests/results/test_results_package.py::TestCalculateAnnualEmissions::test_null PASSED tests/results/test_results_package.py::TestCalculateAnnualEmissions::test_minimal PASSED tests/results/test_results_package.py::TestCalculateAnnualEmissions::test_missing_tech PASSED tests/results/test_results_package.py::TestCalculateAnnualTechnologyEmissions::test_null PASSED tests/results/test_results_package.py::TestCalculateAnnualTechnologyEmissions::test_minimal PASSED tests/results/test_results_package.py::TestCalculateAnnualTechnologyEmissions::test_no_zeros PASSED tests/results/test_results_package.py::TestCalculateAnnualTechnologyEmissionsByMode::test_null PASSED tests/results/test_results_package.py::TestCalculateAnnualTechnologyEmissionsByMode::test_minimal PASSED tests/results/test_results_package.py::TestCalculateAnnualTechnologyEmissionsByMode::test_no_zeros PASSED tests/results/test_results_package.py::TestDiscountedTechnologyEmissionsPenalty::test_calculate PASSED tests/results/test_results_package.py::TestAccumulatedNewCapacity::test_individual PASSED tests/results/test_results_package.py::TestAccumulatedNewCapacity::test_overlapping PASSED tests/results/test_results_package.py::TestAccumulatedNewCapacity::test_overlapping_bitty PASSED tests/results/test_results_package.py::TestComputeFixedandVariableOperatingCost::test_fixed PASSED tests/results/test_results_package.py::TestComputeFixedandVariableOperatingCost::test_null_fixed PASSED tests/results/test_results_package.py::TestComputeFixedandVariableOperatingCost::test_variable PASSED tests/results/test_results_package.py::TestComputeFixedandVariableOperatingCost::test_null_variable PASSED tests/results/test_results_package.py::TestComputeTotalAnnualCapacity::test_compute PASSED tests/results/test_results_package.py::TestComputeTotalAnnualCapacity::test_null PASSED tests/results/test_results_package.py::TestCapitalRecoveryFactor::test_crf PASSED tests/results/test_results_package.py::TestCapitalRecoveryFactor::test_crf_null PASSED tests/results/test_results_package.py::TestPvAnnuity::test_pva PASSED tests/results/test_results_package.py::TestPvAnnuity::test_pva_null PASSED tests/results/test_results_package.py::TestDiscountFactor::test_df_start FAILED tests/results/test_results_package.py::TestDiscountFactor::test_df_mid FAILED tests/results/test_results_package.py::TestDiscountFactor::test_df_end FAILED tests/results/test_results_package.py::TestDiscountFactor::test_df_null PASSED tests/results/test_results_package.py::TestDiscountFactorStorage::test_dfs_start PASSED tests/results/test_results_package.py::TestDiscountFactorStorage::test_dfs_mid PASSED tests/results/test_results_package.py::TestDiscountFactorStorage::test_dfs_end PASSED tests/results/test_results_package.py::TestDiscountFactorStorage::test_df_null PASSED tests/results/test_results_package.py::TestResultsPackage::test_results_package_init PASSED tests/results/test_results_package.py::TestResultsPackage::test_results_package_dummy_results PASSED ====================================================== FAILURES ======================================================= ______________________________________ TestConvert.test_convert_commands[excel] _______________________________________ self = commands = ['otoole', '-v', 'convert', 'datafile', 'excel', 'tests\\fixtures\\simplicity.txt', ...], expected = '' @mark.parametrize("commands,expected", test_data, ids=["help", "excel", "datafile"]) def test_convert_commands(self, commands, expected): actual = run(commands, capture_output=True) assert expected in str(actual.stdout) print(" ".join(commands)) > assert actual.returncode == 0, print(actual.stdout) E AssertionError: None E assert 1 == 0 E + where 1 = CompletedProcess(args=['otoole', '-v', 'convert', 'datafile', 'excel', 'tests\\fixtures\\simplicity.txt', 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmpp_6_i7ax.xlsx', 'tests\\fixtures\\config.yaml'], returncode=1, stdout=b'', stderr=b'INFO:otoole.convert:Reading config from tests\\fixtures\\config.yaml\r\nINFO:otoole.convert:Validating config from tests\\fixtures\\config.yaml\r\nINFO:root:Checking datatypes for AccumulatedAnnualDemand\r\nINFO:root:dtype of column REGION does not match str for parameter AccumulatedAnnualDemand\r\nINFO:root:dtype of column FUEL does not match str for parameter AccumulatedAnnualDemand\r\nINFO:root:dtype of column YEAR does not match int for parameter AccumulatedAnnualDemand\r\nINFO:root:Checking datatypes for AnnualEmissionLimit\r\nINFO:root:dtype of column REGION does not match str for parameter AnnualEmissionLimit\r\nINFO:root:dtype of column EMISSION does not match str for parameter AnnualEmissionLimit\r\nINFO:root:dtype of column YEAR does not match int for parameter AnnualEmissionLimit\r\nINFO:root:Checking datatypes for AnnualExogenousEmission\r\nINFO:root:dtype of column REGION does not match str for parameter AnnualExogenousEmission\r\nINFO:ro...ne 247, in write\r\n handle = self._header()\r\n ^^^^^^^^^^^^^^\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\write_strategies.py", line 15, in _header\r\n return pd.ExcelWriter(self.filepath, mode="w")\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\pandas\\io\\excel\\_openpyxl.py", line 60, in __init__\r\n super().__init__(\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\pandas\\io\\excel\\_base.py", line 1219, in __init__\r\n self._handles = get_handle(\r\n ^^^^^^^^^^^\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\pandas\\io\\common.py", line 868, in get_handle\r\n handle = open(handle, ioargs.mode)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^\r\nPermissionError: [Errno 13] Permission denied: \'C:\\\\Users\\\\Olex\\\\AppData\\\\Local\\\\Temp\\\\tmpp_6_i7ax.xlsx\'\r\n').returncode tests\test_cli.py:85: AssertionError _____________________________________ TestConvert.test_convert_commands[datafile] _____________________________________ self = commands = ['otoole', '-v', 'convert', 'datafile', 'datafile', 'tests\\fixtures\\simplicity.txt', ...], expected = '' @mark.parametrize("commands,expected", test_data, ids=["help", "excel", "datafile"]) def test_convert_commands(self, commands, expected): actual = run(commands, capture_output=True) assert expected in str(actual.stdout) print(" ".join(commands)) > assert actual.returncode == 0, print(actual.stdout) E AssertionError: None E assert 1 == 0 E + where 1 = CompletedProcess(args=['otoole', '-v', 'convert', 'datafile', 'datafile', 'tests\\fixtures\\simplicity.txt', 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmp43bw7ctq.dat', 'tests\\fixtures\\config.yaml'], returncode=1, stdout=b'', stderr=b'INFO:otoole.convert:Reading config from tests\\fixtures\\config.yaml\r\nINFO:otoole.convert:Validating config from tests\\fixtures\\config.yaml\r\nINFO:root:Checking datatypes for AccumulatedAnnualDemand\r\nINFO:root:dtype of column REGION does not match str for parameter AccumulatedAnnualDemand\r\nINFO:root:dtype of column FUEL does not match str for parameter AccumulatedAnnualDemand\r\nINFO:root:dtype of column YEAR does not match int for parameter AccumulatedAnnualDemand\r\nINFO:root:Checking datatypes for AnnualEmissionLimit\r\nINFO:root:dtype of column REGION does not match str for parameter AnnualEmissionLimit\r\nINFO:root:dtype of column EMISSION does not match str for parameter AnnualEmissionLimit\r\nINFO:root:dtype of column YEAR does not match int for parameter AnnualEmissionLimit\r\nINFO:root:Checking datatypes for AnnualExogenousEmission\r\nINFO:root:dtype of column REGION does not match str for parameter AnnualExogenousEmission\r\nINFO:...otoole\\convert.py", line 344, in convert\r\n context.convert(from_path, to_path)\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\input.py", line 114, in convert\r\n self._write(inputs, output_filepath, default_values, **kwargs)\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\input.py", line 103, in _write\r\n self._write_strategy.write(inputs, filepath, default_values, **kwargs)\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\input.py", line 247, in write\r\n handle = self._header()\r\n ^^^^^^^^^^^^^^\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\write_strategies.py", line 125, in _header\r\n filepath = open(self.filepath, "w", newline="")\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\nPermissionError: [Errno 13] Permission denied: \'C:\\\\Users\\\\Olex\\\\AppData\\\\Local\\\\Temp\\\\tmp43bw7ctq.dat\'\r\n').returncode tests\test_cli.py:85: AssertionError _____________________________ TestConvert.test_convert_datafile_datafile_with_user_config _____________________________ self = def test_convert_datafile_datafile_with_user_config(self): simplicity = os.path.join("tests", "fixtures", "simplicity.txt") user_config = os.path.join("tests", "fixtures", "config.yaml") temp_datafile = NamedTemporaryFile(suffix=".dat") commands = [ "otoole", "-vvv", "convert", "datafile", "datafile", simplicity, temp_datafile.name, user_config, ] actual = run(commands, capture_output=True) > assert actual.returncode == 0 E assert 1 == 0 E + where 1 = CompletedProcess(args=['otoole', '-vvv', 'convert', 'datafile', 'datafile', 'tests\\fixtures\\simplicity.txt', 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmp4_y2iu0l.dat', 'tests\\fixtures\\config.yaml'], returncode=1, stdout=b'', stderr=b'INFO:otoole.convert:Reading config from tests\\fixtures\\config.yaml\r\nINFO:otoole.convert:Validating config from tests\\fixtures\\config.yaml\r\nDEBUG:otoole.read_strategies:Amply Elements: param AccumulatedAnnualDemand {REGION,FUEL,YEAR};\r\nparam AnnualEmissionLimit {REGION,EMISSION,YEAR};\r\nparam AnnualExogenousEmission {REGION,EMISSION,YEAR};\r\nparam AvailabilityFactor {REGION,TECHNOLOGY,YEAR};\r\nparam CapacityFactor {REGION,TECHNOLOGY,TIMESLICE,YEAR};\r\nparam CapacityOfOneTechnologyUnit {REGION,TECHNOLOGY,YEAR};\r\nparam CapacityToActivityUnit {REGION,TECHNOLOGY};\r\nparam CapitalCost {REGION,TECHNOLOGY,YEAR};\r\nparam CapitalCostStorage {REGION,STORAGE,YEAR};\r\nparam Conversionld {TIMESLICE,DAYTYPE};\r\nparam Conversionlh {TIMESLICE,DAILYTIMEBRACKET};\r\nparam Conversionls {TIMESLICE,SEASON};\r\nset DAILYTIMEBRACKET;\r\nparam DaysInDayType {SEASON,DAYTYPE,YEAR};\r\nparam DaySplit {DAILYTIMEBRACKET,YEAR};\r\nset DAYTYPE;\r\nparam Depre...otoole\\convert.py", line 344, in convert\r\n context.convert(from_path, to_path)\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\input.py", line 114, in convert\r\n self._write(inputs, output_filepath, default_values, **kwargs)\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\input.py", line 103, in _write\r\n self._write_strategy.write(inputs, filepath, default_values, **kwargs)\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\input.py", line 247, in write\r\n handle = self._header()\r\n ^^^^^^^^^^^^^^\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\write_strategies.py", line 125, in _header\r\n filepath = open(self.filepath, "w", newline="")\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\nPermissionError: [Errno 13] Permission denied: \'C:\\\\Users\\\\Olex\\\\AppData\\\\Local\\\\Temp\\\\tmp4_y2iu0l.dat\'\r\n').returncode tests\test_cli.py:128: AssertionError ____________________________ TestConvert.test_convert_datafile_datafile_with_default_flag _____________________________ self = def test_convert_datafile_datafile_with_default_flag(self): simplicity = os.path.join("tests", "fixtures", "simplicity.txt") user_config = os.path.join("tests", "fixtures", "config.yaml") temp_datafile = NamedTemporaryFile(suffix=".dat") commands = [ "otoole", "-vvv", "convert", "datafile", "datafile", simplicity, temp_datafile.name, user_config, "--write_defaults", ] actual = run(commands, capture_output=True) > assert actual.returncode == 0 E assert 1 == 0 E + where 1 = CompletedProcess(args=['otoole', '-vvv', 'convert', 'datafile', 'datafile', 'tests\\fixtures\\simplicity.txt', 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmpmlc1jn7q.dat', 'tests\\fixtures\\config.yaml', '--write_defaults'], returncode=1, stdout=b'', stderr=b'INFO:otoole.convert:Reading config from tests\\fixtures\\config.yaml\r\nINFO:otoole.convert:Validating config from tests\\fixtures\\config.yaml\r\nDEBUG:otoole.read_strategies:Amply Elements: param AccumulatedAnnualDemand {REGION,FUEL,YEAR};\r\nparam AnnualEmissionLimit {REGION,EMISSION,YEAR};\r\nparam AnnualExogenousEmission {REGION,EMISSION,YEAR};\r\nparam AvailabilityFactor {REGION,TECHNOLOGY,YEAR};\r\nparam CapacityFactor {REGION,TECHNOLOGY,TIMESLICE,YEAR};\r\nparam CapacityOfOneTechnologyUnit {REGION,TECHNOLOGY,YEAR};\r\nparam CapacityToActivityUnit {REGION,TECHNOLOGY};\r\nparam CapitalCost {REGION,TECHNOLOGY,YEAR};\r\nparam CapitalCostStorage {REGION,STORAGE,YEAR};\r\nparam Conversionld {TIMESLICE,DAYTYPE};\r\nparam Conversionlh {TIMESLICE,DAILYTIMEBRACKET};\r\nparam Conversionls {TIMESLICE,SEASON};\r\nset DAILYTIMEBRACKET;\r\nparam DaysInDayType {SEASON,DAYTYPE,YEAR};\r\nparam DaySplit {DAILYTIMEBRACKET,YEAR};\r\nset DAY...otoole\\convert.py", line 344, in convert\r\n context.convert(from_path, to_path)\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\input.py", line 114, in convert\r\n self._write(inputs, output_filepath, default_values, **kwargs)\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\input.py", line 103, in _write\r\n self._write_strategy.write(inputs, filepath, default_values, **kwargs)\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\input.py", line 247, in write\r\n handle = self._header()\r\n ^^^^^^^^^^^^^^\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\write_strategies.py", line 125, in _header\r\n filepath = open(self.filepath, "w", newline="")\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\nPermissionError: [Errno 13] Permission denied: \'C:\\\\Users\\\\Olex\\\\AppData\\\\Local\\\\Temp\\\\tmpmlc1jn7q.dat\'\r\n').returncode tests\test_cli.py:146: AssertionError _________________________________ TestSetup.test_setup_commands[setup_with_overwrite] _________________________________ self = commands = ['otoole', '-v', 'setup', 'config', 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmp43t8rjik.yaml', '--overwrite'] expected = '' @mark.parametrize( "commands,expected", test_data, ids=["setup", "setup_with_overwrite"] ) def test_setup_commands(self, commands, expected): actual = run(commands, capture_output=True) assert expected in str(actual.stdout) print(" ".join(commands)) > assert actual.returncode == 0, print(actual.stdout) E AssertionError: None E assert 1 == 0 E + where 1 = CompletedProcess(args=['otoole', '-v', 'setup', 'config', 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmp43t8rjik.yaml', '--overwrite'], returncode=1, stdout=b'', stderr=b'Traceback (most recent call last):\r\n File "", line 198, in _run_module_as_main\r\n File "", line 88, in _run_code\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Scripts\\otoole.exe\\__main__.py", line 7, in \r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\cli.py", line 318, in main\r\n args.func(args)\r\n File "C:\\Users\\Olex\\Documents\\MANRID\\ResLab\\Playground\\otoole-review\\otoole\\.tox\\default\\Lib\\site-packages\\otoole\\cli.py", line 135, in setup\r\n shutil.copyfile(\r\n File "C:\\Program Files\\Python311\\Lib\\shutil.py", line 258, in copyfile\r\n with open(dst, \'wb\') as fdst:\r\n ^^^^^^^^^^^^^^^\r\nPermissionError: [Errno 13] Permission denied: \'C:\\\\Users\\\\Olex\\\\AppData\\\\Local\\\\Temp\\\\tmp43t8rjik.yaml\'\r\n').returncode tests\test_cli.py:175: AssertionError ____________________________________________ TestWrite.test_write_datafile ____________________________________________ self = def test_write_datafile(self): """Test writing data to a file""" data = {"REGION": pd.DataFrame({"VALUE": ["BB"]})} temp = NamedTemporaryFile() > assert write( os.path.join("tests", "fixtures", "config.yaml"), "datafile", temp.name, data, ) tests\test_convert.py:63: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox\default\Lib\site-packages\otoole\convert.py:409: in write write_strategy.write(inputs, to_path, {}) .tox\default\Lib\site-packages\otoole\input.py:247: in write handle = self._header() _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _header(self): > filepath = open(self.filepath, "w", newline="") E PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmprm0oug65' .tox\default\Lib\site-packages\otoole\write_strategies.py:125: PermissionError _____________________________________________ TestWrite.test_write_excel ______________________________________________ self = def test_write_excel(self): """Test writing data to an Excel file""" data = {"REGION": pd.DataFrame({"VALUE": ["BB"]})} temp = NamedTemporaryFile(suffix=".xlsx") > assert write( os.path.join("tests", "fixtures", "config.yaml"), "excel", temp.name, data ) tests\test_convert.py:74: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox\default\Lib\site-packages\otoole\convert.py:409: in write write_strategy.write(inputs, to_path, {}) .tox\default\Lib\site-packages\otoole\input.py:247: in write handle = self._header() .tox\default\Lib\site-packages\otoole\write_strategies.py:15: in _header return pd.ExcelWriter(self.filepath, mode="w") .tox\default\Lib\site-packages\pandas\io\excel\_openpyxl.py:60: in __init__ super().__init__( .tox\default\Lib\site-packages\pandas\io\excel\_base.py:1219: in __init__ self._handles = get_handle( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ path_or_buf = 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmp3zp799a3.xlsx', mode = 'wb' @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") def get_handle( path_or_buf: FilePath | BaseBuffer, mode: str, *, encoding: str | None = None, compression: CompressionOptions = None, memory_map: bool = False, is_text: bool = True, errors: str | None = None, storage_options: StorageOptions = None, ) -> IOHandles[str] | IOHandles[bytes]: """ Get file handle for given path/buffer and mode. Parameters ---------- path_or_buf : str or file handle File path or object. mode : str Mode to open path_or_buf with. encoding : str or None Encoding to use. {compression_options} .. versionchanged:: 1.0.0 May now be a dict with key 'method' as compression mode and other keys as compression options if compression mode is 'zip'. .. versionchanged:: 1.1.0 Passing compression options as keys in dict is now supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. .. versionchanged:: 1.4.0 Zstandard support. memory_map : bool, default False See parsers._parser_params for more information. Only used by read_csv. is_text : bool, default True Whether the type of the content passed to the file/buffer is string or bytes. This is not the same as `"b" not in mode`. If a string content is passed to a binary file/buffer, a wrapper is inserted. errors : str, default 'strict' Specifies how encoding and decoding errors are to be handled. See the errors argument for :func:`open` for a full list of options. storage_options: StorageOptions = None Passed to _get_filepath_or_buffer .. versionchanged:: 1.2.0 Returns the dataclass IOHandles """ # Windows does not default to utf-8. Set to utf-8 for a consistent behavior encoding = encoding or "utf-8" errors = errors or "strict" # read_csv does not know whether the buffer is opened in binary/text mode if _is_binary_mode(path_or_buf, mode) and "b" not in mode: mode += "b" # validate encoding and errors codecs.lookup(encoding) if isinstance(errors, str): codecs.lookup_error(errors) # open URLs ioargs = _get_filepath_or_buffer( path_or_buf, encoding=encoding, compression=compression, mode=mode, storage_options=storage_options, ) handle = ioargs.filepath_or_buffer handles: list[BaseBuffer] # memory mapping needs to be the first step # only used for read_csv handle, memory_map, handles = _maybe_memory_map(handle, memory_map) is_path = isinstance(handle, str) compression_args = dict(ioargs.compression) compression = compression_args.pop("method") # Only for write methods if "r" not in mode and is_path: check_parent_directory(str(handle)) if compression: if compression != "zstd": # compression libraries do not like an explicit text-mode ioargs.mode = ioargs.mode.replace("t", "") elif compression == "zstd" and "b" not in ioargs.mode: # python-zstandard defaults to text mode, but we always expect # compression libraries to use binary mode. ioargs.mode += "b" # GZ Compression if compression == "gzip": if isinstance(handle, str): # error: Incompatible types in assignment (expression has type # "GzipFile", variable has type "Union[str, BaseBuffer]") handle = gzip.GzipFile( # type: ignore[assignment] filename=handle, mode=ioargs.mode, **compression_args, ) else: handle = gzip.GzipFile( # No overload variant of "GzipFile" matches argument types # "Union[str, BaseBuffer]", "str", "Dict[str, Any]" fileobj=handle, # type: ignore[call-overload] mode=ioargs.mode, **compression_args, ) # BZ Compression elif compression == "bz2": # Overload of "BZ2File" to handle pickle protocol 5 # "Union[str, BaseBuffer]", "str", "Dict[str, Any]" handle = _BZ2File( # type: ignore[call-overload] handle, mode=ioargs.mode, **compression_args, ) # ZIP Compression elif compression == "zip": # error: Argument 1 to "_BytesZipFile" has incompatible type # "Union[str, BaseBuffer]"; expected "Union[Union[str, PathLike[str]], # ReadBuffer[bytes], WriteBuffer[bytes]]" handle = _BytesZipFile( handle, ioargs.mode, **compression_args # type: ignore[arg-type] ) if handle.buffer.mode == "r": handles.append(handle) zip_names = handle.buffer.namelist() if len(zip_names) == 1: handle = handle.buffer.open(zip_names.pop()) elif not zip_names: raise ValueError(f"Zero files found in ZIP file {path_or_buf}") else: raise ValueError( "Multiple files found in ZIP file. " f"Only one file per ZIP: {zip_names}" ) # TAR Encoding elif compression == "tar": compression_args.setdefault("mode", ioargs.mode) if isinstance(handle, str): handle = _BytesTarFile(name=handle, **compression_args) else: # error: Argument "fileobj" to "_BytesTarFile" has incompatible # type "BaseBuffer"; expected "Union[ReadBuffer[bytes], # WriteBuffer[bytes], None]" handle = _BytesTarFile( fileobj=handle, **compression_args # type: ignore[arg-type] ) assert isinstance(handle, _BytesTarFile) if "r" in handle.buffer.mode: handles.append(handle) files = handle.buffer.getnames() if len(files) == 1: file = handle.buffer.extractfile(files[0]) assert file is not None handle = file elif not files: raise ValueError(f"Zero files found in TAR archive {path_or_buf}") else: raise ValueError( "Multiple files found in TAR archive. " f"Only one file per TAR archive: {files}" ) # XZ Compression elif compression == "xz": # error: Argument 1 to "LZMAFile" has incompatible type "Union[str, # BaseBuffer]"; expected "Optional[Union[Union[str, bytes, PathLike[str], # PathLike[bytes]], IO[bytes]]]" handle = get_lzma_file()(handle, ioargs.mode) # type: ignore[arg-type] # Zstd Compression elif compression == "zstd": zstd = import_optional_dependency("zstandard") if "r" in ioargs.mode: open_args = {"dctx": zstd.ZstdDecompressor(**compression_args)} else: open_args = {"cctx": zstd.ZstdCompressor(**compression_args)} handle = zstd.open( handle, mode=ioargs.mode, **open_args, ) # Unrecognized Compression else: msg = f"Unrecognized compression type: {compression}" raise ValueError(msg) assert not isinstance(handle, str) handles.append(handle) elif isinstance(handle, str): # Check whether the filename is to be opened in binary mode. # Binary mode does not support 'encoding' and 'newline'. if ioargs.encoding and "b" not in ioargs.mode: # Encoding handle = open( handle, ioargs.mode, encoding=ioargs.encoding, errors=errors, newline="", ) else: # Binary mode > handle = open(handle, ioargs.mode) E PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmp3zp799a3.xlsx' .tox\default\Lib\site-packages\pandas\io\common.py:868: PermissionError _____________________________________ TestConvert.test_convert_excel_to_datafile ______________________________________ self = def test_convert_excel_to_datafile(self): """Test converting from Excel to datafile""" user_config = os.path.join("tests", "fixtures", "config.yaml") tmpfile = NamedTemporaryFile() from_path = os.path.join("tests", "fixtures", "combined_inputs.xlsx") > convert(user_config, "excel", "datafile", from_path, tmpfile.name) tests\test_convert.py:100: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox\default\Lib\site-packages\otoole\convert.py:344: in convert context.convert(from_path, to_path) .tox\default\Lib\site-packages\otoole\input.py:114: in convert self._write(inputs, output_filepath, default_values, **kwargs) .tox\default\Lib\site-packages\otoole\input.py:103: in _write self._write_strategy.write(inputs, filepath, default_values, **kwargs) .tox\default\Lib\site-packages\otoole\input.py:247: in write handle = self._header() _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _header(self): > filepath = open(self.filepath, "w", newline="") E PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmp8yq3382c' .tox\default\Lib\site-packages\otoole\write_strategies.py:125: PermissionError __________________________________________ TestReadResults.test_read_results __________________________________________ self = def test_read_results(self): config = os.path.join("tests", "fixtures", "super_simple", "super_simple.yaml") input_path = os.path.join("tests", "fixtures", "super_simple", "csv") input_format = "csv" from_format = "cbc" from_path = os.path.join( "tests", "fixtures", "super_simple", "super_simple_gnu.sol" ) actual, _ = read_results( config, from_format, from_path, input_format, input_path ) expected_data = [["BB", "gas_import", 2016, 2.342422]] expected_columns = ["REGION", "TECHNOLOGY", "YEAR", "VALUE"] index = ["REGION", "TECHNOLOGY", "YEAR"] expected_data_frame = pd.DataFrame( expected_data, columns=expected_columns ).set_index(index) > pd.testing.assert_frame_equal( actual["AccumulatedNewCapacity"], expected_data_frame ) tests\test_convert.py:153: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2016], dtype='int32', name='YEAR'), right = Index([2016], dtype='int64', name='YEAR') obj = 'MultiIndex level [2]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [2] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError ______________________________________ TestReadStrategy.test_check_index[param] _______________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} input_data = {'CapitalCost': VALUE REGION TECHNOLOGY YEAR SIMPLICITY NGCC 2014 1.23 2015 2.34 2016 3.45} expected = VALUE REGION TECHNOLOGY YEAR SIMPLICITY NGCC 2014 1.23 2015 2.34 2016 3.45 @mark.parametrize( "input_data, expected", input_data_correct, ids=["param", "set"], ) def test_check_index(self, user_config, input_data, expected): reader = DummyReadStrategy(user_config) actual = reader._check_index(input_data) for _, df in actual.items(): > pd.testing.assert_frame_equal(df, expected) tests\test_input.py:407: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2014, 2015, 2016], dtype='int32', name='YEAR') right = Index([2014, 2015, 2016], dtype='int64', name='YEAR'), obj = 'MultiIndex level [2]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [2] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError _______________________________________ TestReadStrategy.test_check_index[set] ________________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} input_data = {'YEAR': VALUE 0 2014 1 2015 2 2016}, expected = VALUE 0 2014 1 2015 2 2016 @mark.parametrize( "input_data, expected", input_data_correct, ids=["param", "set"], ) def test_check_index(self, user_config, input_data, expected): reader = DummyReadStrategy(user_config) actual = reader._check_index(input_data) for _, df in actual.items(): > pd.testing.assert_frame_equal(df, expected) E AssertionError: Attributes of DataFrame.iloc[:, 0] (column name="VALUE") are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 tests\test_input.py:407: AssertionError ___________________________________ TestReadStrategy.test_check_index_dtype[param] ____________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} input_data = {'CapitalCost': VALUE REGION TECHNOLOGY YEAR SIMPLICITY NGCC 2014 1.23 2015 2.34 2016 3.45} expected = VALUE REGION TECHNOLOGY YEAR SIMPLICITY NGCC 2014 1.23 2015 2.34 2016 3.45 @mark.parametrize( "input_data, expected", input_data_incorrect_dtype, ids=["param", "set"], ) def test_check_index_dtype(self, user_config, input_data, expected): reader = DummyReadStrategy(user_config) actual = reader._check_index(input_data) for _, df in actual.items(): > pd.testing.assert_frame_equal(df, expected) tests\test_input.py:418: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2014, 2015, 2016], dtype='int32', name='YEAR') right = Index([2014, 2015, 2016], dtype='int64', name='YEAR'), obj = 'MultiIndex level [2]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [2] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError ____________________________________ TestReadStrategy.test_check_index_dtype[set] _____________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} input_data = {'YEAR': VALUE 0 2014 1 2015 2 2016}, expected = VALUE 0 2014 1 2015 2 2016 @mark.parametrize( "input_data, expected", input_data_incorrect_dtype, ids=["param", "set"], ) def test_check_index_dtype(self, user_config, input_data, expected): reader = DummyReadStrategy(user_config) actual = reader._check_index(input_data) for _, df in actual.items(): > pd.testing.assert_frame_equal(df, expected) E AssertionError: Attributes of DataFrame.iloc[:, 0] (column name="VALUE") are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 tests\test_input.py:418: AssertionError ______________________________________ TestReadStrategy.test_check_dtypes[param] ______________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} input_data = {'CapitalCost': VALUE REGION TECHNOLOGY YEAR SIMPLICITY NGCC 2014 1.23 2015 2.34 2016 3.45} expected = VALUE REGION TECHNOLOGY YEAR SIMPLICITY NGCC 2014 1.23 2015 2.34 2016 3.45 @mark.parametrize( "input_data, expected", input_data_correct, ids=["param", "set"], ) def test_check_dtypes(self, user_config, input_data, expected): reader = DummyReadStrategy(user_config) for param, df in input_data.items(): actual = reader._check_index_dtypes( name=param, config=user_config[param], df=df ) > pd.testing.assert_frame_equal(actual, expected) tests\test_input.py:465: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2014, 2015, 2016], dtype='int32', name='YEAR') right = Index([2014, 2015, 2016], dtype='int64', name='YEAR'), obj = 'MultiIndex level [2]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [2] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError _______________________________________ TestReadStrategy.test_check_dtypes[set] _______________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} input_data = {'YEAR': VALUE 0 2014 1 2015 2 2016}, expected = VALUE 0 2014 1 2015 2 2016 @mark.parametrize( "input_data, expected", input_data_correct, ids=["param", "set"], ) def test_check_dtypes(self, user_config, input_data, expected): reader = DummyReadStrategy(user_config) for param, df in input_data.items(): actual = reader._check_index_dtypes( name=param, config=user_config[param], df=df ) > pd.testing.assert_frame_equal(actual, expected) E AssertionError: Attributes of DataFrame.iloc[:, 0] (column name="VALUE") are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 tests\test_input.py:465: AssertionError _ TestReadCbc.test_read_cbc_to_otoole_dataframe[0 Trade(Globe,Globe,IP,L_AGR,2015) -0.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2016) -1.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2017) -2.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2018) -3.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2019) -4.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2020) -5.0 0\n-expected0] _ self = cbc_input = '0 Trade(Globe,Globe,IP,L_AGR,2015) -0.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2016) -1.0 0\n0 Trade(Globe,Globe,IP,L_AGR,20...be,Globe,IP,L_AGR,2018) -3.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2019) -4.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2020) -5.0 0\n' expected = VALUE REGION _REGION TIMESLICE FUEL YEAR Globe Globe IP L_AGR 2... 2018 -3.0 2019 -4.0 2020 -5.0 user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} @mark.parametrize("cbc_input,expected", test_data) def test_read_cbc_to_otoole_dataframe(self, cbc_input, expected, user_config): with StringIO(cbc_input) as file_buffer: actual = ReadCbc(user_config).read(file_buffer, kwargs={"input_data": {}})[ 0 ]["Trade"] > pd.testing.assert_frame_equal(actual, expected) tests\test_read_strategies.py:271: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2016, 2017, 2018, 2019, 2020], dtype='int32', name='YEAR') right = Index([2016, 2017, 2018, 2019, 2020], dtype='int64', name='YEAR'), obj = 'MultiIndex level [4]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [4] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError _______________________________ TestReadCbc.test_read_cbc_dataframe_to_otoole_dataframe _______________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} def test_read_cbc_dataframe_to_otoole_dataframe(self, user_config): prelim_data = pd.DataFrame( data=[ ["Trade", "Globe,Globe,IP,L_AGR,2016", -1.0], ["Trade", "Globe,Globe,IP,L_AGR,2017", -2.0], ["Trade", "Globe,Globe,IP,L_AGR,2018", -3.0], ["Trade", "Globe,Globe,IP,L_AGR,2019", -4.0], ["Trade", "Globe,Globe,IP,L_AGR,2020", -5.0], ], columns=["Variable", "Index", "Value"], ) actual = ReadCbc(user_config)._convert_wide_to_long(prelim_data)["Trade"] > pd.testing.assert_frame_equal(actual, self.otoole_data) tests\test_read_strategies.py:286: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2016, 2017, 2018, 2019, 2020], dtype='int32', name='YEAR') right = Index([2016, 2017, 2018, 2019, 2020], dtype='int64', name='YEAR'), obj = 'MultiIndex level [4]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [4] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError ____________________________ TestReadCbc.test_convert_cbc_to_csv_long[TotalDiscountedCost] ____________________________ self = results = Variable Index Value 0 TotalDiscountedCost SIMPLICITY,2015 187.01576 1 TotalDiscount...Y,2018 218.08923 4 TotalDiscountedCost SIMPLICITY,2019 193.85792 5 TotalDiscountedCost SIMPLICITY,2020 233.79202 expected = {'TotalDiscountedCost': VALUE REGION YEAR SIMPLICITY 2015 187.01576 2016 183.30788 2017 181.05465 2018 218.08923 2019 193.85792 2020 233.79202} user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} @mark.parametrize( "results,expected", test_data_2, ids=["TotalDiscountedCost", "AnnualEmissions1"], ) def test_convert_cbc_to_csv_long(self, results, expected, user_config): cbc_reader = ReadCbc(user_config=user_config) actual = cbc_reader._convert_wide_to_long(results) assert isinstance(actual, dict) for name, df in actual.items(): > pd.testing.assert_frame_equal(df, expected[name]) tests\test_read_strategies.py:399: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2015, 2016, 2017, 2018, 2019, 2020], dtype='int32', name='YEAR') right = Index([2015, 2016, 2017, 2018, 2019, 2020], dtype='int64', name='YEAR'), obj = 'MultiIndex level [1]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [1] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError _____________________________ TestReadCbc.test_convert_cbc_to_csv_long[AnnualEmissions1] ______________________________ self = results = Variable Index Value 0 AnnualEmissions REGION,CO2,2017 137958.840038 1 AnnualEmissions REGION,CO2,2018 305945.384106 2 AnnualEmissions REGION,CO2,2019 626159.961154 expected = {'AnnualEmissions': VALUE REGION EMISSION YEAR REGION CO2 2017 137958.840038 2018 305945.384106 2019 626159.961154} user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} @mark.parametrize( "results,expected", test_data_2, ids=["TotalDiscountedCost", "AnnualEmissions1"], ) def test_convert_cbc_to_csv_long(self, results, expected, user_config): cbc_reader = ReadCbc(user_config=user_config) actual = cbc_reader._convert_wide_to_long(results) assert isinstance(actual, dict) for name, df in actual.items(): > pd.testing.assert_frame_equal(df, expected[name]) tests\test_read_strategies.py:399: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2017, 2018, 2019], dtype='int32', name='YEAR') right = Index([2017, 2018, 2019], dtype='int64', name='YEAR'), obj = 'MultiIndex level [2]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [2] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError _________________________ TestReadCbc.test_convert_cbc_to_csv_long_read[TotalDiscountedCost] __________________________ self = cbc_solution = 'Optimal - objective value 4483.96932237\n 1 TotalDiscountedCost(SIMPLICITY,2015) ...iscountedCost(SIMPLICITY,2020) 233.79202 0\n\n' input_data = {} expected = {'TotalDiscountedCost': VALUE REGION YEAR SIMPLICITY 2015 187.01576 2016 183.30788 2017 181.05465 2018 218.08923 2019 193.85792 2020 233.79202} user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} @mark.parametrize( "cbc_solution,input_data,expected", test_data_3, ids=["TotalDiscountedCost"], ) def test_convert_cbc_to_csv_long_read( self, cbc_solution, input_data, expected, user_config ): cbc_reader = ReadCbc(user_config=user_config) with StringIO(cbc_solution) as file_buffer: actual = cbc_reader.read(file_buffer, kwargs={"input_data": input_data})[0][ "TotalDiscountedCost" ] assert isinstance(actual, pd.DataFrame) > pd.testing.assert_frame_equal(actual, expected["TotalDiscountedCost"]) tests\test_read_strategies.py:417: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2015, 2016, 2017, 2018, 2019, 2020], dtype='int32', name='YEAR') right = Index([2015, 2016, 2017, 2018, 2019, 2020], dtype='int64', name='YEAR'), obj = 'MultiIndex level [1]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [1] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError _______________________________________ TestReadCbc.test_solution_to_dataframe ________________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} def test_solution_to_dataframe(self, user_config): input_file = self.total_cost_cbc reader = ReadCbc(user_config) with StringIO(input_file) as file_buffer: actual = reader.read(file_buffer) expected = self.total_cost_otoole_df > pd.testing.assert_frame_equal( actual[0]["TotalDiscountedCost"], expected["TotalDiscountedCost"] ) tests\test_read_strategies.py:491: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2015, 2016, 2017, 2018, 2019, 2020], dtype='int32', name='YEAR') right = Index([2015, 2016, 2017, 2018, 2019, 2020], dtype='int64', name='YEAR'), obj = 'MultiIndex level [1]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [1] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError ____________________________________________ TestReadGlpk.test_read_model _____________________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} def test_read_model(self, user_config): model_data = self.model_data with StringIO(model_data) as file_buffer: reader = ReadGlpk(user_config=user_config, glpk_model=file_buffer) actual = reader.model expected = pd.DataFrame( [ ["i", 2, "CAa4_Constraint_Capacity", "SIMPLICITY,ID,BACKSTOP1,2014"], ["i", 3, "CAa4_Constraint_Capacity", "SIMPLICITY,ID,BACKSTOP1,2015"], ["i", 300, "CAa4_Constraint_Capacity", "SIMPLICITY,ID,LNDFORCOV,2015"], ["i", 301, "CAa4_Constraint_Capacity", "SIMPLICITY,ID,LNDFORCOV,2016"], ["j", 1, "SalvageValueStorage", "SIMPLICITY,DAM,2014"], ["j", 2, "SalvageValueStorage", "SIMPLICITY,DAM,2015"], ["j", 130, "StorageLevelSeasonStart", "SIMPLICITY,DAM,2,2035"], ["j", 131, "StorageLevelSeasonStart", "SIMPLICITY,DAM,2,2036"], ["j", 1025, "NewCapacity", "SIMPLICITY,WINDPOWER,2039"], ["j", 1026, "NewCapacity", "SIMPLICITY,WINDPOWER,2040"], ["j", 1027, "RateOfActivity", "SIMPLICITY,ID,BACKSTOP1,1,2014"], ["j", 1028, "RateOfActivity", "SIMPLICITY,IN,BACKSTOP1,1,2014"], ], columns=["ID", "NUM", "NAME", "INDEX"], ) > pd.testing.assert_frame_equal(actual, expected) E AssertionError: Attributes of DataFrame.iloc[:, 1] (column name="NUM") are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 tests\test_read_strategies.py:628: AssertionError ___________________________________________ TestReadGlpk.test_read_solution ___________________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} def test_read_solution(self, user_config): model_data = self.model_data sol_data = self.sol_data with StringIO(model_data) as file_buffer: reader = ReadGlpk(user_config=user_config, glpk_model=file_buffer) with StringIO(sol_data) as file_buffer: actual_status, actual_data = reader.read_solution(file_buffer) expected_status = { "name": "osemosys_fast", "status": "OPTIMAL", "objective": 4497.31967, } assert actual_status == expected_status > pd.testing.assert_frame_equal(actual_data, self.expected_solution) E AssertionError: Attributes of DataFrame.iloc[:, 1] (column name="NUM") are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 tests\test_read_strategies.py:645: AssertionError _______________________________________ TestReadMemoryStrategy.test_read_memory _______________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} def test_read_memory(self, user_config): data = [ ["SIMPLICITY", "ETH", 2014, 1.0], ["SIMPLICITY", "RAWSUG", 2014, 0.5], ["SIMPLICITY", "ETH", 2015, 1.03], ["SIMPLICITY", "RAWSUG", 2015, 0.51], ] df = pd.DataFrame(data=data, columns=["REGION", "FUEL", "YEAR", "VALUE"]) parameters = {"AccumulatedAnnualDemand": df} actual, default_values = ReadMemory(parameters, user_config).read() expected = { "AccumulatedAnnualDemand": pd.DataFrame( data=data, columns=["REGION", "FUEL", "YEAR", "VALUE"] ).set_index(["REGION", "FUEL", "YEAR"]) } assert "AccumulatedAnnualDemand" in actual.keys() > pd.testing.assert_frame_equal( actual["AccumulatedAnnualDemand"], expected["AccumulatedAnnualDemand"] ) tests\test_read_strategies.py:791: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2014, 2014, 2015, 2015], dtype='int32', name='YEAR') right = Index([2014, 2014, 2015, 2015], dtype='int64', name='YEAR'), obj = 'MultiIndex level [2]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [2] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError _________________________________ TestReadMemoryStrategy.test_read_memory_user_config _________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} def test_read_memory_user_config(self, user_config): data = [ ["SIMPLICITY", "ETH", 2014, 1.0], ["SIMPLICITY", "RAWSUG", 2014, 0.5], ["SIMPLICITY", "ETH", 2015, 1.03], ["SIMPLICITY", "RAWSUG", 2015, 0.51], ] df = pd.DataFrame(data=data, columns=["REGION", "FUEL", "YEAR", "VALUE"]) parameters = {"AccumulatedAnnualDemand": df} actual, default_values = ReadMemory(parameters, user_config=user_config).read() expected = { "AccumulatedAnnualDemand": pd.DataFrame( data=data, columns=["REGION", "FUEL", "YEAR", "VALUE"] ).set_index(["REGION", "FUEL", "YEAR"]) } assert "AccumulatedAnnualDemand" in actual.keys() > pd.testing.assert_frame_equal( actual["AccumulatedAnnualDemand"], expected["AccumulatedAnnualDemand"] ) tests\test_read_strategies.py:815: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2014, 2014, 2015, 2015], dtype='int32', name='YEAR') right = Index([2014, 2014, 2015, 2015], dtype='int64', name='YEAR'), obj = 'MultiIndex level [2]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [2] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError ___________________________________________ TestReadExcel.test_check_index ____________________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} def test_check_index(self, user_config): data = [ ["IW0016", 2017, 0.238356164], ["IW0016", 2018, 0.238356164], ["IW0016", 2019, 0.238356164], ["IW1624", 2017, 0.119178082], ["IW1624", 2018, 0.119178082], ["IW1624", 2019, 0.119178082], ["IH0012", 2017, 0.071232876], ["IH0012", 2018, 0.071232876], ["IH0012", 2019, 0.071232876], ] df = { "YearSplit": pd.DataFrame(data, columns=["TIMESLICE", "YEAR", "VALUE"]) .astype({"YEAR": object}) .set_index(["TIMESLICE", "YEAR"]) } reader = ReadExcel(user_config=user_config) actual = reader._check_index(df) expected = { "YearSplit": pd.DataFrame( data, columns=["TIMESLICE", "YEAR", "VALUE"] ).set_index(["TIMESLICE", "YEAR"]) } > pd.testing.assert_frame_equal(actual["YearSplit"], expected["YearSplit"]) tests\test_read_strategies.py:1091: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2017, 2018, 2019, 2017, 2018, 2019, 2017, 2018, 2019], dtype='int32', name='YEAR') right = Index([2017, 2018, 2019, 2017, 2018, 2019, 2017, 2018, 2019], dtype='int64', name='YEAR') obj = 'MultiIndex level [1]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [1] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError _______________________________________________ test_get_csv_setup_data _______________________________________________ def test_get_csv_setup_data(): config = { "AccumulatedAnnualDemand": { "indices": ["REGION", "FUEL", "YEAR"], "type": "param", "dtype": "float", "default": 0, }, "REGION": { "dtype": "str", "type": "set", }, "FUEL": { "dtype": "str", "type": "set", }, "YEAR": { "dtype": "int", "type": "set", }, "Demand": { "indices": ["REGION", "TIMESLICE", "FUEL", "YEAR"], "type": "result", "dtype": "float", "default": 0, }, } accumulated_annual_demand = pd.DataFrame( columns=["REGION", "FUEL", "YEAR", "VALUE"] ).astype( { "REGION": "str", "FUEL": "str", "YEAR": "int64", "VALUE": "float", } ) expected_inputs = { "AccumulatedAnnualDemand": accumulated_annual_demand.set_index( ["REGION", "FUEL", "YEAR"] ), "REGION": pd.DataFrame(columns=["VALUE"]), "FUEL": pd.DataFrame(columns=["VALUE"]), "YEAR": pd.DataFrame(columns=["VALUE"]), } expected_defaults = { "AccumulatedAnnualDemand": 0, "Demand": 0, } actual_inputs, actual_defaults = get_csv_setup_data(config) > assert_frame_equal( actual_inputs["AccumulatedAnnualDemand"], expected_inputs["AccumulatedAnnualDemand"], ) tests\test_setup.py:59: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([], dtype='int32', name='YEAR'), right = Index([], dtype='int64', name='YEAR') obj = 'MultiIndex level [2]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [2] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError ____________________________________ test_excel_name_length_error[full_name_error] ____________________________________ user_config_simple = 'user_config_long_param_name' request = > @pytest.mark.parametrize( "user_config_simple", user_config_name_errors, ids=["full_name_error", "short_name_error"], ) def test_excel_name_length_error(user_config_simple, request): user_config = request.getfixturevalue(user_config_simple) write_excel = WriteExcel(user_config=user_config) temp_excel = NamedTemporaryFile(suffix=".xlsx") > handle = pd.ExcelWriter(temp_excel.name) tests\test_utils.py:81: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox\default\Lib\site-packages\pandas\io\excel\_openpyxl.py:60: in __init__ super().__init__( .tox\default\Lib\site-packages\pandas\io\excel\_base.py:1219: in __init__ self._handles = get_handle( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ path_or_buf = 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmpv3g3rcp4.xlsx', mode = 'wb' @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") def get_handle( path_or_buf: FilePath | BaseBuffer, mode: str, *, encoding: str | None = None, compression: CompressionOptions = None, memory_map: bool = False, is_text: bool = True, errors: str | None = None, storage_options: StorageOptions = None, ) -> IOHandles[str] | IOHandles[bytes]: """ Get file handle for given path/buffer and mode. Parameters ---------- path_or_buf : str or file handle File path or object. mode : str Mode to open path_or_buf with. encoding : str or None Encoding to use. {compression_options} .. versionchanged:: 1.0.0 May now be a dict with key 'method' as compression mode and other keys as compression options if compression mode is 'zip'. .. versionchanged:: 1.1.0 Passing compression options as keys in dict is now supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. .. versionchanged:: 1.4.0 Zstandard support. memory_map : bool, default False See parsers._parser_params for more information. Only used by read_csv. is_text : bool, default True Whether the type of the content passed to the file/buffer is string or bytes. This is not the same as `"b" not in mode`. If a string content is passed to a binary file/buffer, a wrapper is inserted. errors : str, default 'strict' Specifies how encoding and decoding errors are to be handled. See the errors argument for :func:`open` for a full list of options. storage_options: StorageOptions = None Passed to _get_filepath_or_buffer .. versionchanged:: 1.2.0 Returns the dataclass IOHandles """ # Windows does not default to utf-8. Set to utf-8 for a consistent behavior encoding = encoding or "utf-8" errors = errors or "strict" # read_csv does not know whether the buffer is opened in binary/text mode if _is_binary_mode(path_or_buf, mode) and "b" not in mode: mode += "b" # validate encoding and errors codecs.lookup(encoding) if isinstance(errors, str): codecs.lookup_error(errors) # open URLs ioargs = _get_filepath_or_buffer( path_or_buf, encoding=encoding, compression=compression, mode=mode, storage_options=storage_options, ) handle = ioargs.filepath_or_buffer handles: list[BaseBuffer] # memory mapping needs to be the first step # only used for read_csv handle, memory_map, handles = _maybe_memory_map(handle, memory_map) is_path = isinstance(handle, str) compression_args = dict(ioargs.compression) compression = compression_args.pop("method") # Only for write methods if "r" not in mode and is_path: check_parent_directory(str(handle)) if compression: if compression != "zstd": # compression libraries do not like an explicit text-mode ioargs.mode = ioargs.mode.replace("t", "") elif compression == "zstd" and "b" not in ioargs.mode: # python-zstandard defaults to text mode, but we always expect # compression libraries to use binary mode. ioargs.mode += "b" # GZ Compression if compression == "gzip": if isinstance(handle, str): # error: Incompatible types in assignment (expression has type # "GzipFile", variable has type "Union[str, BaseBuffer]") handle = gzip.GzipFile( # type: ignore[assignment] filename=handle, mode=ioargs.mode, **compression_args, ) else: handle = gzip.GzipFile( # No overload variant of "GzipFile" matches argument types # "Union[str, BaseBuffer]", "str", "Dict[str, Any]" fileobj=handle, # type: ignore[call-overload] mode=ioargs.mode, **compression_args, ) # BZ Compression elif compression == "bz2": # Overload of "BZ2File" to handle pickle protocol 5 # "Union[str, BaseBuffer]", "str", "Dict[str, Any]" handle = _BZ2File( # type: ignore[call-overload] handle, mode=ioargs.mode, **compression_args, ) # ZIP Compression elif compression == "zip": # error: Argument 1 to "_BytesZipFile" has incompatible type # "Union[str, BaseBuffer]"; expected "Union[Union[str, PathLike[str]], # ReadBuffer[bytes], WriteBuffer[bytes]]" handle = _BytesZipFile( handle, ioargs.mode, **compression_args # type: ignore[arg-type] ) if handle.buffer.mode == "r": handles.append(handle) zip_names = handle.buffer.namelist() if len(zip_names) == 1: handle = handle.buffer.open(zip_names.pop()) elif not zip_names: raise ValueError(f"Zero files found in ZIP file {path_or_buf}") else: raise ValueError( "Multiple files found in ZIP file. " f"Only one file per ZIP: {zip_names}" ) # TAR Encoding elif compression == "tar": compression_args.setdefault("mode", ioargs.mode) if isinstance(handle, str): handle = _BytesTarFile(name=handle, **compression_args) else: # error: Argument "fileobj" to "_BytesTarFile" has incompatible # type "BaseBuffer"; expected "Union[ReadBuffer[bytes], # WriteBuffer[bytes], None]" handle = _BytesTarFile( fileobj=handle, **compression_args # type: ignore[arg-type] ) assert isinstance(handle, _BytesTarFile) if "r" in handle.buffer.mode: handles.append(handle) files = handle.buffer.getnames() if len(files) == 1: file = handle.buffer.extractfile(files[0]) assert file is not None handle = file elif not files: raise ValueError(f"Zero files found in TAR archive {path_or_buf}") else: raise ValueError( "Multiple files found in TAR archive. " f"Only one file per TAR archive: {files}" ) # XZ Compression elif compression == "xz": # error: Argument 1 to "LZMAFile" has incompatible type "Union[str, # BaseBuffer]"; expected "Optional[Union[Union[str, bytes, PathLike[str], # PathLike[bytes]], IO[bytes]]]" handle = get_lzma_file()(handle, ioargs.mode) # type: ignore[arg-type] # Zstd Compression elif compression == "zstd": zstd = import_optional_dependency("zstandard") if "r" in ioargs.mode: open_args = {"dctx": zstd.ZstdDecompressor(**compression_args)} else: open_args = {"cctx": zstd.ZstdCompressor(**compression_args)} handle = zstd.open( handle, mode=ioargs.mode, **open_args, ) # Unrecognized Compression else: msg = f"Unrecognized compression type: {compression}" raise ValueError(msg) assert not isinstance(handle, str) handles.append(handle) elif isinstance(handle, str): # Check whether the filename is to be opened in binary mode. # Binary mode does not support 'encoding' and 'newline'. if ioargs.encoding and "b" not in ioargs.mode: # Encoding handle = open( handle, ioargs.mode, encoding=ioargs.encoding, errors=errors, newline="", ) else: # Binary mode > handle = open(handle, ioargs.mode) E PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmpv3g3rcp4.xlsx' .tox\default\Lib\site-packages\pandas\io\common.py:868: PermissionError ___________________________________ test_excel_name_length_error[short_name_error] ____________________________________ user_config_simple = 'user_config_long_short_name' request = > @pytest.mark.parametrize( "user_config_simple", user_config_name_errors, ids=["full_name_error", "short_name_error"], ) def test_excel_name_length_error(user_config_simple, request): user_config = request.getfixturevalue(user_config_simple) write_excel = WriteExcel(user_config=user_config) temp_excel = NamedTemporaryFile(suffix=".xlsx") > handle = pd.ExcelWriter(temp_excel.name) tests\test_utils.py:81: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox\default\Lib\site-packages\pandas\io\excel\_openpyxl.py:60: in __init__ super().__init__( .tox\default\Lib\site-packages\pandas\io\excel\_base.py:1219: in __init__ self._handles = get_handle( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ path_or_buf = 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmptnznukur.xlsx', mode = 'wb' @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") def get_handle( path_or_buf: FilePath | BaseBuffer, mode: str, *, encoding: str | None = None, compression: CompressionOptions = None, memory_map: bool = False, is_text: bool = True, errors: str | None = None, storage_options: StorageOptions = None, ) -> IOHandles[str] | IOHandles[bytes]: """ Get file handle for given path/buffer and mode. Parameters ---------- path_or_buf : str or file handle File path or object. mode : str Mode to open path_or_buf with. encoding : str or None Encoding to use. {compression_options} .. versionchanged:: 1.0.0 May now be a dict with key 'method' as compression mode and other keys as compression options if compression mode is 'zip'. .. versionchanged:: 1.1.0 Passing compression options as keys in dict is now supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. .. versionchanged:: 1.4.0 Zstandard support. memory_map : bool, default False See parsers._parser_params for more information. Only used by read_csv. is_text : bool, default True Whether the type of the content passed to the file/buffer is string or bytes. This is not the same as `"b" not in mode`. If a string content is passed to a binary file/buffer, a wrapper is inserted. errors : str, default 'strict' Specifies how encoding and decoding errors are to be handled. See the errors argument for :func:`open` for a full list of options. storage_options: StorageOptions = None Passed to _get_filepath_or_buffer .. versionchanged:: 1.2.0 Returns the dataclass IOHandles """ # Windows does not default to utf-8. Set to utf-8 for a consistent behavior encoding = encoding or "utf-8" errors = errors or "strict" # read_csv does not know whether the buffer is opened in binary/text mode if _is_binary_mode(path_or_buf, mode) and "b" not in mode: mode += "b" # validate encoding and errors codecs.lookup(encoding) if isinstance(errors, str): codecs.lookup_error(errors) # open URLs ioargs = _get_filepath_or_buffer( path_or_buf, encoding=encoding, compression=compression, mode=mode, storage_options=storage_options, ) handle = ioargs.filepath_or_buffer handles: list[BaseBuffer] # memory mapping needs to be the first step # only used for read_csv handle, memory_map, handles = _maybe_memory_map(handle, memory_map) is_path = isinstance(handle, str) compression_args = dict(ioargs.compression) compression = compression_args.pop("method") # Only for write methods if "r" not in mode and is_path: check_parent_directory(str(handle)) if compression: if compression != "zstd": # compression libraries do not like an explicit text-mode ioargs.mode = ioargs.mode.replace("t", "") elif compression == "zstd" and "b" not in ioargs.mode: # python-zstandard defaults to text mode, but we always expect # compression libraries to use binary mode. ioargs.mode += "b" # GZ Compression if compression == "gzip": if isinstance(handle, str): # error: Incompatible types in assignment (expression has type # "GzipFile", variable has type "Union[str, BaseBuffer]") handle = gzip.GzipFile( # type: ignore[assignment] filename=handle, mode=ioargs.mode, **compression_args, ) else: handle = gzip.GzipFile( # No overload variant of "GzipFile" matches argument types # "Union[str, BaseBuffer]", "str", "Dict[str, Any]" fileobj=handle, # type: ignore[call-overload] mode=ioargs.mode, **compression_args, ) # BZ Compression elif compression == "bz2": # Overload of "BZ2File" to handle pickle protocol 5 # "Union[str, BaseBuffer]", "str", "Dict[str, Any]" handle = _BZ2File( # type: ignore[call-overload] handle, mode=ioargs.mode, **compression_args, ) # ZIP Compression elif compression == "zip": # error: Argument 1 to "_BytesZipFile" has incompatible type # "Union[str, BaseBuffer]"; expected "Union[Union[str, PathLike[str]], # ReadBuffer[bytes], WriteBuffer[bytes]]" handle = _BytesZipFile( handle, ioargs.mode, **compression_args # type: ignore[arg-type] ) if handle.buffer.mode == "r": handles.append(handle) zip_names = handle.buffer.namelist() if len(zip_names) == 1: handle = handle.buffer.open(zip_names.pop()) elif not zip_names: raise ValueError(f"Zero files found in ZIP file {path_or_buf}") else: raise ValueError( "Multiple files found in ZIP file. " f"Only one file per ZIP: {zip_names}" ) # TAR Encoding elif compression == "tar": compression_args.setdefault("mode", ioargs.mode) if isinstance(handle, str): handle = _BytesTarFile(name=handle, **compression_args) else: # error: Argument "fileobj" to "_BytesTarFile" has incompatible # type "BaseBuffer"; expected "Union[ReadBuffer[bytes], # WriteBuffer[bytes], None]" handle = _BytesTarFile( fileobj=handle, **compression_args # type: ignore[arg-type] ) assert isinstance(handle, _BytesTarFile) if "r" in handle.buffer.mode: handles.append(handle) files = handle.buffer.getnames() if len(files) == 1: file = handle.buffer.extractfile(files[0]) assert file is not None handle = file elif not files: raise ValueError(f"Zero files found in TAR archive {path_or_buf}") else: raise ValueError( "Multiple files found in TAR archive. " f"Only one file per TAR archive: {files}" ) # XZ Compression elif compression == "xz": # error: Argument 1 to "LZMAFile" has incompatible type "Union[str, # BaseBuffer]"; expected "Optional[Union[Union[str, bytes, PathLike[str], # PathLike[bytes]], IO[bytes]]]" handle = get_lzma_file()(handle, ioargs.mode) # type: ignore[arg-type] # Zstd Compression elif compression == "zstd": zstd = import_optional_dependency("zstandard") if "r" in ioargs.mode: open_args = {"dctx": zstd.ZstdDecompressor(**compression_args)} else: open_args = {"cctx": zstd.ZstdCompressor(**compression_args)} handle = zstd.open( handle, mode=ioargs.mode, **open_args, ) # Unrecognized Compression else: msg = f"Unrecognized compression type: {compression}" raise ValueError(msg) assert not isinstance(handle, str) handles.append(handle) elif isinstance(handle, str): # Check whether the filename is to be opened in binary mode. # Binary mode does not support 'encoding' and 'newline'. if ioargs.encoding and "b" not in ioargs.mode: # Encoding handle = open( handle, ioargs.mode, encoding=ioargs.encoding, errors=errors, newline="", ) else: # Binary mode > handle = open(handle, ioargs.mode) E PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmptnznukur.xlsx' .tox\default\Lib\site-packages\pandas\io\common.py:868: PermissionError ____________________________________ TestWriteExcel.test_write_out_empty_dataframe ____________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'FUEL', 'YEAR'], 'type': 'param'}, ... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} def test_write_out_empty_dataframe(self, user_config): temp_excel = NamedTemporaryFile(suffix=".xlsx") > handle = pd.ExcelWriter(temp_excel.name) tests\test_write_strategies.py:118: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox\default\Lib\site-packages\pandas\io\excel\_openpyxl.py:60: in __init__ super().__init__( .tox\default\Lib\site-packages\pandas\io\excel\_base.py:1219: in __init__ self._handles = get_handle( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ path_or_buf = 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmpwnvhugo0.xlsx', mode = 'wb' @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") def get_handle( path_or_buf: FilePath | BaseBuffer, mode: str, *, encoding: str | None = None, compression: CompressionOptions = None, memory_map: bool = False, is_text: bool = True, errors: str | None = None, storage_options: StorageOptions = None, ) -> IOHandles[str] | IOHandles[bytes]: """ Get file handle for given path/buffer and mode. Parameters ---------- path_or_buf : str or file handle File path or object. mode : str Mode to open path_or_buf with. encoding : str or None Encoding to use. {compression_options} .. versionchanged:: 1.0.0 May now be a dict with key 'method' as compression mode and other keys as compression options if compression mode is 'zip'. .. versionchanged:: 1.1.0 Passing compression options as keys in dict is now supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. .. versionchanged:: 1.4.0 Zstandard support. memory_map : bool, default False See parsers._parser_params for more information. Only used by read_csv. is_text : bool, default True Whether the type of the content passed to the file/buffer is string or bytes. This is not the same as `"b" not in mode`. If a string content is passed to a binary file/buffer, a wrapper is inserted. errors : str, default 'strict' Specifies how encoding and decoding errors are to be handled. See the errors argument for :func:`open` for a full list of options. storage_options: StorageOptions = None Passed to _get_filepath_or_buffer .. versionchanged:: 1.2.0 Returns the dataclass IOHandles """ # Windows does not default to utf-8. Set to utf-8 for a consistent behavior encoding = encoding or "utf-8" errors = errors or "strict" # read_csv does not know whether the buffer is opened in binary/text mode if _is_binary_mode(path_or_buf, mode) and "b" not in mode: mode += "b" # validate encoding and errors codecs.lookup(encoding) if isinstance(errors, str): codecs.lookup_error(errors) # open URLs ioargs = _get_filepath_or_buffer( path_or_buf, encoding=encoding, compression=compression, mode=mode, storage_options=storage_options, ) handle = ioargs.filepath_or_buffer handles: list[BaseBuffer] # memory mapping needs to be the first step # only used for read_csv handle, memory_map, handles = _maybe_memory_map(handle, memory_map) is_path = isinstance(handle, str) compression_args = dict(ioargs.compression) compression = compression_args.pop("method") # Only for write methods if "r" not in mode and is_path: check_parent_directory(str(handle)) if compression: if compression != "zstd": # compression libraries do not like an explicit text-mode ioargs.mode = ioargs.mode.replace("t", "") elif compression == "zstd" and "b" not in ioargs.mode: # python-zstandard defaults to text mode, but we always expect # compression libraries to use binary mode. ioargs.mode += "b" # GZ Compression if compression == "gzip": if isinstance(handle, str): # error: Incompatible types in assignment (expression has type # "GzipFile", variable has type "Union[str, BaseBuffer]") handle = gzip.GzipFile( # type: ignore[assignment] filename=handle, mode=ioargs.mode, **compression_args, ) else: handle = gzip.GzipFile( # No overload variant of "GzipFile" matches argument types # "Union[str, BaseBuffer]", "str", "Dict[str, Any]" fileobj=handle, # type: ignore[call-overload] mode=ioargs.mode, **compression_args, ) # BZ Compression elif compression == "bz2": # Overload of "BZ2File" to handle pickle protocol 5 # "Union[str, BaseBuffer]", "str", "Dict[str, Any]" handle = _BZ2File( # type: ignore[call-overload] handle, mode=ioargs.mode, **compression_args, ) # ZIP Compression elif compression == "zip": # error: Argument 1 to "_BytesZipFile" has incompatible type # "Union[str, BaseBuffer]"; expected "Union[Union[str, PathLike[str]], # ReadBuffer[bytes], WriteBuffer[bytes]]" handle = _BytesZipFile( handle, ioargs.mode, **compression_args # type: ignore[arg-type] ) if handle.buffer.mode == "r": handles.append(handle) zip_names = handle.buffer.namelist() if len(zip_names) == 1: handle = handle.buffer.open(zip_names.pop()) elif not zip_names: raise ValueError(f"Zero files found in ZIP file {path_or_buf}") else: raise ValueError( "Multiple files found in ZIP file. " f"Only one file per ZIP: {zip_names}" ) # TAR Encoding elif compression == "tar": compression_args.setdefault("mode", ioargs.mode) if isinstance(handle, str): handle = _BytesTarFile(name=handle, **compression_args) else: # error: Argument "fileobj" to "_BytesTarFile" has incompatible # type "BaseBuffer"; expected "Union[ReadBuffer[bytes], # WriteBuffer[bytes], None]" handle = _BytesTarFile( fileobj=handle, **compression_args # type: ignore[arg-type] ) assert isinstance(handle, _BytesTarFile) if "r" in handle.buffer.mode: handles.append(handle) files = handle.buffer.getnames() if len(files) == 1: file = handle.buffer.extractfile(files[0]) assert file is not None handle = file elif not files: raise ValueError(f"Zero files found in TAR archive {path_or_buf}") else: raise ValueError( "Multiple files found in TAR archive. " f"Only one file per TAR archive: {files}" ) # XZ Compression elif compression == "xz": # error: Argument 1 to "LZMAFile" has incompatible type "Union[str, # BaseBuffer]"; expected "Optional[Union[Union[str, bytes, PathLike[str], # PathLike[bytes]], IO[bytes]]]" handle = get_lzma_file()(handle, ioargs.mode) # type: ignore[arg-type] # Zstd Compression elif compression == "zstd": zstd = import_optional_dependency("zstandard") if "r" in ioargs.mode: open_args = {"dctx": zstd.ZstdDecompressor(**compression_args)} else: open_args = {"cctx": zstd.ZstdCompressor(**compression_args)} handle = zstd.open( handle, mode=ioargs.mode, **open_args, ) # Unrecognized Compression else: msg = f"Unrecognized compression type: {compression}" raise ValueError(msg) assert not isinstance(handle, str) handles.append(handle) elif isinstance(handle, str): # Check whether the filename is to be opened in binary mode. # Binary mode does not support 'encoding' and 'newline'. if ioargs.encoding and "b" not in ioargs.mode: # Encoding handle = open( handle, ioargs.mode, encoding=ioargs.encoding, errors=errors, newline="", ) else: # Binary mode > handle = open(handle, ioargs.mode) E PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Olex\\AppData\\Local\\Temp\\tmpwnvhugo0.xlsx' .tox\default\Lib\site-packages\pandas\io\common.py:868: PermissionError ______________________________ TestWriteDatafile.test_write_parameter_as_tabbing_format _______________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} def test_write_parameter_as_tabbing_format(self, user_config): data = [["SIMPLICITY", "BIOMASS", 0.95969], ["SIMPLICITY", "ETH1", 4.69969]] df = pd.DataFrame(data=data, columns=["REGION", "FUEL", "VALUE"]).set_index( ["REGION", "FUEL"] ) stream = io.StringIO() convert = WriteDatafile(user_config) convert._write_parameter(df, "test_parameter", stream, 0) stream.seek(0) expected = [ "param default 0 : test_parameter :=\n", "SIMPLICITY BIOMASS 0.95969\n", "SIMPLICITY ETH1 4.69969\n", ";\n", ] actual = stream.readlines() for actual_line, expected_line in zip(actual, expected): > assert actual_line == expected_line E AssertionError: assert 'SIMPLICITY B...S 0.95969\r\n' == 'SIMPLICITY BIOMASS 0.95969\n' E - SIMPLICITY BIOMASS 0.95969 E + SIMPLICITY BIOMASS 0.95969 E ? + tests\test_write_strategies.py:169: AssertionError ________________________________ TestWriteDatafile.test_write_parameter_skip_defaults _________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} def test_write_parameter_skip_defaults(self, user_config): data = [ ["SIMPLICITY", "BIOMASS", 0.95969], ["SIMPLICITY", "ETH1", 4.69969], ["SIMPLICITY", "ETH2", -1], ["SIMPLICITY", "ETH3", -1], ] df = pd.DataFrame(data=data, columns=["REGION", "FUEL", "VALUE"]).set_index( ["REGION", "FUEL"] ) stream = io.StringIO() convert = WriteDatafile(user_config) convert._write_parameter(df, "test_parameter", stream, -1) stream.seek(0) expected = [ "param default -1 : test_parameter :=\n", "SIMPLICITY BIOMASS 0.95969\n", "SIMPLICITY ETH1 4.69969\n", ";\n", ] actual = stream.readlines() for actual_line, expected_line in zip(actual, expected): > assert actual_line == expected_line E AssertionError: assert 'SIMPLICITY B...S 0.95969\r\n' == 'SIMPLICITY BIOMASS 0.95969\n' E - SIMPLICITY BIOMASS 0.95969 E + SIMPLICITY BIOMASS 0.95969 E ? + tests\test_write_strategies.py:198: AssertionError __________________________________________ TestWriteDatafile.test_write_set ___________________________________________ self = user_config = {'AccumulatedAnnualDemand': {'default': 0, 'dtype': 'float', 'index_dtypes': {'FUEL': 'str', 'REGION': 'str', 'VALUE':... 'AnnualEmissions': {'default': 0, 'dtype': 'float', 'indices': ['REGION', 'EMISSION', 'YEAR'], 'type': 'result'}, ...} def test_write_set(self, user_config): data = [["BIOMASS"], ["ETH1"]] df = pd.DataFrame(data=data, columns=["VALUE"]) stream = io.StringIO() convert = WriteDatafile(user_config) convert._write_set(df, "TECHNOLOGY", stream) stream.seek(0) expected = ["set TECHNOLOGY :=\n", "BIOMASS\n", "ETH1\n", ";\n"] actual = stream.readlines() for actual_line, expected_line in zip(actual, expected): > assert actual_line == expected_line E AssertionError: assert 'BIOMASS\r\n' == 'BIOMASS\n' E - BIOMASS E + BIOMASS E ? + tests\test_write_strategies.py:215: AssertionError __________________________________________ TestDiscountFactor.test_df_start ___________________________________________ self = , region = VALUE 0 SIMPLICITY year = VALUE 0 2014 1 2015 2 2016 3 2017 4 2018 5 2019 6 2020 discount_rate = VALUE YEAR REGION SIMPLICITY 0.05 [2014, 2015, 2016, 2017, 2018, 2019, 2020] def test_df_start(self, region, year, discount_rate): regions = region["VALUE"].to_list() years = year["VALUE"].to_list() actual = discount_factor(regions, years, discount_rate, 0.0) expected = pd.DataFrame( data=[ ["SIMPLICITY", 2014, 1], ["SIMPLICITY", 2015, 1.05], ["SIMPLICITY", 2016, 1.1025], ["SIMPLICITY", 2017, 1.157625], ["SIMPLICITY", 2018, 1.21550625], ["SIMPLICITY", 2019, 1.276281562], ["SIMPLICITY", 2020, 1.340095640], ], columns=["REGION", "YEAR", "VALUE"], ).set_index(["REGION", "YEAR"]) > assert_frame_equal(actual, expected) tests\results\test_results_package.py:704: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2014, 2015, 2016, 2017, 2018, 2019, 2020], dtype='int32', name='YEAR') right = Index([2014, 2015, 2016, 2017, 2018, 2019, 2020], dtype='int64', name='YEAR'), obj = 'MultiIndex level [1]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [1] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError ___________________________________________ TestDiscountFactor.test_df_mid ____________________________________________ self = , region = VALUE 0 SIMPLICITY year = VALUE 0 2014 1 2015 2 2016 3 2017 4 2018 5 2019 6 2020 discount_rate = VALUE YEAR REGION SIMPLICITY 0.05 [2014, 2015, 2016, 2017, 2018, 2019, 2020] def test_df_mid(self, region, year, discount_rate): regions = region["VALUE"].to_list() years = year["VALUE"].to_list() actual = discount_factor(regions, years, discount_rate, 0.5) expected = pd.DataFrame( data=[ ["SIMPLICITY", 2014, 1.024695076], ["SIMPLICITY", 2015, 1.075929830], ["SIMPLICITY", 2016, 1.129726321], ["SIMPLICITY", 2017, 1.186212638], ["SIMPLICITY", 2018, 1.245523269], ["SIMPLICITY", 2019, 1.307799433], ["SIMPLICITY", 2020, 1.373189405], ], columns=["REGION", "YEAR", "VALUE"], ).set_index(["REGION", "YEAR"]) > assert_frame_equal(actual, expected) tests\results\test_results_package.py:725: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2014, 2015, 2016, 2017, 2018, 2019, 2020], dtype='int32', name='YEAR') right = Index([2014, 2015, 2016, 2017, 2018, 2019, 2020], dtype='int64', name='YEAR'), obj = 'MultiIndex level [1]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [1] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError ___________________________________________ TestDiscountFactor.test_df_end ____________________________________________ self = , region = VALUE 0 SIMPLICITY year = VALUE 0 2014 1 2015 2 2016 3 2017 4 2018 5 2019 6 2020 discount_rate = VALUE YEAR REGION SIMPLICITY 0.05 [2014, 2015, 2016, 2017, 2018, 2019, 2020] def test_df_end(self, region, year, discount_rate): regions = region["VALUE"].to_list() years = year["VALUE"].to_list() actual = discount_factor(regions, years, discount_rate, 1.0) expected = pd.DataFrame( data=[ ["SIMPLICITY", 2014, 1.05], ["SIMPLICITY", 2015, 1.1025], ["SIMPLICITY", 2016, 1.157625], ["SIMPLICITY", 2017, 1.21550625], ["SIMPLICITY", 2018, 1.276281562], ["SIMPLICITY", 2019, 1.340095640], ["SIMPLICITY", 2020, 1.407100422], ], columns=["REGION", "YEAR", "VALUE"], ).set_index(["REGION", "YEAR"]) > assert_frame_equal(actual, expected) tests\results\test_results_package.py:746: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ left = Index([2014, 2015, 2016, 2017, 2018, 2019, 2020], dtype='int32', name='YEAR') right = Index([2014, 2015, 2016, 2017, 2018, 2019, 2020], dtype='int64', name='YEAR'), obj = 'MultiIndex level [1]' def _check_types(left, right, obj: str = "Index") -> None: if not exact: return assert_class_equal(left, right, exact=exact, obj=obj) assert_attr_equal("inferred_type", left, right, obj=obj) # Skip exact dtype checking when `check_categorical` is False if is_categorical_dtype(left.dtype) and is_categorical_dtype(right.dtype): if check_categorical: assert_attr_equal("dtype", left, right, obj=obj) assert_index_equal(left.categories, right.categories, exact=exact) return > assert_attr_equal("dtype", left, right, obj=obj) E AssertionError: MultiIndex level [1] are different E E Attribute "dtype" are different E [left]: int32 E [right]: int64 .tox\default\Lib\site-packages\pandas\_testing\asserters.py:250: AssertionError ---------- coverage: platform win32, python 3.11.1-final-0 ----------- Coverage HTML written to dir htmlcov =============================================== short test summary info =============================================== FAILED tests/test_cli.py::TestConvert::test_convert_commands[excel] - AssertionError: None FAILED tests/test_cli.py::TestConvert::test_convert_commands[datafile] - AssertionError: None FAILED tests/test_cli.py::TestConvert::test_convert_datafile_datafile_with_user_config - assert 1 == 0 FAILED tests/test_cli.py::TestConvert::test_convert_datafile_datafile_with_default_flag - assert 1 == 0 FAILED tests/test_cli.py::TestSetup::test_setup_commands[setup_with_overwrite] - AssertionError: None FAILED tests/test_convert.py::TestWrite::test_write_datafile - PermissionError: [Errno 13] Permission denied: 'C:\\Us... FAILED tests/test_convert.py::TestWrite::test_write_excel - PermissionError: [Errno 13] Permission denied: 'C:\\Users... FAILED tests/test_convert.py::TestConvert::test_convert_excel_to_datafile - PermissionError: [Errno 13] Permission de... FAILED tests/test_convert.py::TestReadResults::test_read_results - AssertionError: MultiIndex level [2] are different FAILED tests/test_input.py::TestReadStrategy::test_check_index[param] - AssertionError: MultiIndex level [2] are diff... FAILED tests/test_input.py::TestReadStrategy::test_check_index[set] - AssertionError: Attributes of DataFrame.iloc[:,... FAILED tests/test_input.py::TestReadStrategy::test_check_index_dtype[param] - AssertionError: MultiIndex level [2] ar... FAILED tests/test_input.py::TestReadStrategy::test_check_index_dtype[set] - AssertionError: Attributes of DataFrame.i... FAILED tests/test_input.py::TestReadStrategy::test_check_dtypes[param] - AssertionError: MultiIndex level [2] are dif... FAILED tests/test_input.py::TestReadStrategy::test_check_dtypes[set] - AssertionError: Attributes of DataFrame.iloc[:... FAILED tests/test_read_strategies.py::TestReadCbc::test_read_cbc_to_otoole_dataframe[0 Trade(Globe,Globe,IP,L_AGR,2015) -0.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2016) -1.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2017) -2.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2018) -3.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2019) -4.0 0\n0 Trade(Globe,Globe,IP,L_AGR,2020) -5.0 0\n-expected0] FAILED tests/test_read_strategies.py::TestReadCbc::test_read_cbc_dataframe_to_otoole_dataframe - AssertionError: Mult... FAILED tests/test_read_strategies.py::TestReadCbc::test_convert_cbc_to_csv_long[TotalDiscountedCost] - AssertionError... FAILED tests/test_read_strategies.py::TestReadCbc::test_convert_cbc_to_csv_long[AnnualEmissions1] - AssertionError: M... FAILED tests/test_read_strategies.py::TestReadCbc::test_convert_cbc_to_csv_long_read[TotalDiscountedCost] - Assertion... FAILED tests/test_read_strategies.py::TestReadCbc::test_solution_to_dataframe - AssertionError: MultiIndex level [1] ... FAILED tests/test_read_strategies.py::TestReadGlpk::test_read_model - AssertionError: Attributes of DataFrame.iloc[:,... FAILED tests/test_read_strategies.py::TestReadGlpk::test_read_solution - AssertionError: Attributes of DataFrame.iloc... FAILED tests/test_read_strategies.py::TestReadMemoryStrategy::test_read_memory - AssertionError: MultiIndex level [2]... FAILED tests/test_read_strategies.py::TestReadMemoryStrategy::test_read_memory_user_config - AssertionError: MultiInd... FAILED tests/test_read_strategies.py::TestReadExcel::test_check_index - AssertionError: MultiIndex level [1] are diff... FAILED tests/test_setup.py::test_get_csv_setup_data - AssertionError: MultiIndex level [2] are different FAILED tests/test_utils.py::test_excel_name_length_error[full_name_error] - PermissionError: [Errno 13] Permission de... FAILED tests/test_utils.py::test_excel_name_length_error[short_name_error] - PermissionError: [Errno 13] Permission d... FAILED tests/test_write_strategies.py::TestWriteExcel::test_write_out_empty_dataframe - PermissionError: [Errno 13] P... FAILED tests/test_write_strategies.py::TestWriteDatafile::test_write_parameter_as_tabbing_format - AssertionError: as... FAILED tests/test_write_strategies.py::TestWriteDatafile::test_write_parameter_skip_defaults - AssertionError: assert... FAILED tests/test_write_strategies.py::TestWriteDatafile::test_write_set - AssertionError: assert 'BIOMASS\r\n' == 'B... FAILED tests/results/test_results_package.py::TestDiscountFactor::test_df_start - AssertionError: MultiIndex level [1... FAILED tests/results/test_results_package.py::TestDiscountFactor::test_df_mid - AssertionError: MultiIndex level [1] ... FAILED tests/results/test_results_package.py::TestDiscountFactor::test_df_end - AssertionError: MultiIndex level [1] ... ================================ 36 failed, 173 passed, 1 skipped in 81.91s (0:01:21) ================================= default: exit 1 (86.86 seconds) C:\Users\Olex\Documents\MANRID\ResLab\Playground\otoole-review\otoole> pytest pid=18832 .pkg: _exit> python "C:\Program Files\Python311\Lib\site-packages\pyproject_api\_backend.py" True setuptools.build_meta default: FAIL code 1 (101.84=setup[14.98]+cmd[86.86] seconds) evaluation failed :( (102.28 seconds)