Julia Quick Syntax Reference - Antonello Lobianco

Julia Quick Syntax Reference (eBook)

A Pocket Guide for Data Science Programming
eBook Download: PDF
2019 | 1st ed.
XVII, 216 Seiten
Apress (Verlag)
978-1-4842-5190-4 (ISBN)
Systemvoraussetzungen
56,99 inkl. MwSt
  • Download sofort lieferbar
  • Zahlungsarten anzeigen
This quick Julia programming language guide is a condensed code and syntax reference to the Julia 1.x programming language, updated with the latest features of the Julia APIs, libraries, and packages. It presents the essential Julia syntax in a well-organized format that can be used as a handy reference. 

This book provides an introduction that reveals basic Julia structures and syntax; discusses data types, control flow, functions, input/output, exceptions, metaprogramming, performance, and more.  Additionally, you'll learn to interface Julia with other programming languages such as R for statistics or Python. You will learn how to use Julia packages for data analysis, numerical optimization and symbolic computation, and how to disseminate your results in dynamic documents or interactive web pages.  

In this book, the focus is on providing important information as quickly as possible. It is packed with useful information and is a must-have for any Julia programmer.

What You Will Learn  
  • Set up the software needed to run Julia and your first Hello World example
  • Work with types and the different containers that Julia makes available for rapid application development
  • Use vectorized, classical loop-based code, logical operators, and blocks
  • Explore Julia functions by looking at arguments, return values, polymorphism, parameters, anonymous functions, and broadcasts
  • Build custom structures in Julia
  • Interface Julia with other languages such as C/C++, Python, and R
  • Program a richer API, modifying the code before it is executed using expressions, symbols, macros, quote blocks, and more
  • Maximize your code's performance 

Who This Book Is For

Experienced programmers new to Julia, as well as existing Julia coders new to the now stable Julia version 1.0 release.



Antonello Lobianco, PhD is a research engineer employed by a French grande école (polytechnic university). He works on the biophysical and economic modelling of the forest sector and is responsible for the lab models portfolio. He does programming in C++, Perl, PHP, Visual Basic, Python, and Julia. He teaches environmental and forest economics at undergraduate and graduate levels and modelling at PhD level.  For a couple of years, he has followed the development of Julia as it fits his modelling needs. He is the author of a few Julia packages (search sylvaticus on GitHub). 


This quick Julia programming language guide is a condensed code and syntax reference to the Julia 1.x programming language, updated with the latest features of the Julia APIs, libraries, and packages. It presents the essential Julia syntax in a well-organized format that can be used as a handy reference. This book provides an introduction that reveals basic Julia structures and syntax; discusses data types, control flow, functions, input/output, exceptions, metaprogramming, performance, and more.  Additionally, you'll learn to interface Julia with other programming languages such as R for statistics or Python. You will learn how to use Julia packages for data analysis, numerical optimization and symbolic computation, and how to disseminate your results in dynamic documents or interactive web pages.  In this book, the focus is on providing important information as quickly as possible. It is packed with useful information and is a must-have for any Julia programmer.What You Will Learn  Set up the software needed to run Julia and your first Hello World exampleWork with types and the different containers that Julia makes available for rapid application developmentUse vectorized, classical loop-based code, logical operators, and blocksExplore Julia functions by looking at arguments, return values, polymorphism, parameters, anonymous functions, and broadcastsBuild custom structures in JuliaInterface Julia with other languages such as C/C++, Python, and RProgram a richer API, modifying the code before it is executed using expressions, symbols, macros, quote blocks, and moreMaximize your code's performance Who This Book Is ForExperienced programmers new to Julia, as well as existing Julia coders new tothe now stable Julia version 1.0 release.

