From ef55f272d4cbc84545c1bd3835f52677efbead6e Mon Sep 17 00:00:00 2001 From: Luka Peschke Date: Mon, 4 Mar 2024 15:05:28 +0100 Subject: [PATCH] refactor: renamed dtypes property to specified_dtypes Signed-off-by: Luka Peschke --- python/fastexcel/__init__.py | 4 ++-- python/fastexcel/_fastexcel.pyi | 2 +- python/tests/test_dtypes.py | 4 ++-- src/types/excelsheet.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/fastexcel/__init__.py b/python/fastexcel/__init__.py index 1e33f48..baf9231 100644 --- a/python/fastexcel/__init__.py +++ b/python/fastexcel/__init__.py @@ -70,9 +70,9 @@ def available_columns(self) -> list[str]: return self._sheet.available_columns @property - def dtypes(self) -> DTypeMap | None: + def specified_dtypes(self) -> DTypeMap | None: """The dtypes specified for the sheet""" - return self._sheet.dtypes + return self._sheet.specified_dtypes def to_arrow(self) -> pa.RecordBatch: """Converts the sheet to a pyarrow `RecordBatch`""" diff --git a/python/fastexcel/_fastexcel.pyi b/python/fastexcel/_fastexcel.pyi index cd614cc..b17fdce 100644 --- a/python/fastexcel/_fastexcel.pyi +++ b/python/fastexcel/_fastexcel.pyi @@ -31,7 +31,7 @@ class _ExcelSheet: def available_columns(self) -> list[str]: """The columns available for the given sheet""" @property - def dtypes(self) -> _DTypeMap | None: + def specified_dtypes(self) -> _DTypeMap | None: """The dtypes specified for the sheet""" def to_arrow(self) -> pa.RecordBatch: """Converts the sheet to a pyarrow `RecordBatch`""" diff --git a/python/tests/test_dtypes.py b/python/tests/test_dtypes.py index 01b6f03..82392ef 100644 --- a/python/tests/test_dtypes.py +++ b/python/tests/test_dtypes.py @@ -133,7 +133,7 @@ def test_sheet_with_mixed_dtypes_specify_dtypes( dtypes: fastexcel.DTypeMap = {0: dtype} if dtype_by_index else {"Employee ID": dtype} # type:ignore[dict-item] excel_reader = fastexcel.read_excel(path_for_fixture("fixture-multi-dtypes-columns.xlsx")) sheet = excel_reader.load_sheet(0, dtypes=dtypes, n_rows=5) - assert sheet.dtypes == dtypes + assert sheet.specified_dtypes == dtypes pd_df = sheet.to_pandas() assert pd_df["Employee ID"].dtype == expected_pd_dtype @@ -165,7 +165,7 @@ def test_sheet_datetime_conversion( excel_reader = fastexcel.read_excel(path_for_fixture("fixture-multi-dtypes-columns.xlsx")) sheet = excel_reader.load_sheet(0, dtypes=dtypes) - assert sheet.dtypes == dtypes + assert sheet.specified_dtypes == dtypes pd_df = sheet.to_pandas() assert pd_df["Date"].dtype == expected_pd_dtype assert pd_df["Date"].to_list() == [expected] * 9 diff --git a/src/types/excelsheet.rs b/src/types/excelsheet.rs index 6b25d69..23cfdfa 100644 --- a/src/types/excelsheet.rs +++ b/src/types/excelsheet.rs @@ -675,7 +675,7 @@ impl ExcelSheet { } #[getter] - pub fn dtypes<'p>(&'p self, py: Python<'p>) -> Option { + pub fn specified_dtypes<'p>(&'p self, py: Python<'p>) -> Option { self.dtypes.as_ref().map(|dtypes| dtypes.to_object(py)) }