Skip to content

Instantly share code, notes, and snippets.

View lgarrison's full-sized avatar

Lehman Garrison lgarrison

View GitHub Profile
@lgarrison
lgarrison / corrfunc_bug_gh193.c
Created September 29, 2019 20:50
GCC Bug (Corrfunc #193)
/*
This is a "minimal" reproducer for an apparent GCC-7 bug related to AVX-512.
It has a 100% reproduction rate on my machine (Cascade Lake).
A simple loop that copies the values from a double array to a float array
sometimes gives the wrong answer in the first few elements (zero, nan, or garbage).
The bug seems correlated with alignment values of the input and output
arrays, but it's not a one-to-one relationship.
@lgarrison
lgarrison / SAO_python_worksheet.ipynb
Created August 14, 2018 15:57
Simple simulations with Python and NumPy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgarrison
lgarrison / scale_free_sigma8.ipynb
Last active October 25, 2019 19:18
sigma8 in Scale-Free Cosmologies
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgarrison
lgarrison / high_performance_python.ipynb
Last active December 12, 2024 08:21
High-Performance Python, or When to Write For Loops in Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgarrison
lgarrison / repeat_histogram.py
Created December 27, 2016 22:25
Fast repeated histogramming in numpy
# Note: this function uses the term 'radius', but the histogramming is completely general
import numpy as np
def RadialBin(radii, values, bin_edges, bin_indices=None):
"""
Radial histogramming that supports fast re-evaluation
for the same `radii` with new `values` by passing back `bin_indices`.
Parameters
@lgarrison
lgarrison / RR_autocorrelations.ipynb
Last active July 24, 2020 12:52
A note on the RR term in autocorrelations
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgarrison
lgarrison / swot vs corrfunc
Last active February 1, 2017 20:16
swot vs corrfunc: timing & accuracy
swot: https://github.com/jcoupon/swot/
corrfunc: https://github.com/manodeep/Corrfunc
To test the speed and agreement of swot vs corrfuc, we generated random
datasets of increasing size and measured the w(theta) autocorrelation function.
Swot has an approximation parameter 'OA' (opening angle) that critically impacts its runtime.
We tried OA=0.03 and OA='no'. However, even the conservative value of OA=0.03
caused >10% errors in wtheta for this randomized configuration. Thus, it should
be used with caution.