SHARE
TWEET

Untitled

a guest Apr 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using Test, Distributions, CSV, GLM, Lasso, DataFrames
  2. using Random, Distributed, LinearAlgebra, SparseArrays, SharedArrays
  3.  
  4. include("./test/testutils.jl")
  5. include("./test/addworkers.jl")
  6.  
  7. import HurdleDMR; @everywhere using HurdleDMR
  8.  
  9. include("./test/testdata.jl")
  10.  
  11. testargs = Dict(:verbose=>false,:showwarnings=>true)
  12.  
  13. zcounts = deepcopy(counts);
  14. zcounts[:,2] = zeros(n);
  15. zcounts[:,3] = ones(n);
  16.  
  17. # make sure we are not adding all zero obseravtions
  18. m = sum(zcounts, dims=2)
  19. @test sum(m .== 0) == 0
  20.  
  21. # hurdle dmr parallel local cluster
  22. hdmrcoefs = fit(HDMR,covars, zcounts; parallel=true, testargs...)
  23. coefsHppos, coefsHpzero = coef(hdmrcoefs);
  24.  
  25. # hurdle dmr parallel remote cluster
  26. hdmrcoefs2 = fit(HDMRPaths,covars, zcounts; parallel=true, local_cluster=false, testargs...)
  27. coefsHppos2, coefsHpzero2 = coef(hdmrcoefs2)
  28. @test coefsHppos ≈ coefsHppos2
  29. @test coefsHpzero ≈ coefsHpzero2
  30.  
  31. η = predict(hdmrcoefs2,newcovars)
  32. # 10×4 Array{Float64,2}:
  33. #  0.00632811   0.0  0.0  0.993672
  34. #  0.0820357    0.0  0.0  0.917964
  35. #  0.120042     0.0  0.0  0.879958
  36. #  0.000773842  0.0  0.0  0.999226
  37. #  0.00158558   0.0  0.0  0.998414
  38. #  0.0587256    0.0  0.0  0.941274
  39. #  0.0155122    0.0  0.0  0.984488
  40. #  0.00119599   0.0  0.0  0.998804
  41. #  0.018085     0.0  0.0  0.981915
  42. #  0.0141473    0.0  0.0  0.985853
  43. @test sum(η, dims=2) ≈ ones(size(newcovars, 1))
  44. # Test Passed
  45. @test η[:,2] == zeros(size(newcovars,1))
  46. # Test Passed
  47. @test η[:,3] ≈ ones(size(newcovars,1))*0.36 rtol=0.05
  48. # Test Failed at none:1
  49. #   Expression: ≈(η[:, 3], ones(size(newcovars, 1)) * 0.36, rtol=0.05)
  50. #    Evaluated: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] ≈ [0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.36, 0.36] (rtol=0.05)
  51. # ERROR: There was an error during testing
  52. @test η[:,4] ≈ ones(size(newcovars,1))*0.6 rtol=0.06
  53. # Test Failed at none:2
  54. #   Expression: ≈(η[:, 4], ones(size(newcovars, 1)) * 0.6, rtol=0.06)
  55. #    Evaluated: [0.993672, 0.917964, 0.879958, 0.999226, 0.998414, 0.941274, 0.984488, 0.998804, 0.981915, 0.985853] ≈ [0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6] (rtol=0.06)
  56. # ERROR: There was an error during testing
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top