Skip to content

Commit

Permalink
House keeping - fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrouswheel committed Mar 19, 2013
1 parent 8ea1fa3 commit 700552d
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 53 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ test/repository/variables/model.xml.bak1
test/repository/variables/model.xml.bak2
../test/grass_location/PERMANENT/.bashrc
*.pyc
grass-modules/**/*.tmp.html
grass-modules/**/OBJ*
*.swp
*.un~
47 changes: 22 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
# MDiG - Modular Dispersal in GIS
# mdig - Modular Dispersal in GIS

## Requirements
## Setup

- [**GRASS 6.4RC5**](http://grass.itc.it/download/index.php) or later, hasn't been tested with the new GRASS 7.0.
In particular, we recommend an SVN snapshot as RC5 has an annoying
g.region issue that can be confusing for new users.
- [**GDAL 1.6.0**](http://trac.osgeo.org/gdal/wiki/DownloadingGdalBinaries) or later (earlier versions have bugs)
Although it is a GRASS requirement instead of a direct MDiG one, stuff can
break if you have earlier buggy versions.

- ImageMagick's convert utility (imagemagick)
- [lxml](http://codespeak.net/lxml/) and its dependency, the [Gnome XML library](http://xmlsoft.org/)
- GNU Scientific Library (libgsl, libgsl0-dev) http://www.gnu.org/software/gsl/

sudo apt-get install \
gsl-bin libgsl0-dev bc libxml2 libxml2-dev python-lxml python-imaging-tk \
python-scipy python-matplotlib python-numpy python-configobj python-paste \
python-simplejson imagemagick

- Python dependencies
sudo apt-get install grass grass-dev
sudo apt-get install libxml2 libxml2-dev gsl-bin libgsl0-dev imagemagick bc

# Numpy and scipy are potentially finicky, so safest to install them separate
# and in order:
mkvirtualenv mdig
pip install numpy
pip install scipy
# Rest of python dependencies should be fine, ensure you are in mdig root dir
pip install -r requirements.txt

## Compile modules
That's the core mdig simulation manager, but to install the custom GRASS
modules that are particularly useful for people modelling dispersal:

Change into MDiG's grass-module dir
cd grass-modules
sudo make MODULE_TOPDIR=/usr/lib/grass64

cd mdig/grass-modules
Or if you installed GRASS from source, you can do something like:

and run:

export GRASS_SRC=~/src/grass63_release
export GRASS_SRC=~/src/grass64_release
make -S MODULE_TOPDIR=$GRASS_SRC
cd $GRASS_SRC
make install
Expand All @@ -41,3 +32,9 @@ These are the requests that I've had for MDiG to support:

* [PRIORITY] Keep track of area treated by management strategies.

## Troubleshooting

Older versions of requirements have some bugs to be aware of:

* GRASS 6.4RC5 has an annoying g.region issue that can be confusing for new users.
* GDAL <1.6.0 or later, earlier versions can run into segfaults.
22 changes: 8 additions & 14 deletions TESTING
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
If you wish to run the unit tests for MDiG while developing code, then install
nosetests for python which is a testing framework, and optionally "coverage"
which is to measure the code coverage of tests:
If you wish to run the unit tests for MDiG while developing code, then go to
the mdig program directory ('mdig/' from the root of the source) and run:

easy_install nose coverage paste

Then if you go to the mdig program directory (mdig/ from the root of the source)
and run:

nosetests -v
nosetests -v

Or to run with code coverage analysis:

nosetests -v --with-coverage
nosetests -v --with-coverage

You'll run a bunch of tests to check everything's working correctly.

Note - currently only basic tests are run, more rigarous tests are
needed (although this has been greatly improved over the last year):
* More model files that more thoroughly test the potential model types.
Note - currently only basic tests are run, more rigorous tests are needed
(although this has been greatly improved over the last year):

* Additional model files that more thoroughly test the potential model types.
* More coverage in unit tests for components within MDiG.
* Comparison of the output maps from various models versus what the expected map
should look like. For modules, create before and after maps and make sure they
have no difference,implement as a shell script to be run within GRASS.

16 changes: 9 additions & 7 deletions mdig/mdig/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,20 @@ def find_grass_base_dir():
opts = glob.glob(os.path.join(os.environ['OSGEO4W_ROOT'],'apps\\grass\\grass-*'))
else:
opts = glob.glob('/usr/local/grass-*')
if len(opts) > 0: return opts[-1]
else: return None
opts.extend(glob.glob('/usr/lib/grass*'))
if len(opts) > 0:
return opts[-1]

def find_grassdb_dir():
# TODO find from GRASS environment if it exists
# find from guessing /home/user/src/mdig/test
my_path = os.path.normpath(os.path.join(home_dir, '..', 'src/mdig/test'))
if os.path.isdir(my_path): return my_path
if os.path.isdir(my_path):
return my_path
if 'OSGEO4W_ROOT' in os.environ:
my_path = os.path.normpath(os.path.join(os.environ['OSGEO4W_ROOT'], 'src/mdig/test'))
if os.path.isdir(my_path): return my_path
return None
if os.path.isdir(my_path):
return my_path

def find_location_dir():
# TODO find from GRASS environment if it exists
Expand All @@ -127,7 +129,6 @@ def find_location_dir():
if os.path.isdir(d) and \
os.path.isdir(os.path.join(d,'PERMANENT')):
return os.path.basename(d)
return None

class MDiGConfig(ConfigObj):

Expand Down Expand Up @@ -311,7 +312,8 @@ def prompt_for_config(self,section,k,fresh):
if section in MDiGConfig.required \
and k in MDiGConfig.required[section]:
guess = MDiGConfig.required[section][k]
if guess: guess = guess() # guess should be a callable
if guess:
guess = guess() # guess should be a callable
if not fresh:
print "While setting up config, required parameter %s:%s was missing" % (section,k)
is_done = False
Expand Down
5 changes: 1 addition & 4 deletions mdig/mdig/grass.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import logging
import random
import re
import signal
import pdb
import subprocess
from subprocess import Popen
import StringIO
Expand Down Expand Up @@ -251,7 +249,6 @@ def init_pid_specific_files(self):
os.environ["GISRC"]=gisrc_fn

def get_version_from_dir(self):
import re
if sys.platform == 'win32':
# TODO - place this in config and make NSIS script write it
self.grass_version = "6.4.0svn"
Expand All @@ -260,7 +257,7 @@ def get_version_from_dir(self):
try:
x=re.match(r'grass-(\d\.\d\.[\d\w]+)', end_bit)
self.grass_version = x.groups()[0]
except IndexError, e:
except (IndexError, AttributeError):
self.grass_version = "6.4.0svn"
return self.grass_version

Expand Down
1 change: 1 addition & 0 deletions mdig/mdig/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def setup():
# Copy test repository
c = config.get_config()
c['GRASS']['GISBASE'] = config.find_grass_base_dir()
assert c['GRASS']['GISBASE'], "Couldn't find GRASS GISBASE"
global test_dir
test_dir = tempfile.mkdtemp(prefix="mdig_test_")
end_part = os.path.split(c['GRASS']['GISDBASE'])[1]
Expand Down
2 changes: 1 addition & 1 deletion mdig/mdig/tests/mdig.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GRASS_HTML_BROWSER = firefox
GRASS_MESSAGE_FORMAT = silent
GRASS_GNUPLOT = gnuplot -persist
MAPSET = PERMANENT
GISBASE = c:\\mdig
GISBASE = /usr/lib/grass64
GISDBASE = ../test
GRASS_TRUECOLOR = TRUE
GRASS_PAGER = cat
Expand Down
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ python-dateutil<2.0
numpy
scipy
matplotlib
imagetk
pillow
nose
coverage
paste

mock

0 comments on commit 700552d

Please sign in to comment.