#!/usr/bin/env python # coding: utf-8 # # MatRepr NumPy # # Compare the native NumPy repr with MatRepr's formatting. # In[1]: import numpy as np np.random.seed(123) # so matrepr can be imported from the source tree. import sys sys.path.insert(0, '..') from matrepr import mdisplay, mprint # ### 1D vector # In[2]: v1 = np.arange(10, 50) print(v1) # In[3]: mdisplay(v1) # ### A small 2D matrix # In[4]: mat = np.random.random((10, 10)) print(mat) # In[5]: mdisplay(mat, floatfmt=".4f") # ### A 4D matrix # In[6]: dense_4d = np.random.random((1000, 4, 4, 4)) mdisplay(dense_4d, floatfmt=".2f", max_rows=10) # ### A big 2D matrix # In[7]: big_2D = np.random.random_sample((100, 100)) print(big_2D) # In[8]: mdisplay(big_2D) # In[ ]: