Skip to content

Commit 3bd3f13

Browse files
committed
test default-colour behaviour
1 parent b5c8115 commit 3bd3f13

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

lib/PDL/Graphics/TriD/Object.pm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use strict;
44
use warnings;
55
use Scalar::Util qw(weaken);
66
use Carp 'confess';
7-
use PDL::ImageND;
7+
use PDL::ImageND ();
88

99
use fields qw(Objects IsValid ChangedSub Impl Options);
1010

@@ -43,7 +43,7 @@ sub normalise_as {
4343
# Allowable forms:
4444
# x(3,..) [x(..),y(..),z(..)]
4545
sub realcoords {
46-
my($type,$c) = @_;
46+
my ($type,$c) = @_;
4747
if (ref $c ne "ARRAY") {
4848
my $dim0 = $c->getdim(0);
4949
confess "If one ndarray given for coordinate, must be (2|3,...) or have default interpretation" if $dim0 != 2 and $dim0 != 3;
@@ -96,13 +96,13 @@ sub get_valid_options { +{
9696
}}
9797

9898
sub clear_objects {
99-
my($this) = @_;
99+
my ($this) = @_;
100100
$this->{Objects} = [];
101101
$this->{IsValid} = 0;
102102
}
103103

104104
sub delete_object {
105-
my($this,$object) = @_;
105+
my ($this,$object) = @_;
106106
my $ref = $this->{Objects};
107107
return unless defined $object && defined $ref;
108108
my @inds = grep $object == $ref->[$_], 0..$#$ref;
@@ -127,13 +127,13 @@ sub contained_objects {
127127
}
128128

129129
sub changed_from_above {
130-
my($this) = @_;
130+
my ($this) = @_;
131131
print "CHANGED_FROM_ABOVE\n" if $PDL::Graphics::TriD::verbose;
132132
$this->changed;
133133
}
134134

135135
sub add_changedsub {
136-
my($this,$chsub) = @_;
136+
my ($this,$chsub) = @_;
137137
push @{$this->{ChangedSub}}, $chsub;
138138
for (@{$this->{Objects}}) {
139139
$_->add_changedsub($chsub);
@@ -142,7 +142,7 @@ sub add_changedsub {
142142

143143

144144
sub clear {
145-
my($this) = @_;
145+
my ($this) = @_;
146146
# print "Clear: $this\n";
147147
for (@{$this->{Objects}}) {
148148
$_->clear();
@@ -153,15 +153,15 @@ sub clear {
153153
}
154154

155155
sub changed {
156-
my($this) = @_;
156+
my ($this) = @_;
157157
print "VALID0 $this\n" if $PDL::Graphics::TriD::verbose;
158158
$this->{IsValid} = 0;
159159
$_->($this) for @{$this->{ChangedSub}};
160160
}
161161

162162
# In the future, have this happen automatically by the ndarrays.
163163
sub data_changed {
164-
my($this) = @_;
164+
my ($this) = @_;
165165
$this->changed;
166166
$_->changed for $this->contained_objects;
167167
}

lib/PDL/Graphics/TriD/Objects.pm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ package # hide from PAUSE
100100
PDL::Graphics::TriD::Lines;
101101
use base qw/PDL::Graphics::TriD::GObject/;
102102
sub cdummies { $_[1]->slice(":," . join ',', map "*$_", grep defined, ($_[2]->dims)[1,2]) }
103-
sub r_type { return "SURF2D";}
103+
sub r_type { "SURF2D" }
104104
sub get_valid_options { +{
105105
UseDefcols => 0,
106106
}}
@@ -109,7 +109,7 @@ package # hide from PAUSE
109109
PDL::Graphics::TriD::LineStrip;
110110
use base qw/PDL::Graphics::TriD::Object/;
111111
sub cdummies { $_[1]->slice(":," . join ',', map "*$_", grep defined, ($_[2]->dims)[1,2]) }
112-
sub r_type { return "SURF2D";}
112+
sub r_type { "SURF2D" }
113113
sub get_valid_options { +{
114114
UseDefcols => 0,
115115
}}
@@ -155,7 +155,7 @@ sub new {
155155
}
156156
$this;
157157
}
158-
sub r_type { return "";}
158+
sub r_type { "" }
159159
sub get_valid_options { +{
160160
UseDefcols => 0,
161161
Lines => 0,
@@ -234,7 +234,7 @@ use base qw/PDL::Graphics::TriD::Object/;
234234
sub cdummies {
235235
$_[1]->slice(":," . join ',', map "*$_", ($_[2]->dims)[1,2])
236236
}
237-
sub r_type {return "SURF2D";}
237+
sub r_type {"SURF2D" }
238238
sub get_valid_options { +{
239239
UseDefcols => 0,
240240
Lines => 1,
@@ -324,7 +324,7 @@ sub set_labels {
324324
package # hide from PAUSE
325325
PDL::Graphics::TriD::Arrows;
326326
use base qw/PDL::Graphics::TriD::Object/;
327-
sub r_type { return "";}
327+
sub r_type { "" }
328328
sub get_valid_options { +{
329329
UseDefcols => 0,
330330
FromTo => [],

t/object.t

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ like $@, qr/Given 1D ndarray as colour but no points to match/;
1414

1515
sub PDL::Graphics::TriD::Object::cdummies { $_[1]->dummy(1,$_[2]->getdim(1)); }
1616
is_pdl $o->normalise_as('COLOR', pdl(1,4,7), zeroes(2,4)), float('1 4 7; 1 4 7; 1 4 7; 1 4 7');
17+
eval { $o->normalise_as('COLOR', pdl(1,4,7)) };
18+
like $@, qr/Given 1D ndarray as colour but no points to match/;
19+
is_pdl $o->normalise_as('COLOR', undef, zeroes(2,4)), float('1 1 1; 1 1 1; 1 1 1; 1 1 1');
1720

1821
is_pdl $o->normalise_as('', [SURF2D=>pdl('1 4 7;5 8 9')]), float('
1922
[0 0 1; 1 0 4; 2 0 7]

0 commit comments

Comments
 (0)