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

Renaming the package to r-tree #31

Merged
merged 11 commits into from
Sep 8, 2024
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
55 changes: 0 additions & 55 deletions .circleci/config.yml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI
on:
- push
- pull_request

defaults:
run:
shell: bash

jobs:
main:
name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

# https://github.com/orgs/community/discussions/57827
if: github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name !=
github.event.pull_request.base.repo.full_name

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
ghc:
- "9.0"
- "9.2"
- "9.4"
- "9.6"
- "9.8"
- "9.10"

steps:

- uses: actions/checkout@v4

- uses: haskell-actions/setup@v2
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}

- uses: actions/cache@v4
name: Cache cabal stuff
with:
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}

- name: Cabal version
run: |
cabal --version

- name: Build & Test
run: |
cabal build --enable-tests
cabal test --enable-tests --test-show-details=direct properties
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 1.0.0.0 -- September 2024

- Initial rewrite.
- Library renamed from `data-r-tree`.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
data-r-tree
# r-tree [![Hackage](http://img.shields.io/hackage/v/r-tree.svg)](https://hackage.haskell.org/package/r-tree)

---
A Haskell library for [R-trees](https://en.wikipedia.org/wiki/R-tree) and [R\*-trees](https://en.wikipedia.org/wiki/R\*-tree).

R/R\*-trees, currently only two-dimensional `Float` and `Double` varieties.
> [!NOTE]
>
> R-trees are self-balancing and as such can only be spine-strict.

Featuring:

- `Data.R2Tree.*`: two-dimensional R-tree with the R\*-tree insertion algorithm.

`Double`-based implementation is considered the default one;
a `Float`-based variant is provided for cases where reduced precision is preferred,
for example rendering.

Higher-dimensional R-trees are not currently provided,
but should be trivial to add if needed.
2 changes: 1 addition & 1 deletion benchmark/space/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Main where

import qualified Data.RTree.D2.Float as R
import qualified Data.R2Tree.Float as R

import Control.Monad
import Data.Foldable
Expand Down
20 changes: 10 additions & 10 deletions benchmark/time/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

module Main where

import Data.RTree.D2.Double (RTree, MBR, Predicate)
import qualified Data.RTree.D2.Double as R
import Data.R2Tree.Double (R2Tree, MBR, Predicate)
import qualified Data.R2Tree.Double as R

import Control.DeepSeq
import Control.Monad
import Data.Foldable
import Data.List hiding (lookup, map)
import Data.Monoid
import Gauge
import Prelude hiding (lookup, map)
import System.Random.Stateful
import Test.Tasty.Bench



Expand Down Expand Up @@ -51,7 +51,7 @@ genAreas n = replicateM n . randPoint


lookup
:: String -> ([(MBR, Int)] -> RTree Int)
:: String -> ([(MBR, Int)] -> R2Tree Int)
-> String -> (MBR -> Predicate) -> Benchmark
lookup cat from name pre =
env ( do g <- newIOGenM $ mkStdGen 0
Expand All @@ -70,7 +70,7 @@ lookup cat from name pre =


map
:: String -> ([(MBR, Int)] -> RTree Int)
:: String -> ([(MBR, Int)] -> R2Tree Int)
-> String -> (MBR -> Predicate) -> Benchmark
map cat from name pre =
env ( do g <- newIOGenM $ mkStdGen 0
Expand All @@ -83,7 +83,7 @@ map cat from name pre =
fmap $ \x -> [R.adjustRangeWithKey (pre x) (\_ -> (+) 1) r]

traversal
:: String -> ([(MBR, Int)] -> RTree Int)
:: String -> ([(MBR, Int)] -> R2Tree Int)
-> String -> (MBR -> Predicate) -> Benchmark
traversal cat from name pre =
env ( do g <- newIOGenM $ mkStdGen 0
Expand All @@ -96,11 +96,11 @@ traversal cat from name pre =
traverse $ \x -> fmap (:[]) $ R.traverseRangeWithKey (pre x) (\_ -> pure @IO . (+) 1) r


fromList :: Foldable t => t (MBR, b) -> RTree b
fromList = foldr (uncurry R.insert) R.empty
fromList :: Foldable t => t (MBR, b) -> R2Tree b
fromList = foldl' (\z (a, b) -> R.insert a b z) R.empty

fromListGut :: Foldable t => t (MBR, b) -> RTree b
fromListGut = foldr (uncurry R.insertGut) R.empty
fromListGut :: Foldable t => t (MBR, b) -> R2Tree b
fromListGut = foldl' (\z (a, b) -> R.insertGut a b z) R.empty


main :: IO ()
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
packages:
data-r-tree.cabal
r-tree.cabal
visualizer/r-tree-visualizer.cabal
70 changes: 0 additions & 70 deletions changelog.md

This file was deleted.

2 changes: 1 addition & 1 deletion no/No/Tree/D2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

module No.Tree.D2 where

import Data.RTree.D2.Double.Unsafe (MBR (..), Predicate (..))
import Data.R2Tree.Double.Unsafe (MBR (..), Predicate (..))

import Control.DeepSeq
import qualified Data.Foldable as Fold
Expand Down
37 changes: 20 additions & 17 deletions data-r-tree.cabal → r-tree.cabal
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
cabal-version: 2.2

name: data-r-tree
version: 1.2.0
synopsis: R/R*-trees.
description: Spatial trees utilizing R-tree and R*-tree algorithms.
name: r-tree
version: 1.0.0.0
synopsis: R-/R*-trees.
description: R-trees and R*-trees.

See the <https://github.com/sebastian-philipp/r-tree/blob/master/README.md README>
for a brief overview of the data structures included in this package.

license: MIT
license-file: LICENSE
Expand All @@ -13,7 +16,7 @@ copyright: Sebastian Wagner, Birte Wagner, Oleksii Divak
category: Data Structures
build-type: Simple

extra-doc-files: changelog.md
extra-doc-files: CHANGELOG.md
README.md

bug-reports: https://github.com/sebastian-philipp/r-tree/issues
Expand All @@ -31,25 +34,25 @@ library

hs-source-dirs: src

exposed-modules: Data.RTree.D2.Double
Data.RTree.D2.Double.Debug
Data.RTree.D2.Double.Unsafe
Data.RTree.D2.Float
Data.RTree.D2.Float.Debug
Data.RTree.D2.Float.Unsafe
exposed-modules: Data.R2Tree.Double
Data.R2Tree.Double.Debug
Data.R2Tree.Double.Unsafe
Data.R2Tree.Float
Data.R2Tree.Float.Debug
Data.R2Tree.Float.Unsafe

other-modules: Data.RTree.D2.Double.Internal
Data.RTree.D2.Float.Internal
other-modules: Data.R2Tree.Double.Internal
Data.R2Tree.Float.Internal

ghc-options: -Wall

default-language: Haskell2010

benchmark time
build-depends: base
, data-r-tree
, r-tree
, deepseq
, gauge >= 0.2 && < 0.3
, tasty-bench >= 0.3 && < 0.5
, random >= 1.2 && < 1.3

type: exitcode-stdio-1.0
Expand All @@ -64,7 +67,7 @@ benchmark time

benchmark space
build-depends: base
, data-r-tree
, r-tree
, random
, weigh >= 0.0.16 && < 0.1

Expand All @@ -80,7 +83,7 @@ benchmark space

test-suite properties
build-depends: base
, data-r-tree
, r-tree
, deepseq
, hspec >= 2 && < 2.12
, random
Expand Down
Loading