Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw 'not valid pi for Symmetries';
}
// Python: pi[:-1]. Remove the last one
const pi_copy = pi.slice();
pi_copy.pop();
const pi_board = nj.reshape(pi_copy, [this.n, this.n]);
const l = [];
for (let i = 1; i < 5; i++) {
for (const j of [true, false]) {
let newB = nj.rot90(boardNdArray, i);
let newPi = nj.rot90(pi_board, i);
if (j) {
// Python:newB = np.fliplr(newB)
newB = nj.flip(newB, 1);
newPi = nj.flip(newPi, 1);
}
// Python:
// p: ordinary 1d array. after reshape
// >>> y2
// array([[3, 2, 1],
// [6, 5, 4],
// [9, 8, 7]])
// >>> y2.ravel() ~ numjy's flatten
// array([3, 2, 1, 6, 5, 4, 9, 8, 7]). ndarray type
// after list
// [3, 2, 1, 6, 5, 4, 9, 8, 7] !!. list type
// + [pi[-1] (e.g. [33])
// [3, 2, 1, 6, 5, 4, 9, 8, 7, 33]
const p = nj.flatten(newPi).tolist();
p.push(pi[pi.length - 1]);
}
// Python: pi[:-1]. Remove the last one
const pi_copy = pi.slice();
pi_copy.pop();
const pi_board = nj.reshape(pi_copy, [this.n, this.n]);
const l = [];
for (let i = 1; i < 5; i++) {
for (const j of [true, false]) {
let newB = nj.rot90(boardNdArray, i);
let newPi = nj.rot90(pi_board, i);
if (j) {
// Python:newB = np.fliplr(newB)
newB = nj.flip(newB, 1);
newPi = nj.flip(newPi, 1);
}
// Python:
// p: ordinary 1d array. after reshape
// >>> y2
// array([[3, 2, 1],
// [6, 5, 4],
// [9, 8, 7]])
// >>> y2.ravel() ~ numjy's flatten
// array([3, 2, 1, 6, 5, 4, 9, 8, 7]). ndarray type
// after list
// [3, 2, 1, 6, 5, 4, 9, 8, 7] !!. list type
// + [pi[-1] (e.g. [33])
// [3, 2, 1, 6, 5, 4, 9, 8, 7, 33]
const p = nj.flatten(newPi).tolist();
p.push(pi[pi.length - 1]);
const element = { b: newB, p };