-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bacda99
commit dffeac3
Showing
3 changed files
with
91 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,12 @@ authors = ["Mykel Kochenderfer <[email protected]> and contributors"] | |
version = "1.0.0-DEV" | ||
|
||
[deps] | ||
Debugger = "31a5f54b-26ea-5ae9-a837-f05ce5417438" | ||
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" | ||
|
||
[compat] | ||
julia = "1.6" | ||
OrderedCollections = "1.6" | ||
julia = "1.6" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,65 @@ | ||
using WildcardArrays | ||
using Test | ||
|
||
@testset "WildcardArrays.jl" begin | ||
# @testset "WildcardArrays.jl" begin | ||
|
||
str = """ | ||
R: north : warm : cold :more-warning 6 | ||
R: * : cold : almost-cold: warning 7 | ||
R: east : * : almost-cold: warning 7 | ||
R: south : cold : *: warning 7 | ||
R: south : cold : almost-cold: * 7 | ||
R: * : *: almost-cold: more-warning 8 | ||
R: * : warm : *: more-warning 8 | ||
R: * : warm : almost-cold: * 8 | ||
R: east : *: *: more-warning 8 | ||
R: east : *: warm: * 8 | ||
R: east : cold: *: * 8 | ||
R: west : * : * : * 10 | ||
R: * : cold : * : * 10 | ||
R: * :*: cold : * 10 | ||
R: * :*: * : more-warning 10 | ||
R: north : warm : cold :more-warning 1 | ||
R: * : cold : almost-cold: warning 2 | ||
R: east : * : almost-cold: warning 3 | ||
R: south : cold : *: warning 4 | ||
R: south : cold : almost-cold: * | ||
7 10 20 | ||
R: * : *: almost-cold: more-warning 5 | ||
R: * : warm : *: more-warning 6 | ||
R: * : warm : almost-cold: * 7 | ||
R: east : *: *: more-warning 8 | ||
R: east : *: warm: * 9 | ||
R: east : cold: *: * 10 | ||
R: west : * : * : * 11 | ||
R: * : cold : * : * 12 | ||
R: * :*: cold : * 13 | ||
R: * :*: * : more-warning 14 | ||
R: * :*: * : * 0 | ||
""" | ||
""" | ||
|
||
str_original = deepcopy(str) | ||
|
||
reg_ex = r"\s*R:(.*):(.*):(.*):\s*(.*) (.*)\s*(R):|\s*R:(.*):(.*):(.*):\s*(\S*) (\s*.*){1,1}\s*(R):|\s*R:(.*):(.*):(.*):\s*(\S*) \s*(.*)\s*$" | ||
# rp = r"\s*R:(.*):(.*):(.*):\s*(.*) (.*)\s*(R):" | ||
# reg_ex = r"R:(.*?)R:|R:(.*):(.*):(.*):(.*) (\d+)\n" | ||
# bb = match(Regex(string(reg_ex.pattern, "|", rp.pattern)),str) | ||
bb = match(reg_ex, str) | ||
# println(bb.captures) | ||
# println(str[maximum(bb.offsets):end]) | ||
|
||
while bb != nothing | ||
global str, bb | ||
println(str) | ||
# sleep(4) | ||
println(bb.captures) | ||
# sleep(1) | ||
str = str[maximum(bb.offsets):end] | ||
# println(str) | ||
# sleep(1) | ||
bb = match(reg_ex, str) | ||
end | ||
|
||
# println(bb.captures) | ||
|
||
# aa = string.(split(str, "\n")) | ||
# aa = filter(!isempty, aa) | ||
|
||
states = ["warm", "cold", "not-to-cold", "very-very-cold", "almost-cold", "ow-this-is-very-cold"] | ||
actions = ["north", "south", "east", "west"] | ||
observations = ["warning", "more-warning"] | ||
nothing | ||
# wa = WildcardArray{Float64, 4}(4, 6, 6, 2) | ||
# parse!(wa, str, [actions, states, states, observations]) | ||
# @test size(wa) == (4, 6, 6, 2) | ||
# @test eltype(wa) == Float64 | ||
# @test wa[1, 1, 1, 1] == 6 | ||
|
||
wa = WildcardArray{Float64, 4}(4, 6, 6, 2) | ||
parse!(wa, str, [actions, states, states, observations]) | ||
@test size(wa) == (4, 6, 6, 2) | ||
@test eltype(wa) == Float64 | ||
@test wa[1, 1, 1, 1] == 6 | ||
|
||
end | ||
# end |