Skip to content

Commit

Permalink
Merge pull request #94 from Martin-Rey/issue-93
Browse files Browse the repository at this point in the history
Match with slightly unequal timestep times
  • Loading branch information
apontzen authored Feb 21, 2019
2 parents 357e0bc + 56a55d1 commit 0d9be11
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions tangos/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
9 changes: 3 additions & 6 deletions tangos/relation_finding/multi_hop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 0d9be11

Please sign in to comment.