Skip to content

Instantly share code, notes, and snippets.

@clarkmcc
Created October 16, 2023 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarkmcc/2215cf2199742bf82eb3a475ac3f2583 to your computer and use it in GitHub Desktop.
Save clarkmcc/2215cf2199742bf82eb3a475ac3f2583 to your computer and use it in GitHub Desktop.
Decoding and running a Scale function
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