-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor to allow containers to be directly used as spaces #9
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
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ebf59fe
wrote main ideas in README
zsunberg f1ad372
fixed typo
zsunberg 54eaca2
added basic functionality
zsunberg 5ff9fb0
added Box
zsunberg 0c63bcd
added ArraySpace constructor
zsunberg 9cb43f8
ArraySpace tests mostly pass
zsunberg 8a501c8
added products of boxes and friends
zsunberg 61924cf
added some words in the README about products
zsunberg 02605b5
slight rewording
zsunberg e83a732
added tuple fallback
zsunberg 361d999
finished implementing TupleProduct
zsunberg c342b84
fixed Box docstring
zsunberg e48e17b
added docstrings, updated readme
zsunberg 9ee91b5
add minor modifications
findmyway File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -24,4 +24,9 @@ export | |
|
||
include("array.jl") | ||
|
||
export | ||
product | ||
|
||
include("product.jl") | ||
|
||
end |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
product(i1::ClosedInterval, i2::ClosedInterval) = Box(SA[minimum(i1), minimum(i2)], SA[maximum(i1), maximum(i2)]) | ||
|
||
product(b::Box, i::ClosedInterval) = product(b, convert(Box, i)) | ||
product(i::ClosedInterval, b::Box) = product(convert(Box, i), b) | ||
product(b1::Box{<:AbstractVector}, b2::Box{<:AbstractVector}) = Box(vcat(b1.lower, b2.lower), vcat(b1.upper, b2.upper)) | ||
function product(b1::Box, b2::Box) | ||
if size(b1.lower, 2) == size(b2.lower, 2) # same number of columns | ||
return Box(vcat(b1.lower, b2.lower), vcat(b1.upper, b2.upper)) | ||
else | ||
return GenericrSpaceProduct((b1, b2)) | ||
end | ||
end | ||
|
||
# handle case of 3 or more | ||
product(s1, s2, s3, args...) = product(product(s1, s2), s3, args...) | ||
|
||
struct GenericrSpaceProduct{T<:Tuple} | ||
members::T | ||
end | ||
|
||
# handle any case not covered above | ||
product(s1, s2) = GenericrSpaceProduct((s1, s2)) | ||
product(s1::GenericrSpaceProduct, s2) = GenericrSpaceProduct((s1.members..., s2)) |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@testset "Product of boxes" begin | ||
@test product(Box([1], [2]), Box([3], [4])) == Box([1,3], [2,4]) | ||
@test product(Box(ones(2,1), 2*ones(2,1)), Box([3], [4])) == Box(@SMatrix([1;1;3]), @SMatrix([2;2;4])) | ||
end | ||
|
||
@testset "Product of intervals" begin | ||
@test @inferred product(1..2, 3..4) == Box([1,3], [2,4]) | ||
@test @inferred product(1..2, 3..4, 5..6) == Box([1,3,5], [2,4,6]) | ||
@test @inferred product(1..2, 3..4, 5..6, 7..8) == Box([1,3,5,7], [2,4,6,8]) | ||
end | ||
|
||
@testset "Product of Box and interval" begin | ||
@test @inferred product(Box([1,3], [2,4]), 5..6) == Box([1,3,5], [2,4,6]) | ||
@test @inferred product(5..6, Box([1,3], [2,4])) == Box([5,1,3], [6,2,4]) | ||
end |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.