-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tom Tranter
committed
Jan 13, 2018
1 parent
aa38bf6
commit e648388
Showing
8 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ | |
|
||
# Python egg metadata, regenrated from source files in setuptools | ||
/*.egg-info | ||
.cache/ | ||
.coverage |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
sudo: false | ||
|
||
language: python | ||
|
||
python: | ||
- "3.5" | ||
- "3.6" | ||
|
||
before_install: | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start | ||
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh | ||
- bash miniconda.sh -b -p $HOME/miniconda | ||
- export PATH="$HOME/miniconda/bin:$PATH" | ||
|
||
install: | ||
- conda install --yes python=$TRAVIS_PYTHON_VERSION --file requirements/conda_requirements.txt | ||
- pip install -r requirements/pypi_requirements.txt | ||
- pip install -r requirements/test_requirements.txt | ||
- python setup.py install | ||
|
||
script: pytest --pep8 --cov=./ | ||
|
||
notifications: | ||
email: false | ||
|
||
after_success: | ||
- codecov |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
codecov: | ||
branch: master | ||
|
||
coverage: | ||
precision: 2 | ||
round: down | ||
range: "50...100" | ||
|
||
status: | ||
project: | ||
default: | ||
target: auto | ||
threshold: null | ||
branches: null | ||
|
||
patch: | ||
default: | ||
target: auto | ||
branches: null | ||
|
||
comment: | ||
layout: "header, diff, changes, sunburst, uncovered" | ||
branches: null | ||
behavior: default |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
numpy | ||
scipy | ||
matplotlib |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
gitpython | ||
tqdm |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
numpydoc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
codecov | ||
coverage | ||
pep8 | ||
pytest | ||
pytest-cache | ||
pytest-cov | ||
pytest-pep8 | ||
gitpython |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import porespy as ps | ||
import pytrax as pt | ||
import scipy as sp | ||
import os | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
class SimulationTest(): | ||
def setup_class(self): | ||
self.l = 100 | ||
self.im = ps.generators.overlapping_spheres(shape=[self.l, self.l], | ||
radius=5, | ||
porosity=0.5) | ||
self.blobs = ps.generators.blobs([self.l, self.l, self.l]) | ||
self.rw = pt.RandomWalk(self.blobs) | ||
self.blobs_2d = ps.generators.blobs([self.l, self.l]).astype(int) | ||
self.rw_2d = pt.RandomWalk(self.blobs_2d, seed=True) | ||
|
||
def test_random_walk(self): | ||
self.rw.run(nt=1000, nw=100, stride=1) | ||
assert sp.shape(self.rw.real_coords) == (1000, 100, 3) | ||
|
||
def test_plot_msd(self): | ||
self.rw.plot_msd() | ||
pass | ||
|
||
def test_random_walk_2d(self): | ||
self.rw_2d.run(nt=1000, nw=100, same_start=True, stride=100) | ||
assert sp.shape(self.rw_2d.real_coords) == (10, 100, 2) | ||
|
||
def test_plot_walk_2d(self): | ||
self.rw_2d.plot_walk_2d(data='w') | ||
assert hasattr(self.rw_2d, 'im_big') | ||
assert sp.sum(self.rw_2d.im_big > self.rw_2d.nw) == 0 | ||
plt.close('all') | ||
|
||
def test_export(self): | ||
cwd = os.getcwd() | ||
self.rw_2d.export_walk(sub='temp', image=self.rw_2d.im, sample=10) | ||
subdir = os.path.join(cwd, 'temp') | ||
assert os.path.exists(subdir) | ||
file_list = os.listdir(subdir) | ||
# 10 coordinate files based on the stride and number of steps + image | ||
assert len(file_list) == 11 | ||
# Delete all files and folder | ||
for file in file_list: | ||
fp = os.path.join(subdir, file) | ||
os.remove(fp) | ||
os.rmdir(subdir) | ||
|
||
def test_seed(self): | ||
# rw_2d was initialized with seed = True, this should mean running it | ||
# repeatedly produces the same movements | ||
self.rw_2d.run(nt=1000, nw=100, same_start=True) | ||
temp_coords = self.rw_2d.real_coords.copy() | ||
self.rw_2d.run(nt=1000, nw=100, same_start=True) | ||
assert sp.allclose(self.rw_2d.real_coords, temp_coords) | ||
|
||
def test_axial_density_plot(self): | ||
self.rw.axial_density_plot(time=0, axis=0) | ||
plt.close('all') | ||
|
||
def test_rw_analytics(self): | ||
w_list = [10, 100] | ||
t_list = [10, 100] | ||
self.rw_2d.run_analytics(w_list, t_list, fname='test.csv') | ||
cwd = os.getcwd() | ||
fpath = os.path.join(cwd, 'test.csv') | ||
assert os.path.exists(fpath) | ||
os.remove(fpath) | ||
plt.close('all') | ||
|
||
if __name__ == '__main__': | ||
t = SimulationTest() | ||
t.setup_class() | ||
t.test_random_walk() | ||
t.test_plot_msd() | ||
t.test_random_walk_2d() | ||
t.test_plot_walk_2d() | ||
t.test_export() | ||
t.test_seed() | ||
t.test_axial_density_plot() | ||
t.test_rw_analytics() |