在每个测试用例之后清除内存数据库(Clear the in memory database after every testcase)
我使用hsqldb来测试Java中的一些数据访问层。 我有一些像100这样的测试用例。 我创建一个内存数据库,然后在表中插入一些值,以便我的测试用例我可以加载它,但问题是每个测试用例我需要清除内存数据库,只有值不是表。
是否可能,有一件事是我需要手动删除表中的行,还有一些我可以使用的东西。
谢谢
I am using hsqldb for testing some of the data access layer in Java. I have certain test cases like 100 around. I create a in memory database and then insert some values in the table so that with my test case i can load it, but the problem is for every test case i need to clear the in memory database, only the values not the tables.
Is it possible, one thing is i need to manually delete the rows from the table and is there some thing else I can use.
Thanks
原文:https://stackoverflow.com/questions/6936845
最满意答案
我们可以使用
dplyr::data_frame
构建一个只有你想要的动态绘制的x值的数据帧。 我添加了另一个pdf,以证明您希望它呈现的方式将起作用。library(dplyr) # to use data_frame ggplot() + geom_line(data=data_frame(x=seq(2,30, 0.25), y = dnorm(x, mean = 5, sd = 1)), aes(x, y), color = "black") + geom_line(data=data_frame(x=seq(40,70, 0.25), y = dnorm(x, mean = 60, sd = 5)), aes(x, y), color = "red") + xlim(-5,80)+ scale_y_continuous(breaks = NULL)
更新
您也可以通过在
aes(...)
内移动color=
来标记它们:ggplot() + geom_line(data=data_frame(x=seq(2,30, 0.25), y = dnorm(x, mean = 5, sd = 1)), aes(x, y, color = "mean:5, sd:1")) + geom_line(data=data_frame(x=seq(40,70, 0.25), y = dnorm(x, mean = 60, sd = 5)), aes(x, y, color = "mean:60, sd:5")) + xlim(-5,80)+ scale_y_continuous(breaks = NULL) + scale_color_manual(values = c("mean:5, sd:1" = "black", "mean:60, sd:5" = "red"))
UPDATE2
你的密度函数适合我。
dTDF<-function(x,g,a,b,k){ exp(-exp(-(x/a)+((a*k)/(g-x))-b))*(exp(-(x/a)+((a*k)/(g-x))-b))*((1/a)-((a*k)/((g-x)^2))) } df1 <- data_frame(x=seq(2500,11300, 100), y = dTDF(x,g=11263,a=1185, b=-4, k=-0.5)) df2 <- data_frame(x=seq(7000,14300, 100), y = dTDF(x,g=15263,a=1105, b=-10, k=-0.5)) ggplot() + geom_line(data = df1, aes(x, y))+ geom_line(data = df2, aes(x, y)) + xlim(1000, 15000)
We can construct a dataframe with the only the x-values you want plotted on the fly using
dplyr::data_frame
. I added another p.d.f. to demonstrate that the way you want it presented will work.library(dplyr) # to use data_frame ggplot() + geom_line(data=data_frame(x=seq(2,30, 0.25), y = dnorm(x, mean = 5, sd = 1)), aes(x, y), color = "black") + geom_line(data=data_frame(x=seq(40,70, 0.25), y = dnorm(x, mean = 60, sd = 5)), aes(x, y), color = "red") + xlim(-5,80)+ scale_y_continuous(breaks = NULL)
Update
You can also label them like so, by moving the
color=
inside theaes(...)
:ggplot() + geom_line(data=data_frame(x=seq(2,30, 0.25), y = dnorm(x, mean = 5, sd = 1)), aes(x, y, color = "mean:5, sd:1")) + geom_line(data=data_frame(x=seq(40,70, 0.25), y = dnorm(x, mean = 60, sd = 5)), aes(x, y, color = "mean:60, sd:5")) + xlim(-5,80)+ scale_y_continuous(breaks = NULL) + scale_color_manual(values = c("mean:5, sd:1" = "black", "mean:60, sd:5" = "red"))
Update2
Your density function works for me.
dTDF<-function(x,g,a,b,k){ exp(-exp(-(x/a)+((a*k)/(g-x))-b))*(exp(-(x/a)+((a*k)/(g-x))-b))*((1/a)-((a*k)/((g-x)^2))) } df1 <- data_frame(x=seq(2500,11300, 100), y = dTDF(x,g=11263,a=1185, b=-4, k=-0.5)) df2 <- data_frame(x=seq(7000,14300, 100), y = dTDF(x,g=15263,a=1105, b=-10, k=-0.5)) ggplot() + geom_line(data = df1, aes(x, y))+ geom_line(data = df2, aes(x, y)) + xlim(1000, 15000)
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
如果没有看到数据或图表,很难知道问题是什么,以便我们可以看到'重复'的含义。 但是,如果问题出在置信区间线上,我怀疑这个问题可能与lines命令中变量的排序有关。 你是否尝试过对两个变量进行排序,以确保行中的x和y相对应,如下所示? lines(sort(daten$value.1), sort(conf.lower),col="red") 如果这不能解决问题,请提供更多信息,以便我们提供帮助。 It's hard to know what the problem is without seeing th ...
-
以下条件永远不可能是真的,因为任何数字不能同时大于和小于2 x > 2 & x < 2 因此, x1是一个空向量, x2正好是2 ,所以你的绘图命令只会在(2,2)处产生一个点。 您想要使用逻辑或 ( | )来代替 x1 = x(x > 2 | x < 2); 另外一个更好的方式来绘制这将是以下 y = x + 1; % Set all values to x + 1 y(x == 2) = 2; % Replace those that meet your criteria ...
-
> d <- data.frame(Limiter = rep("NO", 44), Starter = rep("NO", 44), Ender = rep("NO", 44), stringsAsFactors = FALSE) > d$Starter[c(1, 3, 15, 25)] <- "Start" > d$Ender[c(1, 13, 23, 44)] <- "End" > d$Limiter[c(2, 14, 24)] <- "Yes" > d$Period <- ifelse(d$Limi ...
-
如果你的矩阵是mat ,那么这将是你想要的柱子的子集: mat[,which(mat[1,] >= 0.5 & mat[1,] <= 0.6 & mat[2,] >= 0 & mat[2,] <= 0.01)] If your matrix is mat, this will subset the columnas that you want: mat[,which(mat[1,] >= 0.5 & mat[1,] ...
-
有两种方法可以实现这一目标。 第一个是定义值的子集: I = 3000:5000; plot(t(I), x(I)); 第二种方法是使用xlim设置: plot(t,x); xlim([3 5]); 这将设置3和5秒的情节界限。 There are two ways to achieve this. The first one is to define a subset of values: I = 3000:5000; plot(t(I), x(I)); The second method is t ...
-
显然你可以使用布局 pdf(file=paste0("Test 2.pdf"), paper = "a4") layout(matrix(1:6, 3, 2, byrow = TRUE), respect = TRUE) par(omi=c(0,0,0,0), mar=c(2, 2, 0, 0)) for (i in 1:6) { plot(1:10) } dev.off() Apparantly you can use layout instead pdf(file=paste0("Test 2 ...
-
我们可以使用dplyr::data_frame构建一个只有你想要的动态绘制的x值的数据帧。 我添加了另一个pdf,以证明您希望它呈现的方式将起作用。 library(dplyr) # to use data_frame ggplot() + geom_line(data=data_frame(x=seq(2,30, 0.25), y = dnorm(x, mean = 5, sd = 1)), aes(x, y), color = "black") + geom_line ...
-
就像你用任何矢量一样: > Test <- as.zoo(1:33) > Test[seq(5,length(Test),by=5)] 5 10 15 20 25 30 5 10 15 20 25 30 Like you would do it with any vector : > Test <- as.zoo(1:33) > Test[seq(5,length(Test),by=5)] 5 10 15 20 25 30 5 10 15 20 25 30