Skip to content

Commit 0651066

Browse files
committed
rewrite the module for best practices
1 parent 7e2022c commit 0651066

File tree

5 files changed

+26
-16
lines changed

5 files changed

+26
-16
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MacOS default directory
22
*.DS_Store
3-
.CondaPkg
3+
*.CondaPkg
44

55
# Files generated by invoking Julia with --code-coverage
66
*.jl.cov

src/Cclib.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module Cclib
2+
using PythonCall
3+
using CondaPkg
24

3-
include("./functions.jl")
5+
include("functions.jl")
6+
include("config.jl")
47

58
const cclib = Ref{Py}()
69

src/data.jl renamed to src/config.jl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export cclibtypes
2+
13
cclibtypes = Dict(
24
"aonames" => Array{String},
35
"aooverlaps" => Array{Float64, 2},
@@ -72,13 +74,3 @@ cclibtypes = Dict(
7274
"vibsyms" => Array{String},
7375
"zpve" => Float64
7476
)
75-
76-
using Cclib
77-
using PythonCall
78-
m3 = ccread("./test/data/Trp_polar_tdhf.out")
79-
80-
for (key, value) in m3
81-
type = cclibtypes[key]
82-
m3[key] = pyconvert(type, value)
83-
end
84-
m3

src/functions.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
using PythonCall
2-
using CondaPkg
3-
41
export ccread
52

63

7-
function ccread(file)
4+
function pyccread(file)
85
data = cclib[].io.ccread(file)
96
keys = pyconvert(Array, data.__dict__.keys())
107
values = pyconvert(Array, data.__dict__.values())
118
return Dict(zip(keys, values))
9+
end
10+
11+
function ccread(pydict)
12+
datadict = pyccread(pydict)
13+
for (key, value) in datadict
14+
type = cclibtypes[key]
15+
datadict[key] = pyconvert(type, value)
16+
end
17+
return datadict
1218
end

test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ using Test
33

44

55
@testset "Cclib.jl" begin
6+
7+
# Start with something simple
68
@test ccread("./test/data/uracil_two.xyz")["natom"] == 12
9+
@test ccread("./test/data/uracil_two.xyz")["atomnos"] == [7, 6, 1, 8, 7, 6, 8, 6, 6, 1, 1, 1]
10+
@test ccread("./test/data/uracil_two.xyz")["atomcoords"] == [5.435 4.091 6.109 3.647 3.253 3.636 2.79 5.065 5.906 2.243 5.448 7.003;
11+
5.42432 4.08846 6.05396 3.68445 3.24195 3.62987 2.83542 5.0864 5.91213 2.2534 5.42415 6.9915;;;
12+
3.248 3.266 3.347 3.394 3.118 2.955 2.842 2.953 3.101 3.138 2.833 3.119;
13+
3.24732 3.26356 3.354 3.39863 3.11963 2.96568 2.83961 2.95832 3.09904 3.12801 2.83814 3.10206;;;
14+
-0.916 -0.635 -0.144 0.495 -1.717 -3.039 -3.923 -3.239 -2.202 -1.514 -4.258 -2.345;
15+
-0.9432 -0.64127 -0.15563 0.50851 -1.70419 -3.0054 -3.9297 -3.25044 -2.21101 -1.51035 -4.27067 -2.32366]
716
end
817

0 commit comments

Comments
 (0)