Displaying 20 results from an estimated 10000 matches similar to: "ifelse logic and multiple assignments"
2017 Sep 22
1
Treating NA in timeSeries package
Dear All,
I am facing problem with NA treatment in my financial time series data.
# data reading
aluminum = read.csv(file="alu.csv", header=T, sep=",")
fut = aluminum [,2]
spt = aluminum [,3]
# Missing Value Treatment (Linear Interpolation)
spt = interpNA(spt, method = c("linear"))
fut = interpNA(fut, method = c("linear"))
fut=fut[,1]
spt =spt[,1]
2019 Jan 17
1
[hivex PATCH] ruby: improve test functions
Use better functions to check for proper values instead of assert:
- refute_nil for non-null functions
- assert_equal for checking equality
Also, make sure that the parameters for assert_equal are correct:
expected value, then got value.
---
ruby/tests/tc_120_rlenvalue.rb | 4 ++--
ruby/tests/tc_130_special.rb | 12 ++++++------
ruby/tests/tc_200_write.rb | 4 ++--
2018 Nov 29
2
MRutter PPA versioning issue, again
Michael,
ESS broke again on my laptop after I upgraded to Ubuntu 18.10. The elpa-ess
package seems to be provided multiple times, sadly the one with xenial
(16.04) in its name wins ... and breaks the setup. I one for cosmic, I had
one from bionic (18.04), but because the names 'wrapped' the 'x' wins over
'b' and 'c'. We had talked about that in the past, it
2013 Jun 09
2
Minitest mock or stub methods
Hi
I''m building a small library to use in my Rails app which interacts with a
3rd party API. It fetches artists and tracks.
So I have:
lib/my_lib.rb
lib/my_lib/artist.rb
lib/my_lib/track.rb
To get an artist I do
artist = MyLib::Artist.find("Oasis")
Which returns an instance of Artist if it finds (via 3rd party API) it or
nil otherwise.
Then I can call artist.tracks which
2011 Oct 19
1
Rails 3.1 and minitest
I''m looking for a simple way to integrate minitest/spec with Rails
3.1. Anybody have it working?
There''s an older article on MetaSkills about this but it adds stuff I
don''t want.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2012 Mar 13
4
minitest validations - is there a cleaner way?
i am trying out minitest, but need some advice on a clean way to test
validations.
I setup my testing to use minitest by following the following railscast
plus i added miniskirt for Factories.
http://railscasts.com/episodes/327-minitest-with-rails
everything works well, but there has to be a cleaner way of testing failed
validations. would i be better off using something besides
2007 Apr 26
3
A coding question involving variable assignments in ifelse()
Dear List,
Below is a simple, standard loss model that takes into account the
terms of an insurance policy:
deductible <- 15
coverage.limit <- 75
insurance.threshold <- deductible + coverage.limit
tmpf <- function() {
loss <- rlnorm(rpois(1, 3), 2, 5)
sum(ifelse(loss > insurance.threshold, loss - coverage.limit,
pmin(loss, deductible)))
}
net <- replicate(1000000, tmpf())
2010 Nov 24
1
segfault interest?
in a long program, I ran into
?*** caught segfault ***
address 0xdc3f9b48, cause 'memory not mapped'
Traceback:
?1: rep.int(seq_len(nx), rep.int(rep.fac, nx))
?2: rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep)
?3: expand.grid(seq_len(nx), seq_len(ny))
?4: merge.data.frame(d, ss)
?5: merge(d, ss)
?6: valid.range(opt)
?7: eval.with.vis(expr, envir, enclos)
?8: eval.with.vis(ei,
2016 Jun 07
3
[PATCH 1/2] ruby: Print exceptions thrown by event callbacks.
---
generator/ruby.ml | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/generator/ruby.ml b/generator/ruby.ml
index 97ccfdc..0f71ccc 100644
--- a/generator/ruby.ml
+++ b/generator/ruby.ml
@@ -404,15 +404,17 @@ event_callback_wrapper_wrapper (VALUE argvv)
return Qnil;
}
+/* Callbacks aren't supposed to throw exceptions. We just print the
+ * exception on
2016 Jun 07
0
[PATCH 2/2] ruby: tests: Give each test class and method a unique name.
'tc_410_close_event.rb' was not being run. You could prove this by
simply inserting "exit 1" into that test.
The reason is unclear, but by renaming every class and method in the
tests to be unique, this ensures the tests are run.
---
ruby/t/tc_010_load.rb | 4 ++--
ruby/t/tc_020_create.rb | 4 ++--
ruby/t/tc_030_create_flags.rb | 4 ++--
2016 Feb 23
2
[PATCH 1/2] Revert "ruby: Run tests one at a time, instead of in parallel."
It seems the default behaviour of rake is to run tests sequentially, and
not in parallel (there are separate gems to achieve that behaviour).
Hence just invoke "rake test" to run all the available tests at once.
This reverts commit 8f30c3c3f8c063f7c5ff8c6154d881e07a820251.
---
ruby/run-ruby-tests | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git
2011 Nov 05
2
Where is my gem file located so that i can rake test
Googling around, I found that apparently adding to the gem file will
fix my problems, but where do i find the gem file? what is the name of
the gem file?
"group :test do
# Pretty printed test output
gem ''minitest'' ####### add this line #######
end"
Here is what happens when i run rake test, please note that i have
already installed minitest
2004 Mar 17
1
ANCOVA when you don't know factor levels
Hello people
I am doing some thinking about how to analyse data on dimorphic animals
- where different individuals of the same species have rather different
morphology. An example of this is that some male beetles have large
horns and small wings, and rely on beating the other guys up to get
access to mates, whereas others have smaller horns and larger wings,
and rely on mobility to
2012 Oct 20
1
Logistic regression/Cut point? predict ??
I am new to R and I am trying to do a monte carlo simulation where I
generate data and interject error then test various cut points; however, my
output was garbage (at x equal zero, I did not get .50)
I am basically testing the performance of classifiers.
Here is the code:
n <- 1000; # Sample size
fitglm <- function(sigma,tau){
x <- rnorm(n,0,sigma)
intercept <- 0
beta
2012 Oct 25
2
How to extract auc, specificity and sensitivity
I am running my code in a loop and it does not work but when I run it
outside the loop I get the values I want.
n <- 1000; # Sample size
fitglm <- function(sigma,tau){
x <- rnorm(n,0,sigma)
intercept <- 0
beta <- 0
ystar <- intercept+beta*x
z <- rbinom(n,1,plogis(ystar))
xerr <- x + rnorm(n,0,tau)
model<-glm(z ~ xerr, family=binomial(logit))
2011 Mar 23
0
Passing NilClass To Create & MiniTest Backtrace Cleaner
Morning All!
Some things I noticed while playing with 3.1 master last night.
1) When using the #create! method on an association and pass "nil" vs an empty hash, now fails silently with no warning or anything. It''s almost like a no-op. I did not test to see if this behavior occurred on a basic model or not. My app''s controller was setup in such a way that I would
2012 Oct 21
0
rails g problem
When I enter rails g, I get the bunch of logs behind.
Any idea what I''m missing?
I though it''s trying to install minitest, so I manually installed it.
Still this error persists.
$ rails g
gem install minitest
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'': no such file to load -- minitest/unit
2016 Feb 23
0
[PATCH 2/2] ruby: tests: use more asserts instead of manual checks
Make more use of assert_equal/refute_equal instead of manually checking
values and raising errors.
---
ruby/t/tc_100_launch.rb | 4 +---
ruby/t/tc_410_close_event.rb | 8 ++------
ruby/t/tc_420_log_messages.rb | 4 +---
ruby/t/tc_810_rhbz664558c6.rb | 4 +---
4 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/ruby/t/tc_100_launch.rb b/ruby/t/tc_100_launch.rb
index
2013 Apr 02
10
Suggested strategies for testing a gem against Rails 3.x and Rails 4?
I''ve seen a few examples of dummy Rails apps (for testing, so they live
under test or spec dirs, typically) for use with the Appraisals gem that
supposedly work with both Rails 3.x and Rails 4, but they seem hackish and
not fully functional. It is somewhat expected, as it is a stripped down
Frankenstein monster that is trying to be compatible with various versions
of Rails 3 as well
2020 Oct 26
0
How to shade area between lines in ggplot2
Hi
Put fill outside aes
p+geom_ribbon(aes(ymin = slope_1*x + intercept_1 - 1/w[2],
ymax = slope_1*x + intercept_1 + 1/w[2]), fill = "blue", alpha=0.1)
The "hole" is because you have two levels of data (red and blue). To get rid
of this you should put new data in ribbon call.
Something like
newdat <- trainset
newdat$z <- factor(0)
p+geom_ribbon(data=newdat, aes(ymin =