New upstream version 0.56
Damyan Ivanov
6 years ago
0 | 0 | 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. | |
1 | 4 | |
2 | 5 | 0.55 Tue Jul 03 09:30:00 CEST 2017 (Stefan Seifert) |
3 | 6 | - Pass Python floats as floats to Perl, not as string. |
41 | 41 | "Proc::ProcessTable" : "0.53", |
42 | 42 | "Test" : "0", |
43 | 43 | "Test::Deep" : "0", |
44 | "Test::More" : "0" | |
44 | "Test::More" : "0", | |
45 | "Test::Number::Delta" : "0" | |
45 | 46 | } |
46 | 47 | } |
47 | 48 | }, |
53 | 54 | "web" : "http://github.com/niner/inline-python-pm" |
54 | 55 | } |
55 | 56 | }, |
56 | "version" : "0.55", | |
57 | "version" : "0.56", | |
57 | 58 | "x_serialization_backend" : "JSON::PP version 2.27300_01" |
58 | 59 | } |
7 | 7 | Test: '0' |
8 | 8 | Test::Deep: '0' |
9 | 9 | Test::More: '0' |
10 | Test::Number::Delta: '0' | |
10 | 11 | configure_requires: |
11 | 12 | ExtUtils::MakeMaker: '0' |
12 | 13 | dynamic_config: 1 |
26 | 27 | Inline: '0.46' |
27 | 28 | resources: |
28 | 29 | repository: http://github.com/niner/inline-python-pm.git |
29 | version: '0.55' | |
30 | version: '0.56' | |
30 | 31 | x_serialization_backend: 'CPAN::Meta::YAML version 0.018' |
104 | 104 | 'Test' => 0, |
105 | 105 | 'Test::More' => 0, |
106 | 106 | 'Test::Deep' => 0, |
107 | 'Test::Number::Delta' => 0, | |
107 | 108 | 'Proc::ProcessTable' => '0.53', |
108 | 109 | }, |
109 | 110 | OBJECT => 'Python.o py2pl.o perlmodule.o util.o', |
5 | 5 | require Exporter; |
6 | 6 | our ($VERSION, @ISA, @EXPORT_OK); |
7 | 7 | @ISA = qw(Inline DynaLoader Exporter); |
8 | $VERSION = '0.55'; | |
8 | $VERSION = '0.56'; | |
9 | 9 | @EXPORT_OK = qw(py_eval |
10 | 10 | py_new_object |
11 | 11 | py_call_method |
0 | 0 | use Test::More tests => 19; |
1 | use Test::Number::Delta; | |
1 | 2 | |
2 | 3 | use Inline Config => DIRECTORY => './blib_test'; |
3 | 4 | use Inline::Python qw(py_call_function py_is_tuple); |
51 | 52 | is(len_empty_perl_array(Foo->new), 0); |
52 | 53 | |
53 | 54 | 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); | |
55 | 56 | |
56 | 57 | map($b[$_]+$b[$_], 0..$#b); |
57 | is((bounce_array(\@b))[1], 0.2); | |
58 | delta_ok((bounce_array(\@b))[1], 0.2); | |
58 | 59 | |
59 | 60 | is(ref return_tuple(), 'ARRAY'); |
60 | 61 | is(scalar @{ return_tuple() }, 3); |
2 | 2 | |
3 | 3 | use Inline Config => DIRECTORY => './blib_test'; |
4 | 4 | use Test::More tests => 7; |
5 | use Test::Number::Delta; | |
5 | 6 | use POSIX qw(setlocale LC_NUMERIC); |
6 | 7 | |
7 | 8 | use Inline Python => <<END; |
16 | 17 | |
17 | 18 | END |
18 | 19 | |
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); | |
22 | 23 | |
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); | |
25 | 26 | |
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); | |
28 | 29 | |
29 | 30 | # test if float conversion works despite localized number format |
30 | 31 | 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); | |
32 | 33 | |
33 | 34 | ok(is_float(0.1), "Perl float arrives as float in Python"); |
34 | 35 | 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 | } |