<jupyter_start><jupyter_text>OverviewThe purpose of this notebook is to evaluate the original and the current implementation of misorientation calculations.<jupyter_code>import numpy as np

from hexomap.past   import Misorien2FZ1 as miso_new
from hexomap.past   import EulerZXZ2Mat as euler2mat_new
from hexomap.past   import generate_random_rot_mat

from hexomap.RotRep import Misorien2FZ1 as miso_org   # one symop
from hexomap.RotRep import Misorien2FZ2 as miso_org2  # two symops
from hexomap.RotRep import EulerZXZ2Mat as euler2mat_old

from hexomap.orientation import sym_operator
from hexomap.orientation import Quaternion
from hexomap.orientation import Orientation
from hexomap.orientation import Eulers
from hexomap.orientation import Frame
miso_new??
miso_org??<jupyter_output><empty_output><jupyter_text>Test_1: ConsistencyThe first test evaluate the consistence bewteen the original and the new implementation of two misorientation calculation. ```pythondef quaternions_from_eulers(eulers: np.ndarray) -> np.ndarray:    """ Return a quaternion based on given Euler Angles """     allow euler as an numpy array    try:        eulers = eulers.reshape((-1, 3))    except:        raise ValueError(f"Eulers angles much be ROW/horizontal stacked")    ee = 0.5*eulers    cs = np.cos(ee)    ss = np.sin(ee)    c1, c, c2 = cs[:,0], cs[:,1], cs[:,2]    s1, s, s2 = ss[:,0], ss[:,1], ss[:,2]        quats = np.empty([eulers.shape[0], 4])    quats[:,0] =  c1*c*c2 - s1*c*s2    quats[:,1] =  c1*s*c2 + s1*s*s2    quats[:,2] = -c1*s*s2 + s1*s*c2    quats[:,3] =  c1*c*s2 + s1*c*c2    return (quats/np.linalg.norm(quats, axis=1)[:,None]) * np.sign(quats[:,0])[:,None]```<jupyter_code>euler = (np.random.random(3)-0.5)*4*np.pi

q = Quaternion.from_eulers(euler)
print(f"{euler} -> {q.as_array}")

print()
eulers = np.vstack((euler, euler))
qs = Quaternion.quaternions_from_eulers(eulers)
print(eulers)
print("|")
print("v")
print(qs)
def check(m1, m2):
    for lb, me in {
    "current": miso_new, 
    "org1":    miso_org, 
    # "org2":    miso_org2
    }.items():
        print(f"{lb}\t{np.degrees(me(m1, m2)[1])}")
m1 = euler2mat_new(np.radians([0,  45,  0]))
m2 = euler2mat_new(np.radians([98, 45,  0]))
check(m1, m2)

m1 = euler2mat_new(np.radians([0,  45,  0]))
m2 = euler2mat_new(np.radians([0,  45, 98]))
check(m1, m2)
for _ in range(10):
    m1 = euler2mat_new((np.random.random(3)-0.5)*5*np.pi)
    m2 = euler2mat_new((np.random.random(3)-0.5)*5*np.pi)
    
    check(m1, m2)<jupyter_output>current	37.28316471355922
org1	37.283164713559245
current	48.30848916372926
org1	48.30848916372931
current	39.85150205126839
org1	39.85150205126844
current	50.138298864832976
org1	50.13829886483299
current	13.730973075076875
org1	13.730973075076887
current	32.44288075881981
org1	32.44288075881982
current	54.42141450854485
org1	54.421414508544885
current	45.879521056341154
org1	45.879521056341154
current	33.74294831332352
org1	33.74294831332352
current	46.98172944935342
org1	46.98172944935346<jupyter_text>Test_2 speed<jupyter_code>m1 = euler2mat_new((np.random.random(3)-0.5)*2*np.pi)
m2 = euler2mat_new((np.random.random(3)-0.5)*2*np.pi)
%time miso_new(m1, m2)
%time miso_org(m1, m2)<jupyter_output>CPU times: user 1.1 ms, sys: 1.22 ms, total: 2.32 ms
Wall time: 1.22 ms
{'fraction_non_alphanumeric': 0.1334351145038168, 'fraction_numerical': 0.14442748091603053, 'mean_word_length': 4.892086330935252, 'pattern_counts': {'":': 3, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '275404', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1402, 'n_words': 287, 'path': 'private/misorientation/misorientations.ipynb', 'repo_name': 'HeLiuCMU/ICENINE_GPU', 'size': '3275'}