0% found this document useful (0 votes)
98 views

PDF Learning IPython for Interactive Computing and Data Visualization - Second Edition Cyrille Rossant download

Interactive

Uploaded by

smilasahsen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views

PDF Learning IPython for Interactive Computing and Data Visualization - Second Edition Cyrille Rossant download

Interactive

Uploaded by

smilasahsen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.

com

Learning IPython for Interactive Computing and


Data Visualization - Second Edition Cyrille
Rossant

https://textbookfull.com/product/learning-ipython-for-
interactive-computing-and-data-visualization-second-edition-
cyrille-rossant/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Interactive Data Visualization for the Web Murray

https://textbookfull.com/product/interactive-data-visualization-for-
the-web-murray/

textboxfull.com

Interactive Data Visualization for the Web An Introduction


to Designing with D3 1st Edition Murray

https://textbookfull.com/product/interactive-data-visualization-for-
the-web-an-introduction-to-designing-with-d3-1st-edition-murray/

textboxfull.com

Python for Data Analysis Data Wrangling with Pandas NumPy


and IPython Wes Mckinney

https://textbookfull.com/product/python-for-data-analysis-data-
wrangling-with-pandas-numpy-and-ipython-wes-mckinney/

textboxfull.com

Interactive Data Visualization for the Web An Introduction


to Designing with D3 2nd Edition Scott Murray

https://textbookfull.com/product/interactive-data-visualization-for-
the-web-an-introduction-to-designing-with-d3-2nd-edition-scott-murray/

textboxfull.com
Learning d3 js Data Visualization Ændrew Rininsland

https://textbookfull.com/product/learning-d3-js-data-visualization-
aendrew-rininsland/

textboxfull.com

Interactive Web-Based Data Visualization with R, Plotly,


and Shiny 1st Edition Carson Sievert

https://textbookfull.com/product/interactive-web-based-data-
visualization-with-r-plotly-and-shiny-1st-edition-carson-sievert/

textboxfull.com

Bio-inspired Algorithms for Data Streaming and


Visualization, Big Data Management, and Fog Computing
Simon James Fong
https://textbookfull.com/product/bio-inspired-algorithms-for-data-
streaming-and-visualization-big-data-management-and-fog-computing-
simon-james-fong/
textboxfull.com

Practical Python Data Visualization: A Fast Track Approach


To Learning Data Visualization With Python Ashwin Pajankar

https://textbookfull.com/product/practical-python-data-visualization-
a-fast-track-approach-to-learning-data-visualization-with-python-
ashwin-pajankar/
textboxfull.com

Learning Kibana 7 build powerful elastic dashboards with


Kibana s data visualization capabilities Second Edition
Bahaaldine Azarmi
https://textbookfull.com/product/learning-kibana-7-build-powerful-
elastic-dashboards-with-kibana-s-data-visualization-capabilities-
second-edition-bahaaldine-azarmi/
textboxfull.com
[1]
Learning IPython for Interactive
Computing and Data
Visualization
Second Edition

Get started with Python for data analysis and numerical


computing in the Jupyter notebook

Cyrille Rossant

BIRMINGHAM - MUMBAI
Learning IPython for Interactive Computing
and Data Visualization
Second Edition

Copyright © 2015 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book
is sold without warranty, either express or implied. Neither the author nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: April 2013

Second edition: October 2015

Production reference: 1151015

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78398-698-9

www.packtpub.com
Credits

Author Project Coordinator


Cyrille Rossant Shweta H Birwatkar

Reviewers Proofreader
Damián Avila Safis Editing
Nicola Rainiero
G Scott Stukey Indexer
Monica Ajmera Mehta

Commissioning Editor
Kartikey Pandey Production Coordinator
Conidon Miranda

Acquisition Editors
Kartikey Pandey Cover Work
Conidon Miranda
Richard Brookes-Bland

Content Development Editor


Arun Nadar

Technical Editor
Pranil Pathare

Copy Editor
Stephen Copestake
About the Author

Cyrille Rossant is a researcher in neuroinformatics, and is a graduate of Ecole


Normale Superieure, Paris, where he studied mathematics and computer science.
He has worked at Princeton University, University College London, and College
de France. As part of his data science and software engineering projects, he gained
experience in machine learning, high-performance computing, parallel computing,
and big data visualization.

He is one of the main developers of VisPy, a high-performance visualization package


in Python. He is the author of the IPython Interactive Computing and Visualization
Cookbook, Packt Publishing, an advanced-level guide to data science and numerical
computing with Python, and the sequel of this book.

I am grateful to Nick Fiorentini for his help during the revision of


the book. I would also like to thank my family and notably my wife
Claire for their support.
About the Reviewers

Damián Avila is a software developer and data scientist (formerly a biochemist)


from Córdoba, Argentina.

His main focus of interest is data science, visualization, finance, and


IPython/Jupyter-related projects.

In the open source area, he is a core developer for several interesting and popular
projects, such as IPython/Jupyter, Bokeh, and Nikola. He has also started his own
projects, being RISE, an extension to enable amazing live slides in the Jupyter
notebook, the most popular one. He has also written several tutorials about
the Scientific Python tools (available at Github) and presented several talks
at international conferences.

Currently, he is working at Continuum Analytics.

Nicola Rainiero is a civil geotechnical engineer with a background in the


construction industry as a self-employed designer engineer. He is also specialized
in the renewable energy field and has collaborated with the Sant'Anna University
of Pisa for two European projects, REGEOCITIES and PRISCA, using qualitative
and quantitative data analysis techniques.

He has an ambition to simplify his work with open software and use and develop
new ones; sometimes obtaining good results, at other times, negative. You can reach
Nicola on his website at http://rainnic.altervista.org.

A special thanks to Packt Publishing for this opportunity to


participate in the reviewing of this book. I thank my family,
especially my parents, for their physical and moral support.
www.PacktPub.com

Support files, eBooks, discount offers,


and more
For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub
files available? You can upgrade to the eBook version at www.PacktPub.com and as a print
book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
service@packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for
a range of free newsletters and receive exclusive discounts and offers on Packt books and
eBooks.
TM

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book
library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib
today and view 9 entirely free books. Simply use your login credentials for immediate access.
Table of Contents
Preface vii
Chapter 1: Getting Started with IPython 1
What are Python, IPython, and Jupyter? 1
Jupyter and IPython 2
What this book covers 4
References 5
Installing Python with Anaconda 5
Downloading Anaconda 6
Installing Anaconda 6
Before you get started... 7
Opening a terminal 7
Finding your home directory 8
Manipulating your system path 8
Testing your installation 9
Managing environments 9
Common conda commands 10
References 11
Downloading the notebooks 12
Introducing the Notebook 13
Launching the IPython console 13
Launching the Jupyter Notebook 14
The Notebook dashboard 15
The Notebook user interface 16
Structure of a notebook cell 16
Markdown cells 17
Code cells 18

[i]
Table of Contents

The Notebook modal interface 19


Keyboard shortcuts available in both modes 19
Keyboard shortcuts available in the edit mode 19
Keyboard shortcuts available in the command mode 20
References 20
A crash course on Python 20
Hello world 21
Variables 21
String escaping 23
Lists 24
Loops 26
Indentation 27
Conditional branches 27
Functions 28
Positional and keyword arguments 29
Passage by assignment 30
Errors 31
Object-oriented programming 32
Functional programming 34
Python 2 and 3 35
Going beyond the basics 36
Ten Jupyter/IPython essentials 37
Using IPython as an extended shell 37
Learning magic commands 42
Mastering tab completion 45
Writing interactive documents in the Notebook with Markdown 47
Creating interactive widgets in the Notebook 49
Running Python scripts from IPython 51
Introspecting Python objects 53
Debugging Python code 54
Benchmarking Python code 55
Profiling Python code 56
Summary 58
Chapter 2: Interactive Data Analysis with pandas 59
Exploring a dataset in the Notebook 59
Provenance of the data 60
Downloading and loading a dataset 61
Making plots with matplotlib 63
Descriptive statistics with pandas and seaborn 67

[ ii ]
Table of Contents

