| 1 | use strictscip-perl cpan PGPLOT 2.36 strict/; |
| 2 | use warningsscip-perl cpan PGPLOT 2.36 warnings/; |
| 3 | use Test::Morescip-perl cpan PGPLOT 2.36 Test/More/; |
| 4 | BEGIN { |
| 5 | eval {requirescip-perl cpan PGPLOT 2.36 main/require(). PDL}; |
| 6 | planscip-perl cpan PGPLOT 2.36 main/plan(). skip_all => "No PDL, can't test this ($@)" if $@scip-perl cpan PGPLOT 2.36 main/`$@`.; |
| 7 | } |
| 8 | use PDL::LiteFscip-perl cpan PGPLOT 2.36 PDL/LiteF/; |
| 9 | use PDL::Typesscip-perl cpan PGPLOT 2.36 PDL/Types/; |
| 10 | use PDL::Graphics::LUTscip-perl cpan PGPLOT 2.36 PDL/Graphics/LUT/; |
| 11 | |
| 12 | my @names = lut_namesscip-perl cpan PGPLOT 2.36 main/lut_names().(); |
| 13 | isntscip-perl cpan PGPLOT 2.36 main/isnt(). scalarscip-perl cpan PGPLOT 2.36 main/scalar().(@names), 0, "lut_names returns non-empty list"; |
| 14 | |
| 15 | my @cols = lut_datascip-perl cpan PGPLOT 2.36 main/lut_data().( $names[0] ); |
| 16 | isscip-perl cpan PGPLOT 2.36 main/is().( scalarscip-perl cpan PGPLOT 2.36 main/scalar().(@cols), 4, "lut_data returns 4 columns" ); |
| 17 | isscip-perl cpan PGPLOT 2.36 main/is().( $cols[0]->nelemscip-perl cpan PGPLOT 2.36 main/nelem()., $cols[1]->nelemscip-perl cpan PGPLOT 2.36 main/nelem()., "equal number of elements in cols 0 and 1"); |
| 18 | isscip-perl cpan PGPLOT 2.36 main/is().( $cols[2]->get_datatypescip-perl cpan PGPLOT 2.36 main/get_datatype()., $PDL_Fscip-perl cpan PGPLOT 2.36 main/$PDL_F., "datatype of col 2 is float"); |
| 19 | |
| 20 | # check we can reverse things |
| 21 | my @cols2 = lut_datascip-perl cpan PGPLOT 2.36 main/lut_data().( $names[0], 1 ); |
| 22 | okscip-perl cpan PGPLOT 2.36 main/ok().( allscip-perl cpan PGPLOT 2.36 main/all().( approxscip-perl cpan PGPLOT 2.36 main/approx().($cols[3]->slicescip-perl cpan PGPLOT 2.36 main/slice().('-1:0'),$cols2[3])), "reverse lut works"); |
| 23 | |
| 24 | # check we know about the intensity ramps |
| 25 | my @ramps = lut_rampsscip-perl cpan PGPLOT 2.36 main/lut_ramps().(); |
| 26 | isntscip-perl cpan PGPLOT 2.36 main/isnt(). scalarscip-perl cpan PGPLOT 2.36 main/scalar().(@ramps), 0, "lut_ramps returns some ramps"; |
| 27 | |
| 28 | # load in a different intensity ramp |
| 29 | my @cols3 = lut_datascip-perl cpan PGPLOT 2.36 main/lut_data().( $names[0], 0, $ramps[0] ); |
| 30 | isscip-perl cpan PGPLOT 2.36 main/is().( $cols3[0]->nelemscip-perl cpan PGPLOT 2.36 main/nelem()., $cols3[1]->nelemscip-perl cpan PGPLOT 2.36 main/nelem()., "intensity ramp nelem check"); |
| 31 | okscip-perl cpan PGPLOT 2.36 main/ok().( allscip-perl cpan PGPLOT 2.36 main/all().(approxscip-perl cpan PGPLOT 2.36 main/approx().($cols[1],$cols3[1], 1e-6)), "intensity ramp vals check") |
| 32 | or diagscip-perl cpan PGPLOT 2.36 main/diag(). '[ difference, subtract, c[1], c3[1] ]: ', explain [ |
| 33 | absscip-perl cpan PGPLOT 2.36 main/abs().($cols[1] - $cols3[1]).'', |
| 34 | ($cols[1] - $cols3[1]).'', |
| 35 | $cols[1].'', |
| 36 | $cols3[1].'', |
| 37 | ]; |
| 38 | |
| 39 | done_testing; |