Skip to content

Commit c324396

Browse files
authored
Merge pull request #81 from yuehhua/pickle
Use Pickle in favor of PyCall
2 parents d184e5c + b124a43 commit c324396

File tree

8 files changed

+20
-27
lines changed

8 files changed

+20
-27
lines changed

.github/workflows/UnitTest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
julia-version: ['1.0', '1', 'nightly']
19+
julia-version: ['1.3', '1', 'nightly']
2020
os: [ubuntu-latest, windows-latest, macOS-latest]
2121
env:
2222
PYTHON: ""

Project.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
1111
GZip = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
1212
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
1313
MAT = "23992714-dd62-5051-b70f-ba57cb901cac"
14-
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
14+
Pickle = "fbb45041-c46e-462f-888f-7c521cafbc2c"
1515
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
16+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1617

1718
[compat]
1819
BinDeps = "1"
@@ -23,9 +24,9 @@ GZip = "0.5"
2324
ImageCore = "0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8"
2425
JSON3 = "1"
2526
MAT = "0.7, 0.8, 0.9, 0.10"
26-
PyCall = "1"
27+
Pickle = "0.2"
2728
Requires = "1"
28-
julia = "1"
29+
julia = "1.3"
2930

3031
[extras]
3132
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"

src/CiteSeer/CiteSeer.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ using DataDeps
2525
using ..MLDatasets: datafile, read_planetoid_data
2626
using DelimitedFiles: readdlm
2727

28-
using PyCall
29-
3028
const DEPNAME = "CiteSeer"
3129
const LINK = "https://github.com/kimiyoung/planetoid/raw/master/data"
3230
const DOCS = "https://github.com/kimiyoung/planetoid"

src/Cora/Cora.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ using DataDeps
3939
using ..MLDatasets: datafile, read_planetoid_data
4040
using DelimitedFiles: readdlm
4141

42-
using PyCall
43-
4442
const DEPNAME = "Cora"
4543
# LINK = "https://github.com/shchur/gnn-benchmark/raw/master/data/npz"
4644
# LINK = "https://github.com/abojchevski/graph2gauss/raw/master/data/"

src/MLDatasets.jl

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ using ColorTypes: length
55
using Requires
66
using DelimitedFiles: readdlm
77
using FixedPointNumbers, ColorTypes
8-
using PyCall
8+
using Pickle
9+
using SparseArrays
910

1011
# Julia 1.0 compatibility
1112
if !isdefined(Base, :isnothing)
@@ -67,20 +68,6 @@ function __init__()
6768
global __images_supported__ = true
6869
end
6970

70-
# install scipy if not already there
71-
pyimport_conda("scipy", "scipy")
72-
73-
py"""
74-
import pickle
75-
76-
def pyread_planetoid_file(path, name):
77-
out = pickle.load(open(path, "rb"), encoding="latin1")
78-
if name == 'graph':
79-
return out
80-
out = out.todense() if hasattr(out, 'todense') else out
81-
return out
82-
"""
83-
8471
__init__tudataset()
8572
end
8673

src/PubMed/PubMed.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ using DataDeps
2525
using ..MLDatasets: datafile, read_planetoid_data
2626
using DelimitedFiles: readdlm
2727

28-
using PyCall
29-
3028
const DEPNAME = "PubMed"
3129
const LINK = "https://github.com/kimiyoung/planetoid/raw/master/data"
3230
const DOCS = "https://github.com/kimiyoung/planetoid"

src/TUDataset/TUDataset.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function __init__tudataset()
1717
Website: $LINK)
1818
""",
1919
"$LINK/$DATA",
20-
# "81de017067dc045ebdb8ffd5c0e69a209973ffdb1fe2d5b434e94d3614f3f5c7", # if checksum omitted, will be generated by DataDeps
20+
"2da8de15284b88edabca2888ce5444d62f364ed41159260977088c4e53d4d848", # if checksum omitted, will be generated by DataDeps
2121
post_fetch_method = unpack
2222
))
2323
end

src/planetoid.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,23 @@ function read_planetoid_data(DEPNAME; dir=nothing, reverse_edges=true)
6969
directed = reverse_edges != true)
7070
end
7171

72+
function read_pickle_file(filename, name)
73+
out = Pickle.npyload(filename)
74+
if name == "graph"
75+
return out
76+
end
77+
if out isa SparseMatrixCSC
78+
return Matrix(out)
79+
end
80+
return out
81+
end
82+
7283
function read_planetoid_file(DEPNAME, name, dir)
7384
filename = datafile(DEPNAME, name, dir)
7485
if endswith(name, "test.index")
7586
out = 1 .+ vec(readdlm(filename, Int))
7687
else
77-
out = py"pyread_planetoid_file"(filename, name)
88+
out = read_pickle_file(filename, name)
7889
if out isa Matrix
7990
out = collect(out')
8091
end

0 commit comments

Comments
 (0)