Manipulating data 69
Selecting data 69
Selecting columns 70
Selecting rows 70
Filtering with boolean indexing 72
Computing with numbers 73
Working with text 75
Working with dates and times 76
Handling missing data 77
Complex operations 78
Group-by 78
Joins 80
Summary 83
Chapter 3: Numerical Computing with NumPy 85
A primer to vector computing 85
Multidimensional arrays 86
The ndarray 86
Vector operations on ndarrays 87
How fast are vector computations in NumPy? 88
How an ndarray is stored in memory 89
Why operations on ndarrays are fast 91
Creating and loading arrays 91
Creating arrays 91
Loading arrays from files 93
Basic array manipulations 94
Computing with NumPy arrays 97
Selection and indexing 98
Boolean operations on arrays 99
Mathematical operations on arrays 100
A density map with NumPy 103
Other topics 107
Summary 108
Chapter 4: Interactive Plotting and Graphical Interfaces 109
Choosing a plotting backend 109
Inline plots 109
Exported figures 111
GUI toolkits 111
Dynamic inline plots 113
Web-based visualization 114

[ iii ]
Table of Contents

matplotlib and seaborn essentials 115


Common plots with matplotlib 116
Customizing matplotlib figures 120
Interacting with matplotlib figures in the Notebook 122
High-level plotting with seaborn 124
Image processing 126
Further plotting and visualization libraries 129
High-level plotting 129
Bokeh 130
Vincent and Vega 130
Plotly 131
Maps and geometry 132
The matplotlib Basemap toolkit 132
GeoPandas 133
Leaflet wrappers: folium and mplleaflet 134
3D visualization 134
Mayavi 134
VisPy 135
Summary 135
Chapter 5: High-Performance and Parallel Computing 137
Accelerating Python code with Numba 138
Random walk 138
Universal functions 141
Writing C in Python with Cython 143
Installing Cython and a C compiler for Python 143
Implementing the Eratosthenes Sieve in Python and Cython 144
Distributing tasks on several cores with IPython.parallel 148
Direct interface 149
Load-balanced interface 150
Further high-performance computing techniques 153
MPI 153
Distributed computing 153
C/C++ with Python 154
GPU computing 154
PyPy 155
Julia 155
Summary 155

[ iv ]
Table of Contents

Chapter 6: Customizing IPython 157


Creating a custom magic command in an IPython extension 157
Writing a new Jupyter kernel 160
Displaying rich HTML elements in the Notebook 165
Displaying SVG in the Notebook 165
JavaScript and D3 in the Notebook 167
Customizing the Notebook interface with JavaScript 170
Summary 172
Index 173

[v]
Preface
Data analysis skills are now essential in scientific research, engineering, finance,
economics, journalism, and many other domains. With its high accessibility and
vibrant ecosystem, Python is one of the most appreciated open source languages for
data science.

This book is a beginner-friendly introduction to the Python data analysis platform,


focusing on IPython (Interactive Python) and its Notebook. While IPython is an
enhanced interactive Python terminal specifically designed for scientific computing
and data analysis, the Notebook is a graphical interface that combines code, text,
equations, and plots in a unified interactive environment.

The first edition of Learning IPython for Interactive Computing and Data Visualization
was published in April 2013, several months before the release of IPython 1.0. This
new edition targets IPython 4.0, released in August 2015. In addition to reflecting the
novelties of this new version of IPython, the present book is also more accessible to
non-programmer beginners. The first chapter contains a brand new crash course on
Python programming, as well as detailed installation instructions.

Since the first edition of this book, IPython's popularity has grown significantly,
with an estimated user base of several millions of people and ongoing collaborations
with large companies like Microsoft, Google, IBM, and others. The project itself has
been subject to important changes, with a refactoring into a language-independent
interface called the Jupyter Notebook, and a set of backend kernels in various
languages. The Notebook is no longer reserved to Python; it can now also be used
with R, Julia, Ruby, Haskell, and many more languages (50 at the time of this
writing!).

[ vii ]
Preface

The Jupyter project has received significant funding in 2015 from the Leona M. and
Harry B. Helmsley Charitable Trust, the Gordon and Betty Moore Foundation, and
the Alfred P. Sloan Foundation, which will allow the developers to focus on the
growth and maturity of the project in the years to come.

Here are a few references:

• Home page for the Jupyter project at http://jupyter.org/


• Announcement of the funding for Jupyter at https://blog.jupyter.
org/2015/07/07/jupyter-funding-2015/
• Detail of the project's grant at https://blog.jupyter.org/2015/07/07/
project-jupyter-computational-narratives-as-the-engine-of-
collaborative-data-science/

What this book covers


Chapter 1, Getting Started with IPython, is a thorough and beginner-friendly
introduction to Anaconda (a popular Python distribution), the Python language, the
Jupyter Notebook, and IPython.

Chapter 2, Interactive Data Analysis with pandas, is a hands-on introduction to


interactive data analysis and visualization in the Notebook with pandas, matplotlib,
and seaborn.

Chapter 3, Numerical Computing with NumPy, details how to use NumPy for efficient
computing on multidimensional numerical arrays.

Chapter 4, Interactive Plotting and Graphical Interfaces, explores many capabilities of


Python for interactive plotting, graphics, image processing, and interactive graphical
interfaces in the Jupyter Notebook.

Chapter 5, High-Performance and Parallel Computing, introduces the various techniques


you can employ to accelerate your numerical computing code, namely parallel
computing and compilation of Python code.

Chapter 6, Customizing IPython, shows how IPython and the Jupyter Notebook can be
extended for customized use-cases.

[ viii ]
Preface

What you need for this book


The following software is required for the book:

• Anaconda with Python 3


• Windows, Linux, or OS X can be used as a platform

Who this book is for


This book targets anyone who wants to analyze data or perform numerical
simulations of mathematical models.

Since our world is becoming more and more data-driven, knowing how to analyze
data effectively is an essential skill to learn. If you're used to spreadsheet programs
like Microsoft Excel, you will appreciate Python for its much larger range of analysis
and visualization possibilities. Knowing this general-purpose language will also let
you share your data and analysis with other programs and libraries.

In conclusion, this book will be useful to students, scientists, engineers, analysts,


journalists, statisticians, economists, hobbyists, and all data enthusiasts.

Conventions
In this book, you will find a number of text styles that distinguish between different
kinds of information. Here are some examples of these styles and an explanation of
their meaning.

Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"Run it with a command like bash Anaconda3-2.3.0-Linux-x86_64.sh (if
necessary, replace the filename by the one you downloaded)."

A block of code is set as follows:


def load_ipython_extension(ipython):
"""This function is called when the extension is loaded.
It accepts an IPython InteractiveShell instance.
We can register the magic with the `register_magic_function`
method of the shell instance."""
ipython.register_magic_function(cpp, 'cell')

[ ix ]
Preface

Any command-line input or output is written as follows:


$ python
Python 3.4.3 |Anaconda 2.3.0 (64-bit)| (default, Jun 4 2015, 15:29:08)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this: "To create
a new notebook, click on the New button, and select Notebook (Python 3)."

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or disliked. Reader feedback is important for us as it helps
us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail feedback@packtpub.com, and mention


the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide at www.packtpub.com/authors.
You can also report any issues at https://github.com/ipython-books/minibook-
2nd-code/issues.

[x]
Preface

Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.

Downloading the example code


You can download the example code files from your account at http://www.
packtpub.com for all the Packt Publishing books you have purchased. If you
purchased this book elsewhere, you can visit http://www.packtpub.com/support
and register to have the files e-mailed directly to you. You will also find the book's
code on this GitHub repository: https://github.com/ipython-books/minibook-
2nd-code.

Downloading the color images of this book


We also provide you with a PDF file that has color images of the screenshots/
diagrams used in this book. The color images will help you better understand the
changes in the output. You can download this file from https://www.packtpub.
com/sites/default/files/downloads/6989OS_ColouredImages.pdf.

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you could report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your
submission will be accepted and the errata will be uploaded to our website or added
to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/


content/support and enter the name of the book in the search field. The required
information will appear under the Errata section.

[ xi ]
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very seriously.
If you come across any illegal copies of our works in any form on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.

