Skip to content

Instantly share code, notes, and snippets.

View honno's full-sized avatar
🛰️

Matthew Barber honno

🛰️
View GitHub Profile
from microbit import *
import audio
import math
import neopixel
nps = [neopixel.NeoPixel(pin0, i, bpp=3) for i in range(1,10)]
current_np = 0
while True:
if button_a.is_pressed() or button_b.is_pressed():
from typing import Dict, Iterator, Tuple, TypeVar, Union
K = TypeVar("K")
V = TypeVar("V")
NestedDict = Union[V, Dict[K, Union["NestededDict", V]]]
def flatten_nested(
nested: NestedDict, parent_keys: Tuple[K, ...] = ()
) -> Iterator[Tuple[Tuple[K, ...], V]]:
diff --git a/torch_np/tests/numpy_tests/core/test_indexing.py b/torch_np/tests/numpy_tests/core/test_indexing.py
index b2918fd..a1b6c6d 100644
--- a/torch_np/tests/numpy_tests/core/test_indexing.py
+++ b/torch_np/tests/numpy_tests/core/test_indexing.py
@@ -2,6 +2,7 @@ import sys
import warnings
import functools
import operator
+import re
@honno
honno / out.txt
Created February 14, 2023 14:20
pip debug -v
pip version: pip 23.0 from /home/honno/workspaces/foo/.venv/lib/python3.8/site-packages/pip (python 3.8)
sys.version: 3.8.12 (default, Nov 12 2022, 14:27:20)
[GCC 11.3.0]
sys.executable: /home/honno/workspaces/foo/.venv/bin/python
sys.getdefaultencoding: utf-8
sys.getfilesystemencoding: utf-8
locale.getpreferredencoding: UTF-8
sys.platform: linux
sys.implementation:
name: cpython
import math
import sys
from itertools import product
from operator import index
import numpy as np
import pytest
from hypothesis import assume, given, note
from hypothesis import strategies as st
from hypothesis.extra import numpy as nps
def make_strategies_namespace(
xp: Any, *, api_version: Optional[NominalVersion] = None
) -> SimpleNamespace:
...
if api_version is None:
# When api_version=None, we infer the most recent API version for which
# the passed xp is valid. We go through the released versions in
# descending order, passing them to x.__array_namespace__() until no
# errors are raised, thus inferring that specific api_version is
# supported. If errors are raised for all released versions, we raise

A table which lists every function/method. A table which lists every function/method.

data-apis.org/array-api/latest/compliance-table

Pick a library and version:   numpy ▼   1.27.0 ▼

    abs                      🟢
    acos                     🟢
 add 🟡 ▶
@honno
honno / details_summary.md
Created June 14, 2022 11:21
Using `<details>` for code blocks
Summary text
your code
@honno
honno / get_mod.py
Created February 8, 2022 11:14
Get module via path
from importlib.util import spec_from_file_location, module_from_spec
from pathlib import Path
from types import ModuleType
def get_mod(path: Path) -> ModuleType:
mod_name = path.name.replace(".py", "")
spec = spec_from_file_location(mod_name, path)
assert spec is not None
mod = module_from_spec(spec)
assert spec.loader is not None
@honno
honno / _mxnet.py
Last active January 18, 2022 11:00
# Wrapper of mxnet for use with github.com/data-apis/array-api-tests
# Tested with dask version 1.9.0
# How to use:
# 1. Place this file in `array_api_tests/_mxnet.py`
# 2. In `array_api_tests/_array_module.py` replace `array_module = None` with
# `from ._mxnet import array_module`
import mxnet as mx