Open
Conversation
fix to lagfill with TimeArray w/ greater than 1 horizontal dim
Codecov Report
@@ Coverage Diff @@
## master #134 +/- ##
==========================================
+ Coverage 62.81% 63.10% +0.28%
==========================================
Files 8 8
Lines 433 458 +25
==========================================
+ Hits 272 289 +17
- Misses 161 169 +8
Continue to review full report at Codecov.
|
Member
diff --git a/src/utilities.jl b/src/utilities.jl
index 844d746..edc2fc0 100644
--- a/src/utilities.jl
+++ b/src/utilities.jl
@@ -92,19 +92,16 @@ function lagfill(ta::TimeArray, r1::Integer, fill::AbstractFloat)
_lta_values = values(_lta)
_lta_values[1:r1] .= fill
- TimeArray(timestamp(ta), _lta_values, colnames(ta))
+ TimeArray(timestamp(ta), _lta_values, colnames(ta), unchecked = true)
end
-function lagfill(ta::TimeArray, r1::Integer, fill::AbstractMatrix{T}) where T<:AbstractFloat
+function lagfill(ta::TimeArray, r1::Integer, fill::AbstractMatrix{<:AbstractFloat})
@assert size(fill, 2) == size(ta, 2)
_lta = lag(ta, r1, padding = true)
_lta_values = values(_lta)
+ _lta_values[1:r1, :] .= fill
- for i in 1:r1
- _lta_values[i, :] = fill
- end
-
- TimeArray(timestamp(ta), _lta_values, colnames(ta))
+ TimeArray(timestamp(ta), _lta_values, colnames(ta), unchecked = true)
end
_nanmean(x) = mean(filter(!isnan, x)) |
Member
|
And maybe we need to fix the colname of diff --git a/src/momentum.jl b/src/momentum.jl
index d73f151..a42f931 100644
--- a/src/momentum.jl
+++ b/src/momentum.jl
@@ -349,7 +349,7 @@ function dpo(ta::TimeArray, n::Integer = 14)
lagPeriod = Int(floor(0.5*n) + 1)
_lagc = lagfill(ta, lagPeriod, nanmean(values(ta)))
- dpo = rename(_lagc .- moving(nanmean, ta, n), [:dpo])
+ dpo = rename!(_lagc .- moving(nanmean, ta, n), gen_colnames(colnames(ta), [:dpo]))
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.
Fix to lagfill to address issue #133