Throw error in getindex function when string and symbol are passed simultaneously#197
Open
siddjain444 wants to merge 4 commits intoxKDR:mainfrom
Open
Throw error in getindex function when string and symbol are passed simultaneously#197siddjain444 wants to merge 4 commits intoxKDR:mainfrom
siddjain444 wants to merge 4 commits intoxKDR:mainfrom
Conversation
…d symbol are passed simultaneously as input to the function
chiraganand
requested changes
Apr 25, 2024
| ### | ||
|
|
||
| ### Inputs: row scalar, column scalar; Output: scalar | ||
|
|
Member
There was a problem hiding this comment.
Can you remove the extra line here?
| ### Inputs: row scalar, column vector; Output: TSFrame | ||
| function Base.getindex(ts::TSFrame, i::Int, j::AbstractVector{Int}) | ||
| TSFrame(ts.coredata[[i], Cols(:Index, j.+1)]) # increment: account for Index | ||
| TSFrame(ts.coredata[[i], Cols(:Index, j.+1)]) # increment: account for Index |
Member
There was a problem hiding this comment.
There is only whitespace difference in this line. Can you remove this change too?
| end | ||
| end | ||
|
|
||
|
|
| end | ||
|
|
||
| function Base.getindex(ts::TSFrame, i::UnitRange, j::Union{String, Symbol}) | ||
|
|
| function Base.getindex(ts::TSFrame, dt::AbstractVector{D}, j::AbstractVector{T}) where {D<:TimeType, T<:Union{AbstractString, Symbol}} | ||
| idx = map(d -> findfirst(x -> x == d, index(ts)), dt) | ||
| ts[idx, j] | ||
| if length(unique(map(x -> typeof(x), j))) == 1 |
Member
There was a problem hiding this comment.
The check should happen before idx = map(d -> ....
| if length(idx) == 0 | ||
| return nothing | ||
| else | ||
| if length(unique(map(x -> typeof(x), j))) == 1 |
Member
There was a problem hiding this comment.
This check should happen before idx = map(d -> ...).
| end | ||
|
|
||
| function Base.getindex(ts::TSFrame, ::Colon, j::Union{String, Symbol}) | ||
|
|
| else | ||
| throw(ArgumentError("The column vector cannot contain both AbstractString and Symbol types.")) | ||
| 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Updating the getindex function to throw argument error when string and symbol are passed simultaneously as input to the function.
Closes #194, #190