Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixups for MacOS and testing #25

Merged
merged 4 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
perl-version: ['5.14', '5.20']
perl-version: ['5.16', '5.20']
include:
- perl-version: '5.30'
os: ubuntu-latest
Expand Down
4 changes: 1 addition & 3 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ WriteMakefile(
},
TEST_REQUIRES => {
'Machine::Epsilon' => '0',
'Test::More' => '0',
'Test::Version' => '1.003001'

'Test::More' => '0.88',
},
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => '0',
Expand Down
5 changes: 2 additions & 3 deletions lib/Photonic/Geometry/FromImage2D.pm
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ use Moo;
use MooX::StrictConstructor;

BEGIN {
# Put inoffensive path. Or else, PDL::IO::Pic fails in taint mode.
$ENV{'PATH'} = '/bin:/usr/bin';
# Put inoffensive path in taint mode. Or else, PDL::IO::Pic fails.
$ENV{PATH} = '/bin:/usr/bin' if ${^TAINT};
}

use PDL::Lite;
Expand All @@ -119,7 +119,6 @@ sub _build_B {
my $self=shift;
my $path=$self->path;
( $path ) = ($path =~ m|^([A-Z0-9_.-\\/]+)$|ig);
($ENV{PATH})=($ENV{PATH}=~m|^([A-Z0-9_.-\\/]+)$|ig);
confess
"Only letters, numbers, underscores, dots, slashes and hyphens " .
"allowed in file names"
Expand Down
6 changes: 3 additions & 3 deletions lib/Photonic/Roles/Reorthogonalize.pm
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ sub _fullorthogonalize_indeed {
sub _checkorthogonalize {
my ($self, $n, $a, $b, $c, $b_np1, $g_n, $g_np1)=@_;
return 0 if $self->fullorthogonalize_N; #already orthogonalizing
if($self->_justorthogonalized){
if ($self->_justorthogonalized) {
$self->_write_justorthogonalized(0);
my $current_W=PDL->ones($n)*$self->noise;
my $next_W=PDL->ones($n+1)*$self->noise;
my $current_W=PDL->ones($g_n->type, $n)*$self->noise;
my $next_W=PDL->ones($g_np1->type, $n+1)*$self->noise;
$current_W->(-1).=$g_n;
$next_W->(-1).=$g_np1;
$self->_current_W($current_W);
Expand Down
35 changes: 18 additions & 17 deletions t/field-lenr2.t
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use Photonic::LE::NR2::SHChiTensor;
use Test::More;
use lib 't/lib';
use TestUtils;
use Machine::Epsilon;

my $ea=1+2*i;
my $eb=3+4*i;
Expand Down Expand Up @@ -364,46 +365,46 @@ $expected = pdl(<<'EOF');
[ -0.014991596+0.011757369i ]
]
EOF
ok(Cagree($got, $expected, 1e-18), "SHChiTensor SHPs P2") or diag "got: $got\nexpected: $expected";
ok(Cagree($got, $expected, machine_epsilon()), "SHChiTensor SHPs P2") or diag "got: $got\nexpected: $expected";
$got = $chi->evaluate;
$expected = pdl(<<'EOF');
[ [ [ 2.06087e-17+3.64698e-17i ] ] ]
[ [ [ 0 ] ] ]
EOF
ok(Cagree($got, $expected, 1e-41), "P2") or diag "got: $got\nexpected: $expected";
ok(Cagree($got, $expected, machine_epsilon()), "P2") or diag "got: $got\nexpected: $expected";
$got = $chi->evaluate(kind => 'f', mask => pdl(1));
$expected = pdl(<<'EOF');
[ [ [ 4.0239976e-18-9.855343e-19i ] ] ]
[ [ [ 0 ] ] ]
EOF
ok(Cagree($got, $expected, 1e-50), "P2") or diag "got: $got\nexpected: $expected";
ok(Cagree($got, $expected, machine_epsilon()), "P2") or diag "got: $got\nexpected: $expected";
$got = $chi->evaluate(kind => 'l');
$expected = pdl(<<'EOF');
[ [ [ 1.4979937e-18+3.6442788e-18i ] ] ]
[ [ [ 0 ] ] ]
EOF
ok(Cagree($got, $expected, 1e-51), "selfConsistentVecL") or diag "got: $got\nexpected: $expected";
ok(Cagree($got, $expected, machine_epsilon()), "selfConsistentVecL") or diag "got: $got\nexpected: $expected";
$got = $chi->evaluate(kind => 'a');
$expected = pdl(<<'EOF');
[ [ [ -4.890401e-16+5.6504395e-16i ] ] ]
[ [ [ 0 ] ] ]
EOF
ok(Cagree($got, $expected, 1e-47), "P2LMCalt") or diag "got: $got\nexpected: $expected";
ok(Cagree($got, $expected, machine_epsilon()), "P2LMCalt") or diag "got: $got\nexpected: $expected";
$got = $chi->evaluate(kind => 'd');
$expected = pdl(<<'EOF');
[ [ [ 5.0464683e-18+2.5232341e-18i ] ] ]
[ [ [ 0 ] ] ]
EOF
ok(Cagree($got, $expected, 1e-50), "dipolar") or diag "got: $got\nexpected: $expected";
ok(Cagree($got, $expected, machine_epsilon()), "dipolar") or diag "got: $got\nexpected: $expected";
$got = $chi->evaluate(kind => 'q');
$expected = pdl(<<'EOF');
[ [ [ 1.5770213e-19+3.1540427e-19i ] ] ]
[ [ [ 0 ] ] ]
EOF
ok(Cagree($got, $expected, 1e-50), "quadrupolar") or diag "got: $got\nexpected: $expected";
ok(Cagree($got, $expected, machine_epsilon()), "quadrupolar") or diag "got: $got\nexpected: $expected";
$got = $chi->evaluate(kind => 'e');
$expected = pdl(<<'EOF');
[ [ [ 9.9352345e-18+1.5770213e-18i ] ] ]
[ [ [ 0 ] ] ]
EOF
ok(Cagree($got, $expected, 1e-50), "external") or diag "got: $got\nexpected: $expected";
ok(Cagree($got, $expected, machine_epsilon()), "external") or diag "got: $got\nexpected: $expected";
$got = $chi->evaluate(kind => 'el');
$expected = pdl(<<'EOF');
[ [ [ 7.2542982e-18+1.4193192e-18i ] ] ]
[ [ [ 0 ] ] ]
EOF
ok(Cagree($got, $expected, 1e-50), "externalVecL") or diag "got: $got\nexpected: $expected";
ok(Cagree($got, $expected, machine_epsilon()), "externalVecL") or diag "got: $got\nexpected: $expected";

done_testing;
Loading