Skip to content

Commit 208f52b

Browse files
committed
Clean_up_01
1 parent 605ec22 commit 208f52b

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/methods/adjustment_sets.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ $(SIGNATURES)
99
Part of the API, Exported
1010
"""
1111
function syms_in_paths(paths, f, l)
12-
thepaths = deepcopy(paths)
1312
syms = Symbol[]
14-
for p in thepaths
13+
for p in paths
1514
setdiff!(p, [f, l])
1615
append!(syms, p)
1716
unique!(syms)
@@ -44,22 +43,22 @@ $(SIGNATURES)
4443
4544
Part of the API, Exported
4645
"""
47-
function adjustment_sets(d::DAG, f::Symbol, l::Symbol; debug=false)
46+
function adjustment_sets(dag::DAG, f::Symbol, l::Symbol; debug=false)
4847

49-
ap = all_paths(d, f, l)
50-
paths = backdoor_paths(d, ap, f)
48+
ap = all_paths(dag, f, l)
49+
paths = backdoor_paths(dag, ap, f)
5150
debug && display(paths)
5251
lsyms = syms_in_paths(paths, f, l)
5352
adjustmentsets = Vector{Symbol}[]
5453
for s in lsyms
5554
debug && println("checking $s in $lsyms")
5655
if sym_in_all_paths(paths, s)
57-
opensets = length(open_paths(d, paths, [s]))
56+
opensets = length(open_paths(dag, paths, [s]))
5857
if opensets == 0
5958
debug && println("$s closes all paths.")
6059
append!(adjustmentsets, [[s]])
6160
end
62-
elseif length(open_paths(d, paths, [s])) == 0
61+
elseif length(open_paths(dag, paths, [s])) == 0
6362
debug && println("$s not in all paths but no open paths.")
6463
append!(adjustmentsets, [[s]])
6564
end
@@ -74,7 +73,7 @@ function adjustment_sets(d::DAG, f::Symbol, l::Symbol; debug=false)
7473
csyms = collect(combinations(lsyms, len))
7574
debug && csyms |> display
7675
for s in csyms
77-
if length(open_paths(d, paths, s)) == 0
76+
if length(open_paths(dag, paths, s)) == 0
7877
debug && println("$s closes all paths")
7978
append!(adjustmentsets, [s])
8079
setdiff!(lsyms, s)

src/methods/pcor.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The Julia translation is licenced under: MIT.
5353
5454
Part of the api, not exported.
5555
"""
56-
function pcor(d:: DAG, u::SymbolList)
56+
function pcor(d::DAG, u::SymbolList)
5757
us = String.(u)
5858
k = inv(d.s[us, us])
5959
-k[1,2] / sqrt(k[1,1] * k[2,2])

test/test_descendents_03.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using StructuralCausalModels, Test
22

3+
ProjDir = @__DIR__
4+
35
d_str = "dag{k1 -> k2;k2 -> y;v -> x2;w -> k1;x1 -> v;x1 -> w;x2 -> y;x3 -> w;x3 -> y}"
46

57
dag = DAG("test_desc", d_str)
@@ -8,7 +10,7 @@ to_dagitty(dag)
810

911
fname = joinpath(ProjDir, "test_descendents_03.dot")
1012
to_graphviz(dag, fname)
11-
#Sys.isapple() && run(`open -a GraphViz.app $(fname)`)
13+
Sys.isapple() && run(`open -a GraphViz.app $(fname)`)
1214

1315
bs = basis_set(dag)
1416
as = adjustment_sets(dag, :x2, :y)

0 commit comments

Comments
 (0)