esheldon / pymangle

Simple code to read mangle masks, calculate ids and weights, and generate random points

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about `genrand_range`

parnalte opened this issue · comments

Hi,

I have a question about the intended usage of the function genrand_range. From the docs I understood that, for small masks, one would want to choose a box small enough to speed the calculation up but large enough to contain the full mask.

However, when I call the function in this way I get a ValueError: no corners are contained within mask. This is because the code requires that at least one of the corners of the box is contained in the mask:

pymangle/pymangle/_mangle.c

Lines 1589 to 1595 in 0aeec8c

if (num_contained==0) {
PyErr_Format(PyExc_ValueError,
"no corners are contained within mask");
status=0;
goto _genrand_range_cleanup;
}

However, if one of the corners is inside the mask, I understand that it is no longer possible to generate random points from the full mask (only from the part of the mask that overlaps with the box). So, is this a bug or am I misunderstanding the intended usage of the function?

Thanks,
Pablo.

Good point, I think this is a bug.

Great. I think it is solved now. Thanks.