I have a matrix of numbers:
[[a, b, c] 
 [d, e, f] 
 [g, h, i]]
that I would like to be mirrored accordingly:
[[g, h, i]
 [d, e, f]
 [a, b, c] 
 [d, e, f] 
 [g, h, i]]
And then again to yield:
[[i, h, g, h, i]
 [f, e, d, e, f]
 [c, b, a, b, c] 
 [f, e, d, e, f] 
 [i, h, g, h, i]]
I would like to stick to basic Python packages like numpy. Thanks in advance for any help!!
This can be accomplished using a simple helper function in pure python:
def mirror(seq):
    output = list(seq[::-1])
    output.extend(seq[1:])
    return output
inputs = [
   ['a', 'b', 'c'],
   ['d', 'e', 'f'],
   ['g', 'h', 'i'],
]
print(mirror([mirror(sublist) for sublist in inputs]))
Obviously, once the mirrored list is created, you can use it to create a numpy array or whatever...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With