当前位置:网站首页>Array rotation

Array rotation

2022-04-23 17:58:00 Feng Ye 520

import numpy as np

l = np.arange(1, 17, dtype='int16')
l.shape = (4, 4)
print(l)
print()

f1 = lambda x:np.array(list(zip(*l)))
l1 = f1(l)
print(l1)
print()

# Clockwise rotation 90 degree
f2 = lambda x:np.array(list(zip(*l[::-1])))
l2 = f2(l)
print(l2)
print()

# Counter clockwise rotation 90 degree
f3 = lambda x:np.array(list(zip(*map(lambda x:x[::-1], l))))
l3 = f3(l)
print(l3)
 

版权声明
本文为[Feng Ye 520]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230546152320.html