Skip to content

Instantly share code, notes, and snippets.

View honno's full-sized avatar
🛰️

Matthew Barber honno

🛰️
View GitHub Profile
@honno
honno / _dask.py
Last active January 18, 2022 09:42
# Wrapper of dask for use with github.com/data-apis/array-api-tests
# Tested with dask version 2022.01.0
# How to use:
# 1. Place this file in `array_api_tests/_dask.py`
# 2. In `array_api_tests/_array_module.py` replace `array_module = None` with
# `from ._dask import array_module`
from dask import array as da
#!/usr/bin/env python
import pytest
from hypothesis import assume, given, strategies as st
from hypothesis.errors import InvalidArgument
from hypothesis.extra.array_api import DTYPE_NAMES, NUMERIC_NAMES
from tests.array_api.common import COMPLIANT_XP, xp, xps
from tests.common.debug import find_any, minimal
from tests.common.utils import fails_with, flaky
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@honno
honno / wip_hypothesis_array_api_demo.ipynb
Last active August 5, 2021 15:46
WIP demo that demonstrates what my internship project is doing. For those not familiar with Array API and/or Hypothesis I want to try and explain what they do.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@honno
honno / unmute_all.ipynb
Created July 18, 2021 10:05
Unmute everyone you follow. Yaknow, for those times when you fuck around with the API and mute everybody by accident.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@honno
honno / mersenne_twister.py
Last active February 8, 2021 16:56
Stupid simple Mersenne Twister.
class Mersenne:
def __init__(self, seed=1234):
self.seed = seed
self.j = 2 ** 31 - 1
self.k = 16807
self.period = 2 ** 30
def __iter__(self):
return self
@honno
honno / defaultlist.py
Last active December 8, 2020 10:04
Reference implementation of the list with defaults, defaultlist
from collections import defaultdict
from collections.abc import Sequence, MutableSequence
class defaultlist(MutableSequence):
def __init__(self, default_factory=None):
self._ddict = defaultdict(default_factory or defaultlist._none_factory)
@staticmethod
def _none_factory():
return None
@honno
honno / bins.py
Last active November 22, 2020 13:38
Reference implementation of the data binning container "Bins"
from collections.abc import MutableMapping
from bisect import bisect_left
class Bins(MutableMapping):
def __init__(self, intervals):
empty_bins = {interval: 0 for interval in intervals}
self._dict = empty_bins
def __getitem__(self, key):
interval = self._roundkey(key)