Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: RFC: PDL Cheat Sheet

by zentara (Archbishop)
on Jan 03, 2007 at 13:50 UTC ( #592761=note: print w/replies, xml ) Need Help??

in reply to RFC: PDL Cheat Sheet

Here is an interesting tidbit for people just learning. You always want to print your piddles to see what you are doing wrong, but PDL has a limit set of 30000 elements, and if your piddles exceed that, you get the dreaded 'TOO LONG TO PRINT' error message. Fortunately the PDL modules have easy-to-override subs, so you can use this module to print any size piddle.

Include this somewhere in your PERL5LIB, and

use pdldump;

# file package PDL::Core; my $max_elem = 10000000; # set your max here sub PDL::Core::string { my ( $self, $format ) = @_; if ( $PDL::_STRINGIZING ) { return "ALREADY_STRINGIZING_NO_LOOPS"; } local $PDL::_STRINGIZING = 1; my $ndims = $self->getndims; if ( $self->nelem > $max_elem ) { return "TOO LONG TO PRINT"; } if ( $ndims == 0 ) { if ( $self->badflag() and $self->isbad() ) { return "BAD"; } else { my @x = $self->at(); return ( $format ? sprintf( $format, $x[ 0 ] ) : "$x[0]" ); } } return "Null" if $self->isnull; return "Empty" if $self->isempty; # Empty piddle local $PDL::Core::sep = $PDL::use_commas ? "," : " "; local $PDL::Core::sep2 = $PDL::use_commas ? "," : ""; if ( $ndims == 1 ) { return PDL::Core::str1D( $self, $format ); } else { return PDL::Core::strND( $self, $format, 0 ); } } 1;

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://592761]
[Corion]: Has anybody toyed around with Mastodon? There is a Perl module for it, but I'm not sure that it's a yak worth chasing
[Corion]: On the upside, maybe running that for my family would be interesting, or at least for myself
[Corion]: I'm not fond of using a server hosted by other people, even if they claim to be GNU ;)
[Discipulus]: gee a social network with the family.. is this a dread? ;=)
[Corion]: Discipulus: Nah, I'm thinking of posting more short stuff, but not all of it is fit for, more something a bit longer than Twitter but shorter than my usual b.p.o module posts
[Corion]: But Google+ is tedious and I'd like to keep my posts on an open platform instead, which can be followed via RSS

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2017-05-26 07:40 GMT
Find Nodes?
    Voting Booth?