2014-06-28 05:33:53 +00:00
{
2015-06-29 19:35:39 +00:00
"cells": [
2014-06-28 05:33:53 +00:00
{
2015-06-29 19:35:39 +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>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-06-29 19:37:25 +00:00
"### watermark is now located and maintained in a separate GitHub repository: [https://github.com/rasbt/watermark](https://github.com/rasbt/watermark)"
2015-06-29 19:35:39 +00:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 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"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Installation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `watermark` line magic can be directly installed from my GitHub repository via"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Installed watermark.py. To use it, type:\n",
" %load_ext watermark\n"
]
}
],
"source": [
"install_ext https://raw.githubusercontent.com/rasbt/watermark/master/watermark.py"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Loading the `%watermark` magic"
]
},
{
"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",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%load_ext watermark"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Usage"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In order to display the optional `watermark` arguments, type"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%watermark?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<pre> %watermark [-a AUTHOR] [-d] [-e] [-n] [-t] [-z] [-u] [-c CUSTOM_TIME]\n",
" [-v] [-p PACKAGES] [-h] [-m] [-g] [-w]\n",
"\n",
" \n",
"IPython magic function to print date/time stamps \n",
"and various system information.\n",
"\n",
"watermark version 1.2.1\n",
"\n",
"optional arguments:\n",
" -a AUTHOR, --author AUTHOR\n",
" prints author name\n",
" -d, --date prints current date as MM/DD/YYYY\n",
" -e, --eurodate prints current date as DD/MM/YYYY\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",
" -h, --hostname prints the host name\n",
" -m, --machine prints system and machine info\n",
" -g, --githash prints current Git commit hash\n",
" -w, --watermark prints the current version of watermark\n",
"File: ~/.ipython/extensions/watermark.py\n",
"</pre>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Examples"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"06/29/2015 15:34:42\n",
2014-06-28 18:06:33 +00:00
"\n",
2015-06-29 19:35:39 +00:00
"CPython 3.4.3\n",
"IPython 3.2.0\n",
2014-06-28 18:06:33 +00:00
"\n",
2015-06-29 19:35:39 +00:00
"compiler : GCC 4.2.1 (Apple Inc. build 5577)\n",
"system : Darwin\n",
"release : 14.3.0\n",
"machine : x86_64\n",
"processor : i386\n",
"CPU cores : 4\n",
"interpreter: 64bit\n"
2014-07-30 04:22:19 +00:00
]
2015-06-29 19:35:39 +00:00
}
],
"source": [
"%watermark"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"06/29/2015 15:34:43 \n"
2014-06-28 05:33:53 +00:00
]
2015-06-29 19:35:39 +00:00
}
],
"source": [
"%watermark -d -t"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Last updated: Mon Jun 29 2015 15:34:44 EDT\n"
2014-06-28 05:33:53 +00:00
]
2015-06-29 19:35:39 +00:00
}
],
"source": [
"%watermark -u -n -t -z"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPython 3.4.3\n",
"IPython 3.2.0\n"
2014-06-28 05:33:53 +00:00
]
2015-06-29 19:35:39 +00:00
}
],
"source": [
"%watermark -v"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"compiler : GCC 4.2.1 (Apple Inc. build 5577)\n",
"system : Darwin\n",
"release : 14.3.0\n",
"machine : x86_64\n",
"processor : i386\n",
"CPU cores : 4\n",
"interpreter: 64bit\n"
2014-06-28 05:33:53 +00:00
]
2015-06-29 19:35:39 +00:00
}
],
"source": [
"%watermark -m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPython 3.4.3\n",
"IPython 3.2.0\n",
2014-06-28 05:33:53 +00:00
"\n",
2015-06-29 19:35:39 +00:00
"numpy 1.9.2\n",
"scipy 0.15.1\n",
2014-06-28 20:17:42 +00:00
"\n",
2015-06-29 19:35:39 +00:00
"compiler : GCC 4.2.1 (Apple Inc. build 5577)\n",
"system : Darwin\n",
"release : 14.3.0\n",
"machine : x86_64\n",
"processor : i386\n",
"CPU cores : 4\n",
"interpreter: 64bit\n"
2014-06-28 20:17:42 +00:00
]
2015-06-29 19:35:39 +00:00
}
],
"source": [
"%watermark -v -m -p numpy,scipy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"John Doe 06/29/2015 \n",
"\n",
"CPython 3.4.3\n",
"IPython 3.2.0\n",
"\n",
"compiler : GCC 4.2.1 (Apple Inc. build 5577)\n",
"system : Darwin\n",
"release : 14.3.0\n",
"machine : x86_64\n",
"processor : i386\n",
"CPU cores : 4\n",
"interpreter: 64bit\n",
"Git hash : 06830b939358f35f2daf50af42509e603c93d9b4\n"
2014-06-28 20:35:39 +00:00
]
2014-06-28 05:33:53 +00:00
}
],
2015-06-29 19:35:39 +00:00
"source": [
"%watermark -a \"John Doe\" -d -v -m -g"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
2014-06-28 05:33:53 +00:00
}
2015-06-29 19:35:39 +00:00
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}