[yt-users] Type issues with grids

Nathan Goldbaum nathan12343 at gmail.com
Fri Jun 24 10:41:10 PDT 2016


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

> Ack, that didn’t really work:
>
> Traceback (most recent call last):
>   File "foo.py", line 120, in <module>
>     nim = cam.draw_grids(im.astype('int64'))
>   File
> "/Users/user/vjose/lib/python2.7/site-packages/yt/visualization/volume_rendering/camera.py",
> line 320, in draw_grids
>     nim = im.rescale(inline=False)
>   File
> "/Users/user/vjose/lib/python2.7/site-packages/yt/data_objects/image_array.py",
> line 229, in rescale
>     np.multiply(self[:, :, :3], 1.0/cmax, out[:, :, :3])
> TypeError: Cannot cast ufunc multiply output from dtype('float64') to
> dtype('int64') with casting rule 'same_kind'
>

Ah, sorry, I spoke too hastily earlier. Casting the image the int
definitely won't help.


>
> But editing ‘camera.py’ in yt/visualization/volume_rendering/camera.py:326
> to:
>
>         # we flipped it in snapshot to get the orientation correct, so
>         # flip the lines
>         lines(nim.d, px.d.astype('int64'), py.d.astype('int64'), colors,
> 24, flip=1)
>

And indeed, this is likely one way to fix the issue.

It would be nice to get an issue created for this so we can reproduce it
locally and debug.

The next major release of yt has a completely rewritten volume rendering
system, so it would be nice to see if the new volume rendering interface
has the same issue.


>
> Didn’t break me, we’ll see what it does for my colleague.
>
> thanks,
> steve
>
> > On Jun 24, 2016, at 12:34 PM, Steve Spicklemire <spicklemire at uindy.edu>
> wrote:
> >
> > Thanks Nathan,
> >
> > I’m guessing you mean to cast the ‘im’ variable. The line in his script
> is:
> >
> >> nim = cam.draw_grids(im)
> >
> >
> > so this should become:
> >
> > nim = cam.draw_grids(im.astype('int64’))
> >
> > ??
> >
> > I’ll ask him to try that. I’ll also post this to the bug tracker!
> >
> > thanks for the tip!
> > -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.
> >
> >> On Jun 24, 2016, at 9:19 AM, Nathan Goldbaum <nathan12343 at gmail.com>
> wrote:
> >>
> >>
> >>
> >> 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
> >>
> >> _______________________________________________
> >> yt-users mailing list
> >> yt-users at lists.spacepope.org
> >> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
> >
>
> _______________________________________________
> 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/5de2be39/attachment.html>


More information about the yt-users mailing list