This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A Bezier curve implementation. | |
Requires | |
- numpy >= 1.26.4 | |
""" | |
from dataclasses import dataclass | |
from math import comb | |
import numpy as np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
class SPHSolver: | |
def __init__(self, nparticles, size): | |
self.nparticles = nparticles | |
self.size = size | |
self.state = np.zeros((self.nparticles, 4), dtype=float) | |
self.init_dam() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _make_row(separators, entries): | |
"""A string representation of a single row in a table. | |
""" | |
left, middle, right = separators | |
return f'{left}{middle.join(entries)}{right}' | |
CENTERED = ' {:^{width}} ' | |
LEFT_ALIGNED = ' {:<{width}} ' | |
def make_table(rows, labels=None, centered=False): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ast import iter_child_nodes, parse, Load, Store, Delete | |
from igraph import Graph | |
class EnumDict(dict): | |
def __init__(self): | |
self.types = [ ] | |
def __missing__(self, key): | |
self[key] = len(self.types) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import curses | |
from itertools import product | |
from time import time, sleep | |
import cv2 | |
import numpy as np | |
path = "never_gonna.mp4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
class Calculator: | |
ops = { | |
"+":lambda x, y:x + y, | |
"*":lambda x, y:x * y, | |
} | |
precedence = ( | |
("+", "*"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A small test of our setch. | |
""" | |
use "collections" | |
actor Main | |
new create(env: Env) => | |
let s: Setch[USize] = Setch[USize] | |
for j in Range(0, 10) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from importlib import import_module | |
from inspect import signature | |
modules = 'igraph', 'networkx', 'graph_tool' | |
class interface: | |
"""A decorator for Graph methods which will set the correct interface method on the first call to that method. | |
""" | |
def __init__(self, func): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import islice | |
class block: | |
__slots__ = 'prev', 'next', 'val' | |
def __init__(self, val, prev=None, next=None): | |
self.prev = self if prev is None else prev | |
self.next = self if next is None else next | |
self.val = val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from PIL import Image | |
from kivy.app import App | |
from kivy.animation import Animation | |
from kivy.clock import Clock | |
from kivy.uix.widget import Widget | |
from kivy.graphics import Color, Rectangle | |
NewerOlder