view release on metacpan or search on metacpan
t/80optsimple.t view on Meta::CPAN
d2 => $changes,
));
ok($result !~ /\>\>\>/);
ok($result eq $expected);
# ... no matter how many identical chunks we throw at it.
$result = join(':', apply_diffs($original, {optimisers => TEST_OPTIMISERS},
d1 => $changes,
d2 => $changes,
d3 => $changes,
view all matches for this distribution
view release on metacpan or search on metacpan
t/0305-ecc.t view on Meta::CPAN
my $min_distance = 1;
my $ecc = new Algorithm::Evolutionary::Fitness::ECC( $number_of_codewords, $min_distance );
isa_ok( $ecc, "Algorithm::Evolutionary::Fitness::ECC" );
throws_ok { new Algorithm::Evolutionary::Fitness::ECC() } qr/codewords/, "No codewords";
throws_ok { new Algorithm::Evolutionary::Fitness::ECC(2,0) } qr/istance/, "No distance";
my $string = random_bitstring(128);
ok( $ecc->ecc( $string ) > 0, "Seems to work" );
ok( $ecc->ecc( $string ) > 0, "Seems to work again" );
view all matches for this distribution
view release on metacpan or search on metacpan
t/01.functions.t view on Meta::CPAN
$total_fitness += $fitness_of{$population[$i]};
my $count_ones = grep( $_ eq 1, split(//, $population[$i]));
is( $fitness_of{$population[$i]}, $count_ones, "Counting ones" );
}
throws_ok { get_pool_roulette_wheel() } qr/No/, "Population check";
throws_ok { get_pool_roulette_wheel(\@population) } qr/stuff/, "Fitness check";
throws_ok { get_pool_roulette_wheel(\@population, \%fitness_of) } qr/population/, "Population size check";
throws_ok { get_pool_roulette_wheel(\@population, \%fitness_of, $number_of_strings) } qr/fitness/, "Total fitness check";
my @pool = get_pool_roulette_wheel( \@population, \%fitness_of, $number_of_strings, $total_fitness );
is ( scalar( @pool ), $number_of_strings, "Pool generation" );
my @new_pop = produce_offspring( \@pool, $number_of_strings );
t/01.functions.t view on Meta::CPAN
is ( scalar( @new_pop), $number_of_strings, "New population generation");
map( $fitness_of{$_}?$fitness_of{$_}:($fitness_of{$_} = max_ones( $_)), @new_pop );
$total_fitness = 0;
map( $total_fitness += $fitness_of{$_}, @new_pop );
throws_ok { single_generation() } qr/No/, "No population exception";
throws_ok { single_generation( \@new_pop ) } qr/fitness/, "No fitness exception";
my @newest_pop = single_generation( \@new_pop, \%fitness_of, $total_fitness );
my @old_best = rnkeytop { $fitness_of{$_} } 1 => @new_pop; # Extract elite
map( $fitness_of{$_}?$fitness_of{$_}:($fitness_of{$_} = max_ones( $_)), @newest_pop );
my @new_best = rnkeytop { $fitness_of{$_} } 1 => @newest_pop; # Extract elite
is ( $fitness_of{$new_best[0]} >= $fitness_of{$old_best[0]}, 1,
"Improving fitness $fitness_of{$new_best[0]} >= $fitness_of{$old_best[0]}" );
throws_ok { get_pool_binary_tournament() } qr/No/, "Population check";
throws_ok { get_pool_binary_tournament(\@population) } qr/stuff/, "Fitness check";
throws_ok { get_pool_binary_tournament(\@population, \%fitness_of) } qr/population/, "Population size check";
@pool = get_pool_binary_tournament( \@population, \%fitness_of, $number_of_strings );
is ( scalar( @pool ), $number_of_strings, "Pool generation" );
@new_pop = produce_offspring( \@pool, $number_of_strings );
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Gutter.pm view on Meta::CPAN
to water accumulating and then dripping out of a rain gutter.
The cells are held in an array reference (the B<gutter>); the caller may
need to fiddle around with the cells directly simulate various effects.
Various methods may throw errors, for example if a cell lacks an update
callback function. Such callbacks are not mandatory to give the caller
flexibility in wiring up the gutter in fancy ways.
=head1 FIELDS
view all matches for this distribution
view release on metacpan or search on metacpan
t/encode_bitstring.t view on Meta::CPAN
my $string = random_string('c' x LONG_STRING_LENGTH);
UNKNOWN_CHAR_IN_BITSTRING_SHOULD_PRODUCE_AN_EXCEPTION: {
my $bitstring = $huff->encode_bitstring($string);
substr($bitstring,length($string)/2,1) = "a";
throws_ok {$huff->decode_bitstring($bitstring)}
qr/unknown/i,
"Unknown character (an a instead 0/1) into the bitstring";
}
BITSTRING_TOO_SHORT: {
view all matches for this distribution
view release on metacpan or search on metacpan
lib_ann_interface.cpp view on Meta::CPAN
using namespace std;
LibANNInterface::LibANNInterface(std::vector< std::vector<double> >& points, string& dump, bool use_bd_tree, int bucket_size, int split_rule, int shrink_rule) {
if (!points.size() && !dump.size())
throw InvalidParameterValueException("either points or a tree dump must be given");
kd_tree = NULL;
bd_tree = NULL;
data_pts = NULL;
if (points.size()) {
if (bucket_size < 1)
throw InvalidParameterValueException("bucket_size must be >= 1");
// the first element sets the dimension and set the number of availble data points
count_data_pts = points.size();
if (count_data_pts > 0) {
lib_ann_interface.cpp view on Meta::CPAN
annClose();
}
void LibANNInterface::set_annMaxPtsVisit(int max_points) {
if (max_points < 0)
throw InvalidParameterValueException("max_points must be >= 0");
annMaxPtsVisit(max_points);
}
std::vector< std::vector<double> > LibANNInterface::annkSearch(std::vector<double>& query_point, int limit_neighbors, double epsilon) {
lib_ann_interface.cpp view on Meta::CPAN
return ann_search(query_point, limit_neighbors, epsilon, true);
}
std::vector< std::vector<double> > LibANNInterface::ann_search(std::vector<double>& query_point, int limit_neighbors, double epsilon, bool use_prio_search) {
if (limit_neighbors < 0)
throw InvalidParameterValueException("limit_neighbors must be >= 0");
if (limit_neighbors > count_data_pts)
throw InvalidParameterValueException("limit_neighbors must be <= the number of points in the current tree");
if (epsilon < 0)
throw InvalidParameterValueException("epsilon must be >= 0");
if (query_point.size() != dim)
throw InvalidParameterValueException("query_point must have the same dimension as the current tree");
if (limit_neighbors == 0)
limit_neighbors = count_data_pts;
std::vector< std::vector<double> > result;
lib_ann_interface.cpp view on Meta::CPAN
return result;
}
std::vector< std::vector<double> > LibANNInterface::annkFRSearch(std::vector<double>& query_point, int limit_neighbors, double epsilon, double radius) {
if (limit_neighbors < 0)
throw InvalidParameterValueException("limit_neighbors must be >= 0");
if (limit_neighbors > count_data_pts)
throw InvalidParameterValueException("limit_neighbors must be <= the number of points in the current tree");
if (epsilon < 0)
throw InvalidParameterValueException("epsilon must be >= 0");
if (query_point.size() != dim)
throw InvalidParameterValueException("query_point must have the same dimension as the current tree");
if (limit_neighbors == 0)
limit_neighbors = count_data_pts;
std::vector< std::vector<double> > result;
lib_ann_interface.cpp view on Meta::CPAN
return result;
}
int LibANNInterface::annCntNeighbours(std::vector<double>& query_point, double epsilon, double radius) {
if (epsilon < 0)
throw InvalidParameterValueException("epsilon must be >= 0");
if (query_point.size() != dim)
throw InvalidParameterValueException("query_point must have the same dimension as the current tree");
ANNpoint query_pt = annAllocPt(dim);
int i = 0;
std::vector<double>::iterator iter;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/LibLinear.pm view on Meta::CPAN
Notice that C<loss_sensitivity> is affected too when C<update> is set.
=head2 find_parameters(data_set => $data_set, num_folds => $num_folds [, initial_cost => -1.0] [, initial_loss_sensitivity => -1.0] [, update => 0])
Finds the best parameters by N-fold cross validation. If C<initial_cost> or C<initial_loss_sensitivity> is a negative, the value is automatically calculated.
Works only for 3 solvers: C<'L2R_LR'>, C<'L2R_L2LOSS_SVC'> and C<'L2R_L2LOSS_SVR'>. Error will be thrown for otherwise.
When C<update> is set true, the instance is updated to use the found parameters. This behaviour is disabled by default.
Return value is an ArrayRef containing 3 values: found C<cost>, found C<loss_sensitivity> (only if solver is C<'L2R_L2LOSS_SVR'>) and mean accuracy of cross validation with the found parameters.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Loops.pm view on Meta::CPAN
In contrast, MapCar() will simply leave out values for short arrays (just
like I left the "U" out of its name).
MapCarE() will croak without ever calling your subroutine unless all of
the arrays are the same length. It considers it an Error if your arrays
are not of Equal length and so throws an Exception.
Finally, MapCarMin() only calls your subroutine as many times as there
are elements in the B<shortest> array.
In other words,
view all matches for this distribution
view release on metacpan or search on metacpan
t/Algorithm/LossyCount.t view on Meta::CPAN
my ($i) = @_;
1 / ($i * $partition_function);
};
}
throws_ok {
Algorithm::LossyCount->new;
} qr/max_error_ratio/, 'max_error_ratio is a mandatory parameter.';
my $num_samples = 20000;
my $distribution = zipf_distribution($num_samples);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Pair/Best2.pm view on Meta::CPAN
This is a re-write of Algorithm::Pair::Best. The interface is simplified
and the implementation is significantly streamlined.
After creating an Algorithm::Pair::Best2 object (with -E<gt>B<new>), B<add>
items to the list of items (i.e: players) to be paired. The final list
must contain an even number of items or B<pick>ing the pairs will throw an
exception.
Algorithm::Pair::Best2-E<gt>B<pick> explores all combinations of items and
returns the pairing list with the best (lowest) score. This can be an
expensive proposition - the number of combinations goes up very fast with
lib/Algorithm/Pair/Best2.pm view on Meta::CPAN
B<pick> returns the list (or a reference to the list in scalar context) of
items in pairing order: new_pair[0] is paired to new_pair[1], new_pair[2]
to new_pair[3], etc.
If the number of items in the list (from B<add>) is not even, an exception
is thrown.
=back
=head1 OPTIONS
lib/Algorithm/Pair/Best2.pm view on Meta::CPAN
The callback is called as B<scoreSub>(item_0, item_1), where item_0 and item_1
are members of the list created by B<add>ing items. The callback must
return a positive number representing the 'badness' of this pairing. A
good pairing should have a number closer to 0 than a worse pairing. If
B<scoreSub> returns a negative number, an exception is thrown.
B<scoreSub>(A, B) should be equal to B<scoreSub>(B, A). B<scoreSub>(A, B)
is called only one time (for any particular A and B), and the result is
cached. B<scoreSub>(B, A) is never called.
Note that scores are always positive (Algorithm::Pair::Best2 searches for
the lowest combined score).
Default: a subroutine that throws an exception.
=item B<progress> => reference to progress callback
Each time a pair is finalized in the B<pick> routine, the
B<progress>($item_0, $item_1, $idx_0, $idx_1) callback is called where
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Paxos/Exception.pm view on Meta::CPAN
# ABSTRACT: Simple Sugar for Throwable::Error
use Sub::Exporter::Util ();
use Sub::Exporter -setup =>
{ exports => [ throw => Sub::Exporter::Util::curry_method('throw'), ], };
extends qw(Throwable::Error);
sub throw {
my $class = shift;
return $class->new(@_);
}
1;
lib/Algorithm/Paxos/Exception.pm view on Meta::CPAN
=head1 SYNOPSIS
use Algorithm::Paxos::Exception;
...
throw "Something failed";
=head1 DESCRIPTION
This is a very thin sugar wrapper around L<Throwable::Error>.
=head1 FUNCTIONS
=head2 throw ( $message )
Throw a new exception
=head1 SEE ALSO
view all matches for this distribution
view release on metacpan or search on metacpan
0.19
2019-07-31
- There was more processing than needed in least_covered() to do
what was basically a find-the-minimum loop, plus it was
throwing away information that had to be re-created by the
next line of code.
Consolidated all of that, resulting in fewer hash-of-array
manipulations, and changed the return value from the single
term to the term plus its covers.
This won't result in a significant speed increase, as most
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/SVMLight.pm view on Meta::CPAN
C<b>, and the rest of the elements will be the weights themselves.
Thus from 1 upward, the indices align with SVMLight's internal
indices.
If the model has not yet been trained, or if the kernel type is not
linear, an exception will be thrown.
=item feature_names()
Returns a list of feature names that have been fed to
C<add_instance()> as keys of the C<attribute> parameter, or in a
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/SpatialIndex/Storage/DBI.pm view on Meta::CPAN
sub fetch_bucket {
my $self = shift;
my $node_id = shift;
my $dbh = $self->dbh_ro;
my $selsql = $self->{buckets_select_sql};
# This throws SEGV in the driver
#my $sth = $dbh->prepare_cached($selsql);
#$sth->execute($node_id) or die $dbh->errstr;
#my $row = $sth->fetchrow_arrayref;
#$sth->finish;
my $rows = $dbh->selectall_arrayref($selsql, {}, $node_id);
view all matches for this distribution
view release on metacpan or search on metacpan
include/kth_order_statistic.hpp view on Meta::CPAN
DEBUG_ITERABLE("Array", begin, end);
DEBUG("k", k)
DEBUG("n", n)
if (n == 0)
throw std::invalid_argument("Empty array passed");
if ( k > n)
throw std::invalid_argument("Bad argument k. Maybe it's out of range");
auto it = begin,
jt = end-1;
auto pivot = begin + n/2;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/TicketClusterer.pm view on Meta::CPAN
constructor parameter C<misspelled_words_file> that contains misspelled
words in the first column and their corrected versions in the second
column. An example of such a file is included in the C<examples>
directory. You would need to create your own version of such a file for
your application domain. Since conjuring up the misspellings that your
ticket submitters are likely to throw at you is futile, you might consider
using the following approach which I prefer to actually reading the tickets
for such errors: Turn on the debugging options in the constructor for some
initially collected spreadsheets and watch what sort of words the WordNet
is not able to supply any synonyms for. In a large majority of cases,
these would be the misspelled words.
view all matches for this distribution
view release on metacpan or search on metacpan
t/01-setup.t view on Meta::CPAN
my $b = Algorithm::TravelingSalesman::BitonicTour->new;
ok($b);
is($b->N, 0);
throws_ok { $b->R } qr/Problem has no rightmost point/, '... with a nice error message';
# add a few points, making sure they're stored and sorted correctly
$b->add_point(0,0);
is($b->N, 1);
t/01-setup.t view on Meta::CPAN
# make sure that attempts to add points with duplicate X-coordinates croak()
{
dies_ok { $b->add_point(2,1) } 'repeated X-coordinate should die';
dies_ok { $b->add_point(2,2) } 'repeated X-coordinate should die';
dies_ok { $b->add_point(2,3) } 'repeated X-coordinate should die';
throws_ok { $b->add_point(2,1) } qr/duplicates previous point/,
'with a nice error message';
}
# make sure we can retrieve coordinates correctly
is_deeply([ $b->coord( 0) ], [ 0, 0 ]);
view all matches for this distribution
view release on metacpan or search on metacpan
examples/retrieve_with_LSA.pl view on Meta::CPAN
use strict;
use Algorithm::VSM;
my $corpus_dir = "corpus";
my @query = qw/ string getAllChars throw IOException distinct TreeMap histogram map /;
my $stop_words_file = "stop_words.txt"; # This file will typically include the
# keywords of the programming
# language(s) used in the software.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Voting/Plurality.pm view on Meta::CPAN
=head2 Algorithm::Voting::Plurality->new(%args)
Constructs a "ballot box" object that will use the Plurality criterion to
decide the winner. Optionally, specify a list of candidates; any ballot added
to the box that does not indicate one of the listed candidates throws an
exception.
Example:
# construct a ballot box that accepts only three candidates
view all matches for this distribution
view release on metacpan or search on metacpan
t/Relativity.test view on Meta::CPAN
explanations. Let us proceed to disclose these sins.
It is not clear what is to be understood here by "position" and
"space." I stand at the window of a railway carriage which is
travelling uniformly, and drop a stone on the embankment, without
throwing it. Then, disregarding the influence of the air resistance, I
see the stone descend in a straight line. A pedestrian who observes
the misdeed from the footpath notices that the stone falls to earth in
a parabolic curve. I now ask: Do the "positions" traversed by the
stone lie "in reality" on a straight line or on a parabola? Moreover,
what is meant here by motion "in space" ? From the considerations of
t/Relativity.test view on Meta::CPAN
theory of relativity cannot claim an unlinlited domain of validity ;
its results hold only so long as we are able to disregard the
influences of gravitational fields on the phenomena (e.g. of light).
Since it has often been contended by opponents of the theory of
relativity that the special theory of relativity is overthrown by the
general theory of relativity, it is perhaps advisable to make the
facts of the case clearer by means of an appropriate comparison.
Before the development of electrodynamics the laws of electrostatics
were looked upon as the laws of electricity. At the present time we
know that electric fields can be derived correctly from electrostatic
considerations only for the case, which is never strictly realised, in
which the electrical masses are quite at rest relatively to each
other, and to the co-ordinate system. Should we be justified in saying
that for this reason electrostatics is overthrown by the
field-equations of Maxwell in electrodynamics ? Not in the least.
Electrostatics is contained in electrodynamics as a limiting case ;
the laws of the latter lead directly to those of the former for the
case in which the fields are invariable with regard to time. No fairer
destiny could be allotted to any physical theory, than that it should
view all matches for this distribution
view release on metacpan or search on metacpan
examples/t/sudoku/01-sudoku.t view on Meta::CPAN
"..|1.\n"
), $sudoku->to_string_format($format), 'to_string_format');
};
subtest 'from_string' => sub {
plan tests => 26;
throws_ok { Sudoku->new("") } qr/Got empty string/i, 'needs char';
lives_ok { Sudoku->new(".") } 'empty cell suffices';
lives_ok { Sudoku->new("0") } '1 cell suffices';
lives_ok { Sudoku->new("1") } '1 cell suffices';
lives_ok { Sudoku->new("( 1 )") } '1 cell suffices';
lives_ok { Sudoku->new("2") } '1 cell suffices';
lives_ok { Sudoku->new("A") } '1 cell suffices';
lives_ok { Sudoku->new("z") } '1 cell suffices';
throws_ok { Sudoku->new("ABCD .... .... ...E") } qr/Too many different labels/i, 'labels exceed n';
lives_ok { Sudoku->new("ABCD .... .... ...A") } 'labels == n';
my $sudoku = Sudoku->new(join '',
"1.|..",
"..|.2",
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the modification time is only slightly in the future,
# sleep briefly to remove the problem.
my $a = $s - time;
if ( $a > 0 and $a < 5 ) { sleep 5 }
# Too far in the future, throw an error.
my $t = time;
if ( $s > $t ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future ($s > $t).
view all matches for this distribution
view release on metacpan or search on metacpan
corpus/libpalindrome/configure view on Meta::CPAN
link_all_deplibs=yes
;;
sunos4*)
if test sequent = "$host_vendor"; then
# Use $CC to link under sequent, because it throws in some extra .o
# files that make .init and .fini sections work.
archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
else
archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
fi
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Alien/Base.pm view on Meta::CPAN
return if $class->install_type('system');
require DynaLoader;
# Sanity check in order to ensure that dist_dir can be found.
# This will throw an exception otherwise.
$class->dist_dir;
# get a reference to %Alien::MyLibrary::AlienLoaded
# which contains names of already loaded libraries
# this logic may be replaced by investigating the DynaLoader arrays
view all matches for this distribution