Codebase list libinline-python-perl / a3f5f41
New upstream version 0.56 Damyan Ivanov 6 years ago
7 changed file(s) with 35 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
00 Revision history for Perl extension Inline::Python.
1
2 0.56 Fri Aug 04 15:30:00 CEST 2017 (Stefan Seifert)
3 - Fix floating point related test failures on some machines.
14
25 0.55 Tue Jul 03 09:30:00 CEST 2017 (Stefan Seifert)
36 - Pass Python floats as floats to Perl, not as string.
4141 "Proc::ProcessTable" : "0.53",
4242 "Test" : "0",
4343 "Test::Deep" : "0",
44 "Test::More" : "0"
44 "Test::More" : "0",
45 "Test::Number::Delta" : "0"
4546 }
4647 }
4748 },
5354 "web" : "http://github.com/niner/inline-python-pm"
5455 }
5556 },
56 "version" : "0.55",
57 "version" : "0.56",
5758 "x_serialization_backend" : "JSON::PP version 2.27300_01"
5859 }
77 Test: '0'
88 Test::Deep: '0'
99 Test::More: '0'
10 Test::Number::Delta: '0'
1011 configure_requires:
1112 ExtUtils::MakeMaker: '0'
1213 dynamic_config: 1
2627 Inline: '0.46'
2728 resources:
2829 repository: http://github.com/niner/inline-python-pm.git
29 version: '0.55'
30 version: '0.56'
3031 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
104104 'Test' => 0,
105105 'Test::More' => 0,
106106 'Test::Deep' => 0,
107 'Test::Number::Delta' => 0,
107108 'Proc::ProcessTable' => '0.53',
108109 },
109110 OBJECT => 'Python.o py2pl.o perlmodule.o util.o',
55 require Exporter;
66 our ($VERSION, @ISA, @EXPORT_OK);
77 @ISA = qw(Inline DynaLoader Exporter);
8 $VERSION = '0.55';
8 $VERSION = '0.56';
99 @EXPORT_OK = qw(py_eval
1010 py_new_object
1111 py_call_method
00 use Test::More tests => 19;
1 use Test::Number::Delta;
12
23 use Inline Config => DIRECTORY => './blib_test';
34 use Inline::Python qw(py_call_function py_is_tuple);
5152 is(len_empty_perl_array(Foo->new), 0);
5253
5354 my @b = (0.1,0.2,0.3,0.4);
54 is((bounce_array(\@b))[0], 0.1);
55 delta_ok((bounce_array(\@b))[0], 0.1);
5556
5657 map($b[$_]+$b[$_], 0..$#b);
57 is((bounce_array(\@b))[1], 0.2);
58 delta_ok((bounce_array(\@b))[1], 0.2);
5859
5960 is(ref return_tuple(), 'ARRAY');
6061 is(scalar @{ return_tuple() }, 3);
22
33 use Inline Config => DIRECTORY => './blib_test';
44 use Test::More tests => 7;
5 use Test::Number::Delta;
56 use POSIX qw(setlocale LC_NUMERIC);
67
78 use Inline Python => <<END;
1617
1718 END
1819
19 like(pyprint(0.1 + 0.1), qr/\(0\.2(0000000000000001)?,\)/);
20 my @a = (0.1,0.2,0.3,0.4);
21 like(pyprint(\@a), qr/\(\[0\.1(0000000000000001)?, 0\.2(0000000000000001)?, 0\.(29999999999999999|3), 0\.4(0000000000000002)?\],\)/); # Correct output
20 delta_ok(parse_py_list(pyprint(0.1 + 0.1)), 0.2);
21 my @a = (0.1, 0.2, 0.3, 0.4);
22 delta_ok(parse_py_array(pyprint(\@a)), \@a);
2223
23 map($a[$_]+$a[$_], 0..$#a);
24 like(pyprint(\@a), qr/\(\[0\.1(0000000000000001)?, 0\.2(0000000000000001)?, 0\.(29999999999999999|3), 0\.4(0000000000000002)?\],\)/); # Incorrect output (all zeros)
24 @a = map($a[$_] + $a[$_], 0 .. $#a);
25 delta_ok(parse_py_array(pyprint(\@a)), \@a);
2526
26 @a = map($_*1.0, @a);
27 like(pyprint(\@a), qr/\(\[0\.1(0000000000000001)?, 0\.2(0000000000000001)?, 0\.(29999999999999999|3), 0\.4(0000000000000002)?\],\)/); # Correct output
27 @a = map($_ * 1.0, @a);
28 delta_ok(parse_py_array(pyprint(\@a)), \@a);
2829
2930 # test if float conversion works despite localized number format
3031 setlocale LC_NUMERIC, "de_DE.UTF-8";
31 is(pyprint(0.25), '(0.25,)');
32 delta_ok(parse_py_list(pyprint(0.25)), 0.25);
3233
3334 ok(is_float(0.1), "Perl float arrives as float in Python");
3435 ok(is_float(give_float()), "Python float arrives as float in Perl (and can be passed through)");
36
37 sub parse_py_list {
38 my ($str) = @_;
39 my ($num) = $str =~ /\((\d+\.\d+),\)/;
40 return $num;
41 }
42
43 sub parse_py_array {
44 my ($str) = @_;
45 my @num;
46 push @num, $1 while $str =~ /(\d+\.\d+)/g;
47 return \@num;
48 }