Discussion:
[Pdl-porters] PDL-Dims v0.001
Ingo Schmid
2014-02-14 19:43:23 UTC
Permalink
Hi,

this module is an extension to PDL, giving dimensions a meaning. They
have namesand data range (or values if not evenlyspaced).Utility
functions store and retrieve this from your piddle header.

I'm too lazy to remember and keep track of the order of dimensions, so I
wrote this module. Maybe some of you find it useful.

More interesting, wrappers to slice andother functions exist, so you
don't have to do your beloved

$pdl->mv(3,0)->rotate($x)->mv(0,3),

instead you can say

nop($pdl,'rotate','z',$x).

Or you can say

ncop($a,$b,'plus',0)

to add arbitrarily shaped piddles. Equally named dims obey the threading
rules, otherwise they are concatenated.

$pdl: [10,10,10,4]
dims: 'x','y','z','t'

$slice = sln($pdl, x=>'0:10:2', z=>"$a:$b:$c",);

I think you guess this one.

I just uploaded the module to pause, give it a few hours to appear on cpan.

Ingo
Chris Marshall
2014-02-14 20:04:46 UTC
Permalink
Neat! I'll take a look when the module appears.
This type of functionality is already planned for the
PDL3 work. Some things to watch out for going
forward:

(1) The PDL header is going away to be replaced by
a more modular/namespaced functionality. The
current implementation is a blind hash with no
coordination or protection between modules and
their uses of it.

(2) As part of the PDL3 work, we plan to clean up the
PDL support for object oriented programming and
inheritance. The current idea is to replace the
hardwired support for a piddle has a blessed hash
with a PDL key by an object with a PDL attribute.
For the case of an object implemented as a blessed
hash, the effect will be pretty much the same.

(3) I'm not sure how the new types support in PDL3
will affect PDL::Dims.

Cheers,
Chris
Hi,
this module is an extension to PDL, giving dimensions a meaning. They have
names and data range (or values if not evenly spaced). Utility functions
store and retrieve this from your piddle header.
I'm too lazy to remember and keep track of the order of dimensions, so I
wrote this module. Maybe some of you find it useful.
More interesting, wrappers to slice and other functions exist, so you don't
have to do your beloved
$pdl->mv(3,0)->rotate($x)->mv(0,3),
instead you can say
nop($pdl,'rotate','z',$x).
Or you can say
ncop($a,$b,'plus',0)
to add arbitrarily shaped piddles. Equally named dims obey the threading
rules, otherwise they are concatenated.
$pdl: [10,10,10,4]
dims: 'x','y','z','t'
$slice = sln($pdl, x=>'0:10:2', z=>"$a:$b:$c",);
I think you guess this one.
I just uploaded the module to pause, give it a few hours to appear on cpan.
Ingo
Ingo Schmid
2014-02-17 09:29:16 UTC
Permalink
Chris,
Post by Chris Marshall
Neat! I'll take a look when the module appears.
This type of functionality is already planned for the
PDL3 work. Some things to watch out for going
(1) The PDL header is going away to be replaced by
a more modular/namespaced functionality. The
current implementation is a blind hash with no
coordination or protection between modules and
their uses of it.
I think it will boil down onto search/replace $self->hdr with whatever
the new implementation is. It should work seamless, it might break
compatibility with retrieved piddles. I don't worry too much.
Post by Chris Marshall
(2) As part of the PDL3 work, we plan to clean up the
PDL support for object oriented programming and
inheritance. The current idea is to replace the
hardwired support for a piddle has a blessed hash
with a PDL key by an object with a PDL attribute.
For the case of an object implemented as a blessed
hash, the effect will be pretty much the same.
I don't expect too much trouble here, either. To be honest, I still
don't understand the current implementation. At the moment, only
functions work. eg. $piddle->nop(...) does not. What I'm trying to avoid
is to report the result back as a PDL::Dims object instead of a PDL
object, since there are some cases where this causes trouble.
Post by Chris Marshall
(3) I'm not sure how the new types support in PDL3
will affect PDL::Dims.
not at all, I think. There is no explicit link to data types.
Ingo
Post by Chris Marshall
Cheers,
Chris
Hi,
this module is an extension to PDL, giving dimensions a meaning. They have
names and data range (or values if not evenly spaced). Utility functions
store and retrieve this from your piddle header.
I'm too lazy to remember and keep track of the order of dimensions, so I
wrote this module. Maybe some of you find it useful.
More interesting, wrappers to slice and other functions exist, so you don't
have to do your beloved
$pdl->mv(3,0)->rotate($x)->mv(0,3),
instead you can say
nop($pdl,'rotate','z',$x).
Or you can say
ncop($a,$b,'plus',0)
to add arbitrarily shaped piddles. Equally named dims obey the threading
rules, otherwise they are concatenated.
$pdl: [10,10,10,4]
dims: 'x','y','z','t'
$slice = sln($pdl, x=>'0:10:2', z=>"$a:$b:$c",);
I think you guess this one.
I just uploaded the module to pause, give it a few hours to appear on cpan.
Ingo
Chris Marshall
2014-02-15 23:00:23 UTC
Permalink
Hi Ingo-

