Archive of entries posted on September 2014

Needed to convert a one dimensional array to a two dimensional numpy matrix and then add a row vector to the end of the matrix. import numpy array1d = range(10,100) array2d = [array1d[i:i + 10] for i in range(0, len(array1d), 10)] newline = [88 for i in range(1,11)] m = numpy.matrix(array2d) m_extended = numpy.vstack([m, newline])

I needed to convert a JSON hierarchy to an HTML bullet hierarchy and all the solutions I found on the Web were overkill. Enjoy. <!DOCTYPE html> <head> <script> var g_tree = { "1":{ "11":{ "111":{ "option1":1, …