repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
Welzin/advent-of-code | 2021/01/part2.py | #! /usr/bin/env python3
entries = [int(n) for n in open("input")]
print(sum([entries[i] < entries[i+3] for i in range(len(entries)-3)])) |
Welzin/advent-of-code | 2020/22/part2.py | <gh_stars>0
#! /usr/bin/env python3
import copy
from typing import List, T, Tuple
class Queue:
data: List[T]
def __init__(self, ls: List[T]) -> None :
self.data = ls
def queue(self, element: T) -> None :
self.data.append(element)
def dequeue(self) -> T :
return self.data.pop... |
Welzin/advent-of-code | 2021/17/part2.py | <gh_stars>0
#! /usr/bin/env python3
import re
def trajectory(x, y, xmin, xmax, ymin, ymax) :
start = (0, 0)
while (start[0] < xmin or start[1] > ymax) and not(start[0] > xmax or start[1] < ymin) :
start = (start[0] + x, start[1] + y)
x, y = 0 if x == 0 else (abs(x)-1)*(abs(x)//x), y - 1
... |
Welzin/advent-of-code | 2021/20/d20.py | <filename>2021/20/d20.py
#! /usr/bin/env python3
def calculate_point(enhancement, light_pixels, x, y, t, xmin, xmax, ymin, ymax) :
binary = ''.join('1' if (x+i, y+j) in light_pixels or (t & 1 != 0 and not(xmin <= x+i <= xmax and ymin <= y+j <= ymax)) else '0' for i in [-1, 0, 1] for j in [-1, 0, 1])
return enh... |
Welzin/advent-of-code | 2020/18/part1.py | <reponame>Welzin/advent-of-code
#! /usr/bin/env python3
def evaluate(expr: str) -> int :
res, op, i = 0, '+', 0
while i < len(expr) :
c = expr[i]
if c != ' ' :
if c == '*' or c == '+' :
op = c
elif c == '(' :
p_v, p_e = 1, i + 1
... |
Welzin/advent-of-code | 2020/02/part1.py | #! /usr/bin/env python3
import re
fd = open("input", "r")
valid = 0
for line in fd.readlines() :
least, max, char, string = re.search(r"(\d+)-(\d+) (.): (.*)", line).groups()
if int(least) <= string.count(char) <= int(max) :
valid += 1
print(valid)
|
Welzin/advent-of-code | 2021/18/part2.py | #! /usr/bin/env python3
from math import ceil, floor
class Node :
def __init__(self, value = None, leftChild = None, rightChild = None) :
self.__v = value
self.__lc = leftChild
self.__rc = rightChild
def leftChild(self) : return self.__lc
def rightChild(self) : return self.__rc
... |
Welzin/advent-of-code | 2020/03/part2.py | <reponame>Welzin/advent-of-code
#! /usr/bin/env python3
fd = open("input", "r")
counts = [0] * 5
cols = [0] * 5
lines = 0
adds = [1, 3, 5, 7, 1]
for line in fd.readlines() :
for i in range(4) :
counts[i] += line[cols[i] % (len(line) - 1)] == '#'
cols[i] += adds[i]
if lines % 2 == 0 :
... |
Welzin/advent-of-code | 2020/20/part2.py | #! /usr/bin/env python3
import copy
from typing import List
from math import sqrt
class Tile :
id: int
tile: List[List[chr]]
witness: List[List[chr]]
eta: int
tot: int
def __init__(self, tile: List[str]) -> None :
self.id = int(tile[0][tile[0].rfind(' '):-1].strip())
self... |
Welzin/advent-of-code | 2021/21/d21.py | #! /usr/bin/env python3
from copy import deepcopy
def move(from_, dice, score) :
for _ in range(3) :
dice += 1
from_ += dice
while from_ > 10 : from_ -= 10
return from_, dice, score + from_
def part1(p1, p2) :
dice, scorep1, scorep2 = 0,0,0
while scorep1 < 1000 and scorep2 < ... |
Welzin/advent-of-code | 2020/13/part1.py | <filename>2020/13/part1.py
#! /usr/bin/env python3
def closest(x, base):
return base * round(x/base)
with open("input", "r") as fd :
content = fd.read().strip().split('\n')
depart = int(content[0])
bus = [int(x) for x in content[1].split(',') if x != 'x']
nearest, id = 2**32, 0
for b in bus :
... |
Welzin/advent-of-code | 2021/09/part1.py | #! /usr/bin/env python3
def lowest_point(n, i, j, numbers) :
neighbors = filter(lambda tup: 0 <= tup[0] < len(numbers) and 0 <= tup[1] < len(numbers[0]), [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)])
return all(n < numbers[x][y] for x, y in neighbors)
numbers = [list(map(int, [c for c in line.strip()])) f... |
Welzin/advent-of-code | 2020/25/part1.py | #! /usr/bin/env python3
def loop(target: int, subjectNumber: int, encrypt: bool) -> int :
num, count = 1, 0
while (not encrypt and num != target) or (encrypt and count < target) :
num *= subjectNumber
num %= 20201227
count += 1
return count, num
cardPkey, doorPkey = 14222596, 40574... |
Welzin/advent-of-code | 2020/09/part1.py | <filename>2020/09/part1.py
#! /usr/bin/env python3
def isSum(data, number) :
return any(True for i in range(len(data)) if number - data[i] in data[i + 1:])
with open("input", "r") as fd :
numbers = [int(x) for x in fd.read().split('\n')]
for i in range(25, len(numbers)) :
if not isSum(numbers[i - 25:i], ... |
Welzin/advent-of-code | 2020/10/part2.py | #! /usr/bin/env python3
with open("input", "r") as fd :
adapters = [int(x) for x in fd.read().strip().split('\n')]
# Best arrangement
adapters.sort()
adapters.append(max(adapters) + 3)
ans = { 0: 1 }
for a in adapters :
# ways to go from 0 to current adapter. i.e. : [1, 4, 5, 6, 7]
# we have { 1: 1, 4: ... |
Welzin/advent-of-code | 2021/11/part1.py | <gh_stars>0
#! /usr/bin/env python3
def neighbors(i, j) :
return [(x, y) for x in range(i - 1, i + 2) for y in range(j - 1, j + 2) if 0 <= x < 10 and 0 <= y < 10 and (x != i or y != j)]
def process(octopuses, steps, flashes) :
if steps == 0 :
return flashes
to_flash = []
for i in range(10) :
... |
Welzin/advent-of-code | 2021/16/part1.py | <reponame>Welzin/advent-of-code
#! /usr/bin/env python3
def solve_str(N, i=0) :
V = int(N[i:i+3], 2)
T = int(N[i+3:i+6], 2)
i += 6
if T == 4 :
while N[i] == '1' :
i += 5
return V, i+5
else :
I, Vs = N[i], V
i += 1
if I == '0' :
L = i... |
Welzin/advent-of-code | 2020/23/part1.py | <reponame>Welzin/advent-of-code
#! /usr/bin/env python3
from typing import List, Tuple
class CupGame:
data: List[int]
head: int
def __init__(self, ls: List[int]) -> None :
self.data = ls
self.head = 0
def run(self, i) -> None :
save = self.step1()
dest = self.step2(sa... |
Welzin/advent-of-code | 2021/15/dynamic.py | #! /usr/bin/env python3
# Approximation working on easy examples
def solve_dynamic(chitons) :
solve = [[0] * len(chitons[0]) for _ in range(len(chitons))]
for i in range(1, len(chitons[0])) :
solve[0][i] = solve[0][i-1] + chitons[0][i]
for i in range(1, len(chitons)) :
solve[i][0] = s... |
Welzin/advent-of-code | 2020/05/part2.py | <reponame>Welzin/advent-of-code
#! /usr/bin/env python3
def getId(line) :
# Convert to binary
row = int(line[:7].replace('B', '1').replace('F', '0'), 2)
col = int(line[7:].replace('R', '1').replace('L', '0'), 2)
return row * 8 + col
# O(nlog(n)) solution
ids = [getId(line) for line in open("input", "... |
Welzin/advent-of-code | 2020/07/part2.py | #! /usr/bin/env python3
import re
def recurse(content, bag) :
line = [x for x in content if re.search(rf"^{bag}", x) != None][0]
bags = re.findall(r"(\d) ([^ ]+ {1}[^ ]+) ", line)
if len(bags) == 0 :
return 0
return sum([int(bag[0]) + int(bag[0]) * recurse(content, bag[1]) for bag in bags])
... |
Welzin/advent-of-code | 2021/08/part1.py | #! /usr/bin/env python3
numbers = [line.split("|")[1].split() for line in open("input")]
print(sum(sum(len(n) in [2, 3, 4, 7] for n in l) for l in numbers)) |
Welzin/advent-of-code | 2020/06/part2.py | #! /usr/bin/env python3
content = open("input", "r").read().rstrip().split('\n\n')
sum = 0
for entry in content :
# Add the length of the intersection of all sets of a group
sum += len(set.intersection(*[set(answer) for answer in entry.split('\n')]))
print("Sum : ", sum) |
Welzin/advent-of-code | 2020/10/part1.py | <gh_stars>0
#! /usr/bin/env python3
with open("input", "r") as fd :
adapters = [int(x) for x in fd.read().strip().split('\n')]
adapters.append(0)
adapters.append(max(adapters) + 3)
adapters.sort()
differences = [adapters[i + 1] - adapters[i] for i in range(len(adapters) - 1)]
print(differences.count(1) ... |
Welzin/advent-of-code | 2020/09/part2.py | <filename>2020/09/part2.py
#! /usr/bin/env python3
def isSum(data, number) :
return any(True for i in range(len(data)) if number - data[i] in data[i + 1:])
def subSum(data, target) :
st, ed = 0, 1
while ed < len(data):
total = sum(data[st:ed])
if total == target:
return min(dat... |
Welzin/advent-of-code | 2021/02/part2.py | #! /usr/bin/env python3
entries = [(line.split()[0], int(line.split()[1])) for line in open("input")]
print(sum(x for d, x in entries if d == 'forward') * sum(entries[i][1] * sum(x*(d == 'down')-x*(d == 'up') for d, x in entries[:i]) for i in range(len(entries)) if entries[i][0] == 'forward')) |
Welzin/advent-of-code | 2020/24/part2.py | #! /usr/bin/env python3
from typing import List, Tuple, T, Dict
class Hex :
x: int
y: int
z: int
def __init__(self, x: int, y: int, z: int) -> None :
self.x = x
self.y = y
self.z = z
def __eq__(self, oth) -> bool :
return self.x == oth.x and self.y == oth.y and s... |
Welzin/advent-of-code | 2020/16/part2.py | #! /usr/bin/env python3
import re
def getValidValues(fields) :
valid = []
for field in fields :
match = re.match(r"^.*: (\d+-\d+) or (\d+-\d+)$", field).groups()
valid += [(match[0].split('-'), match[1].split('-'))]
return valid
def getMax(rules) :
max, r = -1, -1
for k, v in rule... |
Welzin/advent-of-code | 2020/11/part1.py | #! /usr/bin/env python3
def neighbors(board, x, y) -> int :
minx, maxx = x - 1, x + 1
miny, maxy = y - 1, y + 1
if miny < 0 : miny = 0
if maxy >= len(board[0]) : maxy = len(board[0]) - 1
if minx < 0 : minx = 0
if maxx >= len(board) : maxx = len(board) - 1
count = 0
for i in range(min... |
Welzin/advent-of-code | 2020/03/part1.py | #! /usr/bin/env python3
fd = open("input", "r")
col = 0
count = 0
for line in fd.readlines() :
count += line[col % (len(line) - 1)] == '#'
col += 3
print(count)
|
Welzin/advent-of-code | 2021/13/part1.py | #! /usr/bin/env python3
lines = [line.strip() for line in open("input")]
points = set(tuple(map(int, line.split(',')[::-1])) for line in lines[:lines.index('')])
folds = [(line.split('=')[0][-1:], int(line.split('=')[1])) for line in lines[lines.index('')+1:]]
for axis, above in folds[:1] :
foldedPoints = set()
... |
Welzin/advent-of-code | 2020/24/part1.py | <reponame>Welzin/advent-of-code
#! /usr/bin/env python3
from typing import List, Tuple, T
class Hex :
x: int
y: int
z: int
def __init__(self, x: int, y: int, z: int) -> None :
self.x = x
self.y = y
self.z = z
def __eq__(self, oth) -> bool :
return self.x == oth.x... |
Welzin/advent-of-code | 2020/04/part2.py | <filename>2020/04/part2.py<gh_stars>0
#! /usr/bin/env python3
# Improved previous code with cleaner rule checking :
# - Improved RegEx with the solutions from here : https://www.reddit.com/r/adventofcode/comments/k6e8sw/2020_day_04_solutions/
# - Improved file reading process
# Original clean version : https://www... |
Welzin/advent-of-code | 2021/15/part2.py | <gh_stars>0
#! /usr/bin/env python3
def make_graph(cols, rows) :
graph = {}
for i in range(rows) :
for j in range(cols) :
for x, y in [(i-1, j), (i+1, j), (i, j-1), (i, j+1)] :
if 0 <= x < rows and 0 <= y < cols :
if (i, j) in graph : graph[(i, j)].append... |
Welzin/advent-of-code | 2020/12/part1.py | #! /usr/bin/env python3
# Using dx = cos(x) and dy = sin(x), every 90 degrees is a derivative :
# d'x, d'y = sin(x), -cos(x)
# d2x, d2y = -cos(x), -sin(x)
# d3x, d3y = -sin(x), cos(x)
# d4x, d4y = cos(x), sin(x)
def rotate(dx, dy, dir, degrees) -> (int, int) :
if dir == 'R' :
for _ in range(degrees... |
Welzin/advent-of-code | 2021/10/part2.py | <filename>2021/10/part2.py
#! /usr/bin/env python3
def process(queue, char) :
entry = {
']' : '[',
'}' : '{',
')' : '(',
'>' : '<'
}
if char in '[{(<' :
return queue + [char]
else :
if queue.pop() != entry[char] :
raise RuntimeError(char)
... |
Welzin/advent-of-code | 2020/11/part2.py | #! /usr/bin/env python3
def checkSide(board, x, y, side) -> chr :
sides = {
'L' : [-1, 0],
'R' : [1, 0],
'U' : [0, -1],
'D' : [0, 1],
'UL' : [-1, -1],
'UR' : [1, -1],
'DL' : [-1, 1],
'DR' : [1, 1]
}
lx, ly = x, y
while ly < len(board[0])... |
Welzin/advent-of-code | 2021/14/part2.py | #! /usr/bin/env python3
def step(count, polymer, transformations) :
for k, v in polymer.copy().items() :
polymer[k] -= v
char_res = transformations[k]
count[char_res] = insert(count, char_res, v)
keys = [k[0] + char_res, char_res + k[1]]
for key in keys :
polyme... |
Welzin/advent-of-code | 2021/04/part1.py | #! /usr/bin/env python3
entries = [line.strip() for line in open("input") if line.strip()]
draws, entries = list(map(int, entries[0].split(','))), entries[1:]
boards = [[list(map(int, entries[j].split())) for j in range(i*5, (i*5)+5)] for i in range(len(entries)//5)]
def delete(n, board) :
for i in range(len(boar... |
Welzin/advent-of-code | 2021/19/d19.py | <gh_stars>0
#! /usr/bin/env python3
from time import time
def dist(v1, v2) :
x, y, z = v1
a, b, c = v2
return (x-a)**2 + (y-b)**2 + (z-c)**2
def create_distances(scanner) :
return [dist(scanner[i], scanner[j]) for i in range(len(scanner)) for j in range(i + 1, len(scanner))]
def get_possible_match... |
Welzin/advent-of-code | 2020/01/part2.py | <gh_stars>0
#! /usr/bin/env python3
import os
fd = open("input", "r")
entries = []
for line in fd.readlines() :
entries.append(int(line))
# Naive - O(n^3) solution :
for i in range(len(entries)) :
for j in range(i + 1, len(entries)) :
for k in range(j + 1, len(entries)) :
if entries[i] ... |
Welzin/advent-of-code | 2021/15/part1.py | #! /usr/bin/env python3
def make_graph(cols, rows) :
graph = {}
for i in range(rows) :
for j in range(cols) :
for x, y in [(i-1, j), (i+1, j), (i, j-1), (i, j+1)] :
if 0 <= x < rows and 0 <= y < cols :
if (i, j) in graph : graph[(i, j)].append((x, y))
... |
Welzin/advent-of-code | 2020/18/part2.py | #! /usr/bin/env python3
import functools
def evaluate(expr: str) -> int :
res, curr, i = [], 0, 0
while i < len(expr) :
c = expr[i]
if c != ' ' :
if c == '*' :
res.append(curr)
curr = 0
elif c == '(' :
p_v, p_e = 1, i + 1
... |
Welzin/advent-of-code | 2021/07/part1.py | #! /usr/bin/env python3
alignment = list(map(int, open("input").readline().split(",")))
print(min([sum(abs(alignment[j] - alignment[i]) for j in range(len(alignment))) for i in range(len(alignment))])) |
Welzin/advent-of-code | 2020/23/part2.py | <reponame>Welzin/advent-of-code<gh_stars>0
#! /usr/bin/env python3
from typing import List, Tuple, Dict, T
# Linked List
class Node :
val : int
nxt : T
def __init__(self, val) :
self.val = val
self.nxt = None
class CupGame :
head: Node
ndes: List[Node]
def __init__(self, ls... |
Welzin/advent-of-code | 2021/07/part2.py | #! /usr/bin/env python3
alignment = list(map(int, open("input").readline().split(",")))
print(min(sum((abs(alignment[j] - i)*(abs(alignment[j] - i)+1))//2 for j in range(len(alignment))) for i in range(max(alignment)))) |
Welzin/advent-of-code | 2021/13/part2.py | <reponame>Welzin/advent-of-code<gh_stars>0
#! /usr/bin/env python3
lines = [line.strip() for line in open("input")]
points = set(tuple(map(int, line.split(',')[::-1])) for line in lines[:lines.index('')])
folds = [(line.split('=')[0][-1:], int(line.split('=')[1])) for line in lines[lines.index('')+1:]]
for axis, abov... |
Welzin/advent-of-code | 2021/09/part2.py | <gh_stars>0
#! /usr/bin/env python3
import math
def get_basin(i, j, numbers):
if 0 <= i < len(numbers) and 0 <= j < len(numbers[i]) and numbers[i][j] != 9:
numbers[i][j] = 9
return 1 + get_basin(i - 1, j, numbers) + get_basin(i + 1, j, numbers) + get_basin(i, j - 1, numbers) + get_basin(i, j + 1, ... |
Welzin/advent-of-code | 2020/14/part1.py | <filename>2020/14/part1.py
#! /usr/bin/env python3
with open("input", "r") as fd :
content = [x.split('=') for x in fd.read().strip().split('\n')]
values = dict()
mask = content[0][1].strip()
for k, v in content :
k, v = k.strip(), v.strip()
if k == 'mask' :
mask = v
else :
k = k[k.... |
Welzin/advent-of-code | 2020/08/part2.py | <reponame>Welzin/advent-of-code
#! /usr/bin/env python3
def run(instructions) :
acc = 0
done = [False] * len(instructions)
i = 0
while 0 <= i < len(instructions) and not done[i] :
done[i] = True
instruction, value = instructions[i]
if instruction == "acc" :
acc... |
tvdsluijs/dier-en-zorg-py-script | dierenzorg_formulier.py | import os
import pathlib
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from datetime import datetime
from time import sle... |
tvdsluijs/dier-en-zorg-py-script | functions/readConfig.py | #pip install pyyaml
import os
import sys
import logging
import yaml
class readConfig:
config = ""
def __init__(self, file=None):
try:
if file is None:
file = "./config/config.yml"
with open(file) as f:
self.config = yaml.loa... |
will-duncan/ramp_systems | src/ramp_to_hill/hill_system.py | <gh_stars>0
import numpy as np
from scipy.integrate import solve_ivp
def HS_ode(t,y,HS):
rhs = -HS.gamma*y + HS.lambda_value(y)
return rhs
def at_HS_equilibrium(t,y,HS,tol = 1e-3):
val = np.linalg.norm(HS_ode(t,y,HS)) - tol
if val < 0:
return 0
else:
return val
def simulate_HS(x0... |
will-duncan/ramp_systems | src/ramp_systems/ramp_system.py | <filename>src/ramp_systems/ramp_system.py
"""
RampSystem class and methods.
Author: <NAME>
"""
import matplotlib.pyplot as plt
import numpy as np
import itertools
from ramp_systems.ramp_function import RampFunction
from ramp_systems.cell import Cell
from ramp_to_hill.ramp_to_hill_function_map import RampToHillF... |
will-duncan/ramp_systems | src/ramp_systems/decomposition.py | <filename>src/ramp_systems/decomposition.py<gh_stars>0
"""
Functions for decomposing a RampSystem at a loop characteristic cell.
"""
import DSGRN
import numpy as np
from ramp_systems.cyclic_feedback_system import CyclicFeedbackSystem
import dsgrn_utilities.graphtranslation as Gtrans
import itertools
import sympy
from ... |
will-duncan/ramp_systems | src/ramp_systems/ramp_function.py | """
RampFunction class and methods.
Author: <NAME>
"""
import matplotlib.pyplot as plt
import numpy as np
class RampFunction:
def __init__(self, sign, L, Delta, theta):
self.sign = sign
self.Delta = Delta
self.L = L
self.theta = theta
def __eq__(self,other):
if ... |
will-duncan/ramp_systems | tests/test_decomposition_and_cell.py | <filename>tests/test_decomposition_and_cell.py
from ramp_systems.decomposition import *
import DSGRN
from ramp_systems.ramp_system import RampSystem
from ramp_systems.cyclic_feedback_system import CyclicFeedbackSystem
import sympy
def test_get_saddles():
## test on two independent toggle switches
N,L,Delta,the... |
will-duncan/ramp_systems | setup.py | <reponame>will-duncan/ramp_systems<filename>setup.py
from distutils.core import setup
setup(
name='ramp_systems',
package_dir={'':'src'},
packages = ["ramp_systems","ramp_to_hill"],
install_requires = ["DSGRN","sympy"],
author="<NAME>",
url='https://github.com/will-duncan/ramp_systems'
) |
will-duncan/ramp_systems | src/ramp_systems/cell.py | <reponame>will-duncan/ramp_systems<filename>src/ramp_systems/cell.py
import numpy as np
import itertools
import random
def cell_from_coordinates(RS,*coords):
"""
Create a Cell object from state transition graph coordinates.
:param RS: RampSystem object
:param *coords: jth argument is an integer corres... |
will-duncan/ramp_systems | tests/profile_optimal_theta.py | <filename>tests/profile_optimal_theta.py
import cProfile
import DSGRN
import ramp_systems.ramp_system as ramp_system
def run():
network_spec = "\
TGFb : (~Ovol2)(~miR200) : E \n \
Snail1 : (TGFb)(~miR34a) : E \n \
miR200 : (~Snail1)(~Zeb1) : E \n \
Ovol2 : (~Zeb1) \n \
Zeb... |
will-duncan/ramp_systems | tests/test_ramp_system.py | import DSGRN
import numpy as np
from ramp_systems.ramp_function import *
from ramp_systems.ramp_system import *
def test_power_set():
my_list = [0,1,2]
my_list_power_set = {(),(0,),(1,),(2,),(0,1),(0,2),(1,2),(0,1,2)}
power_set_out = {s for s in power_set(my_list)}
assert(my_list_power_set.issubset(pow... |
will-duncan/ramp_systems | src/ramp_to_hill/saddle_node_maps.py | """
saddle_node_maps.py
Implements the N to 1 map from ramp system saddles to hill system saddles for
positive cyclic feedback systems.
To do: implement the map for networks which are not cyclic feedback networks.
Author: <NAME>
TO DO: fix _get_x_jk.
"""
from scipy.optimize import bisect
import numpy as np
... |
will-duncan/ramp_systems | src/ramp_to_hill/ramp_to_hill_function_map.py |
import numpy as np
from scipy.optimize import bisect
from ramp_to_hill.hill_system import *
class RampToHillFunctionMap:
"""
Calling an instance of this class returns a HillParameter which corresponds
to the given RampFunction.
"""
def __init__(self,max_allowed_hill_coefficient = 1e8):
... |
will-duncan/ramp_systems | tests/test_ramp_function.py | <filename>tests/test_ramp_function.py
import DSGRN
import numpy as np
from ramp_systems.ramp_function import *
class TestRampFunction:
def test_call(self):
L = 1
Delta = 1
theta = 1
sign = 1
R = RampFunction(sign,L,Delta,theta)
#eps == 0
assert(... |
will-duncan/ramp_systems | tests/test_cyclic_feedback_system.py |
import DSGRN
from ramp_systems.cyclic_feedback_system import CyclicFeedbackSystem
from ramp_systems.cell import Cell
import sympy
import numpy as np
class TestCyclicFeedbackSystem:
def test_set_attributes(self):
pos_cfs = CyclicFeedbackSystem(*self.positive_toggle())
assert(pos_cfs.cfs_sign == 1... |
will-duncan/ramp_systems | tests/test_saddle_node_maps.py |
from ramp_systems.ramp_function import RampFunction
from ramp_systems.ramp_system import RampSystem
from ramp_systems.cell import Cell
import numpy as np
from ramp_to_hill.saddle_node_maps import *
from ramp_systems.cyclic_feedback_system import CyclicFeedbackSystem
import sympy
import DSGRN
import ramp_systems.decomp... |
will-duncan/ramp_systems | tests/test_hill_system.py | import numpy as np
from ramp_to_hill.hill_system import *
from ramp_systems.ramp_system import RampSystem
import DSGRN
def test_num_unique_vectors():
vectors = [np.array([1,2,3]),np.array([1,1,1]),np.array([1,2,3])]
assert(num_unique_vectors(vectors) == 2)
vectors = [np.array([1,1,1]),np.array([1,2,3]),np.... |
will-duncan/ramp_systems | src/ramp_systems/cyclic_feedback_system.py | """
CyclicFeedbackSystem class and methods. This is a child class of the RampSystem
class (see ramp_system.py).
Author: <NAME>
"""
from ramp_systems.ramp_system import RampSystem
from ramp_systems.cell import Cell
import itertools
import sympy
from sympy.matrices import zeros as sympy_zeros
import numpy as np
impo... |
ahromis/aws-ebs-backup | mount_volume.py | #!/usr/bin/env python
import boto.ec2, os, socket, urllib2, time
from datetime import datetime
block_device = '/dev/xvdf'
region = 'us-east-1'
volume_type = 'gp2'
volume_size = 1
az_url = 'http://169.254.169.254/latest/meta-data/placement/availability-zone'
tag = 'SERVER_BACKUP'
# find current AZ
response = urllib2.... |
ahromis/aws-ebs-backup | backup_volume.py | #!/usr/bin/env python
import boto.ec2, os, socket
from datetime import datetime
max_snapshots = 10 # Number of snapshots to keep
block_device = '/dev/xvdf'
now = datetime.now()
hostname = socket.gethostname()
tag = 'SERVER_BACKUP'
# Connect to EC2 in this region
region = boto.utils.get_instance_metadata()['placeme... |
aumuell/embree | scripts/generate_motion_derivative_coefficients.py | #!/usr/bin/env python3
## Copyright 2009-2021 Intel Corporation
## SPDX-License-Identifier: Apache-2.0
import sympy as sp
import numpy as np
import math
################################################################################
#### Utils
#######################################################################... |
aumuell/embree | scripts/print_size.py | #!/usr/bin/env python3
## Copyright 2009-2021 Intel Corporation
## SPDX-License-Identifier: Apache-2.0
import sys
import os
import re
import subprocess
def printUsage():
sys.stderr.write('Usage: ' + sys.argv[0] + ' libembree.so\n')
sys.exit(1)
if len(sys.argv) < 2:
printUsage()
sys.exit(1)
(cout,sterr) = s... |
wnormandin/hosting_tools | pokeyhost.py | #!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
# PokeyHost library file, the PokeyHost class collects information on the hosting environment
# and can be used to perform various monitoring tasks. Meant to be the back-end library for
# the site_backups.py and site_alerts.py tools, and feeds data to the pokeydash.py ... |
wnormandin/hosting_tools | site_backups.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
import tarfile
import os,os.path
import sys
import time
import logging
import subprocess
import imp
APP_START = time.time() # .clock() unavailable on 2.6?
fw = imp.load_source('PokeyWorks','/home1/wnrmndn/pokeyworks/pokeyworks.py')
# Check for module dependencies (non-... |
cwinkelmann/fetchLandsatSentinelFromGoogleCloud | fels/fels.py | <filename>fels/fels.py<gh_stars>0
"""
# FeLS - Fetch Landsat & Sentinel Data from Google Cloud
Find and download Landsat and Sentinel-2 data from the public Google Cloud
For more info see the
`FeLS GitHub Page <https://github.com/vascobnunes/fetchLandsatSentinelFromGoogleCloud>`_
For command line use see :func:`main`... |
cwinkelmann/fetchLandsatSentinelFromGoogleCloud | fels/__init__.py | <filename>fels/__init__.py<gh_stars>0
# -*- coding: utf-8 -*-
# =============================================================================================
# Copyright 2018 dgketchum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
... |
cwinkelmann/fetchLandsatSentinelFromGoogleCloud | fels/landsat.py | # -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
import csv
import datetime
import os
import socket
import time
import shutil
import ubelt
import dateutil
try:
from urllib2 import urlopen
from urllib2 import HTTPError
from urllib2 import URLError
except ImportError:
... |
cwinkelmann/fetchLandsatSentinelFromGoogleCloud | setup.py | from setuptools import setup
import sys
import os
def parse_version(fpath):
"""
Statically parse the version number from a python file
"""
import ast
if not os.path.exists(fpath):
raise ValueError('fpath={!r} does not exist'.format(fpath))
with open(fpath, 'r') as file_:
source... |
cwinkelmann/fetchLandsatSentinelFromGoogleCloud | fels/utils.py | # -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
import atexit
import gzip
import logging
import os
import shutil
import sqlite3
from pathlib import Path
from loguru import logger
import ubelt
# Set the default output dir to the XDG or System cache dir
# i.e. ~/.cache/fels $XD... |
cwinkelmann/fetchLandsatSentinelFromGoogleCloud | fels/sentinel2.py | <reponame>cwinkelmann/fetchLandsatSentinelFromGoogleCloud
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
import csv
import datetime
import dateutil
import glob
import numpy as np
import os
import shutil
import sys
from bs4 import BeautifulSoup
import pandas as pd
import ubelt... |
KawaiiUroboros/urbanPoaching | soundReco.py | <filename>soundReco.py<gh_stars>0
def printmew():
print('mew') |
KawaiiUroboros/urbanPoaching | app.py | import imghdr
import os
from soundReco import printmew
from random import random
os.environ['CUDA_VISIBLE_DEVICES'] = ''
from PIL import Image
from flask_cors import CORS, cross_origin
from flask import Flask, render_template, request, redirect, url_for, abort, \
send_from_directory, Response, jsonify
from werkzeu... |
EURITO/eurito_daps | eurito_daps/routines/cordis/cordis_neo4j_task.py | """
Cordis to Neo4j
===============
Task for piping Cordis data from SQL to Neo4j.
"""
from nesta.core.orms.cordis_orm import Base
from nesta.core.orms.orm_utils import db_session_query, get_mysql_engine
from nesta.core.orms.orm_utils import graph_session
from nesta.core.luigihacks.luigi_logging import set_log_level
... |
EURITO/eurito_daps | eurito_daps/packages/utils/centrality_utils.py | <filename>eurito_daps/packages/utils/centrality_utils.py<gh_stars>1-10
import logging
from py2neo import Node, NodeMatcher, Relationship
def add_betw_property(graph, igraph, betw):
'''A utility function, which adds calculated betweenness property to each node in Neo4j graph and commits the related transaction ... |
EURITO/eurito_daps | eurito_daps/schemas/tier_1/tests/test_validate.py | import os
import json
from collections import Counter
class TestValidate():
def test_validate(self):
# Load the ontology
cwd = os.path.dirname(__file__)
filename = os.path.join(cwd, '../tier_1.json')
with open(filename) as f:
data = json.load(f)
ontology ... |
EURITO/eurito_daps | eurito_daps/batchables/novelty/lolvelty/run.py | <filename>eurito_daps/batchables/novelty/lolvelty/run.py<gh_stars>1-10
"""
run.py (lolvelty)
-----------------
Calculates the "lolvelty" novelty score to documents
in Elasticsearch, on a document-by-document basis.
Note that this is a slow procedure, and the bounds of
document "lolvelty" can't be known a priori.
"""
... |
EURITO/eurito_daps | eurito_daps/batchables/example/some_task/run.py | '''
run.py (batch_example)
======================
The batchable for the :code:`routines.examples.batch_example`,
which simply increments a muppet's age by one unit.
'''
import os
import logging
from nesta.core.orms.orm_utils import load_json_from_pathstub
from nesta.core.orms.orm_utils import setup_es
from nesta.core... |
EURITO/eurito_daps | eurito_daps/packages/utils/globals.py | <reponame>EURITO/eurito_daps<filename>eurito_daps/packages/utils/globals.py
dbsession = ''
|
EURITO/eurito_daps | eurito_daps/routines/example/example_batch_pipeline.py | '''
Batch Example
=============
An example of building a pipeline with batched tasks.
'''
from nesta.production.luigihacks.mysqldb import MySqlTarget
from nesta.production.luigihacks.misctools import get_config
from nesta.production.luigihacks.misctools import find_filepath_from_pathstub
from nesta.production.luigihac... |
EURITO/eurito_daps | eurito_daps/routines/centrality/centrality.py | <filename>eurito_daps/routines/centrality/centrality.py<gh_stars>1-10
'''
Centrality Pipeline
===================
Takes network from Neo4j database, calculates network centrality measures and updates each node in the database with new centrality attributes
'''
from nesta.core.luigihacks.mysqldb import MySqlTar... |
EURITO/eurito_daps | eurito_daps/packages/utils/silo.py | import boto3
import json
def s3_json_pointer(dataset, bucket, extension=".json"):
"""Retrieve the S3 object pointer, assumed to be json.
Args:
dataset (str): Name of the dataset (the S3 object key will
be constructed as :obj:`dataset` + :obj:`extension`.
bucket (str): N... |
EURITO/eurito_daps | eurito_daps/packages/cordis/cordis_neo4j.py | """
Cordis to Neo4j
---------------
Tools for piping data from a SqlAlchemy ORM to Neo4j,
to be used in the Luigi pipeline.
"""
from py2neo import NodeMatcher
from py2neo.data import Node, Relationship
from sqlalchemy.inspection import inspect
from nesta.core.orms.orm_utils import get_class_by_tablename, object_to_di... |
EURITO/eurito_daps | eurito_daps/routines/es_data/es_data.py | <reponame>EURITO/eurito_daps
"""
Transfer of Elasticsearch data
==============================
This pipeline is responsible for the transfer of Elasticsearch data
from a remote origin (in our case, Nesta's Elasticsearch endpoint)
to EURITO's endpoint.
"""
from es2es import es2es
import luigi
from datetime import date... |
EURITO/eurito_daps | eurito_daps/packages/utils/tests/test_silo.py | <reponame>EURITO/eurito_daps
from unittest import mock
from eurito_daps.packages.utils.silo import get
from eurito_daps.packages.utils.silo import put
from eurito_daps.packages.utils.silo import s3_json_pointer
@mock.patch("eurito_daps.packages.utils.silo.boto3")
def test_s3_json_pointer(mocked_boto3):
obj = s3_... |
EURITO/eurito_daps | setup.py | from setuptools import setup
from setuptools import find_namespace_packages
import os
required = ['nesta @ git+ssh://git@github.com/nestauk/nesta@dev#egg=nesta']
is_travis = 'TRAVIS' in os.environ
exclude = ['docs', 'tests*']
common_kwargs = dict(
version='0.1',
license='MIT',
install_requires=required,
... |
EURITO/eurito_daps | eurito_daps/packages/utils/openaire_utils.py | """
Enrich Cordis with OpenAIRE
===========================
Tools for collecting OpenAIRE data (by Cordis project), and piping
to Neo4j.
"""
from bs4 import BeautifulSoup
import logging
import time
from py2neo import Node
def write_record_to_neo(record, output_type, graph):
'''A utility function,... |
EURITO/eurito_daps | eurito_daps/routines/example/centrality.py | <reponame>EURITO/eurito_daps<filename>eurito_daps/routines/example/centrality.py<gh_stars>1-10
'''
Centrality Pipeline
==============
Takes network from Neo4j database, calculates network centrality measures and updates each node in the database with new centrality attributes
'''
from nesta.core.luigihacks.mys... |
EURITO/eurito_daps | eurito_daps/routines/openaire/openaire_to_neo4j_search.py | '''
OpenAIRE to Neo4j
=================
Pipe data directly from the OpenAIRE API to Neo4j by matching to Cordis projects
already in Neo4j.
'''
from nesta.core.luigihacks.mysqldb import MySqlTarget
from nesta.core.luigihacks.misctools import get_config
from eurito_daps.packages.utils import openaire_utils
... |
EURITO/eurito_daps | eurito_daps/routines/example/openaire_simple_pipeline.py | <gh_stars>1-10
'''
Simple Example
==============
An example of building a pipeline with just a wrapper task and a regular task.
'''
from nesta.core.luigihacks.mysqldb import MySqlTarget
from nesta.core.luigihacks.misctools import get_config
from eurito_daps.packages.utils import openaire_utils
from eurito_d... |
zmehdiz97/Object-DGCNN | ply_utils/convert.py | #!/usr/bin/env python3
import argparse
import os
import d3.model.tools as mt
import functools as fc
from d3.model.basemodel import Vector
def PLYwithRGB(objFile, plyFile):
fileToMake = plyFile[:len(plyFile)-4]
fileToMake = fileToMake+"WithRGB.ply"
objFileOpened = open(objFile,"r")
plyFileOpened = open(plyFile,"r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.