From b1922c9fc03c295446b320281c44da0eda212225 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 13 Feb 2022 10:41:10 +0100 Subject: [PATCH] return most specific type --- python/damask/_orientation.py | 8 ++++---- python/damask/util.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index 16df11984..c3afd0bed 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -558,8 +558,8 @@ class Orientation(Rotation,Crystal): s = self.equivalent o = other.equivalent - s_ = s.reshape((s.shape[0],1)+ self.shape).broadcast_to((s.shape[0],o.shape[0])+blend,mode='right') #type: ignore - o_ = o.reshape((1,o.shape[0])+other.shape).broadcast_to((s.shape[0],o.shape[0])+blend,mode='right') #type: ignore + s_ = s.reshape((s.shape[0],1)+ self.shape).broadcast_to((s.shape[0],o.shape[0])+blend,mode='right') + o_ = o.reshape((1,o.shape[0])+other.shape).broadcast_to((s.shape[0],o.shape[0])+blend,mode='right') r_ = s_.misorientation(o_) _r = ~r_ @@ -654,7 +654,7 @@ class Orientation(Rotation,Crystal): raise ValueError('input is not a field of three-dimensional vectors') eq = self.equivalent blend = util.shapeblender(eq.shape,vector_.shape[:-1]) - poles = eq.broadcast_to(blend,mode='right') @ np.broadcast_to(vector_,blend+(3,)) #type: ignore + poles = eq.broadcast_to(blend,mode='right') @ np.broadcast_to(vector_,blend+(3,)) ok = self.in_SST(poles,proper=proper) ok &= np.cumsum(ok,axis=0) == 1 loc = np.where(ok) @@ -884,7 +884,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,)) #type: ignore + return ~(self.broadcast_to(blend))@ np.broadcast_to(v,blend+(3,)) def Schmid(self, *, diff --git a/python/damask/util.py b/python/damask/util.py index cc5b8906e..ab34df7c0 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 +from typing import Union, Tuple, Iterable, Callable, Dict, List, Any, Literal 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) -> Tuple[SupportsIndex, ...]: + keep_ones: bool = False) -> Tuple[int, ...]: """ 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, ...]) -> Tuple[SupportsIndex, ...]: + b: Tuple[int, ...]) -> Tuple[int, ...]: """ Return a shape that overlaps the rightmost entries of 'a' with the leftmost of 'b'.