Please contact us at copyright@packtpub.com with a link to the suspected pirated


material.

We appreciate your help in protecting our authors and our ability to bring you
valuable content.

Questions
If you have a problem with any aspect of this book, you can contact us at
questions@packtpub.com, and we will do our best to address the problem.
Getting Started with IPython
In this chapter, we will cover the following topics:

• What are Python, IPython, and Jupyter?


• Installing Python with Anaconda
• Introducing the Notebook
• A crash course on Python
• Ten Jupyter/IPython essentials

What are Python, IPython, and Jupyter?


Python is an open source general-purpose language created by Guido van Rossum
in the late 1980s. It is widely-used by system administrators and developers for many
purposes: for example, automating routine tasks or creating a web server. Python is
a flexible and powerful language, yet it is sufficiently simple to be taught to school
children with great success.

In the past few years, Python has also emerged as one of the leading open
platforms for data science and high-performance numerical computing. This might
seem surprising as Python was not originally designed for scientific computing.
Python's interpreted nature makes it much slower than lower-level languages like
C or Fortran, which are more amenable to number crunching and the efficient
implementation of complex mathematical algorithms.

However, the performance of these low-level languages comes at a cost: they are
hard to use and they require advanced knowledge of how computers work. In the
late 1990s, several scientists began investigating the possibility of using Python for
numerical computing by interoperating it with mainstream C/Fortran scientific
libraries. This would bring together the ease-of-use of Python with the performance
of C/Fortran: the dream of any scientist!

[1]
Getting Started with IPython

Consequently, the past 15 years have seen the development of widely-used libraries
such as NumPy (providing a practical array data structure), SciPy (scientific
computing), matplotlib (graphical plotting), pandas (data analysis and statistics),
scikit-learn (machine learning), SymPy (symbolic computing), and Jupyter/IPython
(efficient interfaces for interactive computing). Python, along with this set of
libraries, is sometimes referred to as the SciPy stack or PyData platform.

Competing platforms
Python has several competitors. For example, MATLAB (by Mathworks)
is a commercial software focusing on numerical computing that is
widely-used in scientific research and engineering. SPSS (by IBM) is a
commercial software for statistical analysis. Python, however, is free and
open source, and that's one of its greatest strengths. Alternative open
source platforms include R (specialized in statistics) and Julia (a young
language for high-performance numerical computing).

More recently, this platform has gained popularity in other non-academic


communities such as finance, engineering, statistics, data science, and others.

This book provides a solid introduction to the whole platform by focusing on one
of its main components: Jupyter/IPython.

Jupyter and IPython


IPython was created in 2001 by Fernando Perez (the I in IPython stands for
"interactive"). It was originally meant to be a convenient command-line interface
to the scientific Python platform. In scientific computing, trial and error is the rule
rather than the exception, and this requires an efficient interface that allows for
interactive exploration of algorithms, data, and graphs.

In 2011, IPython introduced the interactive Notebook. Inspired by commercial


software such as Maple (by Maplesoft) or Mathematica (by Wolfram Research), the
Notebook runs in a browser and provides a unified web interface where code, text,
mathematical equations, plots, graphics, and interactive graphical controls can be
combined into a single document. This is an ideal interface for scientific computing.
Here is a screenshot of a notebook:

[2]
Chapter 1

Example of a notebook

It quickly became clear that this interface could be used with languages other than
Python such as R, Julia, Lua, Ruby, and many others. Further, the Notebook is not
restricted to scientific computing: it can be used for academic courses, software
documentation, or book writing thanks to conversion tools targeting Markdown,
HTML, PDF, ODT, and many other formats. Therefore, the IPython developers
decided in 2014 to acknowledge the general-purpose nature of the Notebook by
giving a new name to the project: Jupyter.

Jupyter features a language-independent Notebook platform that can work with


a variety of kernels. Implemented in any language, a kernel is the backend of the
Notebook interface. It manages the interactive session, the variables, the data, and so
on. By contrast, the Notebook interface is the frontend of the system. It manages the
user interface, the text editor, the plots, and so on. IPython is henceforth the name
of the Python kernel for the Jupyter Notebook. Other kernels include IR, IJulia,
ILua, IRuby, and many others (50 at the time of this writing).

[3]
Getting Started with IPython

In August 2015, the IPython/Jupyter developers achieved the "Big Split" by splitting
the previous monolithic IPython codebase into a set of smaller projects, including
the language-independent Jupyter Notebook (see https://blog.jupyter.
org/2015/08/12/first-release-of-jupyter/). For example, the parallel
computing features of IPython are now implemented in a standalone Python
package named ipyparallel, the IPython widgets are implemented in ipywidgets,
and so on. This separation makes the code of the project more modular and facilitates
third-party contributions. IPython itself is now a much smaller project than before
since it only features the interactive Python terminal and the Python kernel for the
Jupyter Notebook.

You will find the list of changes in IPython 4.0 at http://ipython.


readthedocs.org/en/latest/whatsnew/version4.html.
Many internal IPython imports have been deprecated due to the
code reorganization. Warnings are raised if you attempt to perform
a deprecated import. Also, the profiles have been removed and
replaced with a unique default profile. However, you can simulate
this functionality with environment variables. You will find more
information at http://jupyter.readthedocs.org.

What this book covers


This book covers the Jupyter Notebook 1.0 and focuses on its Python kernel,
IPython 4.0. In this chapter, we will introduce the platform, the Python language,
the Jupyter Notebook interface, and IPython. In the remaining chapters, we will
cover data analysis and scientific computing in Jupyter/IPython with the help of
mainstream scientific libraries such as NumPy, pandas, and matplotlib.

