Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match with slightly unequal timestep times #94

Merged
merged 6 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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