Skip to content

Instantly share code, notes, and snippets.

@RashidLadj
RashidLadj / _ keyboart shortcut clear cmd
Last active Nov 8, 2020
this is a script to create keyboard shortcut to clear cmd and windows_terminal and vscode_terminal in Windows
View _ keyboart shortcut clear cmd
this is a script to create keyboard shortcut to clear cmd and windows_terminal and vscode_terminal in Windows
@RashidLadj
RashidLadj / intersect2D.py
Last active Oct 16, 2020
Python function to find the intersection between two 2D (or nD) numpy arrays, i.e. intersection of rows
View intersect2D.py
import numpy as np
def intersect2D(Array_A, Array_B):
"""
Find row intersection between 2D numpy arrays, a and b.
"""
# ''' Using Tuple ''' #
intersectionList = np.asarray([x for x in Array_A for y in Array_B if(tuple(x) == tuple(y))])
@RashidLadj
RashidLadj / intersect2D_with_Index.py
Last active Feb 4, 2021
Python function to find the intersection between two 2D numpy arrays with index in each array, i.e. intersection of rows
View intersect2D_with_Index.py
import numpy as np
def intersect2D(Array_A, Array_B):
"""
Find row intersection between 2D numpy arrays, a and b.
Returns another numpy array with shared rows and index of items in A & B arrays
"""
# [[IDX], [IDY], [value]] where Equal
# ''' Using Tuple ''' #
IndexEqual = np.asarray([(i, j, x) for i,x in enumerate(Array_A) for j, y in enumerate (Array_B) if(tuple(x) == tuple(y))]).T