Issue
I am trying to define a dictionary that will hold a list:
import numpy as np
def processing_stitch_visual_outputs(
saved_visual_outputs: dict[str, np.ndarray],
nrow: int,
ncol: int
)
But I am getting an error indicating the dictionary is not subscriptable:
Exception has occurred: TypeError 'type' object is not subscriptable File "functions.py", line 168, in saved_visual_outputs: dict[str, np.ndarray],
My guess is that the dict variable can not contain an array, but I don't see a reason why not.
Any hint towards the why is very much appreciated!
Solution
To solve this error you want to make use of the Dict
class from the typing
module as follows:
from typing import Dict
import numpy as np
def processing_stitch_visual_outputs(
saved_visual_outputs: Dict[str, np.ndarray],
nrow: int,
ncol: int
)
I haven't tried it myself, but the way you have used type hintin might work for python version 3.9 and up, so trying to upgrade your python version might also solve the issue.
Answered By - Oxbowerce
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.