Category Python Modules

Modules is one of the best feature of Python. Except some core modules, you can install what you need and keep your Python setup smooth.

NumPy empty and empty_like

NumPy empty and empty_like

When you’re about to fill a NumPy array with your own values straight away, you only need NumPy to set aside the space. np.empty creates that array without setting its values, and np.empty_like does the same using another array’s shape…

Use np.arctan2() for Coordinate Angles

Use np.arctan2() for Coordinate Angles

Given a point’s x and y coordinates, you may need the angle it makes with the x-axis. np.arctan2 calculates that angle and uses the signs of both coordinates to put it in the right quadrant. You’ll get the angle in…

SciPy Minimize: Fit a Function and Check the Result

SciPy Minimize: Fit a Function and Check the Result

Fitting a line to data points means finding the slope and intercept that make the line’s errors as small as possible. SciPy’s minimize function searches for those values, starting from a guess you give it. The example writes the error…