In [3]:
%matplotlib inline 
%load_ext autoreload 
%autoreload 2

__author__ = 'Song Huang'
__email__ = 'shuang89@ucsc.edu'
__version__ = '170505A'

from __future__ import (print_function, division, absolute_import)

import os
import sys
import math
import glob
import copy
import warnings
import subprocess

import numpy as np
#import seaborn as sns
#sns.set(color_codes=True, style="darkgrid")

# Matplotlib related
import matplotlib as mpl
import matplotlib.pyplot as plt
#mpl.style.use('classic')
plt.rc('text', usetex=True)
#plt.rc('font', family='serif')

from astropy.io import fits
from astropy.table import \
    Table, \
    Column, \
    vstack, \
    unique
    
from astropy.utils.metadata import MergeConflictWarning
warnings.filterwarnings('ignore', category=MergeConflictWarning, 
                        append=True)
from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.utils.console import ProgressBar

import hsc_massive
from hsc_massive import \
    s16a_path, \
    sample_selection, \
    prepare_sed, \
    catalog_summary, \
    smhm, \
    plotting

#envir = s16a_path.set_env(version='astro4')
envir = s16a_path.set_env(version='kungpao')

ORG = plotting.ORG
BLK = plotting.BLK
BLU = plotting.BLU
GRN = plotting.GRN


The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

In [12]:
from numba import jit, void, double

from kungpao.isophote.ellipse import Ellipse
from kungpao.isophote.ellipse import Centerer
from kungpao.isophote.ellipse import Geometry
from kungpao.isophote.ellipse.model import build_model

Test Numba


In [7]:
xx = np.random.random((2000, 2000))
yy = np.random.random((2000, 2000))

def testA(x, y):
    return np.sqrt(x) * np.log10(y) + np.exp(x)

@jit 
def testB(x, y):
    return np.sqrt(x) * np.log10(y) + np.exp(x)

In [18]:
%timeit testA(xx, yy)
%timeit testB(xx, yy)


10 loops, best of 3: 104 ms per loop
10 loops, best of 3: 66.5 ms per loop

In [13]:
testA_numba = jit(void(double[:], double[:,:]))(testA)

%timeit testA_numba(xx, yy)


10 loops, best of 3: 105 ms per loop