forked from gorgonia/gorgonia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
op_test.go
51 lines (40 loc) · 869 Bytes
/
op_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package gorgonia
import "testing"
func TestStupid(t *testing.T) {
g := NewGraph()
n := newNode(WithType(Float64), In(g))
op := newElemUnaryOp(negOpType, n)
t.Logf("%v %d %s", op, op.unaryOpType(), op.ʘUnaryOperator)
v := newF64(3.1415)
rv, err := op.Do(v)
t.Logf("%v, %v", rv, err)
}
func TestOpEquality(t *testing.T) {
var op1, op2 Op
g := NewGraph()
a := NewScalar(g, Float64, WithValue(3.14))
b := NewScalar(g, Float64, WithValue(6.28))
op1 = newElemBinOp(addOpType, a, b)
op2 = newElemBinOp(addOpType, a, b)
if op1.Hashcode() != op2.Hashcode() {
t.Error("oops")
}
op1 = maxOp{
along: axes{0, 1},
d: 2,
}
op2 = maxOp{
along: axes{0, 1},
d: 2,
}
if op1.Hashcode() != op2.Hashcode() {
t.Error("oops")
}
op2 = sumOp{
along: axes{0, 1},
d: 2,
}
if op1.Hashcode() == op2.Hashcode() {
t.Error("oops")
}
}