Commit 68cfc91d authored by Jay's avatar Jay
Browse files

Removes unused health module and observables

parents 9ba884b8 51b2d115
Loading
Loading
Loading
Loading
+28 −21
Original line number Diff line number Diff line
sudo: false

language: python
python:
  - "3.5"

branches:
only:
  - master
@@ -11,24 +7,24 @@ only:
env:
  global:
    - BINSTAR_USER: jlaura
  matrix:
    - PYTHON_VERSION: 3.5

os:
  - linux
  - osx

before_install:

install:
  # We do this conditionally because it saves us some downloading if the
  # version is the same.
  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then
      if [ "$TRAVIS_PYTHON_VERSION" == 2.7 ]; then
      if [ "$PYTHON_VERSION" == 2.7 ]; then
        wget https://repo.continuum.io/miniconda/Miniconda-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
    else
      if ["$TRAVIS_PYTHON_VERSION" == 2.7]; then
      if ["$PYTHON_VERSION" == 2.7]; then
        curl -o miniconda.sh  https://repo.continuum.io/miniconda/Miniconda-latest-MacOSX-x86_64.sh;
      else
        curl -o miniconda.sh  https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh;
@@ -42,30 +38,41 @@ install:
  # Useful for debugging any issues with conda
  - conda info -a

  - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION
  - source activate test-environment

  # Install dependencies
  - conda config --add channels conda-forge
  - conda config --add channels menpo
  - conda config --add channels jlaura
  - conda config --set ssl_verify false
  - conda install python=$PYTHON_VERSION
  - conda install -c conda-forge numpy
  # The plio install is pulling in pandas as well.
  - conda install -c jlaura plio
  - conda install -c conda-forge vlfeat opencv3
  - conda install -c jlaura plio opencv3=3.0.0
  - conda install -c conda-forge vlfeat
  - conda install -c menpo cyvlfeat
  - conda install scipy networkx numexpr cython pyyaml pillow matplotlib
  - pip install pillow pysal
  - conda install scipy networkx numexpr dill cython pyyaml matplotlib runipy

  # Development installation
  - conda install pytest sh anaconda-client
  - pip install pytest-cov
  - conda install pytest pytest-cov coverage sh anaconda-client
  - pip install coveralls
  - python runipynbs.py

script:
  - py.test --cov-report term-missing --cov=autocnet .
  - conda config --set anaconda_upload True
  - conda build conda --user $BINSTAR_USER --token $BINSTAR_KEY
    # Straight from the menpo team
  - if [["$TRAVIS_OS_NAME" == "osx"]]; then
      curl -o condaci.py https://raw.githubusercontent.com/menpo/condaci/v0.4.8/condaci.py;
    else
      wget https://raw.githubusercontent.com/menpo/condaci/v0.4.8/condaci.py -O condaci.py;
    fi
    # Build autocnet and push to anaconda cloud
  - python condaci.py setup

script:
  - pytest --cov=autocnet
  # clean up any remaining processes...
  - if [ $TRAVIS_OS_NAME == "linux" ]; then killall5; fi

after_success:
  # Upload to anaconda and push to coveralls
  - ~/miniconda/bin/python condaci.py build ./conda
  - coveralls

notifications:
+2 −2
Original line number Diff line number Diff line
@@ -158,8 +158,8 @@ class CorrespondenceNetwork(object):

            destination_idx = int(df['destination_idx'][k])

            sidx = Correspondence(source_idx, *s_kps[source_idx], serial=edge.source.isis_serial)
            didx = Correspondence(destination_idx, *d_kps[destination_idx], serial=edge.destination.isis_serial)
            sidx = Correspondence(source_idx, *s_kps[int(source_idx)], serial=edge.source.isis_serial)
            didx = Correspondence(destination_idx, *d_kps[int(destination_idx)], serial=edge.destination.isis_serial)

            p.correspondences = [sidx, didx]

autocnet/matcher/health.py

deleted100644 → 0
+0 −35
Original line number Diff line number Diff line
import warnings


class EdgeHealth(object):
    """
    Storage and computation of the health of a graph edge using the metric:


    """

    def __init__(self):
        self.FundamentalMatrix = 0.0

    @property
    def health(self):
        return self.recompute_health()

    def update(self, *args, **kwargs):
        """
        Pass through called when the observable (model) changes.
        *args and **kwargs are passed through from the observable.
        """
        for k, v in kwargs.items():
            if hasattr(self, k):
                setattr(self, k, v)

    def recompute_health(self):
        """
        Recompute the health of the edge.
        """
        try:
            return self.FundamentalMatrix.error.mean()
        except:
            warnings.warn('Unable to compute new health, defaulting to 1.0')
            return 1.0
+0 −20
Original line number Diff line number Diff line
import unittest

from .. import health


class TestEdgeHealth(unittest.TestCase):

    def setUp(self):
        self.H = health.EdgeHealth()

    def test_fundamental(self):
        self.assertEqual(self.H.FundamentalMatrix, 0.0)

    def test_update(self):
        self.H.foo = 'a'
        self.H.bar = 1
        self.H.update(**{'foo': 'b', 'bar': 2})

        self.assertEqual(self.H.foo, 'b')
        self.assertEqual(self.H.bar, 2)

autocnet/utils/observable.py

deleted100644 → 0
+0 −85
Original line number Diff line number Diff line
import abc


class Observable(object):

    """
    Abstract Base Class representing some observable object that can
    register observers and update them on change.  The object is stateful
    and managed do/undo functionality.
    """

    __metaclass__ = abc.ABCMeta

    @abc.abstractmethod
    def subscribe(self, func):
        """
        Subscribe some observer to the edge

        Parameters
        ----------
        func : object
               The callable that is to be executed on update
        """
        self._observers.add(func)

    @abc.abstractmethod
    def _notify_subscribers(self, *args, **kwargs):
        """
        The 'update' call to notify all subscribers of
        a change.
        """
        for update_func in self._observers:
            update_func(*args, **kwargs)

    @abc.abstractmethod
    def rollforward(self, n=1):
        """
        Roll forwards in the object history, e.g. do

        Parameters
        ----------
        n : int
            the number of steps to roll forwards
        """
        idx = self._current_action_stack + n
        if idx > len(self._action_stack) - 1:
            idx = len(self._action_stack) - 1

        self._current_action_stack = idx
        state = self._action_stack[idx]
        for a in self.attrs:
            setattr(self, a, state[a])
        # Reset attributes (could also cache)
        self._notify_subscribers(self)

    @abc.abstractmethod
    def rollback(self, n=1):
        """
        Roll backward in the object histroy, e.g. undo

        Parameters
        ----------
        n : int
            the number of steps to roll backwards
        """
        idx = self._current_action_stack - n
        if idx < 0:
            idx = 0
        self._current_action_stack = idx
        state = self._action_stack[idx]
        for a in self.attrs:
            setattr(self, a, state[a])

        # Reset attributes (could also cache)
        self._notify_subscribers(self)

    @abc.abstractmethod
    def _update_stack(self, state):
        self._action_stack.append(state)
        self._current_action_stack = len(self._action_stack) - 1
        self._notify_subscribers

    @abc.abstractmethod
    def _clean_attrs(self):
        pass
Loading