Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions xattree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,11 @@ def _register_nested_dims(child_spec: Child, path=None):
dtype = xatmeta.get(_DTYPE, None)

# Extract dtype from type hint if not explicitly provided
if dtype is None and origin is np.ndarray and args:
if (
dtype is None
and args
and (origin is np.ndarray or args[-1] is types.NoneType)
):
if len(args) >= 2 and hasattr(args[1], "__args__"):
# Handle NDArray[np.float64] style hints
dtype_arg = args[1].__args__[0]
Expand Down Expand Up @@ -1233,7 +1237,8 @@ def array(
raise CannotExpand("If no dims, no scalar defaults.")
if dtype is not None and default is NOTHING:
if isinstance(dtype, (str, np.dtype)):
default = _get_fill_value(np.dtype(dtype))
dtype = np.dtype(dtype)
default = _get_fill_value(dtype)
elif isinstance(dtype, type):
default = Factory(dtype)
else:
Expand Down