O'Reilly logo

Digital Signal Processing (DSP) with Python Programming by Maurice Charbit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Few Functions of Python®

To get function documentation, use .__doc__, e.g. print(range.__doc__), or help, e.g. help(zeros) or help(’def’), or ?, e.g. range.count?

  • def: introduces a function definition
  • if, else, elif: an if statement consists of a Boolean expression followed by one or more statements
  • for: executes a sequence of statements multiple times
  • while: repeats a statement or group of statements while a given condition is true
  • 1j or complex: returns complex value, e.g. a=1.3+1j*0.2 or a=complex(1.3,0.2)

Methods:

  • – type A=array([0,4,12,3]), then type A. and tab, it follows a lot of methods, e.g. the argument of the maximum using A.argmax. For help type, e.g. A.dot?.

Functions:

  • int: converts a number or string to an integer
  • len: returns the number of items in a container
  • range: returns an object that produces a sequence of integers
  • type: returns the object type

From numpy:

  • abs: returns the absolute value of the argument
  • arange: returns evenly spaced values within a given interval
  • argwhere: finds the indices of array elements that are non-zero, grouped by element
  • array: creates an array
  • cos, sin, tan: respectively calculate the cosine, the sine and the tangent
  • cosh: calculates the hyperbolic cosine
  • cumsum: calculates the cumulative sum of array elements
  • diff: calculates the n-th discrete difference along a given axis
  • dot: product of two arrays
  • exp, log: respectively calculate the exponential, the logarithm
  • fft: calculates the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required