I was able to build PDL::Dims on cygwin and tests
passed but there were a bunch of error/warning type
output.

Do you have some more examples and explanations
for the different routines, including input data and the
results? I don't understand ncop() from the description.

Also, one thing that is a nice idiom for the operate on
Post by Ingo Schmid
$pdl->mv(3,0)->rotate($x)->mv(0,3),
Is to perform the first dimension move slice and
save as a lexical piddle. Then just do the 'rotate'
or whatever on that piddle. Because of dataflow
the result will flow back to the right dimension
order in the original piddle. This also allows you
to debug things since there is a separate value
for each step of the processing.

--Chris
Post by Ingo Schmid
Hi,
this module is an extension to PDL, giving dimensions a meaning. They have
names and data range (or values if not evenly spaced). Utility functions
store and retrieve this from your piddle header.
I'm too lazy to remember and keep track of the order of dimensions, so I
wrote this module. Maybe some of you find it useful.
More interesting, wrappers to slice and other functions exist, so you don't
have to do your beloved
$pdl->mv(3,0)->rotate($x)->mv(0,3),
instead you can say
nop($pdl,'rotate','z',$x).
Or you can say
ncop($a,$b,'plus',0)
to add arbitrarily shaped piddles. Equally named dims obey the threading
rules, otherwise they are concatenated.
$pdl: [10,10,10,4]
dims: 'x','y','z','t'
$slice = sln($pdl, x=>'0:10:2', z=>"$a:$b:$c",);
I think you guess this one.
I just uploaded the module to pause, give it a few hours to appear on cpan.
Ingo
_______________________________________________
Perldl mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
Ingo Schmid
2014-02-17 10:10:11 UTC
Permalink
Post by Chris Marshall
Hi Ingo-
I was able to build PDL::Dims on cygwin and tests
passed but there were a bunch of error/warning type
output.
There are a couple of warnings, issued when a dim is defined and initdim
is called. Can be ignored at this point.
Post by Chris Marshall
Do you have some more examples and explanations
for the different routines, including input data and the
results? I don't understand ncop() from the description.
There are different routines for different kind of functions.

sln() is for performing slicing. Use the output to pass on to whatever
you would.

nop is to perform operations on a given dim, like rotate. Are there
others, I just can't think of any at this moment.

ncop is the wrapper to perform functions that have two operands, e.g.
+-*/ ... You have to say 'plus',0 ... at the moment.

