add traceback to port type warnings

nolock
Jan Petykiewicz 3 years ago
parent 1dc7d5bd56
commit 7225fd5715

@ -1,6 +1,7 @@
from typing import Dict, Iterable, List, Tuple, Union, TypeVar, Any, Iterator, Optional, Sequence from typing import Dict, Iterable, List, Tuple, Union, TypeVar, Any, Iterator, Optional, Sequence
import copy import copy
import warnings import warnings
import traceback
import logging import logging
from collections import Counter from collections import Counter
@ -620,6 +621,7 @@ class Device(Copyable, Mirrorable):
for nn, (k, v) in enumerate(map_in.items()): for nn, (k, v) in enumerate(map_in.items()):
if type_conflicts[nn]: if type_conflicts[nn]:
msg += f'{k} | {s_types[nn]:g}:{o_types[nn]:g} | {v}\n' msg += f'{k} | {s_types[nn]:g}:{o_types[nn]:g} | {v}\n'
msg = ''.join(traceback.format_stack()) + '\n' + msg
warnings.warn(msg, stacklevel=2) warnings.warn(msg, stacklevel=2)
rotations = numpy.mod(s_rotations - o_rotations - pi, 2 * pi) rotations = numpy.mod(s_rotations - o_rotations - pi, 2 * pi)

Loading…
Cancel
Save