首页 \ 问答 \ 在每个测试用例之后清除内存数据库(Clear the in memory database after every testcase)

在每个测试用例之后清除内存数据库(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
更新时间:2022-03-24 15:03

最满意答案

我们可以使用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) 

enter image description here

Update

You can also label them like so, by moving the color= inside the aes(...):

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"))

enter image description here

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)

enter image description here

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。