[cctbxbb] flex.histogram giving ArgumentError when arguments correct

Winter, Graeme (DLSLtd,RAL,LSCI) Graeme.Winter at diamond.ac.uk
Tue Aug 4 05:31:38 PDT 2020


Oh right, this one has legs, trying it

Right, you nailed it, + many points for Team Croll, much appreciated! 

Dang 

“the wrong sort of int” with no hint of this. sweet. 

I have no idea about how to trap this more usefully, maybe should just copy the stack trace into an issue and then close with the workaround so $person-in-future googling has some hope of finding a solution

But… is fixed, so thanks! 

> On 4 Aug 2020, at 13:25, Tristan Croll <tic20 at cam.ac.uk> wrote:
> 
> An out-there possibility - but in the past I ran into a similar head-scratcher when working with SWIG (thankful to not be using that any more). Numpy integer scalars are distinct from the Python int type, leading to similar error messages when you try to feed one into a SWIG-wrapped function expecting a C++ integer type. Had to be explicitly cast on the Python side first, i.e. int(numpy_array_of_ints[i]).
> 
> On 2020-08-04 13:19, Winter, Graeme (DLSLtd,RAL,LSCI) wrote:
>> Hi Tristan
>> Given that it worked for other integers as input (as shown further
>> down) I’d hope this makes no difference however
>>    H = flex.histogram(data=coords, data_min=0.0, data_max=float(dim),
>> n_slots=dim)
>> Boost.Python.ArgumentError: Please report this error to
>> dials-support at lists.sourceforge.net: Python argument types in
>> Nope :-(
>> It still fails…
>> This one is properly weird…
>> Thanks Graeme
>>> On 4 Aug 2020, at 13:14, Tristan Croll <tic20 at cam.ac.uk> wrote:
>>> Not a specialist in boost.python by any stretch - but as a quick sanity check, have you tried data_max=float(dim) to see if it's failing to do the implicit conversion?
>>> On 2020-08-04 12:56, Winter, Graeme (DLSLtd,RAL,LSCI) wrote:
>>>> H = flex.histogram(coords, data_min=0.0, data_max=dim, n_slots=dim)
>>>> Gives
>>>> Boost.Python.ArgumentError: Please report this error to
>>>> dials-support at lists.sourceforge.net: Python argument types in
>>>>   histogram.__init__(histogram)
>>>> did not match C++ signature:
>>>>   __init__(_object*, double, double, double,
>>>> scitbx::af::shared<long>, unsigned long)
>>>>   __init__(_object*, scitbx::histogram<double, long> other,
>>>> scitbx::af::const_ref<double, scitbx::af::trivial_accessor> data,
>>>> double relative_tolerance=0.0001)
>>>>   __init__(_object*, scitbx::af::const_ref<double,
>>>> scitbx::af::trivial_accessor> data, double data_min, double data_max,
>>>> unsigned long n_slots=1000, double relative_tolerance=0.0001)
>>>>   __init__(_object*, scitbx::af::const_ref<double,
>>>> scitbx::af::trivial_accessor> data, unsigned long n_slots=1000)
>>>> Despite
>>>> coords being
>>>> <scitbx_array_family_flex_ext.double object at 0x7fa8d671b5b0>
>>>> with shape
>>>> (31294944,)
>>>> and dim being 18093576 (i.e. integer)
>>>> and
>>>> h = flex.histogram(a, data_min=0, data_max=100, n_slots=100)
>>>> working fine in another context i.e. the calling convention is correct
>>>> This has so far cost a few hours, so what gives? How can this be
>>>> holding it wrong? C++ code suggests that the bin types are long so
>>>> this should be fine
>>>> Any hints?
>>>> Thanks Graeme
>>> _______________________________________________
>>> cctbxbb mailing list
>>> cctbxbb at phenix-online.org
>>> http://phenix-online.org/mailman/listinfo/cctbxbb
> _______________________________________________
> cctbxbb mailing list
> cctbxbb at phenix-online.org
> http://phenix-online.org/mailman/listinfo/cctbxbb


-- 
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. 
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom



More information about the cctbxbb mailing list