in aiops/RCRank/model/modules/QueryFormer/utils.py [0:0]
def filterDict2Hist(hist_file, filterDict, encoding):
buckets = len(hist_file['bins'][0])
empty = np.zeros(buckets - 1)
ress = np.zeros((3, buckets-1))
for i in range(len(filterDict['colId'])):
colId = filterDict['colId'][i]
col = encoding.idx2col[colId]
if col == 'NA':
ress[i] = empty
continue
bins = hist_file.loc[hist_file['table_column']==col,'bins'].item()
opId = filterDict['opId'][0]
op = encoding.idx2op[opId]
val = filterDict['val'][0]
mini, maxi = encoding.column_min_max_vals[col]
val_unnorm = val * (maxi-mini) + mini
left = 0
right = len(bins)-1
for j in range(len(bins)):
if bins[j]<val_unnorm:
left = j
if bins[j]>val_unnorm:
right = j
break
res = np.zeros(len(bins)-1)
if op == '=':
res[left:right] = 1
elif op == '<':
res[:left] = 1
elif op == '>':
res[right:] = 1
ress[i] = res
ress = ress.flatten()
return ress