File: reference.t

package info (click to toggle)
libpdl-io-hdf5-perl 1:0.73-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 596 kB
  • sloc: perl: 1,544; makefile: 14
file content (42 lines) | stat: -rw-r--r-- 1,047 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use PDL;
use PDL::IO::HDF5;
use PDL::Types;

# Test case for HDF5 references
#   This is a new feature as-of version 0.64
#
use Test::More tests => 2;

my $filename = "reference.hdf5";
# get rid of filename if it already exists
unlink $filename if( -e $filename);

my $hdf5 = new PDL::IO::HDF5($filename);

my $group=$hdf5->group('group1');

# Store a dataset
my $dataset=$hdf5->dataset('data1');
my $data = pdl [ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ];
$dataset->set($data, unlimited => 1);

# create the reference
my @regionStart = ( 3 );
my @regionCount = ( 3 );
$hdf5->reference($dataset,"myRef",\@regionStart,\@regionCount);

$expected = 'data1, myRef';
my @datasets1=$hdf5->datasets();
#print "datasets '".join(", ",@datasets1)."'\n";
ok(join(', ',@datasets1) eq $expected);

# dereference the dataset
my $ref = $hdf5->dataset("myRef");
my $dereferenced = $ref->get();

$expected = '[5 6 7]';
#print "dereferenced '$dereferenced'\n";
ok("$dereferenced" eq $expected);

# clean up file
unlink $filename if( -e $filename);