5 Advanced topics on handling collections

 

This chapter covers

  • Vectorizing your code, aka broadcasting
  • Understanding subtyping rules for parametric types
  • Integrating Julia with Python
  • Performing t-SNE dimensionality reduction

You already know from chapter 2 how to process vectors by using loops, the map function, and comprehensions. This chapter introduces another way that is commonly used in practice: broadcasting.

Section 5.2 explains a more advanced topic related to rules of subtyping for parametric types that often raises questions from people learning Julia. This issue is closely linked with collections because, as you will learn in this chapter, types of the most common collections like arrays or dictionaries are parametric. For this reason, you need to learn this topic if you want to know how to correctly write method signatures that allow for collections as their arguments.

5.1 Vectorizing your code using broadcasting

5.1.1 Understanding syntax and meaning of broadcasting in Julia

5.1.2 Expanding length-1 dimensions in broadcasting

5.1.3 Protecting collections from being broadcasted over

5.1.4 Analyzing Anscombe’s quartet data using broadcasting

5.2 Defining methods with parametric types

5.2.1 Most collection types in Julia are parametric

5.2.2 Rules for subtyping of parametric types

5.2.3 Using subtyping rules to define the covariance function

5.3 Integrating with Python

5.3.1 Preparing data for dimensionality reduction using t-SNE

5.3.2 Calling Python from Julia

5.3.3 Visualizing the results of the t-SNE algorithm

Summary