Skip to content

Instantly share code, notes, and snippets.

View ivirshup's full-sized avatar
💭
🫠

Isaac Virshup ivirshup

💭
🫠
View GitHub Profile
@ivirshup
ivirshup / mascot_umap.py
Last active May 15, 2020 14:45
Mascot UMAP
from PIL import image
import pandas as pd
import numpy as np
empty_pixel = np.array([255, 255, 255, 0]).reshape(1, 1, -1)
# !wget https://github.com/theislab/scanpy/raw/master/docs/_static/img/Scanpy_Logo_RGB.png
im = Image.open("./Scanpy_Logo_RGB.png")
a = np.array(im)
@ivirshup
ivirshup / orderedset.py
Created April 22, 2020 02:26
OrderedSet
"""Simple OrderedSet implementation."""
from collections import OrderedDict
from collections.abc import MutableSet
from functools import reduce
from itertools import repeat
from operator import or_, sub
class OrderedSet(MutableSet):
@ivirshup
ivirshup / all-results.txt
Last active March 20, 2020 10:55
Memory benchmark results for moving neighbors to obsp:
All benchmarks:
before after ratio
[4440b90f] [a80db25c]
<doc-fix2> <obsp-update>
- 2.1052631578947367 1.4814814814814814 0.70 views.SubsetMemorySuite.track_repeated_subset_memratio(100, 100, 'X-csr', 'obs', 'boolarray')
- 1.8181818181818181 1.2758620689655173 0.70 views.SubsetMemorySuite.track_repeated_subset_memratio(100, 100, 'X-csr', 'obs', 'intarray')
- 0.6666666666666666 0.5 0.75 views.SubsetMemorySuite.track_repeated_subset_memratio(100, 100, 'X-csr', 'obs', 'slice')
- 1.9473684210526316 1.375 0.71 views.SubsetMemorySuite.track_repeated_subset_memratio(100, 100, 'X-csr', 'var', 'boolarray')
@ivirshup
ivirshup / delegates.py
Created March 5, 2020 02:53
Get delegate counts from nyt, since their visualizations suck
"""
TODO:
* Get dates for each state
"""
from requests_html import HTMLSession
import pandas as pd
import string
@ivirshup
ivirshup / grouped-dims.jl
Last active February 25, 2020 08:37
N-Dimensional split-apply-combine draft
# Attempt at split apply combine for DimensionalData.jl
# This does require some bug fixes for various reduction methods on DimensionalArray's I've got on my local branch.
# Currently not type stable, but performance still beats pandas + scipy for grouping on a sparse array
# It was type stable when I was just grouping over one dimension, but then I hit https://github.com/JuliaLang/julia/issues/29368
# It's quite a fight between being able to preallocate output and having a type-stable function.
# Even though I'm only really avoiding high total memory usage by allocating.
using SplitApplyCombine
using CategoricalArrays
using Dictionaries
@ivirshup
ivirshup / black_error.log
Created November 29, 2019 05:08
Black error log
--- src
+++ dst
@@ -2612,10 +2612,20 @@
) # /Load
id=
'C', # str
) # /Name
) # /Assign
+ Return(
+ value=
@ivirshup
ivirshup / ipython_session.py
Created October 14, 2019 05:37
h5py memory cache performance
Python 3.7.4 (default, Sep 7 2019, 18:27:02)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import h5py
In [2]: import numpy as np
In [3]: indices = np.sort(np.random.choice(int(1e7), int(1e4), replace=False))
@ivirshup
ivirshup / ipython_session.py
Last active October 14, 2019 05:49
hdf5 cache performance testing
Python 3.7.4 (default, Sep 7 2019, 18:27:02)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import h5py
In [2]: import numpy as np
In [3]: indices = np.sort(np.random.choice(int(1e7), int(1e4), replace=False))
@ivirshup
ivirshup / traceback.py
Created September 2, 2019 01:41
Full numba traceback for trying to call `list(x)` where x is numpy array of unicode
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
/usr/local/lib/python3.7/site-packages/numba/errors.py in new_error_context(fmt_, *args, **kwargs)
661 try:
--> 662 yield
663 except NumbaError as e:
/usr/local/lib/python3.7/site-packages/numba/lowering.py in lower_block(self, block)
257 loc=self.loc, errcls_=defaulterrcls):
--> 258 self.lower_inst(inst)
@ivirshup
ivirshup / oz.geojson
Created July 10, 2019 10:47
test geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.