100% found this document useful (1 vote)
29 views

PDF Python for MATLAB Development: Extend MATLAB with 300,000+ Modules from the Python Package Index Danial download

Index

Uploaded by

immsjosefh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
29 views

PDF Python for MATLAB Development: Extend MATLAB with 300,000+ Modules from the Python Package Index Danial download

Index

Uploaded by

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

Download Full Version ebook - Visit ebookmeta.

com

Python for MATLAB Development: Extend MATLAB with


300,000+ Modules from the Python Package Index
Danial

https://ebookmeta.com/product/python-for-matlab-development-
extend-matlab-with-300000-modules-from-the-python-package-
index-danial/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmeta.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

Practical Channel-Aware Resource Allocation: With MATLAB


and Python Code Michael Ghorbanzadeh

https://ebookmeta.com/product/practical-channel-aware-resource-
allocation-with-matlab-and-python-code-michael-ghorbanzadeh/

ebookmeta.com

Dynamic System Modelling and Analysis with MATLAB and


Python 1st Edition Jongrae Kim

https://ebookmeta.com/product/dynamic-system-modelling-and-analysis-
with-matlab-and-python-1st-edition-jongrae-kim/

ebookmeta.com

An Introduction to Scientific Computing with MATLAB and


Python Tutorials 1st Edition Sheng Xu

https://ebookmeta.com/product/an-introduction-to-scientific-computing-
with-matlab-and-python-tutorials-1st-edition-sheng-xu/

ebookmeta.com

Logic Based Program Synthesis and Transformation 31st


International Symposium LOPSTR 2021 Tallinn Estonia
September 7 8 2021 Emanuele De Angelis (Editor)
https://ebookmeta.com/product/logic-based-program-synthesis-and-
transformation-31st-international-symposium-lopstr-2021-tallinn-
estonia-september-7-8-2021-emanuele-de-angelis-editor/
ebookmeta.com
Too Hard 1st Edition I A Dice

https://ebookmeta.com/product/too-hard-1st-edition-i-a-dice/

ebookmeta.com

American Studies in Europe, Volume 1: Their History and


Present Organization Sigmund Skard

https://ebookmeta.com/product/american-studies-in-europe-
volume-1-their-history-and-present-organization-sigmund-skard/

ebookmeta.com

Excel 2019 Charts Graphical Representation of Figures


Peter J. Scharpff Ri

https://ebookmeta.com/product/excel-2019-charts-graphical-
representation-of-figures-peter-j-scharpff-ri/

ebookmeta.com

Williams obstetrics study guide Robyn Horsager Professor


Of Obstetrics Gynecology Scott Roberts Vanessa L Rogers

https://ebookmeta.com/product/williams-obstetrics-study-guide-robyn-
horsager-professor-of-obstetrics-gynecology-scott-roberts-vanessa-l-
rogers/
ebookmeta.com

Software Engineering Artificial Intelligence Networking


and Parallel Distributed Computing Studies in
Computational Intelligence 1012 Roger Lee (Editor)
https://ebookmeta.com/product/software-engineering-artificial-
intelligence-networking-and-parallel-distributed-computing-studies-in-
computational-intelligence-1012-roger-lee-editor/
ebookmeta.com
Cherrington Academy Cherrington 1 1st Edition Rebecca
Caffery

https://ebookmeta.com/product/cherrington-academy-cherrington-1-1st-
edition-rebecca-caffery/

ebookmeta.com
Albert Danial

Python for MATLAB Development


Extend MATLAB with 300,000+ Modules from the
Python Package Index
Albert Danial
Redondo Beach, CA, USA

ISBN 978-1-4842-7222-0 e-ISBN 978-1-4842-7223-7


https://doi.org/10.1007/978-1-4842-7223-7

© Albert Danial 2022

This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks,


service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.

The publisher, the authors and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.

This Apress imprint is published by the registered company APress


