[Rivet] MathUtils median falls over empty vector

Chris Pollard cpollard at cern.ch
Wed Jul 20 09:47:29 BST 2016


I personally prefer throwing an exception.

Chris

On Wed, Jul 20, 2016 at 9:58 AM, Andy Buckley <andy.buckley at cern.ch> wrote:

> On 19/07/16 23:10, Holger Schulz wrote:
>
>> Hi,
>>
>> the Analysis ATLAS_2010_S8914702 calculates the median of a vector<double>
>>
>> and currently segfaults if the vector is empty.
>>
>>
>> I don't know whether we should explicitly check the size of the vector or
>> return 0 in the median function --- not sure if the median of an empty set
>> is well defined though.
>>
>>
>> What do you think?
>>
>
> Good spot. Thanks for adding protection to the analysis. If we add
> protection in the median itself, it would need to be either throwing an
> exception or returning a nan. Both of those would also need a check in the
> analysis code.
>
> I'm going to make a few other tweaks to "utils" functions today, which
> tends to require a full rebuild since those headers are included
> everywhere. So I may as well do this at the same time... what approach do
> we prefer?
>
> Andy
>
> --
> Dr Andy Buckley, Lecturer / Royal Society University Research Fellow
> Particle Physics Expt Group, University of Glasgow
>
> _______________________________________________
> Rivet mailing list
> Rivet at projects.hepforge.org
> https://www.hepforge.org/lists/listinfo/rivet
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.hepforge.org/lists-archive/rivet/attachments/20160720/020c225d/attachment.html>


More information about the Rivet mailing list