Skip to content

Instantly share code, notes, and snippets.

View tylerjereddy's full-sized avatar

Tyler Reddy tylerjereddy

View GitHub Profile
@tylerjereddy
tylerjereddy / test.py
Created April 15, 2019 21:17
Generate test cases for NumPy gh-10741
import numpy as np
import pytest
import hypothesis
from hypothesis import given, settings
from hypothesis import strategies as st
from hypothesis.extra import numpy as hynp
@settings(max_examples=5)
@given(st.floats(min_value=0, max_value=1, width=64),
st.integers(np.finfo(np.double).minexp, np.finfo(np.double).maxexp - 1)
@tylerjereddy
tylerjereddy / warning_probe.py
Last active September 22, 2018 00:07
NumPy warnings parallel test fidelity probe
import subprocess
trials = 20
pass_counts = 0
fail_counts = 0
for i in range(trials):
print("trial number:", i)
try:
o = subprocess.check_output('python runtests.py -t "numpy/testing/tests/test_utils.py" -- -n 4', shell=True)
@tylerjereddy
tylerjereddy / calc_center.py
Created December 2, 2016 17:50
MDA rhombic dodecahedron PBC testing
import MDAnalysis
import numpy as np
from scipy.spatial.distance import euclidean
u = MDAnalysis.Universe('split_rhombic_small.gro')
residue = u.atoms.residues[0]
residue_centroid_no_pbc = residue.atoms.centroid(pbc=False)
residue_centroid = residue.atoms.centroid(pbc=True)
head_centroid_distance = euclidean(residue.atoms.positions[0],
residue_centroid)
@tylerjereddy
tylerjereddy / process_MDA_strings_github_migration.py
Created April 8, 2015 15:03
process_MDA_strings_github_migration
'''Module to assess and adjust URLs / links in MDA project documentation after recent move to github.'''
import os
import subprocess
for dirname, dirnames, filenames in os.walk('/Users/treddy/python_modules/MDAnalysis/MDA_dev/mdanalysis/'):
# print path to all filenames.
#for filename in filenames:
#print os.path.join(dirname, filename)
#print all lines from .py files with OLD HOMEPAGE URLs in them:
@tylerjereddy
tylerjereddy / MDA_julia_test_1.jl
Created July 3, 2014 09:58
Test #1 for using Python MDAnalysis module within the Julia numerical computing language
#if you don't have the Julia PyCall library you can install it with Pkg.add("PyCall") as the first line in this code
using PyCall
@pyimport MDAnalysis
#careful with dotted imports--need simpler module name representation for usage in Julia
@pyimport MDAnalysis.tests.datafiles as MDT
#can now use MDAnalysis seamlessly and leverage some of the powerful features of the Julia numerical computing language
u = MDAnalysis.Universe(MDT.GRO,MDT.XTC) #although this works very naturally, many MDA methods currently require pycall invocation
all_atom_selection = pycall(u["selectAtoms"],PyAny,"all") #double quotes only for the "all" string--single quotes are character literals in Julia