Media, LLC part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
To Ashley, Theodore, Mimi
Preface
In 2018, I was chatting with a young engineer who had recently earned
an engineering master’s degree. MATLAB came up and she spoke of her
frustration with license shortages when projects came due at school. I
had the same frustrations—25 years earlier. Had nothing changed?
Of course, a lot had changed.
By then, we had already found our separate ways to Python to do
the kind of work we used to do in MATLAB. Why were so few MATLAB
users aware of the power and freedom Python could bring them?
I began assembling notes comparing Python solutions to their
MATLAB equivalents and shortly afterward learned of MATLAB’s py
module. A binary API to Python?! Too good to be true. It was too good to
be true, in a sense; early versions couldn’t use critical modules such as
NumPy.
The MathWorks improved py with each MATLAB release, though,
and today MATLAB can run code from NumPy, SciPy, Pandas,
matplotlib, statsmodels, dask, even modules compiled with Cython,
Numba, Pythran, and f2py. The MATLAB + Python combination offers
astounding possibilities to both languages, yet few MATLAB developers
know of this capability or how to take advantage of it. Fertile ground for
a new book, I thought.
Any source code or other supplementary material referenced by the
author in this book is available to readers on GitHub at
https://github.com/Apress/python-for-matlab-development. For more
detailed information, please visit http://www.apress.com/source-code.
Acknowledgments
Rachel Rybarczyk’s comments about MATLAB and Python inspired me
to start the journey that led to this book.
Alain Sei, although bowing out as my coauthor after realizing the
magnitude of the work ahead, nonetheless stayed on as my first reader.
At our weekly meetings in building R2, Alain put thought-provoking
spin on things to keep my perspective fresh.
Rocco Samuele helped elevate the literary quality of the text. While I
don’t have Rocco’s chops for the written word, his edit suggestions
clarified my writing.
Ravi Narasimhan’s critique of an early draft felt more like a mugging
than a review. After the bruises faded, it was clear he’d given me a
goldmine of improvement suggestions. Implementing them led to a
more balanced tone and more convincing assertions. Ravi also provided
the MATLAB examples for the point and line plots on maps shown in
Section 12.​4.
When Curtis Webb first told me about Numba four years ago, I
dismissed his claims that it could make Python functions run 10 ×, even
30 × faster—without using a C/C++/Fortran compiler. Impossible! Yet
somehow, like a magical alien technology, Numba does just that. Best
tip ever, thanks, Curtis!
Parker Hudnut gave valuable “big picture” suggestions on the book’s
overall structure. Thanks! The beer’s on me the next time we’re at
building H.
Thank you Steven Millett, Petra Poschmann, Drew Swalley, and
Mark Vaughn for tips on missing or incomplete topics.
Thanks to Professor John Hedengren for letting me copy his
predband() function in my section on prediction intervals (Section
11.​7.​3). His website1 has excellent videos on statistical computations in
Python.
Thanks to Professor James Doyle for advice on, and a technical
review of, the frequency response section, Section 14.​13.​7. His classic
“red book” on structural wave propagation [1] remains one of my
favorite technical reads.
Dale Williamson’s insights on structural dynamics were inspiring
and educational, and for that I’m grateful; thanks Dale. Errors with the
formulation of equations and procedures are entirely mine.
My technical reviewers, Phillip Feldman and Darrell Yocom, are the
unsung heroes behind the operational aspects of the code and
examples. Both found numerous code errors and saved me from
embarrassingly wrong explanations. Phillip guided me through the
confidence and prediction intervals in the regression section, Section
Section 11.​7.​3. Darrell was the original “observant reader” mentioned
at the end of the TCP Recipe, Section 7.​18, and first altered me to
MATLAB’s type downcast behavior for mixed-type math, Section 15.​2.
To the Apress team, thank you: Steve Anglin for taking a chance on
me; Mark Powers for shepherding the book from early draft to
production; Sherly Nandha for the extensive copy editing and
typesetting work needed to turn my draft into a book.
Finally, and most importantly, thanks to Ashley, Theodore, and Mimi
for believing in me and giving me time and space to write.
A.N.D.
November 2021
Table of Contents
Chapter 1:​Introduction
1.​1 Learn Python Through MATLAB Equivalents
1.​2 Is Python Really Free?​
1.​3 What About Toolboxes?​
1.​4 Why Python Won’t Replace MATLAB
1.​5 Contents at a Glance
1.​6 I Already Know Python.​How Do I Call Python Functions in
MATLAB?​
1.​7 The Recipes Don’t Work! MATLAB Crashes! (and What to Do
About It)
Chapter 2:​Installation
2.​1 Downloads
2.​1.​1 Match Your Python and MATLAB Versions!
2.​1.​2 Verify That Python Runs
2.​2 Post-Install Configuration and Checkout
2.​3 Creating and Running a Python Program
2.​4 The Curse of Choice
2.​5 Virtual Environments
2.​5.​1 matpy, the Virtual Environment Used in This Book
2.​5.​2 Commands to Manage Virtual Environments
2.​5.​3 Keeping Your Virtual Environment Current
2.​6 ipython, IDEs
2.​6.​1 Autoload Modules When ipython Starts
2.​7 Python and MATLAB Versions Used in This Book
Chapter 3:​Language Basics
3.​1 Assignment
3.​1.​1 Assignment with =​
3.​1.​2 In-Place Updates with +=​, -=​, and Others
3.​1.​3 Walrus Operator, =​
3.​2 Printing
3.​3 Indentation
3.​3.​1 Tabs
3.​4 Indexing
3.​4.​1 Brackets vs.​Parentheses
3.​4.​2 Zero-Based Indexing and Index Ranges
3.​4.​3 Start, End, and Negative Indices
3.​4.​4 Index Strides
3.​4.​5 Index Chaining
3.5 for loops
3.​5.​1 Early Loop Exits
3.​5.​2 Exit from Nested Loops
3.6 while Loops
3.7 if Statements
3.​7.​1 Boolean Expressions and Operators
3.​7.​2 Range Tests
3.​8 Functions
3.​8.​1 Pass by Value and Pass by Reference
3.​8.​2 Variable Arguments
3.​8.​3 Keyword Arguments
3.​8.​4 Decorators
3.​8.​5 Type Annotation and Argument Validation
3.​8.​6 Left-Hand Side Argument Count
3.​9 Generators
3.9.1 yield, next()
3.9.2 range()
3.​10 Scoping Rules and Global Variables
3.​11 Comments
3.​11.​1 Docstrings
3.​12 Line Continuation
3.​13 Exceptions
3.​14 Modules and Packages
3.​14.​1 Namespace
3.14.2 def main()
3.​14.​3 Module Search Path
3.​14.​4 Installing New Modules
3.​14.​5 Module Dependency Conflicts and Virtual
Environments
Chapter 4:​Data Containers
4.​1 NumPy Arrays
4.​2 Strings
4.​2.​1 Strings, Character Arrays, and Byte Arrays
4.​2.​2 String Operations
4.​2.​3 Formatting
4.​2.​4 Separate a String into Words
4.​2.​5 Tests on Strings
4.​2.​6 String Searching, Replacing with Regular Expressions
4.​2.​7 String Templates
4.​3 Python Lists and MATLAB Cell Arrays
4.​3.​1 Initialize an Empty List
4.​3.​2 Create a List with Given Values
4.​3.​3 Get the Length of a List
4.​3.​4 Index a List Item
4.​3.​5 Extract a Range of Items
4.​3.​6 Warning—Python Index Ranges Are Not Checked!
4.​3.​7 Append an Item
4.​3.​8 Append Another List
4.​3.​9 Preallocate an Empty List
4.​3.​10 Insert to the Beginning (or Any Other Position) of a
List
4.​3.​11 Indexing Nested Containers
4.​3.​12 Membership Test:​Does an Item Exist in a List?​
4.​3.​13 Find the Index of an Item
4.​3.​14 Apply an Operation to All Items (List
Comprehension)
4.​3.​15 Select a Subset of Items Based on a Condition
4.​3.​16 How Many Times Does an Item Occur?​
4.​3.​17 Remove the First or Last (or Any Intermediate) List
Item
4.​3.​18 Remove an Item by Value
4.​3.​19 Merging Multiple Lists
4.​3.​20 Unmerging Combined Lists
4.​3.​21 Sort a List
4.​3.​22 Reverse a List
4.​4 Python Tuples
4.​5 Python Sets and MATLAB Set Operations
4.​6 Python Dictionaries and MATLAB Maps
4.​6.​1 Iterating over Keys
4.​6.​2 Testing for Key Existence
4.​6.​3 Iterating over Keys, Sorting by Key
4.​6.​4 Iterating over Keys, Sorting by Value
4.​6.​5 Tuples As Keys
4.​6.​6 List Values
4.​7 Structured Data
4.7.1 Method 1: namedtuple
4.7.2 Method 2: SimpleNamespace
4.​7.​3 Method 3:​Classes
4.​7.​4 Method 4:​Data Classes
4.​7.​5 Enumerations
4.8 Caveat: “=” Copies a Reference for Nonscalars!
Chapter 5:​Dates and Times
5.​1 Time
5.​1.​1 Current Time
5.​1.​2 Time String Formats
5.​1.​3 tic, toc; %timeit
5.​2 Dates
5.2.1 datetime Objects to and from Strings
5.​2.​2 Time Deltas
5.​3 Timezones
5.​3.​1 UTC vs.​Local Time
5.4 Time Conversions to and from datetime Objects
5.​4.​1 Unix Epoch Seconds
5.​4.​2 ISO 8601 Time String
5.​4.​3 Julian Date; Modified Julian Date; GPS Time
5.5 zoneinfo in Python >= 3.9
5.​5.​1 List Available Timezones
5.​5.​2 Date Increments Across Daylight Savings Transition
5.​6 References
Chapter 6:​Call Python Functions from MATLAB
6.​1 Configure MATLAB to Recognize Python
6.​2 Does It Work?​
6.​3 Importing (and Reloading) Python Modules
6.4 Configure startup.m for Python Work
6.​5 Create Python Variables and Call Python Functions in
MATLAB
6.​5.​1 Scalars
6.​5.​2 Lists and Cell Arrays
6.​5.​3 Tuples
6.​5.​4 Numeric Arrays
6.​5.​5 Dictionaries and Structs
6.​5.​6 Keyword Arguments
6.​5.​7 Python-to-MATLAB and MATLAB-to-Python Variable
Converters
6.​5.​8 Traversing Generators
6.5.9 Traversing zip()
6.​6 Modifying the Python Search Path Within MATLAB
6.6.1 Extending sys.path with an Alias
6.6.2 Extending sys.path with insert()
6.6.3 Extending sys.path with append()
6.​7 Python Bridge Modules
6.​8 Debugging Python Code Called by MATLAB
6.​9 Summary of Steps to Calling Python Code from MATLAB
6.​10 Call MATLAB from Python
6.10.1 Install matlab.engine
6.​10.​2 Call Functions in a New MATLAB Session
6.​10.​3 Call Functions in an Existing MATLAB Session
6.​11 Other Mechanisms for MATLAB/​Python Interaction
6.​11.​1 System Calls and File I/​O
6.​11.​2 TCP/​IP Exchange
Chapter 7:​Input and Output
7.​1 Text Files
7.1.1 Reading Corrupted Text Files with pathlib
7.​1.​2 Reading and Writing Numeric Data
7.​1.​3 I/​O Exceptions
7.​1.​4 Parsing Text
7.​1.​5 csv
7.​1.​6 XML
7.​1.​7 YAML
7.​1.​8 JSON
7.​1.​9 ini
7.​2 Recipe 7-1:​Read YAML Files
7.​3 Recipe 7-2:​Write YAML Files
7.​4 Recipe 7-3:​Read an ini File
7.​5 Recipe 7-4:​Write an ini File
7.​6 Binary Files
7.7 Excel .xls, .xlsx
7.7.1 Reading .xls and .xlsx Files
7.7.2 Writing .xlsx Files
7.8 Recipe 7-5: Write an .xlsx File
7.​9 HDF5
7.​9.​1 Reading an HDF5 File
7.​9.​2 Writing an HDF5 File
7.​9.​3 Reading and Writing HDF5 Dataset Attributes
7.​9.​4 Iterating over All HDF5 Datasets
7.​10 NetCDF4
7.​10.​1 Reading a NetCDF4 File
7.​11 SQLite
7.​12 Recipe 7-6:​CRUD with an SQLite Database
7.​13 Pickle Files
7.14 MATLAB .mat Files
7.14.1 Inspecting the Contents of a .mat File
7.14.2 Reading a .mat File
7.14.3 Writing a .mat File
7.14.4 mat Version 7.3
7.​15 Command-Line Input
7.15.1 Python: sys.argv
7.15.2 MATLAB: Function Arguments; varargin
7.15.3 Python: argparse
7.​16 Interactive Input
7.​17 Receiving and Sending over a Network
7.​17.​1 HTTP, HTTPS
7.​17.​2 Python As a Web Server
7.​17.​3 TCP/​IP
7.​18 Recipe 7-7:​TCP Server
7.​19 Interacting with Databases
7.​19.​1 PostgreSQL
7.​19.​2 MongoDB
7.​20 Recipe 7-8:​CRUD with a PostgreSQL Database
7.​21 Recipe 7-9:​CRUD with a MongoDB Database
7.​21.​1 Read
7.​21.​2 Update
7.​21.​3 Delete
7.​22 Recipe 7-10:​Interact with Redis
7.​23 Reference
Chapter 8:​Interacting with the File System
8.​1 Reading Directory Contents
8.​2 Finding Files
8.​3 Deleting Files
8.​4 Creating Directories
8.​5 Deleting Directories
8.​6 Walking Directory Trees
Chapter 9:​Interacting with the Operating System and External
Executables
9.​1 Reading, Setting Environment Variables
9.​2 Calling External Executables
9.​2.​1 Checking for Failures
9.​2.​2 A Bytes-Like Object Is Required
9.​3 Inspecting the Process Table and Process Resources
Chapter 10:​Object-Oriented Programming
10.​1 Classes
10.​1.​1 Private vs.​Public
10.​1.​2 Custom Printers
10.​1.​3 Custom Exceptions
10.​2 Performance Implications
Chapter 11:​NumPy and SciPy
11.​1 NumPy Arrays
11.​1.​1 Formatting NumPy Array Values
11.​1.​2 Differences Between NumPy Arrays and MATLAB
Matrices
11.​1.​3 NumPy Data Types
11.​1.​4 Typecasting Scalars and Arrays
11.​1.​5 Hex, Binary, and Decimal Representations
11.​1.​6 Creating Arrays
11.​1.​7 Complex Scalars and Arrays
11.​1.​8 Linear Indexing
11.​1.​9 Reading/​Writing Arrays to/​from Text Files
11.​1.​10 Reading/​Writing Arrays to/​from Binary Files
11.​1.​11 Primitive Array Operations
11.​1.​12 Adding Dimensions
11.​1.​13 Array Broadcasting
11.​1.​14 Index Masks
11.​1.​15 Extracting and Updating Submatrices
11.​1.​16 Finding Terms of Interest
11.​1.​17 Object-Oriented Programming and Computational
Performance
11.​2 Linear Algebra
11.​2.​1 Linear Equations
11.​2.​2 Singular Value Decomposition
11.​2.​3 Eigenvalue Problems
11.​3 Sparse Matrices
11.​3.​1 Sparse Matrix Creation with COO, CSC, CSR
11.​3.​2 Sparse Matrix Creation with LIL, DOK
11.​3.​3 Sparse Matrix Creation with BSR, DIA
11.​3.​4 Test Matrices
11.​3.​5 Sparse Matrix I/​O
11.​3.​6 Linear Algebra
11.​3.​7 Summary of Sparse Formats and Capabilities;
Recommendations
11.​4 Interpolation
11.​4.​1 One-Dimensional Interpolation
11.​4.​2 Two-Dimensional Interpolation
11.​4.​3 Two-Dimensional Interpolation on a Grid
11.​5 Curve Fitting
11.​5.​1 Linear Regression
11.​5.​2 Fitting Higher-Order Polynomials
11.​5.​3 Fitting to Models
11.6 Recipe 11-1: Curve Fitting with
differential_evolution()
11.​7 Regression
11.​7.​1 Ordinary Least Squares
11.​7.​2 Weighted Least Squares
11.​7.​3 Confidence and Prediction Intervals
11.​8 Recipe 11-2:​Weighted Least Squares in MATLAB
11.​9 Recipe 11-3:​Confidence and Prediction Intervals in
MATLAB
11.​10 Finding Roots
11.​10.​1 Univariate
11.​10.​2 Multivariate
11.​11 Recipe 11-4:​Solving Simultaneous Nonlinear Equations
11.​12 Optimization
11.​12.​1 Linear Programming
11.​12.​2 Simulated Annealing
11.​13 Differential Equations
11.​14 Symbolic Mathematics
11.​14.​1 Defining Symbolic Variables
11.​14.​2 Derivatives
11.​14.​3 Integrals
11.​14.​4 Solving Equations
11.​14.​5 Linear Algebra
11.​14.​6 Series
11.​15 Recipe 11-5:​Using SymPy in MATLAB
11.​16 Recipe 11-6:​Compute Laplace Transforms
11.​17 Unit Systems
11.17.1 Defining Units in pint
11.18 Recipe 11-7: Using pint in MATLAB
11.​19 References
Chapter 12:​Plotting
12.​1 Point and Line Plots
12.​1.​1 Saving Plots to Files
12.​1.​2 Multiple Plots per Figure
12.​1.​3 Date and Time on the X Axis
12.​1.​4 Double Y Axes
12.​1.​5 Histograms
12.​1.​6 Stack Plots
12.​2 Area Plots
12.2.1 imshow()
12.​3 Animations
12.​4 Plotting on Maps with Cartopy
12.​4.​1 Points
12.​4.​2 Lines
12.​4.​3 Area
12.​4.​4 MATLAB and Cartopy
12.​4.​5 Avoid matplotlib’s Qt Backend in MATLAB!
12.​5 Recipe 12-1:​Drawing Lines on Maps with Cartopy
12.​6 Recipe 12-2:​Overlay Contours on Globe with Cartopy
12.​7 Recipe 12-3:​Shade Map Regions by Value with Cartopy
12.​8 Plotting on Maps with GeoPandas
12.​9 Making Plots in Batch Mode
12.​10 Interactive Plot Editing
Chapter 13:​Tables and Dataframes
13.​1 Loading Tables from Files
13.​2 Table Summaries
13.​2.​1 Table Size, Column Names, Column Types
13.2.2 summary() and .info()/.describe()
13.​2.​3 groupsummary() and .​value_​counts()
13.2.4 head() and tail()
13.​3 Cleaning Data
13.​3.​1 Renaming Columns
13.​3.​2 Changing Column Data Types
13.​3.​3 Changing Column Data
13.​3.​4 Making Timestamps from Strings
13.​4 Creating Tables Programmatically​
13.​5 Sorting Rows
13.​6 Table Subsets
13.​6.​1 All Rows, Selected Columns
13.​6.​2 All Columns, Selected Rows
13.​6.​3 Selected Rows, Selected Columns
13.​6.​4 Filter Rows by Conditional Operations
13.​7 Iterating over Rows
13.​8 Pivot Tables
13.​8.​1 Single-Level Aggregation
13.​8.​2 Multilevel Aggregation
13.​9 Adding Columns
13.​10 Deleting Columns
13.​11 Joins Across Tables
13.​12 GeoPandas
13.​13 Recipe 13-1:​Maps with GeoPandas
13.​14 References
Chapter 14:​High Performance Computing
14.​1 Paths to Faster Python Code
14.​2 Reference Problems
14.​2.​1 The Mandelbrot Set
14.​2.​2 A 2D Finite Element Solver
14.​3 Reference Hardware and OS
14.​4 Baseline Performance
14.​4.​1 Mandelbrot Set Performance
14.​4.​2 FE Solver Performance
14.​5 Profiling Python Code
14.​5.​1 Scalene
14.​5.​2 Austin and FlameGraph
14.6 Multicore Computation with multiprocessing
14.​7 Vectorization
14.​8 Cython
14.​8.​1 Python Compiled with Cython
14.​8.​2 Parallel for Loops with Cython
14.​8.​3 Cython Performance
14.​9 Pythran
14.​9.​1 Examples of Signature Comments
14.​9.​2 Python Compiled with Pythran; Parallel for Loops
14.​9.​3 Pythran Performance
14.​10 Numba
14.​10.​1 Parallel for Loops with Numba
14.10.2 Numba Keyword Arguments nopython, fastmath
14.​10.​3 Numba Performance
14.​10.​4 Numba Limitations
14.​11 f2py
14.​12 Recipe 14-1:​Accelerating MATLAB with Python on a
Single Computer
14.​12.​1 Compile Python Modules in a MATLAB-Friendly
Virtual Environment
14.​12.​2 MATLAB + Cython
14.​12.​3 MATLAB + Pythran
14.​12.​4 MATLAB + Numba
14.12.5 MATLAB + f2py
14.​12.​6 MATLAB + Python Performance Results
14.​13 Distributed Memory Parallel Processing with Dask
14.​13.​1 Parallel MATLAB
14.​13.​2 Dask Execution Paradigm and Performance
Expectations
14.​13.​3 Example 1:​Sum of Prime Factors on One Computer
14.​13.​4 Setting Up a Dask Cluster on Multiple Computers
14.​13.​5 Example 2:​Sum of Prime Factors on Multiple
Computers
14.​13.​6 Example 3:​A Gigapixel Mandelbrot Image
14.​13.​7 Example 4:​Finite Element Frequency Domain
Response
14.​14 Recipe 14-2:​Accelerating MATLAB with Python on
Multiple Computers
14.​14.​1 Parallel Prime Sums with MATLAB
14.​14.​2 Parallel Gigapixel Mandelbrot with MATLAB
14.​14.​3 Parallel Direct Frequency Response with MATLAB
14.​15 References
Chapter 15:​Language Pitfalls
15.​1 Troublesome Language Features
15.​2 MATLAB
15.​3 Python
Appendix A:​MATLAB/​Python Recipe Index
Appendix B:​Generating Sample Data with Faker
Appendix C:​Finite Element Source Listing
Appendix D:​Python-to-MATLAB and MATLAB-to-Python Variable
Converters
Appendix E:​A Utility to Patch Cartopy to Use requests
Index
About the Author
Albert Danial
is an aerospace engineer with
30 years of experience,
currently working for
Northrop Grumman near Los
Angeles. Before Northrop
Grumman, he was a member
of the NASTRAN Numerical
Methods team at MSC
Software and a systems
analyst at SPARTA. He has a
Bachelor of Aerospace
Engineering degree from the
Georgia Institute of
Technology and master’s and
Ph.D. degrees in Aeronautics
and Astronautics from
Purdue University. He is the
author of cloc, the open
source code counter.
Al has used MATLAB since
1990 and Python since 2006
for algorithm prototyping,
earth science data
processing, spacecraft mission planning, optimization, visualization,
and countless utilities that simplify daily engineering work.
About the Technical Reviewers
Darrell Yocom
earned a master’s degree in Computer
Science from USC and has over 40 years
of experience programming in the
aerospace industry. Through the years,
he’s seen programming change from the
monolithic spaghetti-Fortran programs
of the 1970s to today’s object-oriented
approaches. Darrell is an avid sailor and
sails the Pacific weekly on his sailboat,
Stargazer.

