Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

Commit

Permalink
Remove space (#114)
Browse files Browse the repository at this point in the history
* update dependency of RLBase

* bump version
  • Loading branch information
findmyway authored Dec 26, 2020
1 parent 5b1343d commit 8141ddb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 65 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ReinforcementLearningEnvironments"
uuid = "25e41dd2-4622-11e9-1641-f1adca772921"
authors = ["Jun Tian <[email protected]>"]
version = "0.4.2"
version = "0.4.3"

[deps]
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
Expand All @@ -19,7 +19,7 @@ GR = "0.46, 0.47, 0.48, 0.49, 0.50, 0.51, 0.52, 0.53"
IntervalSets = "0.5"
MacroTools = "0.5"
OrdinaryDiffEq = "5"
ReinforcementLearningBase = "0.9"
ReinforcementLearningBase = "0.9.1"
Requires = "1.0"
StatsBase = "0.32, 0.33"
julia = "1.3"
63 changes: 0 additions & 63 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ end
# WorldSpace
#####

export WorldSpace

"""
In some cases, we may not be interested in the action/state space.
One can return `WorldSpace()` to keep the interface consistent.
"""
struct WorldSpace{T} end

WorldSpace() = WorldSpace{Any}()

Base.in(x, ::WorldSpace{T}) where {T} = x isa T

#####
# ZeroTo
#####
Expand Down Expand Up @@ -58,57 +46,6 @@ end
# Space
#####

export Space

"""
A wrapper to treat each element as a sub-space which supports:
- `Base.in`
- `Random.rand`
"""
struct Space{T}
s::T
end

@forward Space.s Base.getindex, Base.setindex!, Base.size, Base.length

Base.similar(s::Space, args...) = Space(similar(s.s, args...))

Random.rand(s::Space) = rand(Random.GLOBAL_RNG, s)

Random.rand(rng::AbstractRNG, s::Space) =
map(s.s) do x
rand(rng, x)
end

Random.rand(rng::AbstractRNG, s::Space{<:Dict}) = Dict(k => rand(rng, v) for (k, v) in s.s)

function Base.in(X, S::Space)
if length(X) == length(S.s)
for (x, s) in zip(X, S.s)
if x s
return false
end
end
return true
else
return false
end
end

function Base.in(X::Dict, S::Space{<:Dict})
if keys(X) == keys(S.s)
for k in keys(X)
if X[k] S.s[k]
return false
end
end
return true
else
return false
end
end

#####
# Generate README
#####
Expand Down

2 comments on commit 8141ddb

@findmyway
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/26938

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.3 -m "<description of version>" 8141ddb5a979c69e8705016dc87f9ac77ad378d7
git push origin v0.4.3

Please sign in to comment.