Closed ghost closed 9 years ago
Could convert array to list, then convert list to string:
def stringer(y):
x = str(y[0])
for i in range(len(y)):
x+=' '+str(y[i])
return x
But, this is an ugly solution.
Here's a better solution:
def find_subsequence(seq, subseq):
target = np.dot(subseq, subseq)
candidates = np.where(np.correlate(seq, subseq, mode='valid') == target)[0]
# some of the candidates entries may be false positives, double check
check = candidates[:, np.newaxis] + np.arange(len(subseq))
mask = np.all((np.take(seq, check) == subseq), axis=-1)
return candidates[mask]
I can find sub-strings in a string with str.find() but how am I supposed to do this with arrays??