Discussion:
[Pdl-porters] [Perldl] show of hands for PDL users
Ingo Schmid
2013-12-06 17:20:18 UTC
Permalink
Chris,

here are some fragments of where I'm aiming, see below.
Far less important but still, the barf on multielement piddles!
It breaks the expected if ($var) { ...} perl behaviour. This is
an issue whenever you use existing perl code with piddles. I
thought about it and maybe a per-piddle $piddle->cond_behave()
call added? The default value and undef would mean the
current behaviour, the other values would be, for example
'any','all','defined'. Then these calls are used in the
conditional expression. Discussion should go to a separate
thread, I guess.
There has been some discussion about this already and
I think the "proper" solution would be to make PDL be
consistent with other perl objects. The existing error
could be moved to planned PDL warnings support. That
has been on the wish list for quite some time.
I remember the discussion. I think that my suggestion would present a
relatively simple
solution. A modification to Core.pm.PL along the lines of this would do
it (line 870):

'bool' => sub { return 0 if $_[0]->isnull;
unless ($_[0]->pdl_cond ) { # old behaviour;
default
croak("multielement piddle in
conditional expression")
unless $_[0]->nelem == 1;
$_[0]->clump(-1)->at(0);
}
$_[0]->any if ($_[0]->pdl_cond eq 'any');
$_[0]->all if ($_[0]->pdl_cond eq 'all');
$_[0]->defined if ($_[0]->pdl_cond eq 'defined');
},

I would have provided a patch, but I think something like this is also
needed. I didn't figure where exactly I should place it.

sub pdl_cond {
my $self=shift;
my $c=shift;
if ($c) {
unless (UNIVERSAL::isa($self,'HASH')) {
my $h={};
$h{PDL}=$self;
$self=\%h;
}
$self->{multielement_cond}=shift ;
return $self->{umltielement_cond};
}
- I would use PDL more (or at all) if only ...
... I could find the time to look into PP.
honestly, hard to say, I already do most stuff in PDL.
- Any suggestions for PDL development?
many ;)
A lot of work has gone into making PDL easy to install. Keep
that going!
Bug reports, testing and user feedback are critical to
keeping this going.
The graphics side took huge steps forward with bindings to
Prima and Gnuplot. BTW., what do you get if you install PDL but
have no graphics package installed? I'd like to see a big fat
warning whenever that is the case, because nothing would turn
people away faster than not being able to say "plot $x;" and
get something on the screen, I guess.
Good idea.
Better documentation, especially some kind of index to look for
keywords related to modules/functions is always an issue.
Better documentation, cross-references, and a more uniform
method/function naming scheme and argument format are all
much desired features.
There has been a lot of improvements, especially the book is a
real bonus. As a side note, when I click on the PDL Book link
(side panel on pdl.perl.org), I come to the page first steps
with PDL. Only at the very bottom of the page, there is a link
to the sf book! Please provide a link right at the top!
Done.
Support more data types, especially complex.
Generic type support is planned in the PDL3 development.
Right now, the goal for PDL-2.008 is to address the
remaining limitation of the 64bit index support within
the current PDL-2.x development sequence.
The PDL3 work will start from a core-cleanup from the
PDL-2.008 release which is hoped to be completed by
the end of Dec 2013.
Make PDL as perlish as possible from the view of other non-PDL
modules. Ideally, PDL behaves just like another class, and
a piddle is just yet another reference to an object. Recent
discussions on use base PDL; and Storable should give you an
idea what I mean.
Clean up of the default PDL import semantics is also
a goal for PDL3 work. Various clean up along the
way is occurring.
Support for meaningful dimensions (names, units, spacing).
Rather than having to remember and keeping track of what your
piddle looks like, ie. the mes one can end after using several
mv(), reshape(), etc., calling sumover('x','t') would be cool.
Support for attributes to tag dimensions with various
metadata are planned for PDL3 as well. We have a general
approach already (roughly based on HDF5) but want to
clean up the PDL base before adding anything new. The
idea is that PDL3 will be more minimalist (closer to the
current PDL core distribution but allowing for backwards
compatibility to the 2.x sequence while enabling aggressive
new capabilities.
I have been working on that and some stuff is already there.
I plan to release a module some time in the future, but have
currently too much other stuff to do. Discussion should go to a
separate thread, I guess.
Yes, and please keep pdl-porters in the loop. It could
help to avoid redundant effort or inconsistent implementations.
Please take a look at the file attached. It's code that is extracted
from a bigger project which is meant to be its own module. I haven't
come around to actually separate it. This is something to work from, but
it should provide you with the idea where it is aimed. For example, the
sln() function should incorporate a call to slice, etc. At the moment it
operates on the metadata only and does not touch the piddle itself, it
should overload the appropriate basic PDL methods.
To summarise, I like PDL a lot and use it a lot.
Great to hear...
Happy PDL-ing!
Chris
Ingo
Craig DeForest
2013-12-06 17:40:00 UTC
Permalink
Hmmm...

The issues with '&&' and '||' support is that an important part of
those operators are:
(a) they short-circuit, which would require non-deterministic code
execution in the multielement case;
(b) there is no obvious way to clump the results to a single boolean
("any" vs "all" vs "majority-rule", for example)

Ingo, your idea is kind of cool, but I don't see how it helps much.
Since PDL-as-hash-element is mainly meant as a convenience to writers
of subclasses, why not just override 'bool' for that class instead
of adding more strangeness to PDLs themselves?

I actually rather like the default behavior of PDLs: placing a
multielement PDL into a Perl conditional expression is nearly always
an error...
Post by Ingo Schmid
Chris,
here are some fragments of where I'm aiming, see below.
Far less important but still, the barf on multielement piddles!
It breaks the expected if ($var) { ...} perl behaviour. This is
an issue whenever you use existing perl code with piddles. I
thought about it and maybe a per-piddle $piddle->cond_behave()
call added? The default value and undef would mean the
current behaviour, the other values would be, for example
'any','all','defined'. Then these calls are used in the
conditional expression. Discussion should go to a separate
thread, I guess.
There has been some discussion about this already and
I think the "proper" solution would be to make PDL be
consistent with other perl objects. The existing error
could be moved to planned PDL warnings support. That
has been on the wish list for quite some time.
I remember the discussion. I think that my suggestion would present a
relatively simple
solution. A modification to Core.pm.PL along the lines of this would do
'bool' => sub { return 0 if $_[0]->isnull;
unless ($_[0]->pdl_cond ) { # old behaviour;
default
croak("multielement piddle in
conditional expression")
unless $_[0]->nelem == 1;
$_[0]->clump(-1)->at(0);
}
$_[0]->any if ($_[0]->pdl_cond eq 'any');
$_[0]->all if ($_[0]->pdl_cond eq 'all');
$_[0]->defined if ($_[0]->pdl_cond eq 'defined');
},
I would have provided a patch, but I think something like this is also
needed. I didn't figure where exactly I should place it.
sub pdl_cond {
my $self=shift;
my $c=shift;
if ($c) {
unless (UNIVERSAL::isa($self,'HASH')) {
my $h={};
$h{PDL}=$self;
$self=\%h;
}
$self->{multielement_cond}=shift ;
return $self->{umltielement_cond};
}
- I would use PDL more (or at all) if only ...
... I could find the time to look into PP.
honestly, hard to say, I already do most stuff in PDL.
- Any suggestions for PDL development?
many ;)
A lot of work has gone into making PDL easy to install. Keep
that going!
Bug reports, testing and user feedback are critical to
keeping this going.
The graphics side took huge steps forward with bindings to
Prima and Gnuplot. BTW., what do you get if you install PDL but
have no graphics package installed? I'd like to see a big fat
warning whenever that is the case, because nothing would turn
people away faster than not being able to say "plot $x;" and
get something on the screen, I guess.
Good idea.
Better documentation, especially some kind of index to look for
keywords related to modules/functions is always an issue.
Better documentation, cross-references, and a more uniform
method/function naming scheme and argument format are all
much desired features.
There has been a lot of improvements, especially the book is a
real bonus. As a side note, when I click on the PDL Book link
(side panel on pdl.perl.org), I come to the page first steps
with PDL. Only at the very bottom of the page, there is a link
to the sf book! Please provide a link right at the top!
Done.
Support more data types, especially complex.
Generic type support is planned in the PDL3 development.
Right now, the goal for PDL-2.008 is to address the
remaining limitation of the 64bit index support within
the current PDL-2.x development sequence.
The PDL3 work will start from a core-cleanup from the
PDL-2.008 release which is hoped to be completed by
the end of Dec 2013.
Make PDL as perlish as possible from the view of other non-PDL
modules. Ideally, PDL behaves just like another class, and
a piddle is just yet another reference to an object. Recent
discussions on use base PDL; and Storable should give you an
idea what I mean.
Clean up of the default PDL import semantics is also
a goal for PDL3 work. Various clean up along the
way is occurring.
Support for meaningful dimensions (names, units, spacing).
Rather than having to remember and keeping track of what your
piddle looks like, ie. the mes one can end after using several
mv(), reshape(), etc., calling sumover('x','t') would be cool.
Support for attributes to tag dimensions with various
metadata are planned for PDL3 as well. We have a general
approach already (roughly based on HDF5) but want to
clean up the PDL base before adding anything new. The
idea is that PDL3 will be more minimalist (closer to the
current PDL core distribution but allowing for backwards
compatibility to the 2.x sequence while enabling aggressive
new capabilities.
I have been working on that and some stuff is already there.
I plan to release a module some time in the future, but have
currently too much other stuff to do. Discussion should go to a
separate thread, I guess.
Yes, and please keep pdl-porters in the loop. It could
help to avoid redundant effort or inconsistent implementations.
Please take a look at the file attached. It's code that is extracted
from a bigger project which is meant to be its own module. I haven't
come around to actually separate it. This is something to work from, but
it should provide you with the idea where it is aimed. For example, the
sln() function should incorporate a call to slice, etc. At the moment it
operates on the metadata only and does not touch the piddle itself, it
should overload the appropriate basic PDL methods.
To summarise, I like PDL a lot and use it a lot.
Great to hear...
Happy PDL-ing!
Chris
Ingo
<PDL-Dim.pm>_______________________________________________
PDL-porters mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/pdl-porters
Chris Marshall
2013-12-06 19:26:00 UTC
Permalink
On Fri, Dec 6, 2013 at 12:40 PM, Craig DeForest
Post by Craig DeForest
Hmmm...
I actually rather like the default behavior of PDLs: placing a
multielement PDL into a Perl conditional expression is nearly always
an error...
Ingo Schmid
2013-12-09 09:48:20 UTC
Permalink
Craig,
Post by Craig DeForest
Ingo, your idea is kind of cool, but I don't see how it helps much.
Since PDL-as-hash-element is mainly meant as a convenience to writers of
subclasses, ...

How do you store additional data in $piddle?

Ingo
Post by Craig DeForest
Post by Ingo Schmid
Chris,
here are some fragments of where I'm aiming, see below.
Far less important but still, the barf on multielement piddles!
It breaks the expected if ($var) { ...} perl behaviour. This is
an issue whenever you use existing perl code with piddles. I
thought about it and maybe a per-piddle $piddle->cond_behave()
call added? The default value and undef would mean the
current behaviour, the other values would be, for example
'any','all','defined'. Then these calls are used in the
conditional expression. Discussion should go to a separate
thread, I guess.
There has been some discussion about this already and
I think the "proper" solution would be to make PDL be
consistent with other perl objects. The existing error
could be moved to planned PDL warnings support. That
has been on the wish list for quite some time.
I remember the discussion. I think that my suggestion would present a
relatively simple
solution. A modification to Core.pm.PL along the lines of this would do
'bool' => sub { return 0 if $_[0]->isnull;
unless ($_[0]->pdl_cond ) { # old behaviour;
default
croak("multielement piddle in
conditional expression")
unless $_[0]->nelem == 1;
$_[0]->clump(-1)->at(0);
}
$_[0]->any if ($_[0]->pdl_cond eq 'any');
$_[0]->all if ($_[0]->pdl_cond eq 'all');
$_[0]->defined if ($_[0]->pdl_cond eq 'defined');
},
I would have provided a patch, but I think something like this is also
needed. I didn't figure where exactly I should place it.
sub pdl_cond {
my $self=shift;
my $c=shift;
if ($c) {
unless (UNIVERSAL::isa($self,'HASH')) {
my $h={};
$h{PDL}=$self;
$self=\%h;
}
$self->{multielement_cond}=shift ;
return $self->{umltielement_cond};
}
- I would use PDL more (or at all) if only ...
... I could find the time to look into PP.
honestly, hard to say, I already do most stuff in PDL.
- Any suggestions for PDL development?
many ;)
A lot of work has gone into making PDL easy to install. Keep
that going!
Bug reports, testing and user feedback are critical to
keeping this going.
The graphics side took huge steps forward with bindings to
Prima and Gnuplot. BTW., what do you get if you install PDL but
have no graphics package installed? I'd like to see a big fat
warning whenever that is the case, because nothing would turn
people away faster than not being able to say "plot $x;" and
get something on the screen, I guess.
Good idea.
Better documentation, especially some kind of index to look for
keywords related to modules/functions is always an issue.
Better documentation, cross-references, and a more uniform
method/function naming scheme and argument format are all
much desired features.
There has been a lot of improvements, especially the book is a
real bonus. As a side note, when I click on the PDL Book link
(side panel on pdl.perl.org), I come to the page first steps
with PDL. Only at the very bottom of the page, there is a link
to the sf book! Please provide a link right at the top!
Done.
Support more data types, especially complex.
Generic type support is planned in the PDL3 development.
Right now, the goal for PDL-2.008 is to address the
remaining limitation of the 64bit index support within
the current PDL-2.x development sequence.
The PDL3 work will start from a core-cleanup from the
PDL-2.008 release which is hoped to be completed by
the end of Dec 2013.
Make PDL as perlish as possible from the view of other non-PDL
modules. Ideally, PDL behaves just like another class, and
a piddle is just yet another reference to an object. Recent
discussions on use base PDL; and Storable should give you an
idea what I mean.
Clean up of the default PDL import semantics is also
a goal for PDL3 work. Various clean up along the
way is occurring.
Support for meaningful dimensions (names, units, spacing).
Rather than having to remember and keeping track of what your
piddle looks like, ie. the mes one can end after using several
mv(), reshape(), etc., calling sumover('x','t') would be cool.
Support for attributes to tag dimensions with various
metadata are planned for PDL3 as well. We have a general
approach already (roughly based on HDF5) but want to
clean up the PDL base before adding anything new. The
idea is that PDL3 will be more minimalist (closer to the
current PDL core distribution but allowing for backwards
compatibility to the 2.x sequence while enabling aggressive
new capabilities.
I have been working on that and some stuff is already there.
I plan to release a module some time in the future, but have
currently too much other stuff to do. Discussion should go to a
separate thread, I guess.
Yes, and please keep pdl-porters in the loop. It could
help to avoid redundant effort or inconsistent implementations.
Please take a look at the file attached. It's code that is extracted
from a bigger project which is meant to be its own module. I haven't
come around to actually separate it. This is something to work from, but
it should provide you with the idea where it is aimed. For example, the
sln() function should incorporate a call to slice, etc. At the moment it
operates on the metadata only and does not touch the piddle itself, it
should overload the appropriate basic PDL methods.
To summarise, I like PDL a lot and use it a lot.
Great to hear...
Happy PDL-ing!
Chris
Ingo
<PDL-Dim.pm>_______________________________________________
PDL-porters mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/pdl-porters
David Mertens
2013-12-09 14:59:32 UTC
Permalink
(Ab)Use the piddle header:

$piddle->hdr->{key} = $value;
$piddle->hdr->{$key} = $value;

David
Post by Ingo Schmid
Craig,
Ingo, your idea is kind of cool, but I don't see how it helps much. Since
PDL-as-hash-element is mainly meant as a convenience to writers of
subclasses, ...
How do you store additional data in $piddle?
Ingo
Chris,
Post by Ingo Schmid
here are some fragments of where I'm aiming, see below.
Far less important but still, the barf on multielement piddles!
It breaks the expected if ($var) { ...} perl behaviour. This is
an issue whenever you use existing perl code with piddles. I
thought about it and maybe a per-piddle $piddle->cond_behave()
call added? The default value and undef would mean the
current behaviour, the other values would be, for example
'any','all','defined'. Then these calls are used in the
conditional expression. Discussion should go to a separate
thread, I guess.
There has been some discussion about this already and
I think the "proper" solution would be to make PDL be
consistent with other perl objects. The existing error
could be moved to planned PDL warnings support. That
has been on the wish list for quite some time.
I remember the discussion. I think that my suggestion would present a
relatively simple
solution. A modification to Core.pm.PL along the lines of this would do
'bool' => sub { return 0 if $_[0]->isnull;
unless ($_[0]->pdl_cond ) { # old behaviour;
default
croak("multielement piddle in
conditional expression")
unless $_[0]->nelem == 1;
$_[0]->clump(-1)->at(0);
}
$_[0]->any if ($_[0]->pdl_cond eq 'any');
$_[0]->all if ($_[0]->pdl_cond eq 'all');
$_[0]->defined if ($_[0]->pdl_cond eq 'defined');
},
I would have provided a patch, but I think something like this is also
needed. I didn't figure where exactly I should place it.
sub pdl_cond {
my $self=shift;
my $c=shift;
if ($c) {
unless (UNIVERSAL::isa($self,'HASH')) {
my $h={};
$h{PDL}=$self;
$self=\%h;
}
$self->{multielement_cond}=shift ;
return $self->{umltielement_cond};
}
- I would use PDL more (or at all) if only ...
... I could find the time to look into PP.
honestly, hard to say, I already do most stuff in PDL.
- Any suggestions for PDL development?
many ;)
A lot of work has gone into making PDL easy to install. Keep
that going!
Bug reports, testing and user feedback are critical to
keeping this going.
The graphics side took huge steps forward with bindings to
Prima and Gnuplot. BTW., what do you get if you install PDL but
have no graphics package installed? I'd like to see a big fat
warning whenever that is the case, because nothing would turn
people away faster than not being able to say "plot $x;" and
get something on the screen, I guess.
Good idea.
Better documentation, especially some kind of index to look for
keywords related to modules/functions is always an issue.
Better documentation, cross-references, and a more uniform
method/function naming scheme and argument format are all
much desired features.
There has been a lot of improvements, especially the book is a
real bonus. As a side note, when I click on the PDL Book link
(side panel on pdl.perl.org), I come to the page first steps
with PDL. Only at the very bottom of the page, there is a link
to the sf book! Please provide a link right at the top!
Done.
Support more data types, especially complex.
Generic type support is planned in the PDL3 development.
Right now, the goal for PDL-2.008 is to address the
remaining limitation of the 64bit index support within
the current PDL-2.x development sequence.
The PDL3 work will start from a core-cleanup from the
PDL-2.008 release which is hoped to be completed by
the end of Dec 2013.
Make PDL as perlish as possible from the view of other non-PDL
modules. Ideally, PDL behaves just like another class, and
a piddle is just yet another reference to an object. Recent
discussions on use base PDL; and Storable should give you an
idea what I mean.
Clean up of the default PDL import semantics is also
a goal for PDL3 work. Various clean up along the
way is occurring.
Support for meaningful dimensions (names, units, spacing).
Rather than having to remember and keeping track of what your
piddle looks like, ie. the mes one can end after using several
mv(), reshape(), etc., calling sumover('x','t') would be cool.
Support for attributes to tag dimensions with various
metadata are planned for PDL3 as well. We have a general
approach already (roughly based on HDF5) but want to
clean up the PDL base before adding anything new. The
idea is that PDL3 will be more minimalist (closer to the
current PDL core distribution but allowing for backwards
compatibility to the 2.x sequence while enabling aggressive
new capabilities.
I have been working on that and some stuff is already there.
I plan to release a module some time in the future, but have
currently too much other stuff to do. Discussion should go to a
separate thread, I guess.
Yes, and please keep pdl-porters in the loop. It could
help to avoid redundant effort or inconsistent implementations.
Please take a look at the file attached. It's code that is extracted
from a bigger project which is meant to be its own module. I haven't
come around to actually separate it. This is something to work from, but
it should provide you with the idea where it is aimed. For example, the
sln() function should incorporate a call to slice, etc. At the moment it
operates on the metadata only and does not touch the piddle itself, it
should overload the appropriate basic PDL methods.
To summarise, I like PDL a lot and use it a lot.
Great to hear...
Happy PDL-ing!
Chris
Ingo
<PDL-Dim.pm>_______________________________________________
PDL-porters mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/pdl-porters
_______________________________________________
PDL-porters mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/pdl-porters
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." -- Brian Kernighan
Chris Marshall
2013-12-09 15:13:23 UTC
Permalink
The current plan for the PDL2 header key is to replace it
by a top level, modern OO object based on Moo[se]. That
is pretty much isomorphic to the single key but much,
much, much more general and robust for future implementations.

E.g., the current hdr use is a mish-mash of several modules
that take care not to step on eachother. Mysterious code,
reserved key names,...pretty much a poster child for fragile
code. :-(
Post by David Mertens
$piddle->hdr->{key} = $value;
$piddle->hdr->{$key} = $value;
David
Post by Ingo Schmid
Craig,
Ingo, your idea is kind of cool, but I don't see how it helps much. Since
PDL-as-hash-element is mainly meant as a convenience to writers of
subclasses, ...
How do you store additional data in $piddle?
Ingo
Chris Marshall
2013-12-06 19:21:47 UTC
Permalink
Post by Ingo Schmid
Chris,
...
Please take a look at the file attached. It's code that is extracted
from a bigger project which is meant to be its own module. I haven't
come around to actually separate it. This is something to work from, but
it should provide you with the idea where it is aimed. For example, the
sln() function should incorporate a call to slice, etc. At the moment it
operates on the metadata only and does not touch the piddle itself, it
should overload the appropriate basic PDL methods.
Ingo-

Thanks for the example. I would say that this is the general
direction to go but the idea for PDL3 would be to clean up the
implementation details as much as possible to simplify
development in new directions.

For example:
- switch to modern OO perl via Mo[o[se]]
- attributes would be at the pdl object level
- threading would be enhanced use attributes transparently

Regards,
Chris
Loading...