Closed LiamM32 closed 1 year ago
Good bug! Can argue that's not really a bug but a feature. But a feature designed for the normal election workflow, not really for this filter workflow. The problem is that I don't know what to do here, throw an exception is not bad, because I can't return a result without votes. Maybe another exception class and message.... maybe keep this one.
An easy workaround for you could be to catch the exception and do what must be done if caught. I have seen that you do something with this idea in your project (but with a check before, not catching the exception).
Note that the Fatal error is to not catch the exception, not the exception herself.
Aren't you planning to make a new function for getting pairwise comparisons? In that case, it should give a zero for both $i and $j when there are 0 votes for either.
This is a problem with the
$election->getResult()
function in the dev-4.5 branch. When there are 0 votes under the'%tagFilter'
specified, calling this function results in an error.Here is the line from my program that calls it:
$filteredPairwise = $contest->getResult(methodOptions: ['%tagFilter' => true, 'withTag' => true, 'tags' => $country])->pairwise;
$contest
is an object of a class derived from theElection
class. Here is the error output:Commenting out the
->pairwise
part of that line results in the same error.