From 2409608d05bc74c9c100568cf7b261e877fd0373 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Tue, 8 Oct 2024 10:22:17 -0400 Subject: [PATCH] Fix import when pandas/pyarrow not installed (#678) ## Available PR templates - [Default](?expand=1&template=default.md) - [Version Release](?expand=1&template=version_release.md) - _Alternatively delete and start empty_ --- CHANGELOG.md | 8 +++++++- lonboard/types/layer.py | 29 ++++++++++++++++------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c165384..620a4a5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [0.10.1] - 2024-10-08 + +### Fixes :bug: + +- Fix import when pandas not installed. + ## [0.10.0] - 2024-10-07 ### New! :sparkles: @@ -29,7 +35,7 @@ - Fix reading from DuckDB with only geometry column by @kylebarron in https://github.com/developmentseed/lonboard/pull/625 - Fix attribution by @vgeorge in https://github.com/developmentseed/lonboard/pull/561 -## New Contributors +### New Contributors - @MarcSkovMadsen made their first contribution in https://github.com/developmentseed/lonboard/pull/539 - @ATL2001 made their first contribution in https://github.com/developmentseed/lonboard/pull/655 diff --git a/lonboard/types/layer.py b/lonboard/types/layer.py index 786f157c..f30f88d1 100644 --- a/lonboard/types/layer.py +++ b/lonboard/types/layer.py @@ -2,6 +2,7 @@ import sys from typing import ( + TYPE_CHECKING, List, Literal, Sequence, @@ -10,8 +11,6 @@ ) import numpy as np -import pandas as pd -import pyarrow from arro3.core.types import ArrowArrayExportable, ArrowStreamExportable from numpy.typing import NDArray @@ -22,6 +21,10 @@ else: from typing_extensions import TypedDict +if TYPE_CHECKING: + import pandas as pd + import pyarrow + IntFloat = Union[int, float] Units = Literal["meters", "common", "pixels"] @@ -32,8 +35,8 @@ Tuple[int, ...], str, NDArray[np.uint8], - pyarrow.FixedSizeListArray, - pyarrow.ChunkedArray, + "pyarrow.FixedSizeListArray", + "pyarrow.ChunkedArray", ArrowArrayExportable, ArrowStreamExportable, ] @@ -41,9 +44,9 @@ int, float, NDArray[np.number], - pd.Series, - pyarrow.FloatingPointArray, - pyarrow.ChunkedArray, + "pd.Series", + "pyarrow.FloatingPointArray", + "pyarrow.ChunkedArray", ArrowArrayExportable, ArrowStreamExportable, ] @@ -52,18 +55,18 @@ Tuple[int, int, int], Tuple[int, ...], NDArray[np.floating], - pyarrow.FixedSizeListArray, - pyarrow.ChunkedArray, + "pyarrow.FixedSizeListArray", + "pyarrow.ChunkedArray", ArrowArrayExportable, ArrowStreamExportable, ] TextAccessorInput = Union[ str, NDArray[np.str_], - pd.Series, - pyarrow.StringArray, - pyarrow.LargeStringArray, - pyarrow.ChunkedArray, + "pd.Series", + "pyarrow.StringArray", + "pyarrow.LargeStringArray", + "pyarrow.ChunkedArray", ArrowArrayExportable, ArrowStreamExportable, ]