UNPKG

smoothish

Version:

Smooth bad-quality time series data.

1,652 lines (1,416 loc) 48.2 kB
# Snapshot report for `test/test.js` The actual snapshot is saved in `test.js.snap`. Generated by [AVA](https://avajs.dev). ## an example for documentation > input [ '##### 100', '###### 110', '######## 150', ' undefined', '########## 200', '############### 300', '#################### 400', '################################################## 1000', ] > {"falloff":"step"} [ '##### 95', '####### 120', '######## 146.571', '########## 190', '############# 247.143', '################### 350', '################################# 600', '################################################## 916.667', ] > {"algorithm":"movingAverage","falloff":"step"} [ '########### 120', '########### 120', '############ 140', '################# 190', '####################### 262.5', '########################################## 475', '########################################## 475', '################################################## 566.667', ] > {} [ '#### 73.802', '####### 115.134', '########## 165.679', '############## 224.712', '################# 287.134', '######################## 393.234', '################################# 552.986', '################################################## 827.354', ] > {"algorithm":"movingAverage"} [ '############ 142.487', '############# 158.867', '################ 190.539', '#################### 241.074', '######################## 289.17', '############################## 360.207', '###################################### 455.164', '################################################## 601.121', ] ## flat line is unchanged by smoothing > input [ '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', ] > {"falloff":"step"} [ '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', ] > {"algorithm":"movingAverage","falloff":"step"} [ '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', ] > {} [ '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', ] > {"algorithm":"movingAverage"} [ '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', '################################################## 1', ] ## handling increasing radius > input [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":0,"falloff":"step"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":0,"algorithm":"movingAverage","falloff":"step"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":0} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":0,"algorithm":"movingAverage"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > input [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":1,"falloff":"step"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":1,"algorithm":"movingAverage","falloff":"step"} [ '############## 1.5', '################## 2', '########################### 3', '#################################### 4', '############################################# 5', '################################################## 5.5', ] > {"radius":1} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":1,"algorithm":"movingAverage"} [ '############## 1.567', '##################### 2.254', '############################ 3.073', '#################################### 3.927', '############################################ 4.746', '################################################## 5.433', ] > input [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":2,"falloff":"step"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":2,"algorithm":"movingAverage","falloff":"step"} [ '#################### 2', '######################### 2.5', '############################## 3', '######################################## 4', '############################################# 4.5', '################################################## 5', ] > {"radius":2} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":2,"algorithm":"movingAverage"} [ '####################### 2.227', '############################ 2.662', '################################## 3.211', '######################################## 3.789', '############################################# 4.338', '################################################## 4.773', ] > input [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":3,"falloff":"step"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":3,"algorithm":"movingAverage","falloff":"step"} [ '############################ 2.5', '################################# 3', '####################################### 3.5', '####################################### 3.5', '############################################ 4', '################################################## 4.5', ] > {"radius":3} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":3,"algorithm":"movingAverage"} [ '############################# 2.589', '################################# 2.89', '##################################### 3.288', '########################################## 3.712', '############################################### 4.11', '################################################## 4.411', ] > input [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":4,"falloff":"step"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":4,"algorithm":"movingAverage","falloff":"step"} [ '###################################### 3', '############################################ 3.5', '############################################ 3.5', '############################################ 3.5', '############################################ 3.5', '################################################## 4', ] > {"radius":4} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":4,"algorithm":"movingAverage"} [ '################################# 2.798', '#################################### 3.024', '######################################## 3.334', '############################################ 3.666', '############################################### 3.976', '################################################## 4.202', ] > input [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":5,"falloff":"step"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":5,"algorithm":"movingAverage","falloff":"step"} [ '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', ] > {"radius":5} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":5,"algorithm":"movingAverage"} [ '#################################### 2.931', '###################################### 3.111', '######################################### 3.364', '############################################# 3.636', '################################################ 3.889', '################################################## 4.069', ] > input [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":6,"falloff":"step"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":6,"algorithm":"movingAverage","falloff":"step"} [ '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', ] > {"radius":6} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":6,"algorithm":"movingAverage"} [ '###################################### 3.022', '######################################## 3.172', '########################################### 3.384', '############################################# 3.616', '################################################ 3.828', '################################################## 3.978', ] > input [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":7,"falloff":"step"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":7,"algorithm":"movingAverage","falloff":"step"} [ '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', ] > {"radius":7} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":7,"algorithm":"movingAverage"} [ '####################################### 3.088', '######################################### 3.216', '########################################### 3.4', '############################################## 3.6', '################################################ 3.784', '################################################## 3.912', ] > input [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":8,"falloff":"step"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":8,"algorithm":"movingAverage","falloff":"step"} [ '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', ] > {"radius":8} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":8,"algorithm":"movingAverage"} [ '######################################### 3.139', '########################################## 3.25', '############################################ 3.412', '############################################## 3.588', '################################################# 3.75', '################################################## 3.861', ] > input [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":9,"falloff":"step"} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":9,"algorithm":"movingAverage","falloff":"step"} [ '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', '################################################## 3.5', ] > {"radius":9} [ '######## 1', '################# 2', '######################### 3', '################################# 4', '########################################## 5', '################################################## 6', ] > {"radius":9,"algorithm":"movingAverage"} [ '########################################## 3.178', '########################################### 3.276', '############################################# 3.421', '############################################### 3.579', '################################################# 3.724', '################################################## 3.822', ] ## impulse at r=0 (no change) > input [ ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', '################################################## 100', ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', ] > {"radius":0,"falloff":"step"} [ ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', '################################################## 100', ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', ] > {"radius":0,"algorithm":"movingAverage","falloff":"step"} [ ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', '################################################## 100', ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', ] > {"radius":0} [ ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', '################################################## 100', ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', ] > {"radius":0,"algorithm":"movingAverage"} [ ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', '################################################## 100', ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', ] ## impulse at r=1 > input [ ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', '################################################## 100', ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', ] > {"radius":1,"falloff":"step"} [ ' 0', ' 0', ' 0', ' 0', ' 0', '################################################## 33.333', '################################################## 33.333', '################################################## 33.333', ' 0', ' 0', ' 0', ' 0', ' 0', ] > {"radius":1,"algorithm":"movingAverage","falloff":"step"} [ ' 0', ' 0', ' 0', ' 0', ' 0', '################################################## 33.333', '################################################## 33.333', '################################################## 33.333', ' 0', ' 0', ' 0', ' 0', ' 0', ] > {"radius":1} [ ' -0.38', ' -0.064', '# 0.544', '## 2.061', '####### 6.088', '################## 16.94', '################################################## 46.273', '################## 16.94', '####### 6.088', '## 2.061', '# 0.544', ' -0.064', ' -0.38', ] > {"radius":1,"algorithm":"movingAverage"} [ ' 0.157', ' 0.346', '# 0.878', '### 2.332', '####### 6.286', '################## 17.035', '################################################## 46.273', '################## 17.035', '####### 6.286', '### 2.332', '# 0.878', ' 0.346', ' 0.157', ] ## impulse at r=2 (the default) > input [ ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', '################################################## 100', ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', ] > {"radius":2,"falloff":"step"} [ ' 0', ' 0', ' 0', ' 0', '################################################## 20', '################################################## 20', '################################################## 20', '################################################## 20', '################################################## 20', ' 0', ' 0', ' 0', ' 0', ] > {"radius":2,"algorithm":"movingAverage","falloff":"step"} [ ' 0', ' 0', ' 0', ' 0', '################################################## 20', '################################################## 20', '################################################## 20', '################################################## 20', '################################################## 20', ' 0', ' 0', ' 0', ' 0', ] > {"radius":2} [ ' -1.689', ' -0.152', '### 1.739', '######### 4.46', '################# 8.625', '############################## 15.165', '################################################## 25.449', '############################## 15.165', '################# 8.625', '######### 4.46', '### 1.739', ' -0.152', ' -1.689', ] > {"radius":2,"algorithm":"movingAverage"} [ '#### 1.962', '##### 2.613', '######## 3.861', '############ 5.995', '################### 9.565', '############################## 15.513', '################################################## 25.449', '############################## 15.513', '################### 9.565', '############ 5.995', '######## 3.861', '##### 2.613', '#### 1.962', ] ## impulse function is smoothed > input [ ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', '################################################## 100', ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', ] > {"falloff":"step"} [ ' 0', ' 0', ' 0', ' 0', '################################################## 20', '################################################## 20', '################################################## 20', '################################################## 20', '################################################## 20', ' 0', ' 0', ' 0', ' 0', ] > {"algorithm":"movingAverage","falloff":"step"} [ ' 0', ' 0', ' 0', ' 0', '################################################## 20', '################################################## 20', '################################################## 20', '################################################## 20', '################################################## 20', ' 0', ' 0', ' 0', ' 0', ] > {} [ ' -1.689', ' -0.152', '### 1.739', '######### 4.46', '################# 8.625', '############################## 15.165', '################################################## 25.449', '############################## 15.165', '################# 8.625', '######### 4.46', '### 1.739', ' -0.152', ' -1.689', ] > {"algorithm":"movingAverage"} [ '#### 1.962', '##### 2.613', '######## 3.861', '############ 5.995', '################### 9.565', '############################## 15.513', '################################################## 25.449', '############################## 15.513', '################### 9.565', '############ 5.995', '######## 3.861', '##### 2.613', '#### 1.962', ] ## missing point is filled in > input [ '#### 100', '######## 200', '############# 300', '################# 400', '##################### 500', ' undefined', '############################# 700', '################################# 800', '###################################### 900', '########################################## 1000', '############################################## 1100', '################################################## 1200', ] > {"falloff":"step"} [ '#### 100', '######## 200', '############# 300', '################# 400', '##################### 500', '######################### 600', '############################# 700', '################################# 800', '###################################### 900', '########################################## 1000', '############################################## 1100', '################################################## 1200', ] > {"algorithm":"movingAverage","falloff":"step"} [ '######### 200', '########### 250', '############## 300', '################ 350', '###################### 475', '########################### 600', '################################# 725', '####################################### 850', '######################################### 900', '############################################# 1000', '################################################ 1050', '################################################## 1100', ] > {} [ '#### 100', '######## 200', '############ 300', '################# 400', '##################### 500', '######################### 600', '############################# 700', '################################# 800', '##################################### 900', '########################################## 1000', '############################################## 1100', '################################################## 1200', ] > {"algorithm":"movingAverage"} [ '########### 239.495', '############## 287.918', '################# 352.154', '#################### 426.104', '######################## 509.748', '############################# 610.373', '################################## 709.404', '###################################### 794.66', '######################################### 873.076', '############################################# 945.4', '################################################ 1009.33', '################################################## 1057.823', ] ## points beyond edge ignored > input [ ' null', '########## 2', '############### 3', '#################### 4', '######################### 5', '############################## 6', '################################### 7', '######################################## 8', '############################################# 9', '################################################## 10', ' null', ' null', ' null', ' null', ' null', ] > {"falloff":"step"} [ ' null', '########## 2', '############### 3', '#################### 4', '######################### 5', '############################## 6', '################################### 7', '######################################## 8', '############################################# 9', '################################################## 10', ' null', ' null', ' null', ' null', ' null', ] > {"algorithm":"movingAverage","falloff":"step"} [ ' null', '################# 3', '################### 3.5', '###################### 4', '############################ 5', '################################# 6', '####################################### 7', '############################################ 8', '############################################### 8.5', '################################################## 9', ' null', ' null', ' null', ' null', ' null', ] > {} [ ' null', '########## 2', '############### 3', '#################### 4', '######################### 5', '############################## 6', '################################### 7', '######################################## 8', '############################################# 9', '################################################## 10', ' null', ' null', ' null', ' null', ' null', ] > {"algorithm":"movingAverage"} [ ' null', '#################### 3.44', '####################### 3.924', '########################### 4.558', '############################### 5.263', '################################### 6', '####################################### 6.737', '########################################### 7.442', '############################################### 8.076', '################################################## 8.56', ' null', ' null', ' null', ' null', ' null', ] ## step function is smoothed > input [ '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', ] > {"falloff":"step"} [ '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '############################## 120', '################################### 140', '######################################## 160', '############################################# 180', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', ] > {"algorithm":"movingAverage","falloff":"step"} [ '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '######################### 100', '############################## 120', '################################### 140', '######################################## 160', '############################################# 180', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', '################################################## 200', ] > {} [ '######################### 99.082', '######################### 99.376', '######################### 99.652', '######################### 100.001', '######################### 100.51', '######################### 101.301', '########################## 102.569', '########################## 104.631', '########################### 108.006', '############################ 113.547', '############################### 122.66', '################################## 137.66', '######################################## 162.34', '############################################ 177.34', '############################################## 186.453', '################################################ 191.994', '################################################# 195.369', '################################################# 197.431', '################################################# 198.699', '################################################## 199.49', '################################################## 199.999', '################################################## 200.348', '################################################## 200.624', '################################################## 200.918', ] > {"algorithm":"movingAverage"} [ '######################### 100.247', '######################### 100.329', '######################### 100.486', '######################### 100.753', '######################### 101.199', '########################## 101.935', '########################## 103.151', '########################## 105.156', '########################### 108.463', '############################# 113.918', '############################### 122.914', '################################## 137.754', '######################################### 162.246', '############################################ 177.086', '############################################### 186.082', '################################################ 191.537', '################################################# 194.844', '################################################# 196.849', '################################################## 198.065', '################################################## 198.801', '################################################## 199.247', '################################################## 199.514', '################################################## 199.671', '################################################## 199.753', ] ## straight line > input [ '#### 1', '######## 2', '############# 3', '################# 4', '##################### 5', '######################### 6', '############################# 7', '################################# 8', '###################################### 9', '########################################## 10', '############################################## 11', '################################################## 12', ] > {"falloff":"step"} [ '#### 1', '######## 2', '############# 3', '################# 4', '##################### 5', '######################### 6', '############################# 7', '################################# 8', '###################################### 9', '########################################## 10', '############################################## 11', '################################################## 12', ] > {"algorithm":"movingAverage","falloff":"step"} [ '######### 2', '########### 2.5', '############## 3', '################## 4', '####################### 5', '########################### 6', '################################ 7', '#################################### 8', '######################################### 9', '############################################# 10', '################################################ 10.5', '################################################## 11', ] > {} [ '#### 1', '######## 2', '############ 3', '################# 4', '##################### 5', '######################### 6', '############################# 7', '################################# 8', '##################################### 9', '########################################## 10', '############################################## 11', '################################################## 12', ] > {"algorithm":"movingAverage"} [ '############ 2.512', '############## 3.014', '################## 3.68', '##################### 4.433', '######################### 5.24', '############################# 6.077', '################################# 6.923', '##################################### 7.76', '######################################### 8.567', '############################################ 9.32', '################################################ 9.986', '################################################## 10.488', ] ## zeros are handled correctly > input [ ' 0', ' 0', ' 0', ' 0', ' 0', ' 0', '################################################## 100', '################################################## 100', '################################################## 100', '################################################## 100', '################################################## 100', '################################################## 100', ] > {"falloff":"step"} [ ' 0', ' 0', ' 0', ' 0', '########## 20', '#################### 40', '############################## 60', '######################################## 80', '################################################## 100', '################################################## 100', '################################################## 100', '################################################## 100', ] > {"algorithm":"movingAverage","falloff":"step"} [ ' 0', ' 0', ' 0', ' 0', '########## 20', '#################### 40', '############################## 60', '######################################## 80', '################################################## 100', '################################################## 100', '################################################## 100', '################################################## 100', ] > {} [ ' -6.771', ' -2.634', '# 2.183', '#### 9.03', '######### 19.585', '################# 36.435', '############################## 63.565', '###################################### 80.415', '########################################### 90.97', '############################################## 97.817', '################################################ 102.634', '################################################## 106.771', ] > {"algorithm":"movingAverage"} [ '## 4.743', '### 6.318', '##### 9.341', '######## 14.521', '############ 23.209', '#################### 37.754', '################################# 62.246', '######################################## 76.791', '############################################# 85.479', '################################################ 90.659', '################################################# 93.682', '################################################## 95.257', ] ## points beyond edge ignored (2) > input [ ' undefined', '########### 200', '################# 300', ' undefined', '############################ 500', ' undefined', '####################################### 700', '############################################ 800', '################################################## 900', ] > {"falloff":"step"} [ ' undefined', '########### 200', '################# 300', '###################### 400', '############################ 500', '################################# 600', '####################################### 700', '############################################ 800', '################################################## 900', ] > {"algorithm":"movingAverage","falloff":"step"} [ ' undefined', '################ 250', '##################### 333.333', '##################### 333.333', '############################### 500', '########################################## 666.667', '############################################# 725', '################################################## 800', '################################################## 800', ] > {} [ ' undefined', '########### 200', '################# 300', '###################### 400', '############################ 500', '################################# 600', '####################################### 700', '############################################ 800', '################################################## 900', ] > {"algorithm":"movingAverage"} [ ' undefined', '#################### 310.278', '####################### 361.55', '############################ 443.799', '################################# 523.36', '####################################### 608.99', '########################################### 686.513', '############################################### 746.32', '################################################## 790.684', ]