[IPython-User] Help converting to New API

MinRK benjaminrk@gmail....
Mon Aug 1 17:02:14 CDT 2011


I've never used opengrads or pygrads, so I don't know if this is
right, but I think I have pygrads at least mostly working:

https://gist.github.com/1119098

The changes are small, principally how to get the current
InteractiveShell (InteractiveShell.instance()), how to execute code
(ip.ex), and how to launch a full IPython app
(IPython.frontend.terminal import ipapp; ipapp.launch_new_instance()),
have been slightly reorganized.

I don't know if it's all the way there, but it seems to work.

-MinRK

On Sun, Jul 31, 2011 at 18:49, Arlindo da Silva <dasilva@alum.mit.edu> wrote:
> Hi,
>
>     Back in 2010 it was pointed out that our "pygrads" script did not work
> with IPython 0.11 because it relied on the 0.10 API (see below). An issue
> was created by the developers to track the possible creation of a
> "compatibility layer", viz:
>
> https://github.com/ipython/ipython/issues/issue/269
>
> Following the discussion in this ticket it is clear that the developers have
> opted for documenting the API conversion rather than creating this
> compatibility layer, for what appears to be sound technical reasons. Now
> that Enthought (prematurely?) adopted IPython 0.11 in their EPD, it becomes
> imperative that packages such as ours get updated to work with IPython 0.11.
> I am writing to see if someone can give me some pointers to get started as I
> have a relatively straightforward use of the previous API.
>
>  The pygrads wrapper script is a simple customization of "python" that
> introduces a few aliases to make it behave more like the "grads" command
> line utility it is replacing. See,
>
>      http://opengrads.org/wiki/index.php?title=PyGrADS_Interactive_Shell
>
> This was implemented by having this customized "ipythonrc":
>
> include ipythonrc
>
> import_mod numpy grads ipygrads
>
> import_some
>
> import_all numpy
>
> import_all grads
>
> import_all ipygrads
>
> execute global ga
>
> where the bulk of the "aliasing" was implemented in "ipygrads.py"
> (attached), using Ipython.ipapi. It seems that I should be using the
> AliasManager, but I am not clear how pass parameters to a new alias, as I
> used to be able to do through expose magic. A few examples would go a long
> way...
>
>    Any help greatly appreciated.
>
>    Thanks,
>
>       Arlindo
>
>
>
>
>
>
>
>
>
> On Fri, Nov 5, 2010 at 10:37 AM, Ismaila Diallo
> <ismailadiallo64@yahoo.fr> wrote:
>> Dear Python user,
>> i try to install pygrads. i have dowload, unzip and untar the file after
>> that i
>> have done
>> sudo python setup.py install
>>
>> and when i compile pygrads i get this error:
>>
>> Welcome to PyGrADS, a GrADS-based iPython environment.
>>
>> Using existing pygrads rc file </home/lpaosf/.pygrads/pygradsrc>
>> Traceback (most recent call last):
>>  File "/usr/local/bin/pygrads", line 188, in <module>
>>    IPython.Shell.start().mainloop()
>> AttributeError: 'module' object has no attribute 'Shell'
>
> Sorry for having ignored your message for so long...
>
> You are probably running IPython 0.11 and this code was written for
> IPython 0.10.x.  Unfortunately some apis have changed and we haven't
> implemented a backwards compatibility layer (it's not completely clear
> we'll be able to do so completely, though I do want to try, I've
> created an issue to track this
> https://github.com/ipython/ipython/issues/issue/269).
>
> Your best option right now is to either uninstall 0.11.x altogether or
> (better) to create a virtualenv in which you run 0.10.1 by default,
> and run pygrads there.  That way, you can continue to use all the
> improvements of 0.11.x while running pygrads on top of 0.10.x.
>
> Regards,
>
> f
>
>
> --
> Arlindo da Silva
> dasilva@alum.mit.edu
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>


More information about the IPython-User mailing list