Table of Contents 4
About the Author 10
About the Technical Reviewer 11
Acknowledgments 12
Introduction 13
Part I: Language Core 16
Chapter 1: Getting Started 17
1.1 Why Julia? 17
1.2 Installing Julia 19
1.3 Running Julia 22
1.4 Miscellaneous Syntax Elements 24
1.5 Packages 25
1.5.1 Using the Package Manager 26
1.5.2 Using Packages 27
1.6 Help System 29
Chapter 2: Data Types and Structures 31
2.1 Simple Types (Non-Containers) 32
2.1.1 Basic Mathematic Operations 33
2.1.2 Strings 33
Concatenation 34
2.2 Arrays (Lists) 35
2.2.1 Multidimensional and Nested Arrays 39
2.3 Tuples 44
2.4 Named Tuples 45
2.5 Dictionaries 46
2.6 Sets 48
2.7 Memory and Copy Issues 48
2.8 Various Notes on Data Types 52
2.8.1 Random Numbers 53
2.8.2 Missing, Nothing, and NaN 53
Chapter 3: Control Flow and  Functions 55
3.1 Code Block Structure and Variable Scope 55
3.2 Repeated Iteration: for and while Loops, List Comprehension, Maps 57
3.3 Conditional Statements: if Blocks, Ternary Operator 58
3.4 Functions 59
3.4.1 Arguments 61
3.4.2 Return Value 63
3.4.3 Multiple-Dispatch (aka Polymorphism) 63
3.4.4 Templates (Type Parameterization) 64
3.4.5 Functions as Objects 65
3.4.6 Call by Reference/Call by Value 65
3.4.7 Anonymous Functions (aka “Lambda” Functions) 66
3.4.8 Broadcasting Functions 67
3.5 Do Blocks 68
3.6 Exiting Julia 68
Chapter 4: Custom Types 70
4.1 Primitive Type Definition 71
4.2 Structure Definition 72
4.3 Object Initialization and Usage 73
4.4 Abstract Types and Inheritance 74
4.4.1 Implementation of the Object-Oriented Paradigm in Julia 76
4.5 Some Useful Functions Related to Types 79
Chapter 5: Input/Output 80
5.1 Reading (Input) 81
5.1.1 Reading from the Terminal 81
5.1.2 Reading from a File 82
Importing Data for a Matrix 83
Parsing Comma Separated Value (CSV) Files 83
5.1.3 Importing Data from Excel 84
5.1.4 Importing Data from JSON 85
5.1.5 Accessing Web Resources (HTTP) 87
5.2 Writing (Output) 88
5.2.1 Writing to the Terminal 88
5.2.2 Writing to a File 89
5.2.3 Exporting to CSV 90
5.2.4 Exporting Data to Excel 91
5.2.5 Exporting Data to JSON 92
5.3 Other Specialized IO 93
Chapter 6: Metaprogramming and Macros 94
6.1 Symbols 95
6.2 Expressions 96
6.2.1 Creating Expressions 97
Parse a String 97
Colon Prefix Operator 97
Quote Block 97
Use the Exp Constructor with a Tree 98
6.2.2 Evaluating Symbols and Expressions 98
6.3 Macros 100
6.3.1 Macro Definition 100
6.3.2 Macro Invocation 101
6.3.3 String Macros 102
Chapter 7: Interfacing Julia with Other Languages 104
7.1 Julia ? C 105
7.2 Julia ? C++ 107
7.2.1 Interactive C++ Prompt 107
7.2.2 Embed C++ Code in a Julia Program 108
7.2.3 Load a C++ Library 111
7.3 Julia ? Python 113
7.3.1 Embed Python Code in a Julia Program 114
7.3.2 Use Python Libraries 115
7.3.3 PyJulia: Using Julia in Python 116
Installation 116
Usage 117
7.4 Julia ? R 119
7.4.1 Interactive R Prompt 120
7.4.2 Embed R Code in a Julia Program 120
7.4.3 Use R Libraries 121
7.4.4 JuliaCall: Using Julia in R 122
Installation 122
Usage 122
Chapter 8: Effectively Write Efficient Code 125
8.1 Performance 126
8.1.1 Benchmarking 126
8.1.2 Profiling 128
8.1.3 Type Stability 132
8.1.4 Other Tips to Improve Performance 134
Avoid Using Global Variables and Run Performance-Critical Code Within Functions 134
Annotate the Type of Data Structures 134
Annotate the Fields of Composite Types 134
Loop Matrix Elements by Column and Then by Row 135
8.2 Code Parallelization 136
8.2.1 Adding and Removing Processes 136
8.2.2 Running Heavy Computations on a List of Items 138
8.2.3 Aggregate Results 139
8.3 Debugging 140
8.3.1 Introspection Tools 141
8.3.2 Debugging Tools 142
8.4 Managing Runtime Errors (Exceptions) 145
Part II: Packages Ecosystem 146
Chapter 9: Working with Data 147
9.1 Using the DataFrames Package 148
9.1.1 Installing and Importing the Library 148
9.1.2 Creating a DataFrame or Loading Data 149
9.1.3 Getting Insights About the Data 151
9.1.4 Filtering Data (Selecting or Querying Data) 152
9.1.5 Editing Data 155
9.1.6 Editing Structure 156
Merging/Joining/Copying Datasets 158
9.1.7 Managing Missing Values 158
9.1.8 The Split-Apply-Combine Strategy 159
Aggregating 160
Computing the Cumulative Sum by Categories 162
9.1.9 Pivoting Data 163
Stacking Columns 165
Unstacking 165
The Pivot Function 167
Sorting 169
9.1.10 Dataframe Export 169
Exporting to CSV 169
Exporting to the OpenDocument Spreadsheet File 169
Exporting to a Matrix 170
Exporting to a Dict 170
Exporting to the hdf5 Format 171
9.2 Using IndexedTables 171
9.2.1 Creating an IndexedTable (NDSparse) 172
9.2.2 Row Filtering 173
9.2.3 Editing/Adding Values 174
9.3 Using the Pipe Operator 174
9.4 Plotting 176
9.4.1 Installation and Backends 176
9.4.2 The Plot Function 179
9.4.3 Plotting from DataFrames 182
9.4.4 Saving 185
Chapter 10: Mathematical Libraries 186
10.1 JuMP, an Optimization Framework 187
10.1.1 The Transport Problem: A Linear Problem 189
The Problem 189
Importing the Libraries 190
Defining the Sets 190
Defining the Parameters 191
Declaring the Model 192
Declaring the Model Variables 193
Declaring the Model Constraints 193
Declaring the Model Objective 194
Human-Readable Visualization of the Model (Optional) 194
Resolution of the Model 194
Visualization of the Results 195
10.1.2 Choosing Between Pizzas and Sandwiches, a Non-Linear Problem 197
The Problem 197
Importing the Libraries and Declaring the Model 198
Declaring the Model Variables, Constraints, and Objectives 198
Resolution of the Model and Visualization of the Results 199
10.2 SymPy, a CAS System 200
10.2.1 Loading the Library and Declaring Symbols 200
10.2.2 Creating and Manipulating Expressions 201
10.2.3 Solving a System of Equations 202
10.2.4 Retrieving Numerical Values 202
10.3 LsqFit, a Data Fit Library 203
10.3.1 Loading the Libraries and Defining the Model 204
10.3.2 Parameters 204
10.3.3 Fitting the Model 205
10.3.4 Retrieving the Parameters and  Comparing them with the Observations 205
Chapter 11: Utilities 207
11.1 Weave for Dynamic Documents 207
11.2 Zip Files 211
11.2.1 Writing a Zip Archive 211
11.2.2 Reading from a Zipped Archive 212
11.3 Interact and Mux: Expose Interacting Models on the Web 214
11.3.1 Importing the Libraries 214
11.3.2 Defining the Logic of the Model 214
11.3.3 Defining Controls and Layout 215
11.3.4 Providing Widgets to Web Users 216
Index 218

Erscheint lt. Verlag 11.11.2019
Zusatzinfo XVII, 216 p. 66 illus.
Sprache englisch
Themenwelt Informatik Datenbanken Data Warehouse / Data Mining
Mathematik / Informatik Informatik Programmiersprachen / -werkzeuge
Informatik Theorie / Studium Compilerbau
Informatik Theorie / Studium Künstliche Intelligenz / Robotik
Mathematik / Informatik Mathematik Angewandte Mathematik
Schlagworte Analysis • Code • Computer Science • CS • Data Science • Development • Julia • language • Math • programming • Software • source • Statistics
ISBN-10 1-4842-5190-3 / 1484251903
ISBN-13 978-1-4842-5190-4 / 9781484251904
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 3,2 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Datenschutz und Sicherheit in Daten- und KI-Projekten

von Katharine Jarmul

eBook Download (2024)
O'Reilly Verlag
49,90