Skip to content

Latest commit

 

History

History
53 lines (40 loc) · 1.55 KB

lec11.md

File metadata and controls

53 lines (40 loc) · 1.55 KB

Lecture #11: Numpy for Numerical Applications and Data Model/Interface Design

Lecture Objectives

  • create and manipulate numpy arrays for scientific/mathematical applicatinos
  • use a variety of containers to design the data structures for a software project

Textbook Reference

Chapter 9, pages 201-227

Activities

  1. What is numpy?

    • mostly about arrays that can be used mathematically
    • a lot of resemblance to Matlab
  2. Importing numpy

    • common convention: import numpy as np
  3. Common ndarray methods

    • initialization: arange, zeros, ones, empty, linspace, logspace
    • attributes (see table 9-1), esp:
      • ndim, shape, size
      • dtype
    • slicing
    • arithmetic & broadcasting
      • mathematical operations are elementwise by default
      • compatible arrays & broadcasting
      • experiment - formulate hypotheses and test
  4. Structured Arrays

    • tables with named columns and varying data types
    • define the structure of a row: names and types
    • access slices by rows and column names
  5. Designing data models and interfaces

    1. Many reason to break project into distinct pieces with well-defined interfaces
      • division of labor
      • separation of concerns
      • reviewability
    2. all components must share the same data model
      • how will data be shared among components
      • balance between flexibility and simplicity
      • depends heavily on features of language
        • object-oriented
        • advanced containers
    3. define interfaces
      • input, output, behavior