Phillip Feldman
, after receiving a PhD in Electrical
Engineering from the University of
Southern California in 1987, spent six
years as a technology policy analyst with
the RAND Corporation in Santa Monica,
CA. Since then, he’s worked in the
aerospace industry for over 20 years.
Much of this work involves
communications satellites and related
technology. Outside of work, Dr. Feldman
has a broad range of interests, many of
which are showcased on his website at
http://phillipmfeldman.org .
Footnotes
1 https://apmonitor.com/che263/index.php/Main/PythonRegressio
nStatistics
© The Author(s), under exclusive license to APress Media, LLC, part of Springer
Nature 2022
A. Danial, Python for MATLAB Development
https://doi.org/10.1007/978-1-4842-7223-7_1

1. Introduction
Albert Danial1
(1) Redondo Beach, CA, USA

MATLAB is amazing—but you already know this. With a few lines of


code, you can load data, manipulate it countless ways, view it, and
extract its deeper meaning. MATLAB is also a terrific sandbox for
prototyping algorithms and exploring numerical experiments, for
simulating phenomena, for churning through test results, and for
generating reports.
Additionally, MATLAB’s documentation and tutorials—either built-
in, hosted at The MathWorks’ website, or available on YouTube—are
thorough and high quality.
The underdocumented and underappreciated MATLAB py module,
however, motivated the creation of this book. The py module provides a
binary interface between MATLAB and Python. That’s huge—it opens a
door from MATLAB to hundreds of thousands of open source Python
packages for machine learning, artificial intelligence, data mining,
database access, astronometric computation, geographic information
services, web services, high performance computing, and countless
others.
Better still, the power of Python via MATLAB’s py is available for
free to individuals and at low cost to corporations (see Section 1.2).
There is a caveat though: to use py , you must also know Python. This
book aims to be your guide to learning Python and taking full
advantage of MATLAB’s ability to interact with it. When viewed as a
MATLAB extension, it can be said without exaggeration that
Discovering Diverse Content Through
Random Scribd Documents
the Speculum Historiale of Vincentius Bellovacensis, etc. Madden
finds record of twenty-one publications which can certainly be
identified as Mentel’s, and which comprise in all forty-one volumes,
of which thirty-seven are in large folio. During the time of his
business activity, (1465-1478) he appears to have published about
two volumes a year.[438]
Humphreys points out that Mentel was in advance of the other
German printers of the day in first using, in place of the confused old
Gothic black letter, the clear Roman letter which was in use in Italy.
Mentel’s most important publication, the collection of the Specula of
S. Vincent of Beauvais, issued in 1473, in eight volumes folio, was
printed in type of the Roman letter.[439] M. Bernard, in his Origines
de l’Imprimerie, is of opinion that it was in printing these theological
works which were in accord with the taste of the reading public of his
day, that Mentel realised a fortune, while many of his competitors
ruined themselves in reproducing the Latin classics, the taste for
which before the close of the fifteenth century was not sufficiently
developed to ensure a remunerative sale. He was also the first of the
German printers to print descriptive catalogues of his books. At the
head of the catalogue was a notice to the following effect: “Those
who wish to possess any of these books have only to address
themselves to the sign of——.” Here a blank was left, in order that
each retail bookseller to whom the catalogue was sent might fill in
his own name and sign. Such a detail (which is, I may mention, quite
in accord with modern publishing methods) indicates that there was
as early as 1470, a well developed bookselling machinery in western
and central Germany.
Mentel’s principal rival in Strasburg was Heinrich Eggestein.
Eggestein appears to have been a man of scholarly training, and had
received from some university the degree “Magister.” To him belongs
the credit of the issue, in 1466, of the first Bible printed in German.
Important as was this work, the printer was not interested in
associating with it his imprint, and the volumes are identified as the
work of his press only by circumstantial evidence.[440] The first work
which was edited and which bears his imprint was an edition of the
Decretum Gratiani, printed in a gigantic folio in 1471. Before this
date, he had issued three Bibles in Latin text. The Decretum was
again printed by Eggestein in 1472, although the original issue of
1471 had been promptly pirated by the enterprising Schöffer. It is
evident that it proved possible to secure for the book an immediate
and presumably remunerative sale.
Another of Eggestein’s publications in 1472 was an edition of
Clementinæ. In this he gives his imprint and gives notice also that he
has already issued a long series of books treating of “divine and
human law.” The last book bearing a date, issued by Eggestein is the
Decretals of Innocent IV., printed in 1478.
The third Strasburg printer was George Huszner, who was
originally a goldsmith. He married the daughter of another goldsmith,
Nikolaus of Hanau, who later worked with his son-in-law as aurifaber
et pressor librorum.[441] The Speculum Judiciale of Bishop Wilhelm
Duranti, printed by Huszner in 1473, is described by Kapp as a
master-piece of typography. This bears the name as editor of Joh.
Beckenhub, who calls himself a cleric. Martin Flach of Strasburg,
whose business activity covered the years 1475 to 1500 published
something over seventy works, which were, with hardly an
exception, devoted to theology and dogma.
In 1480, was printed a magnificent edition of the Latin Bible in four
volumes, known as Biblia Latina cum glossa ordinaria Walafridi
Strabonis et interlineari Anselmi Laudunensis. This was issued by
Anton Koberger of Nuremberg and it has only recently been
discovered that it was printed for him by Adolph Rusch of Strasburg.
While it was by far the most noteworthy typographical undertaking
that had been completed up to that date, the printer had not thought
it important to associate his name with the volumes. Rusch was a
publisher as well as a printer, and was also a large dealer in paper,
supplying this to printers in Strasburg, Nuremberg, Basel, and
elsewhere. He further carried on a miscellaneous business as a
bookseller and in purchasing from other publishers for his
miscellaneous trade supplies of other publications, and he was
accustomed to make payment for the same in paper. He seems
altogether to have been a man of very wide activities, whose
influence must have been of considerable importance in connection
with the early organisation of the German book-trade. He had
married a daughter of the Strasburg printer, Mentel, and through his
wife, inherited an interest in Mentel’s business. Rusch purchased
from the printer Amerbach, in exchange for paper stock, a portion of
the edition of S. Augustine’s De Civitate Dei, which appears to have
shared with certain essays of Cicero the honour of being one of the
most frequently printed books in the early lists.
One of the earlier of the Strasburg printers who gave particular
attention to works in German was Johann Reinhart, also known
(from his birthplace) as Johann Grüninger, whose list comprised
German editions of works in theology and religion, and in poetic
literature, together with a series of folk-songs and stories for the
people. While his fellow publishers were at that time, with hardly an
exception, limiting their undertakings to works planned for scholars,
such as reprints of the classics and theological works printed in
Latin, Reinhart addressed himself at once to a popular audience,
and while in so doing he was undoubtedly of service in furthering the
education of his generation, he appears also to have secured for
himself satisfactory business results. He gave particular attention to
illustrated books, securing the service of a number of noteworthy
designers and engravers, and ornamenting his books, not only with
full-page illustrations, but with elaborate initial letters and head- and
tail-pieces. He is chronicled as being the only publisher in Strasburg
who, after the Reformation was in full development, continued to
print Catholic tracts and pamphlets. As an instance of the large
distribution that it was possible to secure at the beginning of the
sixteenth century for certain classes of books, is to be noted the sale
made by Reinhart in 1502 to Schönsperger, of 1000 copies of a
volume of The Lives of the Saints. Reinhart was one of the printers
whose presses were utilised by the great publisher Koberger of
Nuremberg. In 1525, he printed for Koberger the translation by
Pirckheimer of the great Geography of Ptolemy. In this work the
translator appears himself to have retained an interest.
There have been preserved a number of the letters which passed
between Pirckheimer, Koberger, and Reinhart, while this work was
going through the press. It appears that, notwithstanding Reinhart’s
personal supervision of the undertaking and his interest in securing
for the pages satisfactory ornamentations, Pirckheimer had found
frequent occasion for dissatisfaction and criticisms, and in his letters
there are many expressions which might have been written by
authors of to-day who were not satisfied that the printers were
following “copy” correctly. At one point, Pirckheimer says that if he
could have foreseen all the difficulties that he was to experience in
securing a correct printing for his volume, he would have burned the
manuscript rather than have put it to press.
Reinhart points out, on his part, however, that, in the first place,
the manuscript had not been prepared in such manner that the
compositors could follow it correctly, and that, secondly, he had given
no little of his own personal attention to re-arranging and re-shaping
the “copy” in order that the text might be as correct as possible.
Pirckheimer was also unhappy in connection with certain of the
designs with which the printer had ornamented his text, and
expresses the wish that in place of using Italian designers, the
printer had given the work to good Germans.[442]
From the middle of the eleventh century, Cologne had competed
with Mayence for the distinction of being the most important trade
centre of Germany. Its favourable position made it a natural point of
exchange for business operations between the dealers of the North
Sea and those of the Mediterranean. To Cologne came from the
south by way of the passes of the Alps, the wares, not only of Italy,
but those which had been brought from the East by the vessels of
Venice and of Genoa, while from the great Russian mart of
Novgorod and the enterprising Hanseatic city Lübeck, were brought
the goods of Russia and of the far North. In Cologne were also ware-
houses under the charge of trading guilds of their several nations,
whither were brought the goods of England, France, and the Low
Countries.
It was not only in mercantile undertakings, however, that the city
had secured for itself prestige. The University, founded in the early
part of the fourteenth century on the model of that of Paris, was
considered to have surpassed in the importance of its scholarly work
the older institutions of Heidelberg, Prague, and Vienna; and it
remained for many years at the head of the scholarship of Germany
and a particular exponent of the doctrinal theology of the Catholic
Church. Cologne was, therefore, recognised by the early printers as
an exceptionally favourable centre for the prosperous development
of their work, and the printing and publishing undertakings of the city
assumed at an early date very considerable importance.
The existing library of the city contains over 400 works, principally
theological, but including also volumes in jurisprudence and in higher
class instruction, which were produced by Cologne printers before
the close of the fifteenth century. At this time the University
contained no less than 4000 students, and the requirements of these
students for text-books and of their instructors for works of reference,
must have given a very decided impetus to the work of the earlier
publishers, while the trade connections possessed by Cologne with
the cities of the North and East furnished channels through which the
publishers were able to extend the demand for their books. The first
introduction of the printing-press into Cologne was due to the
sacking of the City of Mayence in 1462, when Ulrich Zell, of Hanau,
who like Peter Schöffer, called himself a clericus moguntinensis, and
who had been an apprentice of Gutenberg, having been driven from
Mayence, brought to Cologne the invention of his master. While it is
possible that his printing undertakings began earlier, the first dated
work issued from his press was published in 1466, and was an
edition of the Liber Johannes Chrysostomi super Psalmo
Quinquagesimo. This was promptly followed by a volume containing
the De Officiis of Cicero. No publishing list of the period appears to
have progressed very far without including one or more of the
essays of Cicero. The latest book published by Zell was a
commentary by Girard Hardervicus on the new Logic of Albertus
Magnus. The list of books known to have been produced by Zell
includes no less than 120 titles, but a large number of these were
pamphlets of moderate compass, and only eighteen were in the folio
form which was the standard of the time.
A printer whose work was in part contemporary with that of Zell,
was Johann Koelhoff, who included in his list eighty publications, of
which seven were in the German tongue. These last are spoken of
by Kapp as possessing distinctive interest for theologians, because
they included some of the earliest printed examples of the Low-
German dialect. Bartholomäus Unkel, whose list included in all
twenty works, printed, in 1480, in the Low-German dialect an edition
of the Sachsenspiegel, a work which found place during the following
century in the lists of very many of the German publishers.
As before mentioned, the influence of the University was given
strongly to the support of Orthodox doctrines of the Catholic Church,
and doctrinal books which did not conform to the university standard
of orthodoxy were not printed in Cologne. It is probable that in the
beginning of the publishing operations, no direct censorship was
attempted on the part of the theologians of the University, but it
seems evident that they were able notwithstanding, to discourage
publications the opinions of which they might consider pernicious.
The name of Franz Birckmann, whose printing operations began in
1507, occupies an important place in the list of the publishers of
Cologne, and his business relations with Paris and his connections
with the book-dealers of London have brought his name into
reference in much of the correspondence of his time. Birckmann
appears, at the outset at least, not to have himself been a printer. His
first book, the Missale Coloniense, was printed for him in Paris.
Kirchhoff speaks of Birckmann as possessing a fine business
capacity and exceptional enterprise and creative genius, and refers
to him as carrying on his undertakings now in London and
Canterbury, then in Bruges, Liége, or Frankfort; again in Cologne,
Antwerp, Tübingen, and Basel. The list of the places visited by this
enterprising publisher of the time serves to give an indication as to
the centres where literary activities were the most important.[443]
Erasmus, writing on the 21st of December, 1520, from Canterbury, to
his friend Andreas Ammonius in Rotterdam, speaks of Birckmann as
being ready himself to undertake the introduction into England of any
books that might be called for. Birckmann appears finally to have
established in London a permanent business office, for the volume,
Graduale ad Usum Sarum, which was printed for him in Paris in
1528, bears as an imprint, Franz Birckmann of St. Paul’s Church
Yard.[444]
This early connection of the publishers of Cologne with London is
of special interest in connection with the record of William Caxton,
the first English printer, who was said to have learned his art in
Cologne and to have brought it thence (by way of Bruges) to
London. In the same series of letters to Ammonius, Erasmus speaks
of giving to Birckmann the manuscript of his Proverbia, of his
Plutarch, and the Lucian, in order that he might arrange to have the
books printed in Paris, by Jodocus Badius. For some reason, not
stated, Birckmann decided not to place these works in the hands of
Badius, but took them to Froben, in Basel, which was the means of
bringing Erasmus into connection with that publisher, with whom he
had satisfactory intimate relations for so large a portion of his life.
As has been stated in another chapter, the theologians of the
Faculty of the Sorbonne had taken a strong stand against the
writings of Erasmus, and it is very possible that Badius was unable
to secure a permit or a privilege for these volumes.
Birckmann seems, at about this time, to have secured some
interest, if not in the general business of Froben, at least in a certain
number of his publishing undertakings. In 1526, Birckmann came
into trouble with the authorities of Antwerp on account of his having
sold there an edition of the translation of S. Chrysostom, which had
been made by Ökolampadius, and which had come under the ban of
the Antwerp censorship. The publisher succeeded in freeing himself
from the penalties imposed by the Antwerp magistracy only after a
long contest and a considerable expenditure of money.[445] It is a
little difficult to understand the precise grounds of the opposition
raised by the Antwerp censors, and I have not been able to get at
the details of the case. It is of interest as one of the earliest
examples of censorship upon the press which occurred in Northern
Europe. Kapp is of opinion that the censorship exercised by the
Church authorities in Cologne was more rigorous than that instituted
by the authorities in Bavaria. It seems certain that the Catholic
University of the Rhine was able to exercise no little influence in
shaping the direction of the earlier literary undertakings of North
Germany.
Caxton’s sojourn in Cologne must have been some time between
the years 1471 and 1474. Further details concerning his work in
Bruges and his later publishing undertakings in London will be given
in the chapter on printing in England. During the latter part of the
fifteenth century and the earlier years of the sixteenth, Cologne
printers secured for themselves an unenviable reputation as
unauthorised reprinters of works which were the result of the
scholarly labours and investment of publishers elsewhere. They
issued editions as nearly in fac-simile as might be of a number of the
classics published in Venice by Aldus, and they followed these, later,
with the imitations of the scholarly texts published by Plantin in
Antwerp and by the Elzevirs in Leyden.
While it was the case that these texts, with rare exceptions, were
the work of authors dead centuries before, and that in the works
themselves the original publishers could rightfully claim no control, it
is to be borne in mind that the production of the earlier editions of
such classics had nevertheless called for a very considerable
expenditure of capital and of labour, as well in the securing of the
codices used as “copy” by the type-setters as in the revision and
editing of these codices by the scholarly commentators employed,
and also in the preparation of notes, introductions, and elucidations
for the volumes. The risk and investment incurred by Aldus in the
production of his edition of Aristotle, and the exceptional character of
the original labour invested by the publisher in such a work are
grounds for considering that his contention for the control of the text
which came from his printing-office, at least for a certain term of
years, was as well founded as might be a contention of to-day for a
book which was in its entirety the work of a contemporary writer.
The city whose publishing operations are next to be considered in
the chronological record is Basel. For a number of years after the
invention of printing, Basel remained one of the most important
publishing centres, not only of the German Empire (to which at this
time the city belonged), but of Europe. Its position on a direct line of
communication between Italy and Germany had given it an
importance in connection with the general trade of Europe, and the
facilities which furthered this general trade became of value also in
connection with the production of books. The University of Basel,
founded in 1460, speedily brought to the city men devoted to
scholarly pursuits, many of whom took an early interest in the work
of the printing-press, and were ready to give their co-operation to
publishers like Froben, not only in editing manuscripts for the press,
but even in the routine work of the printing-offices in the proof-
reading and correcting. In 1501, at the time Basel broke away from
the imperial control, the city had already secured for itself a
cosmopolitan character, and had become a kind of meeting place for
the exchange of thought as well as for the goods of representatives
of all nations. At this time there were in the city no less than twenty-
six important publishing and printing concerns. The earliest book
bearing a date and an imprint which was issued from a Basel
printing-press was an edition of the Gregorii Magni Moralia in Jobum,
which appeared in 1468. But one or two copies exist, of which the
one that is in the best preservation is contained in the National
Library of Paris.
Printing was introduced into Basel by Berthold Ruppel, who, in
1455, had been an apprentice with Fust. The first work which is
identified as Berthold’s, but which does not bear a date, is the
Repertorium Vocabulorum Exquisitorum of Conrad de Mure. The
difficulties which have attended all organisations of labour appear to
have begun at an early date in Basel, as there is record of a strike of
the compositors occurring as early as 1471. This strike lasted for a
number of months and was finally adjusted by the arbitration of the
authorities of the town, certain concessions being made on the part
of both the master and the employees. The magistrate issued a
decision or mandate to the effect that on a certain date the workmen
must return to their shops and accept the authority of their masters,
and this order appears to have been accepted. It does not appear
what course could have been taken to force the men to their work in
case they might still have been recalcitrant. The fact that a difference
between the printers and their men should have been a matter of
such general importance indicates that already within twenty years of
the beginning of printing in Germany, the business in Basel had
assumed large proportions.
In 1474, there was printed in Basel an edition of the
Sachsenspiegel, a work of popular character, which can share with
the Bible and with different essays of Cicero, the honour of being the
most frequently published book in Germany during the first quarter
century of printing.
Between 1478 and 1514, Johann Amerbach, one of the most
scholarly of the early editors, printers, and publishers of Germany,
made Basel his headquarters. His work was, however, by no means
limited to Basel, as he co-operated with Koberger in Nuremberg and
with other of his contemporaries in editorial and publishing
responsibilities in other cities.
His most important publication in Basel was a series of the works
of the Church Fathers. In carrying these books through the press, he
was able to secure the co-operation of a number of the well known
scholars of the time, including Beatus Rhenanus, Dodo, Conon,
Wyler, Pellikan, and, above all, his old instructor, Heynlin.
Before beginning business in his own name in Basel, Amerbach
had co-operated with Koberger in the production of the great Bible
with the commentaries of Hugo, and he was also in active relations
with Rusch of Strasburg. The last book which was printed with his
own name is an edition of the Decretum Gratiani, which appeared in
1512. His edition of the works of S. Jerome, left unfinished at the
time of his death, was completed by his pupil and successor, Johann
Froben.
Froben, who was like his master, not only a printer but a scholar of
wide attainments, did more, possibly, than any printer of his time,
except Aldus of Venice, to further through his publishing
undertakings the development of scholarship and of literature. He
appears to have had a thorough knowledge, not only of Latin, which
was common to all the scholars of his time, but of Greek and
Hebrew, which were rarities even in university centres. It was the
case with Froben, as with Aldus, that he himself assumed the task of
preparing for the press the texts of a number of works issued by him,
a task which included a comparison of manuscripts, in order to
secure the most correct readings, and such thorough knowledge of
the text as would make possible the correction of errors, not only of
typography, but of statement. Froben’s work and character have
been commemorated by the loving words of Erasmus, who during
the last twenty years of Froben’s life held with him the closest
relations of friendship as well as of business.
It was through Froben that the larger publishing undertakings of
Erasmus were carried on, undertakings which were later in part
shared with Aldus of Venice. Froben’s work was done exclusively for
scholarly readers. His imprint appears upon no book printed in
German, while the list of books issued by him during the thirty-six
years of his business activity includes no less than 257 works, nearly
all of which were of large compass and distinctive importance.
Erasmus himself, ranking at that time possibly as the greatest
scholar of Europe, was ready to give to Froben his assistance in
supervising texts for the compositors and in the corrections of the
proofs. The details of the business arrangements entered into by
publishers like Froben with their scholarly assistants have
unfortunately not been preserved, but it would appear as if in many
cases these scholars had given their services as a labour of love,
and solely with a view to furthering the development of scholarship
and literature. Erasmus was for a number of years an inmate of
Froben’s house, and it is probable that he received a certain annual
stipend for his editorial services, in addition to the returns paid to him
from the sale of his books. The most important of the issues from the
Froben press in the matter of popular sale and of business success
were, as indicated, the writings of Erasmus. Erasmus, in fact, was
possibly the first author who was able, after the invention of printing
to secure from the sale of his books any substantial returns. It is
evident from the various references made by Erasmus that those
returns were sufficient to make him substantially independent,
notwithstanding the fact that piracy editions of his books were printed
in Paris, in Cologne, and elsewhere.
Further information concerning the publishing undertakings of
Erasmus will be found in the chapter devoted to him.
Pamphilus Gengenbach, described as the first dramatist of the
sixteenth century, and who was also a poet, undertook between the
years 1509 and 1522, the business of a printer. We do not learn with
what success. A more noteworthy printer of Basel of the same
period, noteworthy at least from the point of view of commercial
success, was Langendorf. He built up his business by the publication
of piracy editions of the writings of Luther, out of which he is reported
to have made large profits.[446]
The first German printer who appears to have received honours
from royalty was a certain Heinrich Petri, who was carrying on
business between 1520 and 1579, and who in 1556, in recognition of
his services to the community, was knighted by Charles V.
As before indicated, the work of the printers and publishers of
Basel was very much furthered by the presence and by the
intelligent co-operation of the members of its University Faculty. The
University was of service not only in making a certain important
market for editions of scholarly books, but, as a more important
consideration, in giving to the publishers the aid of scholarly
advisers, editors, and proof-correctors. By the close of the fifteenth
century, Basel had secured so great a prestige for the production of
accurate editions of important texts, and for the beauty and
costliness of its typography, that commissions came to its printers
from all parts of Europe.
In 1510, Sir Thomas More, desiring, as he writes, to secure a
European circulation for his books, causes the same to be printed in
Basel, while during the years between 1490 and 1520, the popes
send to Basel printing-offices the orders for their commercial printing.
The next city in chronological order to be considered as a
publishing centre is Zurich, in which printing began in 1504.
The first of the Zurich printers whose name has been preserved is
Christ Froschauer, who is known principally through his association
with Zwingli. Froschauer, who devoted himself earnestly to the cause
of the Calvinists, had a religious as well as a business interest in
securing a wide circulation for the works of Zwingli and his
associates, and together with these works, he printed editions of the
Bible, not only in German, but in French, Italian, Flemish, and
English. Froschauer’s editions were the first Bibles printed on the
Continent in the English language. For these Bibles, which were
distributed at what to-day would be called popular prices, very
considerable sales were secured, and the presses of Froschauer
were thus made an important adjunct to the work of the Reformation.
In Augsburg, the printing business of which began to assume
importance in 1468, the interests of the publishers were, on the other
hand, largely associated with the cause of the Roman Church. The
first book with an Augsburg imprint and date was issued by Zainer,
and was an edition of the Meditationes Vitae Domini Nostri Jesu
Christi. In 1470, was published by Schüssler a Latin edition of
Josephus, and in 1477, Sorg, who was one of the most active of the
Augsburg publishers, issued the book of the Council of Constance,
which contained no less than 1200 wood-cuts, presenting the 1156
coats-of-arms which were represented at the Council.
The most famous of the printer-publishers of Augsburg was,
according to Kapp, Ratdolt, whose list comprised principally
mathematical works and books of religious music. His edition of
Euclid, issued in 1482, constituted the first European edition of the
Syracusan mathematician. The sales of the orthodox theological
books, which constituted a special interest of the Augsburg
publishers, were largely checked by the Reformation. George Willer,
an enterprising Augsburg bookseller, who sold not only his own
publications but those of other German publishers, is to be credited
with the printing of the first classified catalogue known to Germany.
Among the earlier publications of Ulm, the most important was the
geography of Ptolemy, issued by Holl in 1484, with important maps.
The eminence of the city of Nuremberg in the work of publishing is
principally due to the scholarly enterprise of one family, that of the
Kobergers, whose work began about 1470. Antonius Koberger, the
first of the line, is grouped with Froben of Basel and with Aldus of
Venice for the commercial importance of his undertakings, and
above all for the scholarly ideal of his business operations. His active
business work covered the years 1470-1503. Among his earlier
important publications was an edition of Thomas Aquinas, issued in
1474, and of the Consolations of Philosophy of Boëthius, printed in
1475. The latter was the first printed edition of a book which had
been for nearly a thousand years famous among books in
manuscript, and which possibly shares with S. Augustine’s City of
God the reputation of being the work most frequently found in the old
monastery libraries. By the year 1500, Koberger was utilising no less
than twenty-four presses, and undoubtedly was sending out annually
more books than any other publisher of his time. He had branches or
agencies in Frankfort, Paris, and Lyons, a business correspondence
in the Netherlands, Italy, Austria, Hungary, Poland, and England, as
well as, of course, throughout Germany. In respect to the bulk of the
business done by him and of the commercial success secured, he
was a greater publisher than either Aldus or Froben, his two most
famous contemporaries. The work of Aldus, which is considered in
detail in another chapter, was, however, distinctive on the ground of
the special difficulties to be overcome and of his enterprise and
scholarly ambition in the production of Greek literature. The interest
of the work of Froben centres partly in his close friendship and long
association with Erasmus, and in the fact that, as the publisher for
Erasmus, he secured the first important copyright returns for a
contemporary author which had been known in the record of
publishing.
Koberger gave special attention to the production of Bibles and of
works in orthodox theology. The latter division of his list was largely
interfered with by the increasing influence of the Lutherans.
Koberger took the initiative in the production of books containing
expensive and elaborate illustrations, and his illustrated editions will
compare more favourably with those of Plantin and with the other
publishers of the Low Countries, than is the case with the issues of
any other German publisher. Nuremberg had always been the centre
of art interests, and there appear to have been in the town many
designers whose services could be secured for the production of
wood-cuts.
The great German Bible, published by Koberger in 1483, filled with
artistic illustrations engraved on wood, compares not unfavourably
with the illustrated Bible issued by Plantin fifty years later.
The Schedelsche Chronik, published in 1493, contained no less
than 2000 wood-cuts prepared by the Nuremberg artists, Wohlgemut
and Pleydenwurf. After the work of the Reformers became active,
the presses of Nuremberg were occupied for some years in issuing
controversial tracts and pamphlets upholding the orthodox views of
the Church; while, under an edict of the magistrates issued in 1520,
the printers of Nuremberg were forbidden to print and the dealers
were forbidden to sell the writings of Luther, Calvin, Zwingli, and their
associates. Notwithstanding this prohibition, however, there was
enough sympathy with the Reformation among many of the
Nuremberg printers to keep them interested in the surreptitious
production (under risk of fine, confiscation, and imprisonment) of
very many of the Protestant tracts of the times. While the Catholic
tracts were, however, catalogued in due course and openly sold, the
Protestant pamphlets had to be smuggled in and out of the city and
disposed of under various covers and precautions.
In giving chronological consideration to certain of the distinctive
publishing centres and printer-publishers of Germany, it is necessary
at this time to refer to the important undertakings of the Brothers of
Common Life, whose work in the manuscript period has already
been described.
As in the earlier manuscript publishing, the Brothers had interested
themselves particularly in reaching with their books the common
people, and had for this purpose produced their versions in the folk
dialects. When, therefore, they had replaced the scriptoria of their
Houses with well organised printing-offices, they devoted their
presses mainly to the production of devotional books, and of books
of general instruction planned for the service and information of the
middle and lower classes, and printed in the vernacular.
While I have not found record of the business results secured
through these printing-offices established by the Brothers, it seems
probable, in view of the excellent distributing machinery they
possessed for their output, and from the fact that they were almost
the first among printers to prepare publications expressly for the use
of the lower and middle classes, that they secured from the sales of
their books satisfactory business returns, so that the profits produced
by their presses may easily have formed an important part of the
resources and the income of the Order. Their first printing-presses
were established in Marienthal in 1468, in Brussels and in Rostock in
1476, and in Nuremberg in 1479. In 1490, there were no less than
sixty different printing establishments carried on under the
supervision of the Brothers. I am not sufficiently familiar with the
various phases of the complex history of the Reformation to be able
to speak definitely concerning the influence exercised upon the
controversies and the contest of the time by the publications of the
Brothers. It is my impression that these publications remained on the
whole orthodox, but that they represented the more liberal wing of
Catholic Orthodoxy.
The city of Leipzig, which a century after the invention of printing
became the centre of the book-trade of Germany, and the most
important book-producing city in the world, began its printing
somewhat later than the other German cities whose work has
already been referred to.
The earliest printing-press set up in Leipzig was that of an
anonymous printer who issued, in 1481, an edition of the essay of
the Dominican Annius von Viterbo, entitled Glosa Super
Apocalipsim. The second Leipzig publication, also issued without
imprint, was an edition of the fifteen astrological propositions of
Martin Polich. The first Leipzig publisher whose name is recorded is
Markus Brandis, who issued, in 1484, a volume entitled Regimen
Sanitatis, which was the work of Archbishop Albicius of Prague, who
had died in 1427. It is not easy to decide on what basis these first
three publications of the future publishing mart were selected, and it
is difficult to understand how a remunerative sale could have been
depended upon for any one of the three.
By the year 1513, the production of Breviaries had become an
important interest with the Leipzig presses. A printer named Lotter
secured a reputation in the earlier years of the sixteenth century for
the excellence of his typography, and was employed by the
Archbishop of Heller in printing the Breviaries and the Missals of the
Dioceses of Brandenburg. In 1492, a certain Gregor Werman printed
Sacrarum Historiarum Opus. The name of the author does not
appear in connection with the work. In 1497, Bötticher issued an
edition of Virgil’s Bucolics, the first classic which bears a Leipzig
imprint.
By the year 1495, the book-trade of Leipzig had assumed very
considerable proportions, not only in connection with printing and
publishing, but in the organisation of machinery for collecting and
distributing the publications of other cities. In this branch of the book
business, Leipzig was already beginning to rival Frankfort. The
booksellers’ association, organised in 1525, is, at the present time,
370 years later, the most effective and intelligently managed trade
organisation that the world has known. Leipzig publishers gave from
an early period special attention to the printing of the controversial
literature of the Reformation, and, as was natural from their close
relations with Wittenberg, the sympathies of the larger proportion of
the printers were in accord with the Lutherans.
Under the trade restrictions established by Duke George of
Saxony, who was a Catholic, and whose reign covered the period
between 1524 and 1533, the work of the Protestant printers was very
seriously hampered, and the whole book-trade of Leipzig was
affected. The writings of the Reformers were repressed as far as
practicable by rigorous censorship, while those of the Romanists
found few buyers. Lotter, the son of the first printer of that name,
removed his printing-office to Wittenberg, where he continued,
though still under the difficulties of a rigorous supervision, to
distribute the writings of the Reformers. The magistracy of Leipzig,
appreciating the importance of the book-trade, attempted in the first
place to secure for its operations the necessary protection. Later,
however, it was compelled, under pressure from the Duke, to put into
effect the ducal regulations for supervision and censorship, and two
ecclesiastical censors, appointed under the ducal authority, secured
the aid of the city officials in making examination of the books
printed, and in confiscating or cancelling all heretical works found in
the book-shops of either Leipzig or Dresden.
Under the edict issued in 1528, all books printed by Vogel, Goltz,
and Schramm of Wittenberg, were forbidden to be offered for sale in
Leipzig or Dresden, and were forbidden transportation to the
Frankfort Fair. The immediate result of these anti-reform operations
of the Church and of the Duke was the practical destruction for the
time being of the book-trade of Leipzig.
In 1539, a printer of Leipzig, named Michel Wohlrabe, secured for
himself notoriety through the extent of his piracy publications. He
issued editions of the Lutheran Bible and of other writings of the
Reformers, in the face, not only of the claims of these writers to
control their own publications, but of the prohibition of Duke George
against the production of any Lutheran literature whatever. After the
death of George, however, there came a change in regard to the
influence of the ducal government, and at the request of the Elector
John Frederic, an edict was issued forbidding the further printing in
Leipzig of any anti-Lutheran literature. This removed one difficulty in
the way of Wohlrabe’s operations, and Luther and his friends found
that they were helpless, in the conditions which then obtained in the
law and in the book-trade, to prevent the circulation of these
unauthorised editions.
Luther’s complaints, referred to further on, were principally
directed, as it must be remembered, not against the loss of profits to
himself, but to the injury to the community and the grievance to the
writers in having books circulated in an unrevised and incorrect text.
CHAPTER III.
THE PRINTER-PUBLISHERS OF ITALY, 1464-1600.