Please suggest a more self-explaining name, ncop stands for named
combined operations.
Post by Chris Marshall
Also, one thing that is a nice idiom for the operate on
Post by Ingo Schmid
$pdl->mv(3,0)->rotate($x)->mv(0,3),
Is to perform the first dimension move slice and
save as a lexical piddle. Then just do the 'rotate'
or whatever on that piddle. Because of dataflow
the result will flow back to the right dimension
order in the original piddle. This also allows you
to debug things since there is a separate value
for each step of the processing.
It's done that way.
Post by Chris Marshall
--Chris
Post by Ingo Schmid
Hi,
this module is an extension to PDL, giving dimensions a meaning. They have
names and data range (or values if not evenly spaced). Utility functions
store and retrieve this from your piddle header.
I'm too lazy to remember and keep track of the order of dimensions, so I
wrote this module. Maybe some of you find it useful.
More interesting, wrappers to slice and other functions exist, so you don't
have to do your beloved
$pdl->mv(3,0)->rotate($x)->mv(0,3),
instead you can say
nop($pdl,'rotate','z',$x).
Or you can say
ncop($a,$b,'plus',0)
to add arbitrarily shaped piddles. Equally named dims obey the threading
rules, otherwise they are concatenated.
$pdl: [10,10,10,4]
dims: 'x','y','z','t'
$slice = sln($pdl, x=>'0:10:2', z=>"$a:$b:$c",);
I think you guess this one.
I just uploaded the module to pause, give it a few hours to appear on cpan.
Ingo
_______________________________________________
Perldl mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
Chris Marshall
2014-02-17 13:17:22 UTC
Permalink
Post by Ingo Schmid
Post by Chris Marshall
Hi Ingo-
I was able to build PDL::Dims on cygwin and tests
passed but there were a bunch of error/warning type
output.
There are a couple of warnings, issued when a dim is defined and initdim
is called. Can be ignored at this point.
Post by Chris Marshall
Do you have some more examples and explanations
for the different routines, including input data and the
results? I don't understand ncop() from the description.
There are different routines for different kind of functions.
Examples in the pdl shell showing input values,
command, and output values are needed to show
the expected threading, especially for ncop().
Post by Ingo Schmid
sln() is for performing slicing. Use the output to pass on to whatever
you would.
nop is to perform operations on a given dim, like rotate. Are there
others, I just can't think of any at this moment.
ncop is the wrapper to perform functions that have two operands, e.g.
+-*/ ... You have to say 'plus',0 ... at the moment.
Please suggest a more self-explaining name, ncop stands for named
combined operations.
Post by Chris Marshall
Also, one thing that is a nice idiom for the operate on
Post by Ingo Schmid
$pdl->mv(3,0)->rotate($x)->mv(0,3),
Is to perform the first dimension move slice and
save as a lexical piddle. Then just do the 'rotate'
or whatever on that piddle. Because of dataflow
the result will flow back to the right dimension
order in the original piddle. This also allows you
to debug things since there is a separate value
for each step of the processing.
It's done that way.
Not in the nop() routine. You overwrite the $self with
the first mv() result. Then you have to do another mv()
on the $res piddle. I believe if you still had the original
$self you could return that and the inverse mv() operation
would take place by dataflow.
Post by Ingo Schmid
Post by Chris Marshall
--Chris
Post by Ingo Schmid
Hi,
this module is an extension to PDL, giving dimensions a meaning. They have
names and data range (or values if not evenly spaced). Utility functions
store and retrieve this from your piddle header.
I'm too lazy to remember and keep track of the order of dimensions, so I
wrote this module. Maybe some of you find it useful.
More interesting, wrappers to slice and other functions exist, so you don't
have to do your beloved
$pdl->mv(3,0)->rotate($x)->mv(0,3),
instead you can say
nop($pdl,'rotate','z',$x).
Or you can say
ncop($a,$b,'plus',0)
to add arbitrarily shaped piddles. Equally named dims obey the threading
rules, otherwise they are concatenated.
$pdl: [10,10,10,4]
dims: 'x','y','z','t'
$slice = sln($pdl, x=>'0:10:2', z=>"$a:$b:$c",);
I think you guess this one.
I just uploaded the module to pause, give it a few hours to appear on cpan.
Ingo
_______________________________________________
Perldl mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
Ingo Schmid
2014-02-17 13:32:23 UTC
Permalink
Chris,
thanks for your comments.
I uploaded a new version, rewriting the nop, I think it now does what
you suggest.
Post by Chris Marshall
Examples in the pdl shell showing input values,
command, and output values are needed to show
the expected threading, especially for ncop().
I'll do that, when I have time, btw. how do I reload updated modules in
the shell?
Post by Chris Marshall
Post by Ingo Schmid
It's done that way.
Not in the nop() routine.
now it is, see top.

Ingo
Chris Marshall
2014-02-17 18:30:47 UTC
Permalink
I've use do 'filename' on the updated file. There is also a
Module::Reload on CPAN which may do what you wish as
well.

Cheers,
Chris
Post by Ingo Schmid
Chris,
thanks for your comments.
I uploaded a new version, rewriting the nop, I think it now does what
you suggest.
Post by Chris Marshall
Examples in the pdl shell showing input values,
command, and output values are needed to show
the expected threading, especially for ncop().
I'll do that, when I have time, btw. how do I reload updated modules in
the shell?
Post by Chris Marshall
Post by Ingo Schmid
It's done that way.
Not in the nop() routine.
now it is, see top.
Ingo
Ingo Schmid
2014-02-24 22:03:18 UTC
Permalink
Hi,

To put you into the right set of mind, when PDL is about arrays,
PDL::Dims is extending them to hashes. Of course, nothing is lost along
the lines. Hopefully, you can concentrate more on solving your problems
while PDL::Dims takes care of most indexing and dimension ordering.

As a module author or PDL user, you don't need to worry about how your
piddle is organised, the order of dimensions can become completely
opaque and irrelevant to you.

Instead of addressing elements by numbers, you address them by positions
in your coordinates (if you want, that is).

To achieve all operations, several general purpose wrapper functions
should be called with the operation/function/method supplied as an
argument.

If you want to address the functions as methods, call

bless $piddle,'PDL::Dims';

I've been working hard to improve the module. It has matured
substantially since the last release. Don't even look at earlier versions.

Best
Ingo

Loading...