Skip to content

Commit bed8852

Browse files
committed
allow PDL::{Factor,Logical,SV} "initialize" to be instance methods
1 parent b2d9224 commit bed8852

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Revision history of Data-Frame
22

3+
0.006003 TBD
4+
- allow PDL::{Factor,Logical,SV} "initialize" to be instance methods
5+
36
0.006002 2022-01-03 14:33:22-0500
47
- Fix PDL::Factor's ngood, nbad methods for newer PDL versions.
58
See <https://github.com/EntropyOrg/p5-Data-Frame/pull/34>.

lib/PDL/Factor.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ sub levels {
193193

194194
sub initialize {
195195
my ($class) = @_;
196-
return bless( { PDL => PDL::Core::null }, $class );
196+
return bless( { PDL => PDL::Core::null }, ref $class || $class );
197197
}
198198

199199
=method glue

lib/PDL/Logical.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ sub new {
5050

5151
sub initialize {
5252
my ($class) = @_;
53-
return bless( { PDL => PDL::Core::null }, $class );
53+
return bless( { PDL => PDL::Core::null }, ref $class || $class );
5454
}
5555

5656
1;

lib/PDL/SV.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ sub new {
122122

123123
sub initialize {
124124
my ($class) = @_;
125-
return bless( { PDL => PDL::Core::null, _internal => [] }, $class );
125+
return bless( { PDL => PDL::Core::null, _internal => [] }, ref $class || $class );
126126
}
127127

128128
# code modified from <https://metacpan.org/pod/Hash::Path>

t/13-pdl_logical.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ subtest construction => sub {
3131
pdl_is( $l3, PDL::Logical->new( [ [ 0, 1, 1 ], [ 1, 0, 0 ] ] ),
3232
'new($aref_nd)' );
3333
pdl_is( $l3->shape, pdl( [ 3, 2 ] ) );
34+
35+
isa_ok $l1a->initialize, 'PDL::Logical';
3436
};
3537

3638
done_testing;

0 commit comments

Comments
 (0)