Skip to content

Instantly share code, notes, and snippets.

View hovsep's full-sized avatar
🤓
Constant learner

Ovsep Avakian hovsep

🤓
Constant learner
  • SumUp
  • Sofia, Bulgaria
View GitHub Profile
@hovsep
hovsep / testing.go
Created February 23, 2026 20:14
testing_helper
// WithRunningSimulation is a helper function that runs the simulation and executes a callback after a given duration
func WithRunningSimulation(sim *step_sim.Simulation, duration time.Duration, f func()) {
go sim.Run()
defer func() {
sim.SendCommand(step_sim.Exit)
}()
// Let the simulation run for a while
time.Sleep(duration)
@hovsep
hovsep / autonomic_tone.go
Created March 19, 2026 19:28
Components of autonomic tone
// PackAutonomicTone builds a signal that represents autonomic tone
func PackAutonomicTone(sym, paraSym, noise, gain, cardiacBias, vascularBias, respiratoryBias, giBias float64) *signal.Signal {
return signal.New(signal.NewGroup().Add(
NewLevel(sym, common.Sympathetic),
NewLevel(paraSym, common.Parasympathetic),
NewLevel(noise, common.Noise),
NewLevel(gain, common.Gain),
NewBias(cardiacBias, common.Cardiac),
NewBias(vascularBias, common.Vascular),
NewBias(respiratoryBias, common.Respiratory),
// What it checks: run simulation for 100ms and check the ECG, we must see a few R-peaks
func Test_Human(t *testing.T) {
tests := []struct {
name string
assertions func(t *testing.T, sim *step_sim.Simulation)
}{
{
name: "heart is beating",
assertions: func(t *testing.T, sim *step_sim.Simulation) {