changeset 1733:ec5589090faa cleanup

Remove StaticDicts
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 09 Sep 2024 22:20:51 +0200
parents c70b54ab8fc8
children 2311f33b6bd3
files docs/make.jl docs/src/submodules/static_dicts.md src/Diffinitive.jl src/StaticDicts/StaticDicts.jl test/StaticDicts/StaticDicts_test.jl
diffstat 5 files changed, 0 insertions(+), 176 deletions(-) [+]
line wrap: on
line diff
--- a/docs/make.jl	Mon Sep 09 11:06:41 2024 -0700
+++ b/docs/make.jl	Mon Sep 09 22:20:51 2024 +0200
@@ -6,7 +6,6 @@
 using Diffinitive.LazyTensors
 using Diffinitive.RegionIndices
 using Diffinitive.SbpOperators
-using Diffinitive.StaticDicts
 
 sitename = "Diffinitive.jl"
 
@@ -38,7 +37,6 @@
         "submodules/lazy_tensors.md",
         "submodules/region_indices.md",
         "submodules/sbp_operators.md",
-        "submodules/static_dicts.md",
     ],
     "doc_index.md",
 ]
--- a/docs/src/submodules/static_dicts.md	Mon Sep 09 11:06:41 2024 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-# StaticDicts
-
-## Contents
-```@contents
-Pages = ["static_dicts.md"]
-```
-
-## Index
-```@index
-Pages = ["static_dicts.md"]
-```
-
-## Public interface
-```@autodocs
-Modules = [StaticDicts]
-Private = false # Hide unexported objects
-```
-
-## Internal interface
-```@autodocs
-Modules = [StaticDicts]
-Public = false # Hide exported objects
-```
--- a/src/Diffinitive.jl	Mon Sep 09 11:06:41 2024 -0700
+++ b/src/Diffinitive.jl	Mon Sep 09 22:20:51 2024 +0200
@@ -1,6 +1,5 @@
 module Diffinitive
 
-include("StaticDicts/StaticDicts.jl")
 include("RegionIndices/RegionIndices.jl")
 include("LazyTensors/LazyTensors.jl")
 include("Grids/Grids.jl")
--- a/src/StaticDicts/StaticDicts.jl	Mon Sep 09 11:06:41 2024 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-module StaticDicts
-
-export StaticDict
-
-"""
-    StaticDict{K,V,N} <: AbstractDict{K,V}
-
-A static dictionary implementing the interface for an `AbstractDict`. A
-`StaticDict` is fully immutable and after creation no changes can be made.
-
-The immutable nature means that `StaticDict` can be compared with `===`, in
-constrast to regular `Dict` or `ImmutableDict` which can not. (See
-<https://github.com/JuliaLang/julia/issues/4648> for details.) One important
-aspect of this is that `StaticDict` can be used in a struct while still
-allowing the struct to be compared using the default implementation of `==` for
-structs.
-
-Lookups are done by linear search.
-
-Duplicate keys are not allowed and an error will be thrown if they are passed
-to the constructor.
-"""
-struct StaticDict{K,V,N} <: AbstractDict{K,V}
-    pairs::NTuple{N,Pair{K,V}}
-
-    function StaticDict{K,V}(pairs::Vararg{Pair,N}) where {K,V,N}
-        if !allunique(first.(pairs))
-            throw(DomainError(pairs, "keys must be unique"))
-        end
-        return new{K,V,N}(pairs)
-    end
-end
-
-function StaticDict(pairs::Vararg{Pair})
-    K = typejoin(firsttype.(pairs)...)
-    V = typejoin(secondtype.(pairs)...)
-    return StaticDict{K,V}(pairs...)
-end
-
-StaticDict(pairs::NTuple{N,Pair} where N) = StaticDict(pairs...)
-
-function Base.get(d::StaticDict, key, default)
-    for p ∈ d.pairs
-        if key == p.first
-            return p.second
-        end
-    end
-
-    return default
-end
-
-Base.iterate(d::StaticDict) = iterate(d.pairs)
-Base.iterate(d::StaticDict, state) = iterate(d.pairs,state)
-Base.length(d::StaticDict) = length(d.pairs)
-
-
-"""
-    merge(d1::StaticDict, d2::StaticDict)
-
-Merge two `StaticDict`. Repeating keys is considered and error. This may
-change in a future version.
-"""
-function Base.merge(d1::StaticDict, d2::StaticDict)
-    return StaticDict(d1.pairs..., d2.pairs...)
-end
-
-
-"""
-    firsttype(::Pair{T1,T2})
-
-The type of the first element in the pair.
-"""
-firsttype(::Pair{T1,T2}) where {T1,T2} = T1
-
-"""
-    secondtype(::Pair{T1,T2})
-
-The type of the secondtype element in the pair.
-"""
-secondtype(::Pair{T1,T2}) where {T1,T2}  = T2
-
-end # module
--- a/test/StaticDicts/StaticDicts_test.jl	Mon Sep 09 11:06:41 2024 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-using Test
-using Diffinitive.StaticDicts
-
-@testset "StaticDicts" begin
-
-@testset "StaticDict" begin
-    @testset "constructor" begin
-        @test (StaticDict{Int,Int,N} where N) <: AbstractDict
-
-        d = StaticDict(1=>2, 3=>4)
-        @test d isa StaticDict{Int,Int}
-        @test d[1] == 2
-        @test d[3] == 4
-
-        @test StaticDict((1=>2, 3=>4)) == d
-
-        @test StaticDict() isa StaticDict
-        @test StaticDict{Int,String}() isa StaticDict{Int,String,0}
-
-        @test StaticDict(1=>3, 2=>4.) isa StaticDict{Int,Real}
-        @test StaticDict(1. =>3, 2=>4) isa StaticDict{Real,Int}
-        @test StaticDict(1. =>3, 2=>4.) isa StaticDict{Real,Real}
-
-        @test_throws DomainError StaticDict(1=>3, 1=>3)
-    end
-
-    @testset "length" begin
-        @test length(StaticDict()) == 0
-        @test length(StaticDict(1=>1)) == 1
-        @test length(StaticDict(1=>1, 2=>2)) == 2
-    end
-
-    @testset "equality" begin
-        @test StaticDict(1=>1) == StaticDict(1=>1)
-        @test StaticDict(2=>1) != StaticDict(1=>1)
-        @test StaticDict(1=>2) != StaticDict(1=>1)
-
-        @test StaticDict(1=>1) === StaticDict(1=>1) #not true for a regular Dict
-        @test StaticDict(2=>1) !== StaticDict(1=>1)
-        @test StaticDict(1=>2) !== StaticDict(1=>1)
-    end
-
-    @testset "get" begin
-        d = StaticDict(1=>2, 3=>4)
-
-        @test get(d,1,6) == 2
-        @test get(d,3,6) == 4
-        @test get(d,5,6) == 6
-    end
-
-    @testset "iterate" begin
-        pairs = [1=>2, 3=>4, 5=>6]
-
-        d = StaticDict(pairs...)
-        @test collect(d) == pairs
-    end
-
-    @testset "merge" begin
-        @test merge(
-            StaticDict(1=>3, 2=> 4),
-            StaticDict(3=>5,4=>6)) == StaticDict(
-                1=>3, 2=>4, 3=>5, 4=>6
-            )
-        @test_throws DomainError merge(StaticDict(1=>3),StaticDict(1=>3))
-    end
-end
-
-end