diff --git a/.travis.yml b/.travis.yml index ef4234e4..4fd27f4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,12 @@ sudo: false # specify different versions of python and numpy env: - - PYTHON=2.7 NUMPY_VERSION=1.13.1 - - PYTHON=3.5 NUMPY_VERSION=1.13.1 - - PYTHON=3.6 NUMPY_VERSION=1.13.1 - - PYTHON=3.7 NUMPY_VERSION=1.15.1 + - PYTHON=2.7 NUMPY_VERSION=1.10.4 CYTHON_VERSION=0.27 + - PYTHON=2.7 NUMPY_VERSION=1.13.1 CYTHON_VERSION=0.27 + - PYTHON=3.5 NUMPY_VERSION=1.13.1 CYTHON_VERSION=0.27 + - PYTHON=3.6 NUMPY_VERSION=1.13.1 CYTHON_VERSION=0.27 + - PYTHON=3.6 NUMPY_VERSION=1.15.1 CYTHON_VERSION=0.27 + - PYTHON=3.6 NUMPY_VERSION=1.15.1 CYTHON_VERSION=0.29 before_install: - wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh diff --git a/tangos/config.py b/tangos/config.py index 66f3f845..ee114f93 100644 --- a/tangos/config.py +++ b/tangos/config.py @@ -13,9 +13,6 @@ default_fileset_handler_class = "pynbody.PynbodyInputHandler" -num_multihops_max_default = 100 -# the maximum number of links to follow when searching for related halos - default_linking_threshold = 0.005 # the percentage of particles in common between two objects before the database bothers to store the relationship @@ -47,6 +44,10 @@ mergertree_timeout = 15.0 # seconds before abandoning the construction of a merger tree in the web interface mergertree_max_hops = 500 # maximum number of timesteps to scan +# relation finding paremeters for multi hop queries +num_multihops_max_default = 100 # the maximum number of links to follow when searching for related halos +max_relative_time_difference = 1e-4 # the maximum fractional difference in time between two contemporaneous timesteps when searching for related halos + # On some network file systems, concurrency using sqlite is dodgy to say the least. After committing a transaction # on one node, and before attempting to open a new transaction on another node, it seems empirically helpful to # allow a significant time delay. This variable controls that delay. diff --git a/tangos/relation_finding/multi_hop.py b/tangos/relation_finding/multi_hop.py index 6c3062f1..d52c094d 100644 --- a/tangos/relation_finding/multi_hop.py +++ b/tangos/relation_finding/multi_hop.py @@ -17,13 +17,9 @@ from .one_hop import HopStrategy from ..config import num_multihops_max_default as NHOPS_MAX_DEFAULT +from ..config import max_relative_time_difference as SMALL_FRACTION from six.moves import range -# Fractional increase or decrease in time to represent future or past when making hops -# (prevents numerical accuracy issues making the db misunderstand a contemporaneous step -# as being in the future or past) -SMALL_FRACTION = 1e-4 - class MultiHopStrategy(HopStrategy): """An extension of the HopStrategy class that takes multiple hops across HaloLinks, up to a specified maximum, before finding the target halo.""" @@ -163,7 +159,8 @@ def _generate_link_filter(self, timestep_old, timestep_new, table): existing_timestep_ids = self.session.query(core.Halo.timestep_id).\ select_from(self._link_orm_class).join(self._link_orm_class.halo_to).distinct() recursion_filter &= ~timestep_new.id.in_(existing_timestep_ids) - recursion_filter &= sqlalchemy.func.abs(timestep_new.time_gyr - timestep_old.time_gyr) < SMALL_FRACTION + recursion_filter &= sqlalchemy.func.abs(timestep_new.time_gyr - timestep_old.time_gyr) \ + < SMALL_FRACTION * timestep_old.time_gyr else: raise ValueError("Unknown direction %r" % directed)