Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
The following saves floating values of a matrix into textfiles
numpy.savetxt('bool',mat,fmt='%f',delimiter=',')
How to save a boolean matrix ? what is the fmt for saving boolean matrix ?
numpy.load()
numpy.save()
np.savetxt
np.loadtxt
np.save
np.load
Thats correct, bools are integers, so you can always go between the two.
import numpy as np arr = np.array([True, True, False, False]) np.savetxt("test.txt", arr, fmt="%5i")
That gives a file with 1 1 0 0
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
numpy.load()andnumpy.save()will be much more efficient.np.savetxt/np.loadtxt? How aboutnp.save/np.load?