rr

SMR、RR、AR、PAR、OR

我与影子孤独终老i 提交于 2019-12-08 20:51:38
SMR(standardized mortality ratio)标化死亡比 = 观察死亡人数 / 期望死亡人数 ①某厂30~40岁年龄组工人500人,某年内2人死于肺癌,已知该年全人口30~40岁组肺癌的死亡率2%%,求其SMR SMR=2 /(500*2%%)= 2 表明 30~40岁年龄组工人死于肺癌的危险达一般人群的2倍。 ②某厂30~40岁年龄组工人死亡总人数100人,其中死于肺癌5人,全人口中该年30~40岁组肺癌死亡占全死因死亡的比例为2.2%,则 SMR=5 / (100*2.2%)=2.27 表明30~40岁年龄组工人死于肺癌的危险达一般人群的2.27倍。  RR(relative risk)多用于 队列研究 中 ,表示暴露者发生相应疾病的危险是非暴露者的多少倍 AR(attributable risk)归因危险度 ,表示 暴露人群与非暴露人群比较,所增加的疾病发生 数量 来源: https://www.cnblogs.com/super-yb/p/12007119.html

Unit Testing Ruby Blocks by Mocking with rr (was flexmock)

回眸只為那壹抹淺笑 提交于 2019-12-04 02:37:01
问题 How do I unit test the following: def update_config store = YAML::Store.new('config.yaml') store.transaction do store['A'] = 'a' end end Here is my start: def test_yaml_store mock_store = flexmock('store') mock_store .should_receive(:transaction) .once flexmock(YAML::Store).should_receive(:new).returns(mock_store) update_config() end How do I test what is inside the block? UPDATED I have converted my test to spec and switched to rr mocking framework: describe 'update_config' do it 'calls

yield to a block using rr

