Skip to content

Commit

Permalink
remove mutable default in function signature.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Dec 15, 2024
1 parent 2b302e7 commit 336a88a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions py360convert/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from collections.abc import Sequence
from typing import Any

import numpy as np
from numpy.typing import NDArray
from scipy.ndimage import map_coordinates
Expand Down Expand Up @@ -260,12 +263,12 @@ def cube_list2h(cube_list: list[NDArray]) -> NDArray:
return np.concatenate(cube_list, axis=1)


def cube_h2dict(cube_h):
cube_list = cube_h2list(cube_h)
return dict([(k, cube_list[i]) for i, k in enumerate(["F", "R", "B", "L", "U", "D"])])
def cube_h2dict(cube_h) -> dict[str, NDArray]:
return dict(zip("FRBLUD", cube_h2list(cube_h)))


def cube_dict2h(cube_dict, face_k=["F", "R", "B", "L", "U", "D"]):
def cube_dict2h(cube_dict: dict[Any, NDArray], face_k: Sequence | None = None) -> NDArray:
face_k = face_k or "FRBLUD"
if len(face_k) != 6:
raise ValueError(f"6 face_k keys must be provided to construct a cube; got {len(face_k)}.")
return cube_list2h([cube_dict[k] for k in face_k])
Expand Down

0 comments on commit 336a88a

Please sign in to comment.