[yt-users] Type issues with grids

Nathan Goldbaum nathan12343 at gmail.com
Fri Jun 24 06:19:33 PDT 2016


On Fri, Jun 24, 2016 at 5:36 AM, Steve Spicklemire <spicklemire at uindy.edu>
wrote:

> Hi YT folks,
>
> I’m trying to help a colleague who has encountered a problem on Windows.
> I’ve used the same code on my mac and it’s OK. ;-(
>
> The traceback is below.
>
> He’s following an intro tutorial, but using his own data. He’s using an
> anaconda install but he’s updated yt to 3.2.3. It seems when he calls
> ‘cam.draw_grids(im)’ the grid drawing process fails when it hits the cython
> function ‘lines’:
>
>         px, py, dz = self.project_to_plane(vertices, res=im.shape[:2])
>
>         # Must normalize the image
>         nim = im.rescale(inline=False)
>         enhance_rgba(nim)
>         nim.add_background_color('black', inline=True)
>
>         # we flipped it in snapshot to get the orientation correct, so
>         # flip the lines
>         lines(nim.d, px.d, py.d, colors, 24, flip=1)
>
> I think px.d, py.d are somehow ending up as ‘long’ rather than ‘int64’. I
> guess on my system those may be the same type. Maybe on his, they are not?
>

Yes, that sounds right. Long integers on Windows are 4 bytes long - pretty
much everywhere else they're 8 bytes.

http://stackoverflow.com/questions/9689049/what-decides-the-sizeof-an-integer


>
> Thoughts? Thanks!
>
> Here’s the traceback:
>
>  File "<ipython-input-7-6167d268a46c>", line 1, in <module>
>
> runfile('C:/Users/UIndyUser/Documents/Research/Haverhals/multiple_slice_vis.py',
> wdir='C:/Users/UIndyUser/Documents/Research/Haverhals')
>
>   File
> "C:\Users\UIndyUser\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
> line 699, in runfile
>     execfile(filename, namespace)
>
>   File
> "C:\Users\UIndyUser\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
> line 74, in execfile
>     exec(compile(scripttext, filename, 'exec'), glob, loc)
>
>   File
> "C:/Users/UIndyUser/Documents/Research/Haverhals/multiple_slice_vis.py",
> line 111, in <module>
>     nim = cam.draw_grids(im)
>
>   File
> "C:\Users\UIndyUser\Anaconda2\lib\site-packages\yt\visualization\volume_rendering\camera.py",
> line 326, in draw_grids
>     lines(nim.d, px.d, py.d, colors, 24, flip=1)
>
>   File "yt\utilities\lib\misc_utilities.pyx", line 215, in
> yt.utilities.lib.misc_utilities.lines
> (build\src.win-amd64-2.7\yt\utilities\lib\misc_utilities.c:4881)
>
> ValueError: Buffer dtype mismatch, expected 'int64_t' but got ‘long'
>

In principle this should be fixed inside yt to ensure the dtypes match so
users don't need to think about it. However, a quick fix would be to
explicity cast the "nim" variable in your script to int64 before passing it
to draw_grids:

nim = nim.astype('int64')

Any chance you can file a bug about this issue? If you can include a sample
script that triggers the issue on windows that will also help. We probably
just need to explicitly cast some arrays internal to yt to the correct
dtype to avoid this issue.

https://bitbucket.org/yt_analysis/yt/issues/new


>
> thanks,
> -steve
>
> Steve Spicklemire
> University of Indianapolis
> Lilly Science Hall 232B
> Dept. of Physics and Earth Space Sciences
> Shaheen College of Arts and Sciences
> spicklemire at uindy.edu  (317) 788-3313
>
> Confidentiality Notice: This communication and/or its content are for the
> sole use of the intended recipient,and may be privileged, confidential, or
> otherwise protected from disclosure by law.  If you are not the intended
> recipient, please notify the sender and then delete all copies of it.
> Unless you are the intended recipient, your use or dissemination of the
> information contained in this communication may be illegal.
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160624/5f400449/attachment.html>


More information about the yt-users mailing list