return most specific type
This commit is contained in:
parent
2907facfd3
commit
b1922c9fc0
|
@ -558,8 +558,8 @@ class Orientation(Rotation,Crystal):
|
||||||
s = self.equivalent
|
s = self.equivalent
|
||||||
o = other.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
|
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') #type: ignore
|
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_ = s_.misorientation(o_)
|
||||||
_r = ~r_
|
_r = ~r_
|
||||||
|
|
||||||
|
@ -654,7 +654,7 @@ class Orientation(Rotation,Crystal):
|
||||||
raise ValueError('input is not a field of three-dimensional vectors')
|
raise ValueError('input is not a field of three-dimensional vectors')
|
||||||
eq = self.equivalent
|
eq = self.equivalent
|
||||||
blend = util.shapeblender(eq.shape,vector_.shape[:-1])
|
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 = self.in_SST(poles,proper=proper)
|
||||||
ok &= np.cumsum(ok,axis=0) == 1
|
ok &= np.cumsum(ok,axis=0) == 1
|
||||||
loc = np.where(ok)
|
loc = np.where(ok)
|
||||||
|
@ -884,7 +884,7 @@ class Orientation(Rotation,Crystal):
|
||||||
blend += sym_ops.shape
|
blend += sym_ops.shape
|
||||||
v = sym_ops.broadcast_to(shape) \
|
v = sym_ops.broadcast_to(shape) \
|
||||||
@ np.broadcast_to(v.reshape(util.shapeshifter(v.shape,shape+(3,))),shape+(3,))
|
@ 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, *,
|
def Schmid(self, *,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import re
|
||||||
import fractions
|
import fractions
|
||||||
from collections import abc
|
from collections import abc
|
||||||
from functools import reduce
|
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
|
from pathlib import Path
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -427,7 +427,7 @@ def hybrid_IA(dist: np.ndarray,
|
||||||
def shapeshifter(fro: Tuple[int, ...],
|
def shapeshifter(fro: Tuple[int, ...],
|
||||||
to: Tuple[int, ...],
|
to: Tuple[int, ...],
|
||||||
mode: Literal['left','right'] = 'left',
|
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'.
|
Return dimensions that reshape 'fro' to become broadcastable to 'to'.
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ def shapeshifter(fro: Tuple[int, ...],
|
||||||
|
|
||||||
|
|
||||||
def shapeblender(a: 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'.
|
Return a shape that overlaps the rightmost entries of 'a' with the leftmost of 'b'.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue