Skip to content

%alias_magic#2036

Merged
fperez merged 4 commits into
ipython:masterfrom
bfroehle:alias_magic
Jun 26, 2012
Merged

%alias_magic#2036
fperez merged 4 commits into
ipython:masterfrom
bfroehle:alias_magic

Conversation

@bfroehle
Copy link
Copy Markdown
Contributor

A magic function which creates additional magic aliases.

  • %alias_magic myedit edit: %myedit is an alias of %edit.
  • %alias_magic mybash bash: %%mybash is an alias of %bash.
  • %alias_magic mytimeit timeit: %mytimeit is an alias of %timeit, and %%mytimeit is an alias of %%timeit.
  • %alias_magic --cell mytimeit timeit: Only %%mytimeit is an alias of %timeit.

Closes #641.

@fperez
Copy link
Copy Markdown
Member

fperez commented Jun 25, 2012

Test results for commit 4ad5a49 merged into master
Platform: linux2

  • python2.7: OK
  • python3.2: OK (libraries not available: cython matplotlib oct2py pygments pymongo rpy2 wx wx.aui)

Not available for testing: python2.6, python3.1

@fperez
Copy link
Copy Markdown
Member

fperez commented Jun 25, 2012

Code looks clean on first pass, but it's missing tests. There should be at least a test calling it to make an alias and then validate that the aliased function is found and is the correct one. Exercising the flags in separate tests would also be a good idea.

Thanks for this, though! I hope we can wrap it up in time for 0.13.

@bfroehle
Copy link
Copy Markdown
Contributor Author

Okay, added a few tests.

@fperez
Copy link
Copy Markdown
Member

fperez commented Jun 26, 2012

Test results for commit f7ef1be merged into master
Platform: linux2

  • python2.7: OK
  • python3.2: OK (libraries not available: cython matplotlib oct2py pygments pymongo rpy2 wx wx.aui)

Not available for testing: python2.6, python3.1

Comment thread IPython/core/magics/basic.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a couple of one-line examples here would be useful. Just paste them from an interactive session.

In general, for magics we try to give examples so that people can see immediately how to use the tool, without having to figure it out from the documentation.

@fperez
Copy link
Copy Markdown
Member

fperez commented Jun 26, 2012

Thanks! I only noticed the need for a bit of example material (sorry I missed that on my first pass, I was about to merge and saw it now).

Once that goes in (should only take a minute), I'll be happy to merge, the implementation is perfect. Great job!

@fperez
Copy link
Copy Markdown
Member

fperez commented Jun 26, 2012

Tagged for 0.13, as this is basically ready.

@fperez
Copy link
Copy Markdown
Member

fperez commented Jun 26, 2012

Added note above that this closes $641.

@bfroehle
Copy link
Copy Markdown
Contributor Author

I added a few %alias_magic examples:


  In [1]: %alias_magic t timeit

  In [2]: %t -n1 pass
  1 loops, best of 3: 954 ns per loop

  In [3]: %%t -n1
     ...: pass
     ...:
  1 loops, best of 3: 954 ns per loop

  In [4]: %alias_magic --cell whereami pwd
  UsageError: Cell magic function `%%pwd` not found.
  In [5]: %alias_magic --line whereami pwd

  In [6]: %whereami
  Out[6]: u'/home/testuser'

@fperez
Copy link
Copy Markdown
Member

fperez commented Jun 26, 2012

Sweet, thanks! Merging now.

fperez added a commit that referenced this pull request Jun 26, 2012
%alias_magic

A magic function which creates additional magic aliases.

* `%alias_magic myedit edit`: `%myedit` is an alias of `%edit`.

* `%alias_magic mybash bash`: `%%mybash` is an alias of `%bash`.

* `%alias_magic mytimeit timeit`: `%mytimeit` is an alias of `%timeit`, and `%%mytimeit` is an alias of `%%timeit`.

* `%alias_magic --cell mytimeit timeit`: Only `%%mytimeit` is an alias of `%timeit`.

Closes #641.
@fperez fperez merged commit 37bd8f7 into ipython:master Jun 26, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
%alias_magic

A magic function which creates additional magic aliases.

* `%alias_magic myedit edit`: `%myedit` is an alias of `%edit`.

* `%alias_magic mybash bash`: `%%mybash` is an alias of `%bash`.

* `%alias_magic mytimeit timeit`: `%mytimeit` is an alias of `%timeit`, and `%%mytimeit` is an alias of `%%timeit`.

* `%alias_magic --cell mytimeit timeit`: Only `%%mytimeit` is an alias of `%timeit`.

Closes ipython#641.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In %magic help, remove duplicate aliases

2 participants