Skip to content

Commit 87ff250

Browse files
Alexey Stukalovalyst
authored andcommitted
reorder_obs_cov/mean(): cleanup
1 parent 8f88704 commit 87ff250

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/observed/covariance.jl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,8 @@ function reorder_obs_cov(obs_cov, spec_colnames, obs_colnames)
107107
if spec_colnames == obs_colnames
108108
return obs_cov
109109
else
110-
new_position = [findall(x .== obs_colnames)[1] for x in spec_colnames]
111-
indices = reshape(
112-
[CartesianIndex(i, j) for j in new_position for i in new_position],
113-
size(obs_cov, 1),
114-
size(obs_cov, 1),
115-
)
116-
obs_cov = obs_cov[indices]
110+
new_position = [findfirst(==(x), obs_colnames) for x in spec_colnames]
111+
obs_cov = obs_cov[new_position, new_position]
117112
return obs_cov
118113
end
119114
end
@@ -125,7 +120,7 @@ function reorder_obs_mean(obs_mean, spec_colnames, obs_colnames)
125120
if spec_colnames == obs_colnames
126121
return obs_mean
127122
else
128-
new_position = [findall(x .== obs_colnames)[1] for x in spec_colnames]
123+
new_position = [findfirst(==(x), obs_colnames) for x in spec_colnames]
129124
obs_mean = obs_mean[new_position]
130125
return obs_mean
131126
end

0 commit comments

Comments
 (0)