Skip to content
This repository has been archived by the owner on Jul 2, 2019. It is now read-only.

Commit

Permalink
Merge pull request #28 from CosmiQ/dev
Browse files Browse the repository at this point in the history
Release 0.3.1
  • Loading branch information
nrweir authored Dec 14, 2018
2 parents d943ac4 + d6e8688 commit 0011384
Show file tree
Hide file tree
Showing 17 changed files with 253 additions and 15 deletions.
37 changes: 37 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
language: python
sudo: false
python:
- "2.7"
- "3.6"

# command to install dependencies
install:
- sudo apt-get update
# We do this conditionally because it saves us some downloading if the
# version is the same.
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
# switch python version spec in environment.yml to match TRAVIS_PYTHON_VERSION
# annoying workaround to `conda env create python=$TRAVIS_PYTHON_VERSION` not working
- sed -i -E 's/(python=)(.*)/\1'$TRAVIS_PYTHON_VERSION'/' ./environment.yml
- conda env create -n cw-eval --file=environment.yml
- source activate cw-eval
- python --version
- pip install -q -e .
- pip install codecov pytest pytest-cov
# command to run tests
script:
- pytest --cov=./

after_success:
- codecov
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include *.txt
include *.md
include cw_eval/data/*.geojson
2 changes: 1 addition & 1 deletion cw_eval/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

"""cw_eval"""

__version__ = '0.3'
__version__ = '0.3.1'
14 changes: 10 additions & 4 deletions cw_eval/baseeval.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function, with_statement, division

import shapely.wkt
import geopandas as gpd
import pandas as pd
Expand All @@ -22,10 +24,12 @@ def __init__(self, ground_truth_vector_file):
# Load Ground Truth : Ground Truth should be in geojson or shape file
try:
self.ground_truth_GDF = gpd.read_file(ground_truth_vector_file)
except CPLE_OpenFailedError or DriverError: # handles empty geojson
except (CPLE_OpenFailedError, DriverError): # handles empty geojson
self.ground_truth_GDF = gpd.GeoDataFrame({'sindex': [],
'condition': [],
'geometry': []})
except AttributeError: # handles passing gdf instead of path to file
self.ground_truth_GDF = ground_truth_vector_file
self.ground_truth_sindex = self.ground_truth_GDF.sindex # get sindex
# create deep copy of ground truth file for calculations
self.ground_truth_GDF_Edit = self.ground_truth_GDF.copy(deep=True)
Expand Down Expand Up @@ -298,7 +302,8 @@ def load_proposal(self, proposal_vector_file, conf_field_list=['conf'],
case it's assumed to be a .geojson.
pred_row_geo_value : str, optional
The name of the geometry-containing column in the proposal vector
file. Defaults to ``'PolygonWKT_Pix'``.
file. Defaults to ``'PolygonWKT_Pix'``. Note: this method assumes
the geometry is in WKT format.
conf_field_mapping : dict, optional
``'__max_conf_class'`` column value:class ID mapping dict for
multiclass use. Only required in multiclass cases.
Expand All @@ -311,7 +316,8 @@ def load_proposal(self, proposal_vector_file, conf_field_list=['conf'],
-----
Loads in a .geojson or .csv-formatted file of proposal polygons for
comparison to the ground truth and stores it as part of the
``EvalBase`` instance.
``EvalBase`` instance. This method assumes the geometry contained in
the proposal file is in WKT format.
"""

Expand All @@ -331,7 +337,7 @@ def load_proposal(self, proposal_vector_file, conf_field_list=['conf'],
try:
self.proposal_GDF = gpd.read_file(
proposal_vector_file).dropna()
except DriverError or CPLE_OpenFailedError:
except (CPLE_OpenFailedError, DriverError):
self.proposal_GDF = gpd.GeoDataFrame(geometry=[])

if conf_field_list:
Expand Down
2 changes: 2 additions & 0 deletions cw_eval/challenge_eval/off_nadir_dataset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function, with_statement, division

from shapely import geometry
import pandas as pd
from cw_eval import baseeval as bF
Expand Down
2 changes: 1 addition & 1 deletion cw_eval/challenge_eval/spacenet_eval.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Script for executing eval for SpaceNet challenges."""

from __future__ import print_function, with_statement, division
from cw_eval.challenge_eval import off_nadir_dataset
import argparse
import pandas as pd
Expand Down
20 changes: 20 additions & 0 deletions cw_eval/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os
import geopandas as gpd

# define the current directory as `data_dir`
data_dir = os.path.abspath(os.path.dirname(__file__))


def load_geojson(gj_fname):
"""Load a geojson into a gdf using GeoPandas."""
return gpd.read_file(os.path.join(data_dir, gj_fname))


def gt_gdf():
"""Load in a ground truth GDF example."""
return load_geojson('gt.geojson')


def pred_gdf():
"""Load in an example prediction GDF."""
return load_geojson('pred.geojson')
Empty file added cw_eval/data/empty.geojson
Empty file.
Loading

0 comments on commit 0011384

Please sign in to comment.