| 7 | type FailReport<T = unknown> = { error: Error; sample: T }; |
| 8 | |
| 9 | const tryOnSamples = <T = unknown>(samples: T[], fn: (sample: T) => void): FailReport[] => { |
| 10 | const fails: FailReport[] = []; |
| 11 | samples.forEach((sample) => { |
| 12 | try { |
| 13 | fn(sample); |
| 14 | } catch (e) { |
| 15 | fails.push({ error: e as Error, sample }); |
| 16 | } |
| 17 | }); |
| 18 | if (fails.length > 0) { |
| 19 | const { sample, error } = fails.last(); |
| 20 | /* eslint-disable no-console */ |
| 21 | console.error(error); |
| 22 | console.log('Sample:', sample); |
| 23 | /* eslint-enable no-console */ |
| 24 | } |
| 25 | return fails; |
| 26 | }; |
| 27 | |
| 28 | describe('Decoder', () => { |
| 29 | it('Should decode seeded hyperparameters', () => { |