Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Merge pull request #74 from mhearne-usgs/containerfix
Browse files Browse the repository at this point in the history
Fixed issues in container get*s functions, updated installer to use n…
  • Loading branch information
emthompson-usgs authored May 8, 2018
2 parents a814677 + 8a5fb1a commit 93b5a33
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build
.DS_Store
.ipynb_checkpoints/
.cache
.pytest_cache/
.coverage
.coverage.xml
htmlcov
Expand Down
10 changes: 10 additions & 0 deletions impactutils/io/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ def getDictionaries(self):
Returns:
(list) List of names of dictionaries stored in container.
"""
if GROUPS['dict'] not in self._hdfobj:
return []
dictionaries = list(self._hdfobj[GROUPS['dict']].keys())
dictionaries = [name.replace('__', '') for name in dictionaries]
return dictionaries
Expand Down Expand Up @@ -219,6 +221,8 @@ def getLists(self):
Returns:
list: List of names of lists stored in container.
"""
if GROUPS['list'] not in self._hdfobj:
return []
lists = list(self._hdfobj[GROUPS['list']].keys())
lists = [name.replace('__', '') for name in lists]
return lists
Expand Down Expand Up @@ -312,6 +316,8 @@ def getArrays(self):
Returns:
list: List of names of arrays stored in container.
"""
if GROUPS['array'] not in self._hdfobj:
return []
arrays = list(self._hdfobj[GROUPS['array']].keys())
arrays = [name.replace('__', '') for name in arrays]
return arrays
Expand Down Expand Up @@ -386,6 +392,8 @@ def getStrings(self):
Returns:
(list) List of names of strings stored in container.
"""
if GROUPS['string'] not in self._hdfobj:
return []
strings = list(self._hdfobj[GROUPS['string']].keys())
strings = [name.replace('__', '') for name in strings]
return strings
Expand Down Expand Up @@ -469,6 +477,8 @@ def getDataFrames(self):
Returns:
list: List of names of dictionaries stored in container.
"""
if GROUPS['dataframe'] not in self._hdfobj:
return []
dataframes = list(self._hdfobj[GROUPS['dataframe']].keys())
dataframes = [name.replace('__', '') for name in dataframes]
return dataframes
Expand Down
21 changes: 15 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

VENV=impact

unamestr=`uname`
if [ "$unamestr" == 'Linux' ]; then
source ~/.bashrc
elif [ "$unamestr" == 'FreeBSD' ] || [ "$unamestr" == 'Darwin' ]; then
source ~/.bash_profile
fi

# Is the reset flag set?
reset=0
while getopts r FLAG; do
Expand All @@ -15,12 +22,14 @@ done


# Is conda installed?
conda=$(which conda)
if [ ! "$conda" ] ; then
conda --version
if [ $? -ne 0 ] ; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
-O miniconda.sh;
bash miniconda.sh -f -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
# Need this to get conda into path
. $HOME/miniconda/etc/profile.d/conda.sh

fi

# Choose OS-specific environment file, which specifies
Expand All @@ -43,7 +52,7 @@ fi
echo "Environment file: $env_file"

# Turn off whatever other virtual environment user might be in
source deactivate
conda deactivate

# Create a conda virtual environment
echo "Creating the $VENV virtual environment:"
Expand All @@ -57,11 +66,11 @@ fi

# Activate the new environment
echo "Activating the $VENV virtual environment"
source activate $VENV
conda activate $VENV

# This package
echo "Installing impact-utils..."
pip install -e .

# Tell the user they have to activate this environment
echo "Type 'source activate $VENV' to use this new virtual environment."
echo "Type 'conda activate $VENV' to use this new virtual environment."
4 changes: 3 additions & 1 deletion test/comcat/query_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_cc():
'nc72592670': ['us200050nt', 'nn00531804']}

for eventid, cmp_allids in eventids.items():
print(eventid)
ccinfo = ComCatInfo(eventid)
authid, allids = ccinfo.getAssociatedIds()
authsource, othersources = ccinfo.getAssociatedSources()
Expand All @@ -60,6 +61,7 @@ def test_cc():
'at00o30yrz': 'ci37528064',
'us200050nt': 'nc72592670'}
for eventid, cmp_authid in non_auth_ids.items():
print(eventid)
ccinfo = ComCatInfo(eventid)
authid, allids = ccinfo.getAssociatedIds()
assert cmp_authid == authid
Expand Down Expand Up @@ -111,4 +113,4 @@ def test_cc():

if __name__ == '__main__':
test_cc()
test_geoserve()
geoserve()
8 changes: 8 additions & 0 deletions test/io/container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ def test_hdf_dictonaries():
try:
container = HDFContainer.create(testfile)

# before we put anything in here, let's make sure we get empty lists from
# all of the methods that are supposed to return lists of stuff.
assert container.getDictionaries() == []
assert container.getLists() == []
assert container.getArrays() == []
assert container.getStrings() == []
assert container.getDataFrames() == []

# test simple dictionary
print('Test simple dictionary...')
indict1 = {'name': 'Fred', 'age': 34,
Expand Down

0 comments on commit 93b5a33

Please sign in to comment.