2014-06-28 05:33:53 +00:00
{
"metadata": {
"name": "",
2014-07-30 04:22:19 +00:00
"signature": "sha256:968e6f47972d4ab9e2ef4eef6906343257267ccf094fcae08da24fec3647743d"
2014-06-28 05:33:53 +00:00
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
2014-06-28 18:06:33 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Sebastian Raschka](http://sebastianraschka.com) \n",
"\n",
"- [Link to the GitHub Repository python_reference](https://github.com/rasbt/python_reference/)\n",
"\n",
"<hr>\n",
"I would be happy to hear your comments and suggestions. \n",
"Please feel free to drop me a note via\n",
"[twitter](https://twitter.com/rasbt), [email](mailto:bluewoodtree@gmail.com), or [google+](https://plus.google.com/+SebastianRaschka).\n",
"<hr>"
]
},
2014-07-30 04:22:19 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<font color=\"red\">**watermark is now located and maintained in a separate GitHub repository:** [https://github.com/rasbt/watermark](https://github.com/rasbt/watermark)<font>"
]
},
2014-06-28 05:33:53 +00:00
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
2014-06-28 18:06:33 +00:00
"IPython magic function documentation - `%watermark`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"I wrote this simple `watermark` IPython magic function to conveniently add date- and time-stamps to my IPython notebooks. Also, I often want to document various system information, e.g., for my [Python benchmarks](https://github.com/rasbt/One-Python-benchmark-per-day) series.\n"
2014-06-28 05:33:53 +00:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Installation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2014-06-28 18:06:33 +00:00
"The `watermark` line magic can be directly installed from my GitHub repository via"
2014-06-28 05:33:53 +00:00
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 18:06:33 +00:00
"%install_ext https://raw.githubusercontent.com/rasbt/python_reference/master/ipython_magic/watermark.py"
2014-06-28 06:41:42 +00:00
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
2014-06-28 18:08:21 +00:00
"Installed watermark.py. To use it, type:\n",
" %load_ext watermark\n"
2014-06-28 06:41:42 +00:00
]
}
],
"prompt_number": 1
},
2014-06-28 05:33:53 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
2014-06-28 18:06:33 +00:00
"Loading the `%watermark` magic"
2014-06-28 05:33:53 +00:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To load the `date` magic, execute the following line in your IPython notebook or current IPython shell"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 18:06:33 +00:00
"%load_ext watermark"
2014-06-28 05:33:53 +00:00
],
"language": "python",
"metadata": {},
2014-06-28 07:05:21 +00:00
"outputs": [],
2014-06-28 05:33:53 +00:00
"prompt_number": 2
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Usage"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2014-06-28 18:06:33 +00:00
"In order to display the optional `watermark` arguments, type"
2014-06-28 05:33:53 +00:00
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 07:05:21 +00:00
"%watermark?"
2014-06-28 05:33:53 +00:00
],
"language": "python",
"metadata": {},
"outputs": [],
2014-06-28 05:35:21 +00:00
"prompt_number": 3
2014-06-28 05:33:53 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2014-06-29 05:22:49 +00:00
"<pre> %watermark [-a AUTHOR] [-d] [-n] [-t] [-z] [-u] [-c CUSTOM_TIME] [-v]\n",
" [-p PACKAGES] [-h] [-m] [-g]\n",
2014-06-28 05:33:53 +00:00
"\n",
" \n",
2014-06-28 18:06:33 +00:00
"IPython magic function to print date/time stamps \n",
"and various system information.\n",
2014-06-28 05:33:53 +00:00
"\n",
2014-06-29 05:22:49 +00:00
"watermark version 1.1.0\n",
2014-06-28 20:17:42 +00:00
"\n",
2014-06-28 05:33:53 +00:00
"optional arguments:\n",
2014-06-28 20:17:42 +00:00
" -a AUTHOR, --author AUTHOR\n",
" prints author name\n",
2014-06-28 18:06:33 +00:00
" -d, --date prints current date\n",
" -n, --datename prints date with abbrv. day and month names\n",
" -t, --time prints current time\n",
" -z, --timezone appends the local time zone\n",
" -u, --updated appends a string \"Last updated: \"\n",
" -c CUSTOM_TIME, --custom_time CUSTOM_TIME\n",
" prints a valid strftime() string\n",
" -v, --python prints Python and IPython version\n",
" -p PACKAGES, --packages PACKAGES\n",
" prints versions of specified Python modules and\n",
" packages\n",
2014-06-28 20:35:39 +00:00
" -h, --hostname prints the host name\n",
2014-06-28 18:06:33 +00:00
" -m, --machine prints system and machine info\n",
2014-06-29 05:22:49 +00:00
" -g, --githash prints current Git commit hash\n",
2014-06-28 05:33:53 +00:00
"</pre>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Examples"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 07:05:21 +00:00
"%watermark"
2014-06-28 05:33:53 +00:00
],
"language": "python",
"metadata": {},
"outputs": [
{
2014-06-28 07:05:21 +00:00
"output_type": "stream",
"stream": "stdout",
"text": [
2014-06-29 05:22:49 +00:00
"29/06/2014 01:19:10\n",
2014-06-28 18:06:33 +00:00
"\n",
2014-06-28 20:17:42 +00:00
"CPython 3.4.1\n",
2014-06-28 07:05:21 +00:00
"IPython 2.1.0\n",
"\n",
2014-06-28 18:06:33 +00:00
"compiler : GCC 4.2.1 (Apple Inc. build 5577)\n",
2014-06-28 07:05:21 +00:00
"system : Darwin\n",
"release : 13.2.0\n",
"machine : x86_64\n",
"processor : i386\n",
2014-06-28 18:06:33 +00:00
"CPU cores : 2\n",
2014-06-28 07:05:21 +00:00
"interpreter: 64bit\n"
2014-06-28 05:33:53 +00:00
]
}
],
2014-06-29 05:22:49 +00:00
"prompt_number": 3
2014-06-28 05:33:53 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 18:06:33 +00:00
"%watermark -d -t"
2014-06-28 05:33:53 +00:00
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
2014-06-29 05:22:49 +00:00
"29/06/2014 01:19:11 \n"
2014-06-28 05:33:53 +00:00
]
}
],
2014-06-29 05:22:49 +00:00
"prompt_number": 4
2014-06-28 05:33:53 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 18:06:33 +00:00
"%watermark -u -n -t -z"
2014-06-28 05:33:53 +00:00
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
2014-06-29 05:22:49 +00:00
"Last updated: Sun Jun 19 2014 01:19:12 EDT\n"
2014-06-28 05:33:53 +00:00
]
}
],
2014-06-29 05:22:49 +00:00
"prompt_number": 5
2014-06-28 05:33:53 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 18:06:33 +00:00
"%watermark -v"
2014-06-28 05:33:53 +00:00
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
2014-06-28 20:17:42 +00:00
"CPython 3.4.1\n",
2014-06-28 18:06:33 +00:00
"IPython 2.1.0\n"
2014-06-28 05:33:53 +00:00
]
}
],
2014-06-29 05:22:49 +00:00
"prompt_number": 6
2014-06-28 05:33:53 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 18:06:33 +00:00
"%watermark -m"
2014-06-28 05:33:53 +00:00
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
2014-06-28 18:06:33 +00:00
"compiler : GCC 4.2.1 (Apple Inc. build 5577)\n",
"system : Darwin\n",
"release : 13.2.0\n",
"machine : x86_64\n",
"processor : i386\n",
"CPU cores : 2\n",
"interpreter: 64bit\n"
2014-06-28 05:33:53 +00:00
]
}
],
2014-06-29 05:22:49 +00:00
"prompt_number": 7
2014-06-28 05:33:53 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 18:06:33 +00:00
"%watermark -v -m -p numpy,scipy"
2014-06-28 05:33:53 +00:00
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
2014-06-28 18:06:33 +00:00
"stream": "stdout",
2014-06-28 05:33:53 +00:00
"text": [
2014-06-28 20:17:42 +00:00
"CPython 3.4.1\n",
2014-06-28 18:06:33 +00:00
"IPython 2.1.0\n",
"\n",
"numpy 1.8.1\n",
"scipy 0.14.0\n",
"\n",
"compiler : GCC 4.2.1 (Apple Inc. build 5577)\n",
"system : Darwin\n",
"release : 13.2.0\n",
"machine : x86_64\n",
"processor : i386\n",
"CPU cores : 2\n",
"interpreter: 64bit\n"
2014-06-28 05:33:53 +00:00
]
}
],
2014-06-29 05:22:49 +00:00
"prompt_number": 8
2014-06-28 20:17:42 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-29 05:22:49 +00:00
"%watermark -a \"John Doe\" -d -v -m -g"
2014-06-28 20:17:42 +00:00
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
2014-06-29 05:22:49 +00:00
"John Doe 29/06/2014 01:20:48 EDT\n",
2014-06-28 20:17:42 +00:00
"\n",
"CPython 3.4.1\n",
"IPython 2.1.0\n",
"\n",
"compiler : GCC 4.2.1 (Apple Inc. build 5577)\n",
"system : Darwin\n",
"release : 13.2.0\n",
"machine : x86_64\n",
"processor : i386\n",
"CPU cores : 2\n",
2014-06-29 05:22:49 +00:00
"interpreter: 64bit\n",
"Git hash : fbe7759fd7e0298bf0bd05ea4aac01b87aa8ed25\n"
2014-06-28 20:17:42 +00:00
]
}
],
2014-06-29 05:22:49 +00:00
"prompt_number": 16
2014-06-28 20:35:39 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
2014-06-28 05:33:53 +00:00
}
],
"metadata": {}
}
]
}