From cb1143a47215d8327085cd975e45135b42fd9e57 Mon Sep 17 00:00:00 2001 From: Daniel Otto de Mentock Date: Tue, 1 Feb 2022 18:38:49 +0100 Subject: [PATCH] changed return type of util.shapeblender and util.shapeshifter from Sequence[SupportsIndex] to Tuple[SupportsIndex, ...] ignored lines in orientation module that attempt to pass objects of type Tuple[SupportsIndex, ...] to np.broadcast_to() --- python/damask/_orientation.py | 5 ++--- python/damask/util.py | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index f84ca9952..d1488c14e 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -657,7 +657,7 @@ class Orientation(Rotation,Crystal): """ eq = self.equivalent blend = util.shapeblender(eq.shape,np.array(vector).shape[:-1]) - poles = eq.broadcast_to(blend,mode='right') @ np.broadcast_to(np.array(vector),blend+(3,)) + poles = eq.broadcast_to(blend,mode='right') @ np.broadcast_to(np.array(vector),blend+(3,)) #type: ignore ok = self.in_SST(poles,proper=proper) ok &= np.cumsum(ok,axis=0) == 1 loc = np.where(ok) @@ -886,8 +886,7 @@ class Orientation(Rotation,Crystal): blend += sym_ops.shape v = sym_ops.broadcast_to(shape) \ @ np.broadcast_to(v.reshape(util.shapeshifter(v.shape,shape+(3,))),shape+(3,)) - return ~(self.broadcast_to(blend)) \ - @ np.broadcast_to(v,blend+(3,)) + return ~(self.broadcast_to(blend))@ np.broadcast_to(v,blend+(3,)) #type: ignore def Schmid(self, *, diff --git a/python/damask/util.py b/python/damask/util.py index b4c287884..3b0af7177 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -9,7 +9,7 @@ import re import fractions from collections import abc from functools import reduce -from typing import Union, Tuple, Iterable, Callable, Dict, List, Any, Literal, SupportsIndex, Sequence +from typing import Union, Tuple, Iterable, Callable, Dict, List, Any, Literal, SupportsIndex from pathlib import Path import numpy as np @@ -427,7 +427,7 @@ def hybrid_IA(dist: np.ndarray, def shapeshifter(fro: Tuple[int, ...], to: Tuple[int, ...], mode: Literal['left','right'] = 'left', - keep_ones: bool = False) -> Sequence[SupportsIndex]: + keep_ones: bool = False) -> Tuple[SupportsIndex, ...]: """ Return dimensions that reshape 'fro' to become broadcastable to 'to'. @@ -490,7 +490,7 @@ def shapeshifter(fro: Tuple[int, ...], def shapeblender(a: Tuple[int, ...], - b: Tuple[int, ...]) -> Sequence[SupportsIndex]: + b: Tuple[int, ...]) -> Tuple[SupportsIndex, ...]: """ Return a shape that overlaps the rightmost entries of 'a' with the leftmost of 'b'.