Skip to content

Instantly share code, notes, and snippets.

View Ricyteach's full-sized avatar

Rick Teachey Ricyteach

  • KBJW Group
  • Ohio
View GitHub Profile
@Ricyteach
Ricyteach / test_fixture_parallelization.py
Created November 15, 2021 14:58
fixture parallelization using the pytest.mark.parameterize indirect=True argument
import pytest
@pytest.fixture(name="keys")
def keys_fixture(request):
"""A seq of keys"""
return request.param
@pytest.fixture(name="values")
@Ricyteach
Ricyteach / minilang.py
Created November 7, 2021 03:02
Implementation of parser for the formation specification mini language
'''Tools for parsing the format specification mini language used by the ``format`` built-in function.
See the string module docs for more information.
The mini language parsing functionality is not exposed in cPython and has therefore been re-implemented
here.'''
from collections import namedtuple as nt
import re
# only mini-language types
@Ricyteach
Ricyteach / equal.py
Created October 26, 2021 15:16
Utility module for checking internal equality of Collections and efficiently getting back an iterator
"""Utility module for checking internal equality of Collections and efficiently getting back an iterator."""
import itertools
from typing import NamedTuple, TypeVar, Iterator, Collection, Union
T = TypeVar("T")
class _NotEqual:
def __repr__(self):
@Ricyteach
Ricyteach / curry_helper.py
Created October 18, 2021 13:34
Proof of concept for an API providing more "English-like" function calls
"""Proof of concept for an API providing "English-like" function calls.
See original python-ideas [thread](https://mail.python.org/archives/list/[email protected]/thread/YMFRX6K22TZNNAP2PPVV7RGNI5HLC764/#WF232SOAJJWM33ZAY327OAPCONFOUXVX).
API:
```
from curry_helper import curry_helper
# apply the curry_helper decorator with a list of function "suffixes"
@Ricyteach
Ricyteach / load_combination.py
Last active October 19, 2021 21:48
Basic Load Combination API v0.3
"""API for implemenating the concept of civil engineering load combinations.
Compose a string representing a load combination expression:
>>> expr = "1.6*D & 1.2*L & 0.5*(S | Lr | W)"
Create a `Combination` object using the load combination expression, and generate a multiplication matrix:
>>> from ceng.load import Combination
>>> combo_obj = Combination(expr)
>>> combo_obj.matrix
array([[1.6, 1.2, 0.5, 0. , 0. ],