T HE reproduction and distribution of the works of classical writers


to such an extent as not only to influence the scholarly thought
of the time, but to widen enormously the circles of society reached
and affected by intellectual influences, became possible only through
the new art of printing which had been brought across the Alps by
German workmen; while the prompt utilisation of printing for the
service of scholarship called for the devoted labour of printers who
were themselves scholars and who were prepared to subordinate
and even to sacrifice, in the cause of a literary ideal, their immediate
business advantage. It was to the high scholarly ideals and
courageous and unselfish labours of Aldus Manutius and his
immediate successors no less than to the imagination, ingenuity, and
persistency of Gutenberg and Fust, that the Europe of 1495 was
indebted for the great gift of the poetry and the philosophy of
Greece. Mayence and Venice joined hands to place at the service of
the scholarly world the literary heritage of Athens.
The close of the fifteenth century witnessed a great expansion in
more than one direction of European thought. In the West, Columbus
had opened up a new world, and his discovery, while giving manifold
incentives to the men of action, must also have served as a powerful
stimulus to the imagination of the thinkers of the time, in its
suggestions concerning the possibilities of the future. In the East, the
printers of Venice were making use of scholars from Constantinople
to rediscover for Europe the vast realm of Greek thought, and to
bring Homer, Plato, and Aristotle to the knowledge of the students of
Bologna, Paris, and Oxford. Perhaps in no other epoch of the world’s
history has there been so great an expansion of the possibilities of
thought and of action, so suggestive a widening of range of the
imagination, as in the decade succeeding 1492.

You might also like