[petsc-users] petsc4py bool type
Garth N. Wells
gnw20 at cam.ac.uk
Wed Apr 26 17:42:43 CDT 2017
To close this thread off and for reference, Lisandro has pushed a fix
[1] to petsc4py maint and master.
Garth
[1] https://bitbucket.org/petsc/petsc4py/commits/51b4b9fe3948007c2b1320df6130d171297f407c
On 26 April 2017 at 10:05, Garth N. Wells <gnw20 at cam.ac.uk> wrote:
> On 26 April 2017 at 09:06, Lisandro Dalcin <dalcinl at gmail.com> wrote:
>> On 25 April 2017 at 19:48, Garth N. Wells <gnw20 at cam.ac.uk> wrote:
>>> I'm seeing some behaviour with bool types in petsc4py that I didn't
>>> expect. In the Python interface, returned Booleans have type '<class
>>> 'int'>', where I expected them to have type ' <class 'bool'>'. Below
>>> program illustrates issue. Seems to be related to bint in cython. Am I
>>> doing something wrong?
>>
>> Wow! Yes, you are right, this seems like a regression in Cython. In
>> the past, a <bint> cast used to coerce values to the Python `bool`
>> type. Damn, these casts are everywhere, it might take a while to fix
>> all the code, unless I can find a hacky way to workaround the issue.
>>
>
> I've created an issue at https://bitbucket.org/petsc/petsc4py/issues/63/.
>
> From some quick testing, Cython maps int correctly via the bint cast,
> but not PetscBool.
>
> Garth
>
>>
>> --
>> Lisandro Dalcin
>> ============
>> Research Scientist
>> Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
>> Extreme Computing Research Center (ECRC)
>> King Abdullah University of Science and Technology (KAUST)
>> http://ecrc.kaust.edu.sa/
>>
>> 4700 King Abdullah University of Science and Technology
>> al-Khawarizmi Bldg (Bldg 1), Office # 0109
>> Thuwal 23955-6900, Kingdom of Saudi Arabia
>> http://www.kaust.edu.sa
>>
>> Office Phone: +966 12 808-0459
More information about the petsc-users
mailing list