Skip to content

Commit

Permalink
refactor: renamed dtypes property to specified_dtypes
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Peschke <[email protected]>
  • Loading branch information
lukapeschke committed Mar 4, 2024
1 parent 94e59d4 commit ef55f27
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions python/fastexcel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`"""
Expand Down
2 changes: 1 addition & 1 deletion python/fastexcel/_fastexcel.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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`"""
Expand Down
4 changes: 2 additions & 2 deletions python/tests/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/types/excelsheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ impl ExcelSheet {
}

#[getter]
pub fn dtypes<'p>(&'p self, py: Python<'p>) -> Option<PyObject> {
pub fn specified_dtypes<'p>(&'p self, py: Python<'p>) -> Option<PyObject> {
self.dtypes.as_ref().map(|dtypes| dtypes.to_object(py))
}

Expand Down

0 comments on commit ef55f27

Please sign in to comment.