[petsc-users] petsc4py bool type

Garth N. Wells gnw20 at cam.ac.uk
Wed Apr 26 04:05:11 CDT 2017


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