让人想犯罪 __ 提交于 2019-12-02 03:13:33
I'm trying to test the following code using rr : response = RestClient.get(url, {:params => params}){|response, request, result| response } In vanilla rspec , you would do something like this: RestClient.should_receive(:get).with(url, {:params => params}).and_yield(response, request, result) How would I do the same with rr ? Setup: let(:url) { "http://localhost/" } let(:params) { {:item_id => 1234, :n => 5} } let(:response) { Object.new } let(:request) { Object.new } let(:result) { Object.new } I've tried a bunch of variations on: mock(RestClient).get(url, {:params => params}) { response,

Calico配置双RR架构

孤人 提交于 2019-12-01 22:08:54
0 背景 由于本次部署的节点有20个,2个Master,18个Node,而Calico默认采用Full-mesh BGP,将导致建立的连接数过多,故引入RR完成路由的分发 1 节点及配置规划 1.1 地址规划 ip范围 角色 192.168.2.1-2 RR 192.168.2.3-20 RR-Client 1.2 关键配置 修改/etc/ansible/roles/calico/defaults 配置 本K8S集群运行在同网段kvm虚机上,虚机间没有网络ACL限制,因此可以设置CALICO_IPV4POOL_IPIP=off,如果你的主机位于不同网段,或者运行在公有云上需要打开这个选项 CALICO_IPV4POOL_IPIP=always # 设置 CALICO_IPV4POOL_IPIP=“off”,可以提高网络性能 CALICO_IPV4POOL_IPIP: "off" 安装完成后会发现,网卡并未像开启IPIP那样生成tunl0网卡,而是通过物理网卡获取到各节点POD网段的路由,说明配置成功; 查看路由表: 路由表一开始不一定每个节点都会宣告进来,待节点调度生成过POD后即可宣告路由,就可以看到更新后的路由表 配置全局禁用Full-mesh $ cat << EOF | calicoctl -f - apiVersion: projectcalico.org/v3 kind

Unit Testing Ruby Blocks by Mocking with rr (was flexmock)

倾然丶 夕夏残阳落幕 提交于 2019-12-01 14:05:26
How do I unit test the following: def update_config store = YAML::Store.new('config.yaml') store.transaction do store['A'] = 'a' end end Here is my start: def test_yaml_store mock_store = flexmock('store') mock_store .should_receive(:transaction) .once flexmock(YAML::Store).should_receive(:new).returns(mock_store) update_config() end How do I test what is inside the block? UPDATED I have converted my test to spec and switched to rr mocking framework: describe 'update_config' do it 'calls transaction' do stub(YAML::Store).new do |store| mock(store).transaction end update_config end end This

nodejs链接mysql集群

三世轮回 提交于 2019-11-30 07:58:48
const mysql = require('mysql2'); const config = require('../config/config'); module.exports = async (sql, options) => { const poolCluster = mysql.createPoolCluster({ removeNodeErrorCount: 1, // Remove the node immediately when connection fails. defaultSelector: 'RR' //RR,RANDOM,ORDER }); poolCluster.add('node1', config.mysql.node1); poolCluster.add('node2', config.mysql.node2); poolCluster.add('node3', config.mysql.node3); poolCluster.add('node4', config.mysql.node4); return new Promise((resolve, reject) => { poolCluster.getConnection((err, conn) => { if (err) { reject(err) } else { conn.query

What is the best practice when it comes to testing “infinite loops”?

南笙酒味 提交于 2019-11-28 08:09:21
My basic logic is to have an infinite loop running somewhere and test it as best as possible. The reason for having an infinite loop is not important (main loop for games, daemon-like logic...) and I'm more asking about best practices regarding a situation like that. Let's take this code for example: module Blah extend self def run some_initializer_method loop do some_other_method yet_another_method end end end I want to test the method Blah.run using Rspec (also I use RR , but plain rspec would be an acceptable answer). I figure the best way to do it would be to decompose a bit more, like

2019牛客多校第九场

此生再无相见时 提交于 2019-11-27 10:51:01
H Cutting Bamboos 题意 给n个高度,每次独立询问一个区间 \([l,r]\) ,对于这个区间的所有高度,要求砍 \(y\) 次刚好全部砍完,问第 \(x\) 次砍的位置。 分析 可以二分砍的位置,计算出第 \(x\) 次砍掉的所有高度,进行check,所以问题就转化为如何求区间 \([l,r]\) 里大于某个值的高度差和。 显然只需要用主席树维护值域每个数的个数和加和,查询区间大于某个值 \(x\) 的加和,再减去大于 \(x\) 的个数乘以 \(x\) ,即可。 代码 #include <bits/stdc++.h> using namespace std; #define mid (l+r)/2 typedef long long ll; typedef double db; typedef pair<ll,ll> pll; const int N=2e5+50; const db eps=1e-8; int n,q; ll h[N],p[N]; int l,r; ll x,y; int cnt,tr[N],lr[N*40],rr[N*40]; ll num[N*40],sum[N*40]; int build(int l,int r){ int rt=++cnt; sum[rt]=num[rt]=0; if(l==r){ return rt; } lr[rt

What is the best practice when it comes to testing “infinite loops”?

元气小坏坏 提交于 2019-11-27 02:11:16
问题 My basic logic is to have an infinite loop running somewhere and test it as best as possible. The reason for having an infinite loop is not important (main loop for games, daemon-like logic...) and I'm more asking about best practices regarding a situation like that. Let's take this code for example: module Blah extend self def run some_initializer_method loop do some_other_method yet_another_method end end end I want to test the method Blah.run using Rspec (also I use RR, but plain rspec

POJ 1151 Atlantis

末鹿安然 提交于 2019-11-26 19:51:59
线段树+扫描线 矩形面积并 之前写过 矩形周长并 还是跟矩形周长并一样,将每一个矩形的横边和竖边处理出来 用竖边将整个平面分成若干个区间 用线段树维护这些区间被覆盖的长度 再用一条扫描线不断从下往上扫描,扫描横边 当扫描到一个矩形的下边时,将这一段区间在线段树上覆盖掉,更新信息 当扫描到一个矩形的上边时,将这一段区间的覆盖去掉即可 那么只有统计答案时与矩形周长并不同 答案就是当前整个区间被覆盖的长度*两次扫描线的高度之差 #include <iostream> #include <algorithm> #include <map> #include <cstdio> #define inf (int)1e9 using namespace std; int n,w,last,tot,k; double c[10000],ans; double s[10000]; map <double,int> id; struct node { double a,b,c,d; }p[5100]; struct tree { int l,r,sum; double len; }sh[100000]; struct edge { int l,r,kind; double num; }a[11000]; bool cmp(edge a,edge b) { return (a.num<b.num ||