Created
October 16, 2023 13:35
-
-
Save clarkmcc/2215cf2199742bf82eb3a475ac3f2583 to your computer and use it in GitHub Desktop.
Decoding and running a Scale function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sf := new(scalefunc.Schema) | |
err := sf.Decode(model) | |
if err != nil { | |
panic(err) | |
} | |
s, err := scale.New(scale.NewConfig(signature.New).WithFunction(sf)) | |
if err != nil { | |
panic(err) | |
} | |
instance, err := s.Instance() | |
if err != nil { | |
panic(err) | |
} | |
sig := signature.New() | |
sig.Context.Pixels = example | |
err = instance.Run(context.Background(), sig) | |
if err != nil { | |
panic(err) | |
} | |
if sig.Context.Digit != uint32(i) { | |
panic(fmt.Sprintf("expected %d, got %d", i, sig.Context.Digit)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment