-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make #pretty_print actually pretty #52
Comments
I cleaned up the code in a recent commit. Have you tried it with pry (which uses coderay)? It looks a little better. |
Some experiments in IRB: > n = NMatrix.random(4)
> n.pp
[[0.6299860224178115, 0.2626926192712231, 0.9008651790526774, 0.7025077672785742]
[0.6629325603072921, 0.657471929860773, 0.9601643345978037, 0.7900181731280271]
[0.22735456931808107, 0.5035327724154458, 0.6728627567703459, 0.9629883418502257]
[0.36004767980910257, 0.6542623614657115, 0.9829866207607914, 0.6299860224178115]]
=> nil
> u = NVector.random(3)
> u.pretty_print
[0.6652767626356697
0.1188537203789306
0.8368488043457466]
=> nil
> u.pp
=> "#<NVector:0x007fad838f6668 orientation:column shape:[3,1] dtype:float64 stype:dense>" The result from > class NVector
> alias :pp :pretty_print
> end
=> nil
> u.pp
[0.6652767626356697
0.1188537203789306
0.8368488043457466]
=> nil I can send a PR with this. But there's one more question: why isn't there a > n = NMatrix.seq(3)
> u = NVector.random(3)
> puts n
0 1 2
0 0 1 2
1 3 4 5
2 6 7 8
> puts u
0 0.6652767626356697
1 0.1188537203789306
2 0.8368488043457466 I think this can be useful. If you agree with me, I can implement it during the weekend. |
I don't think |
Why not? I agree that I've never seen others do that, but in this case it's much better (and useful) than In any case, I'll ask other Rubyists' opinions on this :) |
Why not? Again, mainly because I haven't seen any other objects that do multiline |
Can we try something like awesome_print? |
No. I think we don't want to complicate NMatrix with additional dependencies, if possible. |
I'm trying to come up with some examples of how to use NMatrix and, obviously,
#pretty_print
/#pp
is used lots of times.I wanted to throw this discussion to see how you guys think
NMatrix
/NVector
should be printed. Any ideas? I'll try to come up with something and implement it, but I don't want to make this kind of change without listening to others.The text was updated successfully, but these errors were encountered: