Skip to content

Instantly share code, notes, and snippets.

@emmanuelle
emmanuelle / skimage_weekly_update.py
Last active April 17, 2020 13:40
Use github API to print weekly updates for a given project (here scikit-image)
from github import Github
from datetime import datetime
# Change start date here
start = datetime(2020, 4, 6)
def print_list(l, title=None):
"""From list of PullRequest of Issue objects,
print their number and title.
from github import Github
import plotly.express as px
from datetime import datetime
# First create a Github instance
# using an access token
g = Github("your own token here")
repo = g.get_repo("scikit-image/scikit-image")
@emmanuelle
emmanuelle / skimage-analytics-choropleth.py
Created December 11, 2019 04:01
Choropleth chart of scikit-image website visits
import plotly.express as px
import pandas as pd
# Analytics file downloaded from matomo, each line is a visit
df = pd.read_csv('december10-skimage.csv', encoding='utf-16le')
df['unit'] = 1
df['hour'] = pd.to_datetime(df['serverTimePretty']).dt.hour
# For each country and hour, count number of visitors
dfg = df[['unit', 'country', 'hour']].groupby(['country', 'hour']).sum()
dfg.reset_index(inplace=True)
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objects as go
import plotly.express as px
gapminder = px.data.gapminder().query("year == 2007").reset_index()
app = dash.Dash(__name__)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import numpy as np
from skimage import data
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import numpy as np
from skimage import data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@emmanuelle
emmanuelle / benchmark_skimage_cv2.py
Created May 31, 2018 22:59 — forked from Jathrone/benchmark_skimage_cv2.py
Compares runtimes for several functions common to opencv and scikit-image
import numpy as np
import inspect
from skimage import exposure, feature, filters, measure, morphology, \
restoration, segmentation, transform, util, data, color
from timeit import default_timer
import pandas as pd
import cv2
import time
###this python script returns a csv of function runtimes
@emmanuelle
emmanuelle / chunk.py
Created April 10, 2018 14:50
Apply function in parallel to overlapping chunks of an array, for example for image processing
import numpy as np
from sklearn.externals.joblib import Parallel, delayed
def apply_parallel(func, data, *args, chunk=100, overlap=10, n_jobs=4,
**kwargs):
"""
Apply a function in parallel to overlapping chunks of an array.
joblib is used for parallel processing.