Showing posts with label ipython. Show all posts
Showing posts with label ipython. Show all posts

Monday, July 14, 2014

Useful functions, tutorials, and other Python-related things



-------------------------------------------------------------------------------------------------

A collection of useful scripts, tutorials, and other Python-related things


// Python tips and tutorials

  • A collection of not so obvious Python stuff you should know! [IPython nb]
  • Python's scope resolution for variable names and the LEGB rule [IPython nb]
  • Key differences between Python 2.x and Python 3.x [IPython nb]
  • A thorough guide to SQLite database operations in Python [Markdown]
  • Unit testing in Python - Why we want to make it a habit [Markdown]
  • Installing Scientific Packages for Python3 on MacOS 10.9 Mavericks [Markdown]
  • Sorting CSV files using the Python csv module [IPython nb]
  • Using Cython with and without IPython magic [IPython nb]
  • Parallel processing via the multiprocessing module [IPython nb]
  • Entry point: Data - using sci-packages to prepare data for Machine Learning tasks and other data analyses [IPython nb]
  • Awesome things that you can do in IPython Notebooks (in progress) [IPython nb]
  • A collection of useful regular expressions [IPython nb]

// Python and the web

  • Creating internal links in IPython Notebooks and Markdown docs [IPython nb]
  • Converting Markdown to HTML and adding Python syntax highlighting [Markdown]

// Algorithms

The algorithms category was moved to a separate GitHub repository rasbt/algorithms_in_ipython_notebooks
  • Sorting Algorithms [IPython nb]
  • Linear regression via the least squares fit method [IPython nb]
  • Dixon's Q test to identify outliers for small sample sizes [IPython nb]
  • Sequential Selection Algorithms [IPython nb]
  • Counting points inside a hypercube [IPython nb]

// Benchmarks

The benchmark category was moved to a separate GitHub repository One-Python-benchmark-per-day
  • 1 - Reversing strings [IPython nb]
  • 2 - Calculating sample means [IPython nb]
  • 3 - 6 different ways to count elements using a dict [IPython nb]
  • 4 - Python vs. Cython vs. Numba [IPython nb]
  • 4.2 - (C)Python compilers - Cython vs. Numba vs. Parakeet [IPython nb]
  • 5 - Comparing 9 ways for flattening lists of sublists [IPython nb]
  • 6 - Determining if a string is a number [IPython nb]
  • 7 - Speeding up NumPy array expressions with Numexpr [IPython nb]
  • 7.2 - Just-in-time compilers for NumPy array expressions [IPython nb]
  • 8 - Calculating square roots and exponents [IPython nb]
  • 9 - The most Pythonic way to check if a string ends with a particular substring [IPython nb]
  • 10 - Cython - Bridging the gap between Python and Fortran [IPython nb]
  • 11 - The deque container data type [IPython nb]
  • 12 - Lightning fast insertion into sorted lists via the bisect module [IPython nb]
  • 13 - Parallel processing via the multiprocessing module [IPython nb]
  • 14 - Python's and NumPy's in-place operator functions [IPython nb]
  • 15 - Array indexing in NumPy: Extracting rows and columns [IPython nb]
  • 16 - Vectorizing a classic for-loop in NumPy [IPython nb]
  • 17 - Stacking NumPy arrays [IPython nb]

// Other

  • Happy Mother's [IPython nb]
  • Numeric matrix manipulation - The cheat sheet for MATLAB, Python NumPy, R, and Julia [Markdown]
  • Python Book Reviews [Markdown]

// Useful scripts and snippets


// Links

// News
  • Python subreddit - my favorite resource to catch up with Python news and great Python-related articles
  • Python community on Google+ - a nice and friendly community to share and discuss everything about Python
  • Python Weekly - A free weekly newsletter featuring curated news, articles, new releases, jobs etc. related to Python
// Resources for learning Python
// My favorite Python projects and packages
  • The IPython Notebook - an interactive computational environment for combining code execution, documentation (with Markdown and LateX support), inline plots, and rich media all in one document.
  • SciPy Stack - Python packages (NumPy, pandas, SciPy, IPython, Matplotlib) for scientific computing
  • Cython - C-extensions for Python, an optimizing static compiler to combine Python and C code
  • Numba - an just-in-time specializing compiler which compiles annotated Python and NumPy code to LLVM (through decorators)
  • scikit-learn - a powerful machine learning library for Python and tools for efficient data mining and analysis

Thursday, November 29, 2012

Autoreload


Executing this on ipython forces ipython to reload functions each time it executes them, really usefull if you are testing and modifying at the same time!

%load_ext autoreload
%autoreload 2

Monday, May 7, 2012

DeprecationWarnings in Python 2.7

If you're using Python versino 2.7, you may notice that the DeprecationWarning no longer displays. This has been de-activated by default, however, it can be switched back on by, for example, doing the following in iPython 


>>> import warnings 
>>> warnings.simplefilter("always") 

If you now call a deprecated class on purpose, iPython will display the full DeprecationWarning

Monday, March 5, 2012

doctest_mode in iPython

If you want to import code into iPython that has been copied from the python console
or code that is to be run as a doctest in Python Sphinx, a useful trick to use in iPython
is

%doctest_mode

For example:

>>> import numpy as np
>>> some_value = 35
>>> np.sqrt(some_value)


You can copy this directly into iPython and it will treat it like normal python code.
No need having to copy every line of code after >>>