2

I have a question regarding how to delete a not-unique pair in a combination array. for example, I have an array that have

array = 
[[x,y],[z,x]]
[[a,b],[c,d]]
[[z,x],[x,y]]

here, the desired outcome is

array = 
[[x,y],[z,x]]
[[a,b],[c,d]]

([[z,x],[x,y]] is deleted because the elements are the same as [[x,y],[z,x]] )

I am attaching a part of my code. Please help! thank you

import numpy as np

filename = example.xyz
xyz_file = np.genfromtxt(fname=filename,skip_header=2,dtype='unicode')
xyz = open(filename)

atom_quantity = int(xyz.readline())
atom_coordinates = (xyz_file[:,1:])
atom_coordinates = atom_coordinates.astype(float)

print("The xyz coordinate of the each atom:",atom_coordinates)

import itertools as it
# the Total number of the iteration = 2 pair combination
# change coordinate data into array 
array = np.array(atom_coordinates)

# apply combination for all atoms on data
combinations = it.product(array,array)

for combination in combinations:
    ### Delete the duplicate combination 
    
    array_comb = np.array(combination)
    print(array_comb)

output so far (print array_comb)

x[[-0.365742 -1.434236  1.086713]
 [-0.365742 -1.434236  1.086713]]
[[-0.365742 -1.434236  1.086713]
 [ 1.758085 -2.733505 -0.455397]]
[[-0.365742 -1.434236  1.086713]
 [-2.77726   0.865973 -0.978809]]
[[-0.365742 -1.434236  1.086713]
 [-0.850929  0.805368 -1.050607]]
[[-0.365742 -1.434236  1.086713]
 [ 0.469728 -1.262455  1.770134]]....
riven
  • 27
  • 4

0 Answers0