Skip to content

ajponte/range_query_intervals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tsrange-intervals

Range Query Intervals

This project is an example of how to use a Range Tree to find overlapping intervals, where each interval represent a start and end epoch value.

In Postgres, this can be implemented in a fairly straightforward way using tsrange.

Range Interface

A range's interface can be thought of a Relation of a partially ordered set. The infimum of the set should be a direct mapping to models.partial_interval.

For instance, on the set with keys (K1, K2, ...Kn), where K1 <= K2 <=...<=Kn, and values (V1, V2, ...Vn), a relation would be a mapping R(k): k -> v.

The relation is encapuslated in PartialInverval through the open_interval and label values, where open_interval is the infimum of (K1, K2, ...Kn).

Package Management

Poetry

This project uses poetry for package management.

Tox Automation

This project includes a tox.ini file to automate tasks such as

  • invoking pytest
  • linting
  • formatting
  • type-checking
  • distribution building.

A fresh tox build can be invoked via tox -r, which whill invoke each task. See https://github.com/tox-dev/tox for more info.

Distribution

A local distribution of the package can be created either through

 poetry build

or

 tos -e dist

Since the build is dependent on poetry, the commands are equivalent.

Unit Tests

This project uses pytest. You can invoke tests in a poetry environment, via

 poetry run pytest tests

Formatting

This project uses black to enforce PEP-8 formatting rules. You can format any file with

 poetry run black <target>

where <target> is the directory or file to run the tool on.

With tox, you can also check formatting any time with

 tox -e format

Note that since tox is intended to be invoked as part of a CI pipeline, we will never rewrite files.

Type Checking

This project (somewhat) enforces static typing through mypy.

About

Experimenting with range queries

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages