Skip to content

Commit ef76a68

Browse files
committed
Better error message
1 parent 20a8eb9 commit ef76a68

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ConvNetSharp.Volume/NcwhVolumeStorage.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,17 @@ public override void Clear()
4444

4545
public override void CopyFrom(VolumeStorage<T> source)
4646
{
47-
var real = source as NcwhVolumeStorage<T>;
47+
var src = source as NcwhVolumeStorage<T>;
4848

49-
Array.Copy(real._storage, this._storage, this._storage.Length);
49+
if (!ReferenceEquals(this, src))
50+
{
51+
if (this.Shape.TotalLength != src.Shape.TotalLength)
52+
{
53+
throw new ArgumentException($"origin and destination volume should have the same number of weight ({this.Shape.TotalLength} != {src.Shape}).");
54+
}
55+
56+
Array.Copy(src._storage, this._storage, this._storage.Length);
57+
}
5058
}
5159

5260
public override T Get(int[] coordinates)

0 commit comments

Comments
 (0)