"""Write a valid example submission: the persistence baseline (predict that activity does not change).

Usage: python make_persistence_submission.py data/benchmark.npz persistence_submission.npz
Persistence needs no training, so the fold rule does not matter here. A trained model must, for each fold f, fit on
animals whose fold (benchmark_meta.json, "fold_of") is not f and predict the animals in fold f.
"""
import sys
import numpy as np

z = np.load(sys.argv[1])
sub = {k[2:]: np.where(z["M/" + k[2:]], z[k], np.nan).astype(np.float32) for k in z.files if k.startswith("X/")}
np.savez_compressed(sys.argv[2], **sub)
print(f"wrote {len(sub)} animals to {sys.argv[2]}")
