Skip to content

Commit 9240dba

Browse files
authored
Improve error description of setproperty! (#287)
* Add throw error dim mis * Fix space * Change assertionerror to dimensionmismatch in test
1 parent f0ba90d commit 9240dba

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/GNNGraphs/datastore.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function Base.setproperty!(ds::DataStore, s::Symbol, x)
109109
@assert s != :_n "cannot set _n directly"
110110
@assert s != :_data "cannot set _data directly"
111111
if getn(ds) >= 0
112-
@assert numobs(x) == getn(ds) "expected (numobs(x) == getn(ds)) but got $(numobs(x)) != $(getn(ds))"
112+
numobs(x) == getn(ds) || throw(DimensionMismatch("expected $(getn(ds)) object features but got $(numobs(x))."))
113113
end
114114
return getdata(ds)[s] = x
115115
end

test/GNNGraphs/datastore.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ end
1717
x = rand(10)
1818
ds = DataStore(10, (:x => x, :y => rand(2, 10)))
1919
@test ds.x == ds[:x] == x
20-
@test_throws AssertionError ds.z=rand(12)
20+
@test_throws DimensionMismatch ds.z=rand(12)
2121
ds.z = [1:10;]
2222
@test ds.z == [1:10;]
2323
end

0 commit comments

Comments
 (0)