Skip to content

Commit

Permalink
Fix a numpy/seq incompatibility bug in 3.8 (#5466)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmao-denver authored and stanbrub committed May 17, 2024
1 parent f33000c commit db65c7c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions py/server/deephaven/_udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import numpy
import numpy as np
import numpy._typing as npt
import jpy

from deephaven import DHError, dtypes
Expand Down Expand Up @@ -279,7 +280,7 @@ def _component_np_dtype_char(t: type) -> Optional[str]:
def _py_sequence_component_type(t: type) -> Optional[type]:
"""Returns the component type of Python subscribed sequence type, otherwise return None."""
component_type = None
if sys.version_info > (3, 8):
if sys.version_info >= (3, 9):
import types
if isinstance(t, types.GenericAlias) and issubclass(t.__origin__, Sequence): # novermin
component_type = t.__args__[0]
Expand All @@ -304,7 +305,7 @@ def _np_ndarray_component_type(t: type) -> Optional[type]:
# component type
component_type = None
if (3, 9) > sys.version_info >= (3, 8):
if isinstance(t, np._typing._generic_alias._GenericAlias) and t.__origin__ is np.ndarray:
if isinstance(t, npt._generic_alias._GenericAlias) and t.__origin__ is np.ndarray:
component_type = t.__args__[1].__args__[0]
# Py3.9+, np.ndarray as a generic alias is only supported in Python 3.9+, also npt.NDArray is still available but a
# specific alias (e.g. npt.NDArray[np.int64]) now is an instance of typing.GenericAlias.
Expand Down

0 comments on commit db65c7c

Please sign in to comment.