Skip to content

Commit

Permalink
v2; make StateSpaceSet subtype Vector{<:AbstractVector} (#32)
Browse files Browse the repository at this point in the history
* bump to 2.0

* add back the .github repo

* fix the main test file for state space sets

* rename files

* restore the bejavior of using SVectors by default, and fix distance tests

* all tests passing

* also test broadcasting

* oops typo

* enforce T real; allow MVector

* add tests for MVector

* add test of no reals

* final changelog
  • Loading branch information
Datseris authored Sep 21, 2024
1 parent c7018ac commit 8689667
Show file tree
Hide file tree
Showing 18 changed files with 431 additions and 262 deletions.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Problem/bug report
about: Create a report for incorrect/unexpected/erroring behavior
title: ''
labels: ''
assignees: ''

---

**Describe the problem**

A clear and concise description of what the problem is, and what you were expecting to happen instead.

**Minimal Working Example**

Please provide a piece of code that leads to the bug you encounter.

This code should be **runnable**, **self-contained**, and minimal. Remove all irrelevant dependencies
and actively try to reduce the code to its smallest possible version.
This will help us identify and fix the problem faster.

**Package versions**

Please provide the versions you use. To do this, run the code:
```julia
import Pkg
Pkg.status(["Package1", "Package2"]; # etc.
mode = PKGMODE_MANIFEST
)
```
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest a new feature for this project
title: ''
labels: ''
assignees: ''

---

**Describe the feature you'd like to have**

**Cite scientific papers related to the feature/algorithm**

**If possible, sketch out an implementation strategy**
44 changes: 44 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CompatHelper
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v1
with:
version: '1'
arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
15 changes: 15 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
26 changes: 26 additions & 0 deletions .github/workflows/doccleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Doc Preview Cleanup

on:
pull_request:
types: [closed]

jobs:
doc-preview-cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v2
with:
ref: gh-pages
- name: Delete preview and history + push changes
run: |
if [ -d "previews/PR$PRNUM" ]; then
git config user.name "Documenter.jl"
git config user.email "[email protected]"
git rm -rf "previews/PR$PRNUM"
git commit -m "delete preview"
git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree})
git push --force origin gh-pages-new:gh-pages
fi
env:
PRNUM: ${{ github.event.number }}
26 changes: 26 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Documentation

on:
push:
branches:
- main
tags: '*'
pull_request:

jobs:
build:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key for using TagBot
run: julia --project=docs/ docs/make.jl
53 changes: 53 additions & 0 deletions .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI - test & coverage
on:
pull_request:
branches:
- main
- '**' # matches every branch
push:
branches:
- main
tags: '*'
jobs:
test:
name: Tests, Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1'
os: [ubuntu-latest] # adjust according to need, e.g. os: [ubuntu-latest] if testing only on linux
arch:
- x64
steps:
# Cancel ongoing CI test runs if pushing to branch again before the previous tests
# have finished
- name: Cancel ongoing test runs for previous commits
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

# Do tests
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1

- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ Changelog for StateSpaceSets.jl is kept w.r.t. version 1.3

# 2.0

- `StateSpaceSet` now subtypes `AbstractVector`, in particular `StateSpaceSet{V<:AbstractVector} <: AbstractVector{X}`. This lead to the breaking change that `size(ssset) = (length(ssset), )` while before `size` was `length(ssset), dimension(ssset)`. Now you have to use `dimension(ssset)` exclusively to get the "number of columns" in the state space set.
- The keyword `container` can be given to all functions that make state space sets
- `StateSpaceSet` now subtypes `AbstractVector`, in particular `StateSpaceSet{V<:AbstractVector} <: AbstractVector{V}`. This leads to the breaking change that `size(ssset) = (length(ssset), )` while before `size` was `length(ssset), dimension(ssset)`. Now you have to use `dimension(ssset)` exclusively to get the "number of columns" in the state space set.
- `StateSpaceSet` now supports arbitrary inner vectors as state space points.
The keyword `container` can be given to all functions that make state space sets
and sets the type of the container of the inner vectors. This is the abstract type
and is typically `SVector` or `Vector`.
- All deprecations of v1 have been removed. Primarily this includes `Dataset` and an old version of `statespace_sampler`.
- All deprecations of v1 have been removed. Primarily this includes the `Dataset` name and an old version of `statespace_sampler`.


# 1.5
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "StateSpaceSets"
uuid = "40b095a5-5852-4c12-98c7-d43bf788e795"
authors = ["George Datseris <[email protected]>"]
repo = "https://github.com/JuliaDynamics/StateSpaceSets.jl.git"
version = "1.5.0"
version = "2.0.0"

[deps]
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
Expand Down
5 changes: 1 addition & 4 deletions src/neighborhoods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ using Neighborhood, Distances
export WithinRange, NeighborNumber
export Euclidean, Chebyshev, Cityblock

Neighborhood.KDTree(D::AbstractStateSpaceSet, metric::Metric = Euclidean(); kwargs...) =
KDTree(vec(D), metric; kwargs...)

# Convenience extensions for ::StateSpaceSet in bulksearches
for f (:bulkisearch, :bulksearch)
for nt (:NeighborNumber, :WithinRange)
@eval Neighborhood.$(f)(ss::KDTree, D::AbstractStateSpaceSet, st::$nt, args...; kwargs...) =
$(f)(ss, D.data, st, args...; kwargs...)
$(f)(ss, vec(D), st, args...; kwargs...)
end
end
4 changes: 4 additions & 0 deletions src/set_distance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ The distance is calculated with the metric given to `Hausdorff` which defaults t
`Hausdorff` is 2x slower than [`StrictlyMinimumDistance`](@ref), however it is
a proper metric in the space of sets of state space sets.
This metric only works for `StateSpaceSet`s whose elements are `SVector`s.
"""
struct Hausdorff{M<:Metric}
metric::M
Expand Down Expand Up @@ -79,6 +81,8 @@ Brute force performs better for datasets that are either large dimensional or
have a small amount of points. Deciding a cutting point is not trivial,
and is recommended to simply benchmark the [`set_distance`](@ref) function to
make a decision.
If `brute = false` this metric only works for `StateSpaceSet`s whose elements are `SVector`s.
"""
struct StrictlyMinimumDistance{M<:Metric}
brute::Bool
Expand Down
Loading

0 comments on commit 8689667

Please sign in to comment.