This book gives you a solid introduction to Jupyter and the SciPy
platform. The IPython Interactive Computing and Visualization Cookbook
(http://ipython-books.github.io/cookbook/) is the sequel of
this introductory-level book. In 15 chapters and more than 500 pages,
it contains a hundred recipes covering a wide range of interactive
numerical computing techniques and data science topics. The IPython
Cookbook is an excellent addition to the present IPython minibook if
you're interested in delving into the platform in much greater detail.

[4]
Chapter 1

References
Here are a few references about IPython and the Notebook:

• The main Jupyter page at: http://jupyter.org/


• The main Jupyter documentation at: https://jupyter.readthedocs.org/
en/latest/
• The main IPython page at: http://ipython.org/
• Jupyter on GitHub at: https://github.com/jupyter
• Try Jupyter online at: https://try.jupyter.org/
• The IPython Notebook in research, a Nature note at http://www.nature.
com/news/interactive-notebooks-sharing-the-code-1.16261

Installing Python with Anaconda


Although Python is an open-source, cross-platform language, installing it with the
usual scientific packages used to be overly complicated. Fortunately, there is now
an all-in-one scientific Python distribution, Anaconda (by Continuum Analytics),
that is free, cross-platform, and easy to install. Anaconda comes with Jupyter and all
of the scientific packages we will use in this book. There are other distributions and
installation options (like Canopy, WinPython, Python(x, y), and others), but for the
purpose of this book we will use Anaconda throughout.

Running Jupyter in the cloud


You can also use Jupyter directly from your web browser, without
installing anything on your local computer: go to http://try.
jupyter.org. Note that the notebooks created there are not saved.
Let's also mention a similar service, Wakari (https://wakari.io),
by Continuum Analytics.

Anaconda comes with a package manager named conda, which lets you manage
your Python distribution and install new packages.

Miniconda
Miniconda (http://conda.pydata.org/miniconda.html) is
a light version of Anaconda that gives you the ability to only install
the packages you need.

[5]
Getting Started with IPython

Downloading Anaconda
The first step is to download Anaconda from Continuum Analytics' website
(http://continuum.io/downloads). This is actually not the easiest part since
several versions are available. Three properties define a particular version:

• The operating system (OS): Linux, Mac OS X, or Windows. This will depend
on the computer you want to install Python on.
• 32-bit or 64-bit: You want the 64-bit version, unless you're on an old or low-
end computer. The 64-bit version will allow you to manipulate large datasets.
• The version of Python: 2.7, or 3.4 (or later). In this book, we will use
Python 3.4. You can also use Python 3.5 (released in September 2015)
which introduces many features, including a new @ operator for matrix
multiplication. However, it is easy to temporarily switch to a Python 2.7
environment with Anaconda if necessary (see the next section).

Python 3 brought a few backward-incompatible changes over Python 2 (also


known as Legacy Python). This is why many people are still using Python
2.7 at this time, even though Python 3 was released in 2008. We will use
Python 3 in this book, and we recommend that newcomers learn Python
3. If you need to use legacy Python code that hasn't yet been updated to
Python 3, you can use conda to temporarily switch to a Python 2 interpreter.

Once you have found the right link for your OS and Python 3 64-bit, you can
download the package. You should then find it in your downloads directory
(depending on your OS and your browser's settings).

Installing Anaconda
The Anaconda installer comes in different flavors depending on your OS, as follows:

• Linux: The Linux installer is a bash .sh script. Run it with a command
like bash Anaconda3-2.3.0-Linux-x86_64.sh (if necessary, replace the
filename by the one you downloaded).
• Mac: The Mac graphical installer is a .pkg file that you can run with a
double-click.
• Windows: The Windows graphical installer is an .exe file that you can run
with a double-click.

[6]
Chapter 1

Then, follow the instructions to install Anaconda on your computer. Here are a few
remarks:

• You don't need administrator rights to install Anaconda. In most cases, you
can choose to install it in your personal user account.
• Choose to put Anaconda in your system path, so that Anaconda's Python is
the system default.

Anaconda comes with a graphical launcher that you can use to start
IPython, manage environments, and so on. You will find more details
at http://docs.continuum.io/anaconda-launcher/

Before you get started...


Before you get started with Anaconda, there are a few things you need to know:
• Opening a terminal
• Finding your home directory
• Manipulating your system path

You can skip this section if you already know how to do these things.

Opening a terminal
A terminal is a command-line application that lets you interact with your computer
by typing commands with the keyboard, instead of clicking on windows with the
mouse. While most computer users only know Graphical User Interfaces, developers
and scientists generally need to know how to use the command-line interface for
advanced usage. To use the command-line interface, follow the instructions that are
specific to your OS:

• On Windows, you can use Powershell. Press the Windows + R keys, type
powershell in the Run box, and press Enter. You will find more information
about Powershell at https://blog.udemy.com/powershell-tutorial/.
Alternatively, you can use the older Windows terminal by typing cmd in the
Run box.
• On OS X, you can open the Terminal application, for example by pressing
Cmd + Space, typing terminal, and pressing Enter.
• On Linux, you can open the Terminal from your application manager.

In a terminal, use the cd /path/to/directory command to move to a given


directory. For example, cd ~ moves to your home directory, which is introduced in
the next section.
[7]
Getting Started with IPython

Finding your home directory


Your home directory is specific to your user account on your computer. It generally
contains your applications' settings. It is often referred to as ~.Depending on the OS,
the location of the home directory is as follows:

• On Windows, its location is C:\Users\YourName\ where YourName is the


name of your account.
• On OS X, its location is /Users/YourName/ where YourName is the name of
your account.
• On Linux, its location is generally /home/yourname/ where yourname is the
name of your account.

For example, the directory ~/anaconda3 refers to C:\Users\YourName\anaconda3\


on Windows and /home/yourname/anaconda3/ on Linux.

Manipulating your system path


The system path is a global variable (also called an environment variable) defined
by your operating system with the list of directories where executable programs are
located. If you type a command like python in your terminal, you generally need
to have a python (or python.exe on Windows) executable in one of the directories
listed in the system path. If that's not the case, an error may be raised.

You can manually add directories to your system path as follows:

• On Windows, press the Windows + R keys, type rundll32.exe sysdm.


cpl,EditEnvironmentVariables, and press Enter. You can then edit the
PATH variable and append ;C:\path\to\directory if you want to add
that directory. You will find more detailed instructions at http://www.
computerhope.com/issues/ch000549.htm.
• On OS X, edit or create the file ~/.bash_profile and add export
PATH="$PATH:/path/to/directory" at the end of the file.
• On Linux, edit or create the file ~/.bashrc and add export PATH="$PATH:/
path/to/directory" at the end of the file.

[8]
Chapter 1

Testing your installation


To test Anaconda once it has been installed, open a terminal and type python. This
opens a Python console, not to be confused with the OS terminal. The Python
console is identified with a >>> prompt string, whereas the OS terminal is identified
with a $ (Linux/OS X) or > (Windows) prompt string. These strings are displayed
in the terminal, often preceded by your computer's name, your login, and the
current directory (for example, yourname@computer:~$ on Linux or PS C:\Users\
YourName> on Windows). You can type commands after the prompt string. After
typing python, you should see something like the following:
$ python
Python 3.4.3 |Anaconda 2.3.0 (64-bit)| (default, Jun 4 2015, 15:29:08)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

What matters is that Anaconda or Continuum Analytics is mentioned here.


Otherwise, typing python might have launched your system's default Python, which
is not the one you want to use in this book.

If you have this problem, you may need to add the path to the Anaconda executables
to your system path. For example, this path will be ~/anaconda3/bin if you chose to
install Anaconda in ~/anaconda3. The bin directory contains Anaconda executables
including python.

If you have any problem installing and testing Anaconda, you can ask for help on
the mailing list (see the link in the References section under the Installing Python with
Anaconda section of this chapter).

Next, exit the Python prompt by typing exit() and pressing Enter.

Managing environments
Anaconda lets you create different isolated Python environments. For example, you
can have a Python 2 distribution for the rare cases where you need to temporarily
switch to Python 2.

[9]
Getting Started with IPython

To create a new environment for Python 2, type the following command in an OS


terminal:
$ conda create -n py2 anaconda python=2.7

This will create a new isolated environment named py2 based on the original
Anaconda distribution, but with Python 2.7. You could also use the command conda
env: type conda env -h to see the details.

You can now activate your py2 environment by typing the following command in a
terminal:

• Windows: activate py2 (note that you might have problems with
Powershell, see https://github.com/conda/conda/issues/626, or use the
old cmd terminal)
• Linux and Mac OS X: source activate py2

Now, you should see a (py2) prefix in front of your terminal prompt. Typing
python in your terminal with the py2 environment activated will open a Python 2
interpreter.

Type deactivate on Windows or source deactivate on Linux/OS X to deactivate


the environment in the terminal.

Common conda commands


Here is a list of common commands:

• conda help: Displays the list of conda commands.


• conda list: Lists all packages installed in the current environment.
• conda info: Displays system information.
• conda env list: Displays the list of environments installed. The currently
active one is marked by a star *.
• conda install somepackage: Installs a Python package (replace
somepackage by the name of the package you want to install).
• conda install somepackage=0.7: Installs a specific version of a package.
• conda update somepackage: Updates a Python package to the latest
available version.
• conda update anaconda: Updates all packages.
• conda update conda: Updates conda itself.

[ 10 ]
Another Random Scribd Document
with Unrelated Content
make it easy for the other party to yield to his interest. It mattered
little to him on what terms she accepted him as her husband. He
would have given the greater part of his fortune to assure the
performance of the ceremony which the world awaited at noon.
“There is an alternative,” he said, solemnly, “that would satisfy the
obligation honor puts upon you and at the same time leave inviolate
the sentiment you have just expressed.”
“An alternative?” she repeated, wondering.
“Yes. I will be satisfied if you become my wife only in name—in
the eyes of society, the Church, and the civil law.”
Hera understood as she had not until then how desperate was
the strait to which her refusal had brought him. For a moment she
did not answer the entreaty in his eyes. She walked to the open
window and looked out on the night. Tarsis had planned shrewdly in
keeping this for the last card to play. In her state of mind it was the
one appeal that could have the effect he desired. To Hera the offer
did seem the only way that remained of serving honor as well as
saving herself from what she contemplated as a loathsome
degradation. The inevitable misery of the sort of relation he proposed
rose before her mind; but of her happiness she thought no more, so
eager was she to mitigate in some degree the wrong of which she
perceived he must be the greater victim. Presently Tarsis was at her
side again, saying:
“Will you do this? Be my wife only in name. On these terms, if
you will, you may redeem your promise—you may save me.”
And wishing to do that—wishing to save him, to do him justice—
swayed, too, by pity for him and remorse for her broken promise,
and crushed in spirit by her disappointment in Mario—she yielded.
“There is no other way,” she said, turning to him, wearily—“no
other way to screen you—to meet the demand of honor.”
He caught up her hand and kissed it.
“You will never regret this act of justice,” he said, confident that
his complete triumph was only a matter of time. Perhaps he betrayed
the working of his mind in some unguarded gleam of the eye, some
play of the lip, for she said to him, her manner showing grave
determination:
“Don’t think I shall change—that you can swerve me in the least
from this position. You must foster no false hopes. When I become
your wife I shall remain to the last only that in appearance—in the
eyes of the world. In reality I shall be as far removed from you as if I
were actually married to another. I tell you this as emphatically as
possible, because it is only just that you clearly understand what our
marriage will mean to both.”
“All is quite clear,” Tarsis returned, cunningly.
“Oh, it is a terrible deed!” she exclaimed, the consequences rising
to her mind and filling it with horror. “Think well, I beg of you. In
despoiling me of my life’s happiness you are going to ruin your own.
Perhaps you did not think I should make the conditions so absolute,
so irrevocable. If you wish to withdraw your offer do so, and save us
from a lot that can not fail to be one of misery so long as we both are
alive.”
She had only multiplied his motives for wishing to make her his
wife. She understood him even less than he understood her. At no
time before had her beauty made such a living appeal to him. Until
now it had never been his privilege to behold her when emotion was
at play. Her outward image of loveliness was all she had ever
revealed to him. The voice she gave him in the past was not the
passionate one he had just heard; the soul her eyes had mirrored
was not the one that looked from them when she spoke the name of
Mario Forza. The heave of her bosom, the come and go of carnation
in her cheeks, the tides of tenderness that rose amid her promises of
a vehement strength, portrayed to him a Hera he had not known
before—a woman he would have given all his vast fortune to win.
“What you have said does not deter me,” he told her, “though I
apprehend the situation as fully as you wish me to. I accept.”
And thus the thread of the story took a new twist, but one of
which Aunt Beatrice never learned, nor did Don Riccardo.
CHAPTER VIII
A WEDDING JOURNEY

At noon they kneeled before the Cardinal of Milan, in the great


white cathedral, speaking the words that welded their bonds. It was
an hour of gray skies, and the many-hued sunshine that often had
sifted through the great stained glass windows to felicitate a bride did
not fall upon Hera. The gay world of Lombardy was there, filling the
transept with its silks and jewels, and in the backward parts of the
nave and aisles common folk looked on at the famous wedding.
There was to be a breakfast in Villa Barbiondi, and when the
ceremony at the altar was over some of the princes and dukes and
marquises, with their dames, followed Tarsis and his bride to the
main door. In the journals of that evening were the names of the
ladies and gentlemen who composed the brilliant procession, with
details, more or less accurate, as to the gowns.
Other particulars of the event, within the cathedral and without,
were set down minutely by press men and press women. They told
of the concourse of people in the square—hundreds of them idle
working folk; how they crowded the steps before the church, and
how the Civil Guards kept open a lane to the carriages of the bridal
party; but no mention was made of the sullen faces bordering that
lane.
Nor was there any account of the doings of La Ferita, the woman
of the scarred face, who shook her fist at Tarsis. Before he came
from the church she had annoyed the Civil Guards by crying out:
“Joy to the bridegroom! Death to the children in his factories!” The
guards gave her a final warning, which she understood; and when
Tarsis passed by her tongue was stilled, but the long scar glowed
and her eyes looked savage hatred. Tarsis saw the woman shaking
her fist at him, and so did Hera. In after days he was aware of that
face, with its deep red mark running across one eyelid from forehead
to cheekbone. Another detail overlooked or purposely omitted by the
conservative press was the low muttering against the bridegroom
that sounded here and there in the crowd.
The nuptial cortege started for the railway station. In Corso
Vittorio Emanuele it passed a café where a youthful artist, in satirical
mood, was amusing some comrades with his pencil. He threw off a
cartoon of the wedding. It depicted the bridegroom receiving a blow
on the nose from the brawny fist of a workman; and in the place of
blood there flowed—gold pieces! The editor of a revolutionary journal
picked it up, and while the merry breakfast at the villa was in
progress the thing circulated, filling many of the Milanese with delight
and moving others to indignation.
Tarsis and his bride set off for Paris by the night express. The
station master at Milan greeted them as they alighted from the train
that bore them from the Brianza, and with many a bow and smile
conducted them to the private car in which they were to travel as
only the King and the Queen travel in Italy. The ceremonious tribute
of the conductor and the guards as they passed along the platform
tickled the vanity of Tarsis in no small degree. To the keen eye his
manner betrayed the pride he felt in this public display of his
husbandship to the beautiful daughter of the aristocracy who walked
by his side.
That was Hera’s thought when they were seated in their moving
drawing-room. Oddly enough she found herself studying his attire.
She recalled that hitherto it had never given her any distinct
impression; he had always appeared dressed in the height of
fashion, with a certain mercantile brilliancy best described, perhaps,
as stylish. Now it seemed that he looked a trifle too much like a
bridegroom. In this moment she awoke sharply to the truth that he
was, irreparably, for better or for worse, her husband. Again she
heard the solemn voice of the cardinal proclaiming, “This bond may
not be severed so long as you do live.” Before, the fact had not
assumed a phase of such vivid actuality; it all had been so utterly
opposed to the current of her thoughts and the desire of her heart.
Now the trial she had accepted in a sentiment of duty came home to
her in its practical aspect. And in the spirit of a gentlewoman she
resolved to meet the situation with good grace. As well look the fact
in the eye and make the best of it. Then and there she decided that
under the chafing of the yoke she would not fret and lose her peace.
It turned out that the wedding journey began with a pleasant
surprise for Tarsis. He found his wife a most cheerful companion.
She talked with him lightly and let her laughter ripple. Of course, she
overplayed the part in her first essay. But Tarsis, in his exultation,
was completely hors de critique. This unexpected melting of his
iceberg produced cups of vanity which went to his head and
intoxicated him to the verge of blindness. All he could see was his
own supposed success in making himself agreeable to his wife. After
dinner, when the attendant had set out the Marsala and cigars, she
bade him smoke, and while he did so she read to him from the
Milanese Firefly. Together they laughed over the droll jests and
anecdotes told so quaintly in the Lombardian patter. He told her
about his career in the money-making world; how success there was
once his only aspiration, but that now he was aware of a waning zest
in the game. He paused to look into her eyes, while a certain
softness, as of meek appeal, showed in his own. Then he said, rising
and standing near her chair:
“Life holds only one prize for me to-day. It is your tender regard.”
A deep tide of colour dyed Hera’s cheeks, and, without making
other reply, she turned her head and gazed upon the sparkling
electric lamps of a village that was sailing by. A moment more, and
she rose, but only to bid him good-night and withdraw to the
compartment prepared for her. Tarsis followed her with his eyes, an
amused smile on his lips, and when she had disappeared he took a
cigar from the box, lighted it, and threw himself into a long-cushioned
chair. For an hour he stayed there, meditative, cheerful, while the
train wound and climbed and burrowed its way across the Alps.
In the late afternoon they rolled into a gloomy terminal station of
the French capital. It had been a day of rain clouds with short-lived
intervals of clear sky; and while on their way to an obscure but
aristocratic hotel on the left bank of the Seine they saw Paris in one
of her happiest moments—a period of sunshine between showers.
There was an air of gladness about the passing throngs—a
momentary lift of spirits imparted by the smiling heavens; the wet
pavements glistened, as did the oil-cloths of cabmen and
gendarmes, and the moving life everywhere gave forth a lightened
resonance. But before they reached the hotel umbrellas were up,
and Paris was cross again.
So the weather served them nearly every hour of their week’s
stay. Tarsis made no effort to reapproach the theme of “tender
regard,” and Hera seemed to enter heartily into the enjoyment of the
amusements he provided. The opera had no auditor more pleased
than she, and when they drove in the Bois—between showers—she
saw so many things in the spring’s unfolding, and talked about them
so brightly, that Tarsis found himself interested for once in the
wonders of nature’s workshop. She had put on the armour of
contentment, believing he would perceive that she wore it not only in
kindness but from a sense of duty consequent upon the giving of her
hand. She believed that he would comprehend as well that it was
meant no less for self-defence than for self-effacement. Upon his
keenness of intellect she had counted, and not in vain. He read her
declaration as clearly as if she had written it in the plainest of Tuscan
words: The lot he had chosen was the one by which he must abide;
her armour of contentment was so frail that it might be broken by
even an essay on his part at disturbing the status quo to which he
had agreed. All this he appreciated and made believe to accept as
her immutable law.
The wedding journey took its course over the English Channel. In
London Hera found many letters from Italy. From Aunt Beatrice there
were four precisely written pages, over which the sage spinster had
spread her dictum, with a fine tone of authority, on the amenities of
wifehood. The letter from Don Riccardo breathed tenderness and
sympathy, but proved a fresh reminder of the frail nature that was
her father’s. He charged her that the Barbiondi were not made for
slavery. Never must she sink under the burden of her marriage. If
ever it became too heavy to bear with honour she must cast it off,
come what might. Well he knew the sacrifice she was making. Was
the father’s heart to be deceived because the daughter was too
brave to come to him with her trouble? Ah, no!
“Beloved Hera,” he went on, “your absence
tears my heart. Oh, fate! Why could it not have
spared us enough to live in our humble peace?
But no—ah, well, why weep over the
irreparable? A chi tocca, tocca. Is it not so?
With my warmest blessing and prayers most
ardent for your happiness, I am your
affectionate
“Babbo.”
Hera was able to utter a heartfelt thanksgiving that her father had
not urged her to the marriage. She was glad he had done nothing in
that affair to lessen the respect for him which she mingled with her
love. There was a letter from a comrade of the Brianza—the little
Marchioness di Tramonta; she wrote from the eminence of almost a
year of married life. Letters from girl friends—dainty missives in
cream and lilac—conveyed glowing wishes for a bright future.
Typewritten letters in printed envelopes had haunted Tarsis from
the hour of his arrival in Paris. And now they pursued him to London.
Thanks to the eclipse of the honeymoon, he found opportunity to
read and answer many of them, as well as to spend a part of the day
in Lombard street on “urgent matters of business,” as he explained
to his bride.
Hera sent her father a most cheerful reply. “To-day,” she said, in
closing, “I have had an interesting experience in dreary London. I
promised you to pay a visit to the Duchess of Claychester. I did so
this afternoon, and I am glad indeed. You did not tell me, babbo, that
the Duchess is one of those English ladies of whom we read in Italy
because of their work among the poor. We had luncheon in her
house in Cavendish Square, then went to a place called a
‘settlement,’ of which she is chief patroness. It is a large modern
building in the midst of the most squalid section of Marylebone—a
quarter, I am told, that for human wretchedness is worse than the
East End one hears so much about in the novels. My heart turned
sick at the sights. Is it possible that we have anything so bad in
Milan? Signor Forza told me of the poor of our Porta Ticinese quarter
and I have heard about them from others. I have never been there,
yet I cannot believe it equals the miserable life of this London slum.
Now, what I saw gave me an idea. And what do you think it is? That I
may be useful in the world! Yes, and in the way that the Duchess of
Claychester is; but among our own people in Milan. I learned all that
I could about the work.
“They have women called ‘visitors’ who go to the homes of the
poor people, and with one of these I went for an hour or more. It was
an experience I shall never forget. She told me that she had to
employ rare tact sometimes, because there were men and women in
the slums who objected to being ‘elevated’ or ‘ameliorated.’ It was so
that my guide expressed it. We had a striking proof of the fact in one
place. The family consisted of a very small woman, a very large
man, and two wee girls. That they were in need anyone could see.
As soon as we entered the man acted like a hunted animal at bay.
The visitor was a woman of severe manner, and I must say that I did
not detect in the way she went about this case any of that ‘rare tact’
which she said was so necessary. ‘Charity!’ the man roared back at
her (I give it in his own language), ‘who asks yer bloody charity?
What we wants is justice, we do. An’ justice we’ll ’ave some day, yer
bet yer boots!’ He shook his fist in the visitor’s face, and his wife
tugged at his coat, saying: ‘Be-ive yerself, ’Enry; be-ive yerself!’
“The visitor thought it time to go, and I agreed with her. These
English! These English!
“It has rained every day since we left Italy. In France we caught a
peep of the sun now and then; here, never. If ever again I stand
under our skies I shall rejoice. Before I thought of being useful it
seemed that those skies could never be bright, and I dreaded going
back. But now, oh, how eager I am to be there! Ever your
affectionate daughter, who counts the hours until she shall see you,
“Hera.”
CHAPTER IX
A SEED OF GRATITUDE

In the evening they departed from Charing Cross, and without


interruption their journey to France was accomplished. When a day
had come and gone the Alpine solitudes were behind them, and they
beheld once more the Arcadian valleys of Vaudois. Soon after that
they moved in the sunlight over stretches of Lombardian plain. Now
the azure above them resembled the sky color of pictures in old
missals. How beautiful it was to Hera’s eyes! She felt the irresistible
charm of the prospect, even as the barbarians did in ancient days.
She wondered if it was any different then. Through all time those
plains seemed to have been under the husbandman’s rule, ever
fruitful, ever smiling in their bright verdure.
Tarsis lowered a window and the breath of springtime fanned
their faces. It brought a delicious freshness from the little man-made
streamlets that, catching the heavens’ mood, wove a blue network
over the land, and sparkled in the sun-play like great strings of
precious stones. In their purpose of irrigation they crossed the white
highroads and the by-paths, coursed in sluices under the railway,
and cut the fields how and where they pleased, too well bent upon
practical service to care for symmetry of form. They drew near one
another, they rambled far apart, but in the end always meeting in the
wide canal that bore elsewhere their enriching flood; and so forever
running, yet never wasted. A few weeks, and this pampered soil
would render its marvellous account; the meadows would yield their
many harvests; the rice stalks would be crowded with ears; the
clover would be like a blossoming thicket, the cornfields like
canebrakes; but the men and women who toiled to produce this
abundance would live on in their poverty. The clod-breakers were
there again to-day—as they had been with the returning springtime
for ages, about their work—boys digging trenches, ploughmen at
their shafts, women and girls planting seed.
Hera noticed that the villages along the way had not the neat and
cheerful look of the French and Swiss hamlets. Seen from afar,
crowning a hilltop, their tiled roofs brightly red in the sun-glare, and
the yellow walls gleaming like burnished gold, the pictorial
expression of them was full of beauty; but when the train halted in
the heart of one, and its wretchedness lay bare, her spirit was
saddened by the grim reality.
“I mean to do something to help the poor of Milan,” she said to
Tarsis, one of the gloomy pictures haunting her memory.
“You have chosen a wide field of good endeavour,” he returned,
in a slight tone of banter.
“And I wonder why the field is so wide,” she pursued. “Milan is
called our City Prosperous.”
“I think the reason is not difficult to find,” he said, with assurance.
“Do you mean that the poor are unworthy?”
“No; I should not give that as the first cause; it is a result. This
sentimental nonsense called the New Democracy has turned
working people’s heads. It gives them puffed-up notions of their
value, and they will not work for the wages that the masters offer—
the wages that it is possible for them to pay. They spend too much
time talking about the dignity of labour. If only they would work for
what they can get and not squander their wages in the wine-shops
they would be well enough off. They want too much; more than they
will ever get. Their warfare against capital only hurts themselves.”
“Do they want more than they need?” she asked.
“I am not familiar with their needs,” he answered, with a note of
petulance. “I do know, however, that they often demand more than it
is possible to pay. I am not a theorist. I happen to have gained my
knowledge in the school of practice, as you may be aware.”
“Still, suffering exists among them,” she reasoned, “and, while the
fault may be as you say, the families of these men—misguided
though they may be—are the victims rather than the culprits. I
suppose it would be only common humanity to give them help.”
“Oh, yes; that is true,” he acknowledged. “The women and
children have to play martyr while the men indulge in what our new
economists delight to call divine discontent. By the way,” he went on,
“I am paying some charitable concern five thousand liras a year.”
His manner told her that it was a benefice ungraced by a sense
of moral obligation; that he merely had followed the example of
modern rich men by returning a part of his tremendous revenue in
benefactions to the public.
“It is good to give heart to the disheartened, relief to the
suffering,” she said, holding up a journal they had obtained at Turin.
“Have you seen this account of disorders in the Porta Ticinese
quarter? I fear there is a hungry mouth in Milan that will show its
teeth some day.”
Tarsis could hear the voice of Mario Forza. He betrayed a
twitching of the lips, but tried to carry it off with a careless smile, as
he said:
“I suppose the money is put to good use. Precisely how they
disburse it I do not know. The secretary sends printed reports, but I
have not read them.”
There was a quality of absence in his manner, accounted for by
the fact that his mind was busying itself with Hera’s remark about the
hungry mouth. While in Paris he had received by post from unknown
senders not one but many copies of the newspaper that contained
the picture of his punched nose and its plenteous flow of gold pieces.
Then the cartoon had seemed to him merely one more shaft of
malice aimed at a successful man. In his career of achievement he
had steeled his sensibility against criticism, rating it as the twin
brother of envy, and borrowing no disquiet on either score; but now,
grace to the chance observation of Hera, he saw the cartoon with a
new and clearer eye. He perceived the force at work behind it—the
popular ill-will, which gave such point to the product of the artist’s
pencil; and he apprehended, as he never had before, that herein
smouldered an ember easily fanned to flame.
He had accustomed himself to meeting difficulties promptly, and
turning apparent disadvantage to a factor of self-service. Now he
reflected—and the thought gleamed shrewdly in his half-closed eyes
—that this ember of peril might be smothered with a few handfuls of
those coins, which were his by right of conquest, though the growing
madness of the time found them so ignoble. Indeed, it was an
excellent idea—this one of his wife—to throw a bone to the snarling
dogs. He would give her charitable whim his countenance, even his
unstinted support. He would let his wife scatter largesse among the
malcontents; let her shine as the doer of good deeds, but the world
would know—the house of Barbiondi had no name for wealth—the
workers would applaud Antonio Tarsis, friend of the poor. Moreover,
this co-operation would place his wife under an obligation to him,
give her one more proof of his desire to gratify her every wish. So he
said to her, at the moment that the train entered the suburbs of
Milan:
“I count it noble of you, Hera, to have a care for the unfortunate.
A little thought convinces me that you are right in your view. There
are times when we should not stop to reason why.”
“I am glad that we can see alike in this,” she said. “There is joy, I
know, in giving.”
“And I wish to be in accord with you. Believe me, you have my
warmest sympathy in whatever work you contemplate. As to funds, I
need not tell you that my fortune is at your disposal.”
“You are most generous; I thank you,” she said, and told him of
the plan conceived in London.
In the station they saw Don Riccardo and his sister coming down
the platform to welcome them.
“Babbo!” Hera cried out before her father caught sight of her, and
the next moment she was in his arms.
“Ah, truant!” he said, holding her hands and swinging them, while
he looked into her eyes as if to read their secret. “I have you again.
And you come to stay. Is it not so, my treasure?”
“You may be sure of that, babbo!” she laughed, and turned to
receive her aunt’s caresses. “Here I am and here I stay. Long live
Italia is my song, and I think Antonio will join in the chorus.”
“With all my heart!” Tarsis said genially, his hopes taking a
sudden bound. It was the first time she had addressed him by his
Christian name.
Never had anyone seen Hera in better spirits. It was good to be
once more in the land she loved, to hear again the familiar “minga”
and “lu” of her native patter; but the real inspiration of her gladness,
although the fact did not appear to her mind, was that she had come
to dwell in the city whose walls enclosed Mario Forza, and whose air
he breathed. Aunt Beatrice accepted her lightness of heart
triumphantly as a tribute to her own splendid work as a matchmaker.
Tarsis’s automobile awaited them, and they got in, all four. Hera
noted that the crest of her house was painted none too small on the
olive green sides of the car.
Through the spick and span wide, modern streets they rolled to
the Barbiondi palace. Milan was gayly picturesque in her springtime
magic of light and colour. An impress of the Gothic feeling met the
eye in buildings that recalled where they did not typify the pointed
architecture of the north. They passed a procession of priests and
acolytes following a crozier that flashed the sunlight. Here and there,
at a street corner, a public porter slept peacefully while awaiting a
call to work. For a minute or two they were in the busy movement of
Via Manzoni. Cavalry officers in bright uniforms lounged at the
outdoor tables of the cafés, or dragged their sabres lazily amid the
throngs of civilians.
Then they entered a quieter way, that yielded vistas of courtyards
with frescoed walls, arcades clad in climbing greenery, playing
fountains; and at the next turning they were in sight of Palazzo
Barbiondi. For two months artisans had been at work restoring the
ancient family seat to life and splendour. In point of splendour Tarsis
had done somewhat more than recall the past. As they approached
the arched gateway Don Riccardo exclaimed at sight of the newly-
coloured iron palings tipped with gilt. The fountain in the court was
playing. Out of the pool rose an Apollo Musagetes, and from his
crown a sparkling shower shot down in diverging lines to symbolise
the sun’s rays, or—as the Greeks had it—the arrows of Apollo. The
side walls of the court were frescoed with the Barbiondi crown and
the “Lux in tenebras lucet” of the once haughty and powerful house.
A corps of domestics in livery of white and olive were waiting,
lined on either side of the main entrance. The fountain statues and
all the marble ornamenture of the court had been despoiled of their
yellow patina, and showed once more in native white. The façade of
the palace—accounted one of the noblest in the North—had been
spared by the renovator, but its grand staircase, rising from one side
of the wide portico, and its carved balustrade, were as white as St.
Bernard’s peak. Everywhere that the artisans could turn back the
clock they had done so by dint of scouring and scraping, painting
and stuccoing, chiselling and carving, tearing out and building in.
Don Riccardo paused at the opening to the grand staircase and
looked up at the armorial bearings of his house done in stone.
“Bacco!” he exclaimed, “we are the first Barbiondi to set foot here
for more than a hundred years.”
It was in the Duke’s heart to denounce the fungous nobility and
shop-keeping snobs who had from time to time violated his ancestral
home with their occupancy; but in the presence of Tarsis he bridled
his tongue.
“Yes, it is indeed more than a hundred years,” remarked Donna
Beatrice, adjusting her lorgnette. “Our eighteenth Riccardo was the
last of the line to dwell here. With this day, Antonio,” she added,
beaming upon the bridegroom, “we may say with literal truth that the
restoration begins. Ah, that eighteenth Duke was an open-handed
nobleman—a lord of regal expenditure. Lombardy never had so
liberal a patron of the beautiful arts. These mural paintings, I believe,
are the fruit of his munificence.”
“Yes; our great grandfather,” mused the living Duke, casting his
eye about the stairway. “Still, I should be none the less proud of him
had he lavished less on his walls and more on his posterity.”
They ascended the broad steps, and Donna Beatrice, primed
with the lore of the place, began to radiate her knowledge. The
staircase, with its balustrade of richly carved Carrara, she
announced was a product of Vanitelli, and the solitary work Milan
possessed of that great architect. This acquisition, as well as many
more to which she drew his attention, proved a surprise to the new
lord of the palace. The idea of buying the mediæval pile came to
Tarsis—so he believed—as an inspiration, and he had lost not a
second in giving it practical form. Accompanied by the owner—a
Genoese money-lender—he went there one morning, and spent
something less than half an hour looking about the palace, the
stables, and the grounds. Before the day was out he had bound the
bargain with his check. Within twenty-four hours the contractor and
his gang attacked the house, armed with authority to renovate and
restore.
It was with a newly-awakened interest, therefore—not unmixed
with an appreciation of its humorous side—that Tarsis listened to
Donna Beatrice’s running talk. In a manner that made him think of
the guides in the Brera Gallery she reeled off the history of this
painting or that medallion, explained the frescoes of the ceiling, and
identified the busts in the niches, with their age-old faces shining
again like newly scrubbed schoolboys.
A sculptured frieze that bordered the staircase pictured a battle
between the Lombards and the Barbiondi in the days of King Alboin.
Above it, following the long flight of steps, unfolded a panorama of
scenes from the life of Mary. At the top of the staircase, set in the
wall, was a trophy that had been sawed out of a church by some
conquering Barbiondi. It depicted St. Mark preaching at Alexandria.
In the banquet hall were some less pious conceptions of beauty.
Here the mural art found expression in a hunting scene and a
mediæval dance with the hills of the Brianza in the background.
The grand saloon—a gorgeous chamber in marble and gold—
was worthy of a royal abode. It had been known for centuries as the
Atlantean chamber. Engaging the eye before all else were two rows
of Atlantes supporting the ceiling on either side, all of heroic size.
They were equal in number to the windows, between which they
rested on pedestals of grained marble. A huge fist of each gripped a
bronze candelabra of many lights. Their torsos were undraped, but
the rest of them was lost in chiselled oak leaves. On the ceiling pink
sea nymphs sported in silvery foam and gods and angels revelled in
rosy vapours. Through the stained glass of a dome the sun flowed
down upon the mellow fairness of the tessellated pavement.
They all paused before a large painting. It was a vivid picture of
Italy’s chief industry during the era of her free cities—men slaying
one another in furious combat. Where the glory of war shone
brightest—where the blood flowed fastest—there could be seen a
great car, drawn by oxen, flying the standard of Milan, and bearing
an altar with the host. The leather-clad warriors of the time called it
their caroccio. Like the Israelites’ ark of the covenant, it was a
rallying point in battle, and reminded the artisans that they had a
church as well as a city to fight for.
“It is the car of Heribert,” said Hera, for the enlightenment of
Tarsis, “an Archbishop of Milan. He was of our race.”
“And the inventor of the caroccio,” added Donna Beatrice,
proudly.
“And the first labour agitator. Isn’t that so?” put in Don Riccardo,
keeping a straight face.
“I don’t know what that is,” replied his sister.
“Signor Tarsis can tell you, perhaps,” the other suggested.
“A labour agitator?” Tarsis repeated. “Why, I should define him as
a breeder of discontent and a foe to the public peace.”
“If that definition be fair,” Hera rejoined earnestly, “Heribert was
indeed a labour agitator. Undeniably he sowed discontent, but
discontent against injustice.”
“And what was his particular method?” asked Tarsis, smiling as if
to make light of her remark and keeping his eyes on the mimic
warfare.
“He gave tongue to a hitherto voiceless people,” she answered,
“and made them into an army, so that they were able not only to
express their wrongs but to fight for their rights.” The words seemed
to have a present-day meaning, and with her companions’
perception of the fact the name of Mario Forza leaped into their
minds. It stirred them, one and all, to a fresh appreciation that the
man she had made no secret of loving was still a prevalent force in
her life; her thoughts were in sympathy with his, the colours he gave
to the world were the colours in which she beheld it.
To her father’s face the incident brought a look of pity; it caused
Donna Beatrice to screw up her little features into wrinkles of
disgust, and in the changing glances of Tarsis it was easy to read a
rising tide of resentment. When he spoke it was in the cold vein of
mockery whereof on occasion he could be master.
“The rights of labour,” he said, “are, of course, the only rights that
a nation should consider. We have a new wisdom in Italy—it has
come in with the New Democracy—the wisdom that is blind to the
rights of capital and laughs at the idea of its having any virtue; all the
prosperity our country enjoys to-day, understand, is due to the
champions of the horny-fisted—the dreamers of the Camera. Is not
that the fact, Don Riccardo?”
“To be precise,” the Duke answered, “I don’t know.”
“Surely you must be aware,” his son-in-law asserted, “that it is not
men like myself who are giving the country what she needed so long
—the breath of industrial life. Oh, no; it is our critics who are doing
this, the silver-tongued doctrinaires. They would give us a very
different sort of industry—the sort you see in that picture. Strife and
bloodshed were the business of that day, and will be in ours, depend
upon it, unless a stronger hand rules at Rome.”
“What do you think ought to be done?” asked Donna Beatrice,
frightened by the black forecast.
“Done? The thing is simple. The Government should take
measures to silence these mischief-makers, these plotters against
industrial peace. We build up the wealth of the nation, they would
tear it down. They delude themselves with the notion that they are
the only patriots. How delicious! They are Italy’s deadliest foes.”
“I tremble to think of the consequences,” said Donna Beatrice.
“Why, our heads would not be safe. See how those blacksmiths and
clod-hoppers lay about them with their pikes and terrible swords! I
suppose the heads they are cracking are the heads that wouldn’t
take in their new ideas! Ugh!”
“Still, the world is somewhat hard for many,” Don Riccardo
observed, for the sake of a word in support of Hera, who had moved
away, resolved not to join issue with her husband.
“I have always found the world what I made it,” Tarsis returned,
and they passed on toward the door of the library. The contractor
had stocked the massive oak shelves with volumes old and new, and
supplied the room with modern leather furniture.
“Oh, the Napoleonic relic!” exclaimed Donna Beatrice at sight of a
large oblong table of Florentine mosaic. Tarsis was all attention.
“Napoleonic relic?” he asked. “What do you mean?”
“Ah, you must know,” she told him, “that when the conqueror
came to Milan he made the palace his headquarters. This table was
once in Villa Barbiondi, and my great-grandfather gave it to
Napoleon.”
Tarsis drew a chair to the table, and, with a nod of apology to the
others, seated himself; resting his arms on the polished surface, he
moved his right hand in simulation of the act of writing.
“It is of convenient height,” he said, “and I shall use it. I cannot tell
you how pleased I am to find this relic. Napoleon Bonaparte is the
man above all the world’s heroes whom I admire.”
“Truly a marvellous man, a matchless genius,” attested Donna
Beatrice, gravely contemplative.
“From childhood his life has been my guiding star,” Tarsis
continued. “And to possess, to use the table that he used, is a
privilege I never thought to enjoy. And the work itself,” he added,
rising and drawing back to admire it, with an interest which no other
object of art in the palace had been able to awaken in him, “is it not
magnificent?”
“Quite a treasure,” acquiesced Don Riccardo, showing more
concern in the bookcases, which he was sweeping with his eyes; but
for Hera—explain it she could not—the thing inspired a strange
aversion—a feeling that came vividly to her mind in after days when
that table played its tragic part in the destiny of the man she called
husband.
CHAPTER X
THE DOOR OF FRA PANDOLE

They followed Donna Beatrice and Tarsis across the figured


expanse of pavement, down the grand staircase and through the
portico to the gardens. Beyond the yellow wall at the backward limit
they could see the red roofs of Via Cappuccini—humble abodes of
workmen partly screened by the trees. All about them nature had
opened her poetry book. Plants in the great urns were dappled with
snowy fairness, the maples showed richly green, the magnolias were
unfolding their eager beauty, and the air was rapturous with the
voices of birds. When they had looked upon the row of swishing tails
in the stable and surveyed the store of motor cars Donna Beatrice
remarked to Tarsis, she and he standing apart from the others:
“I perceive that your wife cannot escape happiness. You are
giving her all that mortal heart can wish.”
“I am following your advice,” he said, with a smile that his
companion did not see was cunning—“striving to win her gratitude,
you perceive. But I fear there is no short road to her affection.”
“My friend,” Donna Beatrice announced, impressively, “you are
nearer to it than you believe.”
“Why do you think so?”
“Because it is inevitable,” she answered, positively. “Besides, I
have never seen our Hera in happier mood.”
“Still, it may be studied,” Tarsis suggested, out of his deeper
knowledge.
“Oh, no: it is genuine; depend upon that. Listen to her laughter.
Has it not the true ring? Indeed, Antonio, I confess astonishment at
your wonderful progress. For an hour I have been aching to offer my
felicitations.”
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like