From 1f0ca068dcc54f0d64e579ec4d295030fc5518dc Mon Sep 17 00:00:00 2001 From: ishii-norimi Date: Sun, 9 Nov 2025 22:15:52 +0900 Subject: [PATCH 1/9] Use vitest for lib test --- package-lock.json | 657 +++++++++++++++++- package.json | 6 +- tests/lib/model/a2c.test.js | 7 +- tests/lib/model/abod.test.js | 11 +- tests/lib/model/adaptive_thresholding.test.js | 4 +- tests/lib/model/affinity_propagation.test.js | 5 +- tests/lib/model/agglomerative.test.js | 2 +- tests/lib/model/akima.test.js | 2 +- tests/lib/model/ar.test.js | 5 +- tests/lib/model/arma.test.js | 7 +- tests/lib/model/art.test.js | 2 +- tests/lib/model/autoencoder.test.js | 5 +- tests/lib/model/ballseptron.test.js | 5 +- tests/lib/model/banditron.test.js | 2 +- tests/lib/model/bessel.test.js | 9 +- tests/lib/model/birch.test.js | 7 +- tests/lib/model/bisecting_kmeans.test.js | 5 +- tests/lib/model/bogd.test.js | 7 +- tests/lib/model/box_cox.test.js | 10 +- tests/lib/model/bpa.test.js | 9 +- tests/lib/model/bridge.test.js | 5 +- tests/lib/model/bsgd.test.js | 11 +- tests/lib/model/budget_perceptron.test.js | 2 +- tests/lib/model/catmull_rom.test.js | 5 +- tests/lib/model/chameleon.test.js | 5 +- tests/lib/model/chebyshev.test.js | 7 +- tests/lib/model/clique.test.js | 7 +- tests/lib/model/clues.test.js | 7 +- tests/lib/model/coll.test.js | 2 +- tests/lib/model/confidence_weighted.test.js | 7 +- tests/lib/model/crf.test.js | 7 +- tests/lib/model/dbclasd.test.js | 5 +- .../lib/model/delaunay_interpolation.test.js | 5 +- tests/lib/model/denclue.test.js | 9 +- tests/lib/model/diffusion_map.test.js | 5 +- tests/lib/model/diffusion_model.test.js | 5 +- tests/lib/model/doc.test.js | 9 +- tests/lib/model/dqn.test.js | 7 +- tests/lib/model/drake_kmeans.test.js | 5 +- tests/lib/model/elkan_kmeans.test.js | 5 +- tests/lib/model/elm.test.js | 7 +- tests/lib/model/enn.test.js | 2 +- tests/lib/model/findit.test.js | 5 +- tests/lib/model/forgetron.test.js | 7 +- tests/lib/model/gan.test.js | 7 +- tests/lib/model/gaussian_process.test.js | 7 +- tests/lib/model/gbdt.test.js | 11 +- tests/lib/model/genetic_algorithm.test.js | 5 +- tests/lib/model/gmeans.test.js | 5 +- tests/lib/model/gmm.test.js | 9 +- tests/lib/model/gplvm.test.js | 6 +- tests/lib/model/growing_neural_gas.test.js | 5 +- tests/lib/model/growing_som.test.js | 2 +- tests/lib/model/gtm.test.js | 5 +- tests/lib/model/hamelry_kmeans.test.js | 5 +- tests/lib/model/hampel.test.js | 5 +- tests/lib/model/hdbscan.test.js | 9 +- tests/lib/model/histogram.test.js | 5 +- tests/lib/model/hlle.test.js | 7 +- tests/lib/model/hmm.test.js | 11 +- tests/lib/model/holt_winters.test.js | 9 +- tests/lib/model/huber_regression.test.js | 2 +- tests/lib/model/ica.test.js | 5 +- tests/lib/model/inflo.test.js | 5 +- tests/lib/model/isodata.test.js | 5 +- tests/lib/model/isomap.test.js | 2 +- tests/lib/model/kalman_filter.test.js | 2 +- tests/lib/model/kdeos.test.js | 7 +- .../model/kernel_density_estimator.test.js | 9 +- tests/lib/model/kernel_kmeans.test.js | 5 +- tests/lib/model/kernelized_pegasos.test.js | 4 +- tests/lib/model/kernelized_perceptron.test.js | 4 +- tests/lib/model/kliep.test.js | 7 +- tests/lib/model/kmeans.test.js | 4 +- tests/lib/model/kmodes.test.js | 5 +- tests/lib/model/knearestneighbor.test.js | 17 +- tests/lib/model/kprototypes.test.js | 5 +- tests/lib/model/ksvd.test.js | 5 +- tests/lib/model/label_propagation.test.js | 2 +- tests/lib/model/label_spreading.test.js | 2 +- tests/lib/model/ladder_network.test.js | 5 +- tests/lib/model/lagrange.test.js | 5 +- tests/lib/model/laplacian.test.js | 2 +- tests/lib/model/laplacian_eigenmaps.test.js | 9 +- tests/lib/model/lasso.test.js | 2 +- .../model/latent_dirichlet_allocation.test.js | 5 +- tests/lib/model/lda.test.js | 11 +- tests/lib/model/ldof.test.js | 5 +- tests/lib/model/lerp.test.js | 5 +- tests/lib/model/lle.test.js | 5 +- tests/lib/model/lmclus.test.js | 5 +- tests/lib/model/lmeds.test.js | 2 +- tests/lib/model/loci.test.js | 2 +- tests/lib/model/loess.test.js | 5 +- tests/lib/model/lof.test.js | 5 +- .../model/logarithmic_interpolation.test.js | 5 +- tests/lib/model/lowess.test.js | 5 +- tests/lib/model/lowpass.test.js | 7 +- tests/lib/model/lsa.test.js | 2 +- tests/lib/model/lsdd.test.js | 7 +- tests/lib/model/lsif.test.js | 5 +- tests/lib/model/ltsa.test.js | 7 +- tests/lib/model/lvq.test.js | 5 +- tests/lib/model/macqueen_kmeans.test.js | 5 +- tests/lib/model/madaline.test.js | 9 +- tests/lib/model/markov_switching.test.js | 5 +- tests/lib/model/mars.test.js | 2 +- tests/lib/model/maximum_likelihood.test.js | 5 +- tests/lib/model/mh.test.js | 5 +- tests/lib/model/mlle.test.js | 5 +- tests/lib/model/mlp.test.js | 7 +- tests/lib/model/mod.test.js | 5 +- tests/lib/model/monte_carlo.test.js | 5 +- tests/lib/model/mountain.test.js | 5 +- tests/lib/model/moving_average.test.js | 5 +- tests/lib/model/mt.test.js | 5 +- ...tivariate_kernel_density_estimator.test.js | 5 +- tests/lib/model/mutual_information.test.js | 5 +- tests/lib/model/mutual_knn.test.js | 7 +- tests/lib/model/n_cubic_interpolation.test.js | 5 +- tests/lib/model/narow.test.js | 2 +- .../natural_neighbor_interpolation.test.js | 5 +- tests/lib/model/nca.test.js | 5 +- tests/lib/model/nice.test.js | 5 +- tests/lib/model/nlmeans.test.js | 2 +- tests/lib/model/nns/layer/apl.test.js | 5 +- tests/lib/model/nns/layer/argmax.test.js | 29 +- tests/lib/model/nns/layer/argmin.test.js | 29 +- tests/lib/model/nns/layer/attention.test.js | 11 +- tests/lib/model/nns/layer/averagepool.test.js | 5 +- .../nns/layer/batch_normalization.test.js | 2 +- tests/lib/model/nns/layer/blu.test.js | 5 +- tests/lib/model/nns/layer/brelu.test.js | 5 +- tests/lib/model/nns/layer/celu.test.js | 5 +- tests/lib/model/nns/layer/cloglog.test.js | 5 +- tests/lib/model/nns/layer/cloglogm.test.js | 5 +- tests/lib/model/nns/layer/conv.test.js | 7 +- tests/lib/model/nns/layer/div.test.js | 7 +- tests/lib/model/nns/layer/eelu.test.js | 5 +- tests/lib/model/nns/layer/equal.test.js | 2 +- tests/lib/model/nns/layer/erelu.test.js | 5 +- tests/lib/model/nns/layer/erf.test.js | 5 +- tests/lib/model/nns/layer/felu.test.js | 5 +- tests/lib/model/nns/layer/frelu.test.js | 5 +- tests/lib/model/nns/layer/function.test.js | 28 +- .../nns/layer/global_averagepool.test.js | 5 +- .../lib/model/nns/layer/global_lppool.test.js | 5 +- .../model/nns/layer/global_maxpool.test.js | 5 +- tests/lib/model/nns/layer/graph_conv.test.js | 7 +- tests/lib/model/nns/layer/graph_sage.test.js | 5 +- tests/lib/model/nns/layer/greater.test.js | 2 +- .../model/nns/layer/greater_or_equal.test.js | 2 +- tests/lib/model/nns/layer/hard_shrink.test.js | 5 +- tests/lib/model/nns/layer/hexpo.test.js | 4 +- tests/lib/model/nns/layer/input.test.js | 2 +- tests/lib/model/nns/layer/isigmoid.test.js | 4 +- .../nns/layer/layer_normalization.test.js | 2 +- tests/lib/model/nns/layer/less.test.js | 2 +- .../lib/model/nns/layer/less_or_equal.test.js | 2 +- tests/lib/model/nns/layer/loglog.test.js | 5 +- tests/lib/model/nns/layer/logsoftmax.test.js | 8 +- tests/lib/model/nns/layer/lppool.test.js | 5 +- tests/lib/model/nns/layer/lrn.test.js | 5 +- tests/lib/model/nns/layer/lstm.test.js | 7 +- tests/lib/model/nns/layer/max.test.js | 5 +- tests/lib/model/nns/layer/maxpool.test.js | 5 +- tests/lib/model/nns/layer/mean.test.js | 38 +- tests/lib/model/nns/layer/min.test.js | 5 +- tests/lib/model/nns/layer/mish.test.js | 5 +- tests/lib/model/nns/layer/mpelu.test.js | 5 +- tests/lib/model/nns/layer/nlrelu.test.js | 5 +- tests/lib/model/nns/layer/pau.test.js | 4 +- tests/lib/model/nns/layer/pdelu.test.js | 5 +- tests/lib/model/nns/layer/pelu.test.js | 5 +- tests/lib/model/nns/layer/power.test.js | 5 +- tests/lib/model/nns/layer/prelu.test.js | 5 +- tests/lib/model/nns/layer/preu.test.js | 5 +- tests/lib/model/nns/layer/prod.test.js | 43 +- tests/lib/model/nns/layer/psf.test.js | 9 +- tests/lib/model/nns/layer/ptanh.test.js | 4 +- tests/lib/model/nns/layer/ptelu.test.js | 7 +- tests/lib/model/nns/layer/reduce_max.test.js | 38 +- tests/lib/model/nns/layer/reduce_min.test.js | 38 +- tests/lib/model/nns/layer/relu.test.js | 5 +- tests/lib/model/nns/layer/resech.test.js | 5 +- tests/lib/model/nns/layer/rnn.test.js | 7 +- tests/lib/model/nns/layer/rrelu.test.js | 2 +- tests/lib/model/nns/layer/rtrelu.test.js | 7 +- tests/lib/model/nns/layer/selu.test.js | 5 +- tests/lib/model/nns/layer/silu.test.js | 5 +- tests/lib/model/nns/layer/slu.test.js | 5 +- tests/lib/model/nns/layer/soft_shrink.test.js | 5 +- tests/lib/model/nns/layer/softargmax.test.js | 9 +- tests/lib/model/nns/layer/softmax.test.js | 8 +- tests/lib/model/nns/layer/softmin.test.js | 8 +- tests/lib/model/nns/layer/sparse.test.js | 5 +- tests/lib/model/nns/layer/srelu.test.js | 5 +- tests/lib/model/nns/layer/srs.test.js | 9 +- tests/lib/model/nns/layer/stanh.test.js | 4 +- tests/lib/model/nns/layer/std.test.js | 45 +- tests/lib/model/nns/layer/sum.test.js | 38 +- .../model/nns/layer/thresholded_relu.test.js | 5 +- tests/lib/model/nns/layer/upsampling.test.js | 7 +- tests/lib/model/nns/layer/variance.test.js | 38 +- tests/lib/model/nns/onnx/layer/abs.test.js | 2 +- tests/lib/model/nns/onnx/layer/acos.test.js | 2 +- tests/lib/model/nns/onnx/layer/acosh.test.js | 2 +- tests/lib/model/nns/onnx/layer/add.test.js | 4 +- tests/lib/model/nns/onnx/layer/and.test.js | 4 +- tests/lib/model/nns/onnx/layer/apl.test.js | 4 +- tests/lib/model/nns/onnx/layer/aranda.test.js | 4 +- tests/lib/model/nns/onnx/layer/argmax.test.js | 2 +- tests/lib/model/nns/onnx/layer/argmin.test.js | 2 +- tests/lib/model/nns/onnx/layer/asin.test.js | 2 +- tests/lib/model/nns/onnx/layer/asinh.test.js | 2 +- tests/lib/model/nns/onnx/layer/atan.test.js | 2 +- tests/lib/model/nns/onnx/layer/atanh.test.js | 2 +- .../model/nns/onnx/layer/average_pool.test.js | 4 +- .../onnx/layer/batch_normalization.test.js | 4 +- tests/lib/model/nns/onnx/layer/bdaa.test.js | 4 +- .../nns/onnx/layer/bent_identity.test.js | 2 +- .../model/nns/onnx/layer/bitwise_and.test.js | 4 +- .../model/nns/onnx/layer/bitwise_or.test.js | 4 +- .../model/nns/onnx/layer/bitwise_xor.test.js | 4 +- tests/lib/model/nns/onnx/layer/blu.test.js | 4 +- tests/lib/model/nns/onnx/layer/brelu.test.js | 4 +- tests/lib/model/nns/onnx/layer/ceil.test.js | 2 +- tests/lib/model/nns/onnx/layer/celu.test.js | 4 +- tests/lib/model/nns/onnx/layer/clip.test.js | 2 +- .../lib/model/nns/onnx/layer/cloglog.test.js | 2 +- .../lib/model/nns/onnx/layer/cloglogm.test.js | 2 +- tests/lib/model/nns/onnx/layer/cond.test.js | 2 +- tests/lib/model/nns/onnx/layer/conv.test.js | 4 +- tests/lib/model/nns/onnx/layer/cos.test.js | 2 +- tests/lib/model/nns/onnx/layer/cosh.test.js | 2 +- tests/lib/model/nns/onnx/layer/div.test.js | 4 +- tests/lib/model/nns/onnx/layer/eelu.test.js | 4 +- tests/lib/model/nns/onnx/layer/elish.test.js | 2 +- .../lib/model/nns/onnx/layer/elliott.test.js | 2 +- tests/lib/model/nns/onnx/layer/elu.test.js | 4 +- tests/lib/model/nns/onnx/layer/equal.test.js | 2 +- tests/lib/model/nns/onnx/layer/erelu.test.js | 2 +- tests/lib/model/nns/onnx/layer/erf.test.js | 2 +- tests/lib/model/nns/onnx/layer/eswish.test.js | 4 +- tests/lib/model/nns/onnx/layer/exp.test.js | 2 +- tests/lib/model/nns/onnx/layer/felu.test.js | 4 +- tests/lib/model/nns/onnx/layer/floor.test.js | 2 +- tests/lib/model/nns/onnx/layer/frelu.test.js | 4 +- tests/lib/model/nns/onnx/layer/full.test.js | 2 +- .../lib/model/nns/onnx/layer/gaussian.test.js | 2 +- tests/lib/model/nns/onnx/layer/gelu.test.js | 4 +- .../onnx/layer/global_average_pool.test.js | 4 +- .../nns/onnx/layer/global_lp_pool.test.js | 4 +- .../nns/onnx/layer/global_max_pool.test.js | 4 +- .../lib/model/nns/onnx/layer/greater.test.js | 2 +- .../nns/onnx/layer/greater_or_equal.test.js | 2 +- .../model/nns/onnx/layer/hard_elish.test.js | 2 +- .../model/nns/onnx/layer/hard_shrink.test.js | 4 +- .../model/nns/onnx/layer/hard_sigmoid.test.js | 4 +- .../model/nns/onnx/layer/hard_swish.test.js | 2 +- .../model/nns/onnx/layer/hard_tanh.test.js | 4 +- tests/lib/model/nns/onnx/layer/hexpo.test.js | 4 +- .../lib/model/nns/onnx/layer/identity.test.js | 2 +- tests/lib/model/nns/onnx/layer/is_inf.test.js | 2 +- tests/lib/model/nns/onnx/layer/is_nan.test.js | 2 +- .../lib/model/nns/onnx/layer/isigmoid.test.js | 2 +- .../model/nns/onnx/layer/leaky_relu.test.js | 4 +- .../nns/onnx/layer/left_bitshift.test.js | 4 +- tests/lib/model/nns/onnx/layer/less.test.js | 2 +- .../nns/onnx/layer/less_or_equal.test.js | 2 +- tests/lib/model/nns/onnx/layer/lisht.test.js | 2 +- tests/lib/model/nns/onnx/layer/log.test.js | 2 +- .../model/nns/onnx/layer/log_softmax.test.js | 4 +- tests/lib/model/nns/onnx/layer/loglog.test.js | 2 +- .../model/nns/onnx/layer/logsigmoid.test.js | 2 +- .../lib/model/nns/onnx/layer/lp_pool.test.js | 4 +- tests/lib/model/nns/onnx/layer/lrn.test.js | 7 +- tests/lib/model/nns/onnx/layer/matmul.test.js | 2 +- .../lib/model/nns/onnx/layer/max_pool.test.js | 4 +- tests/lib/model/nns/onnx/layer/mean.test.js | 2 +- tests/lib/model/nns/onnx/layer/mish.test.js | 2 +- tests/lib/model/nns/onnx/layer/mod.test.js | 4 +- tests/lib/model/nns/onnx/layer/mpelu.test.js | 4 +- tests/lib/model/nns/onnx/layer/mult.test.js | 4 +- .../lib/model/nns/onnx/layer/negative.test.js | 2 +- tests/lib/model/nns/onnx/layer/nlrelu.test.js | 4 +- tests/lib/model/nns/onnx/layer/or.test.js | 4 +- tests/lib/model/nns/onnx/layer/pau.test.js | 2 +- tests/lib/model/nns/onnx/layer/pdelu.test.js | 4 +- tests/lib/model/nns/onnx/layer/pelu.test.js | 4 +- tests/lib/model/nns/onnx/layer/plu.test.js | 4 +- tests/lib/model/nns/onnx/layer/power.test.js | 4 +- tests/lib/model/nns/onnx/layer/prelu.test.js | 4 +- tests/lib/model/nns/onnx/layer/preu.test.js | 4 +- tests/lib/model/nns/onnx/layer/prod.test.js | 2 +- tests/lib/model/nns/onnx/layer/psf.test.js | 4 +- tests/lib/model/nns/onnx/layer/ptanh.test.js | 4 +- tests/lib/model/nns/onnx/layer/ptelu.test.js | 4 +- .../model/nns/onnx/layer/reciprocal.test.js | 2 +- .../model/nns/onnx/layer/reduce_max.test.js | 2 +- .../model/nns/onnx/layer/reduce_min.test.js | 2 +- tests/lib/model/nns/onnx/layer/relu.test.js | 2 +- tests/lib/model/nns/onnx/layer/repu.test.js | 4 +- tests/lib/model/nns/onnx/layer/resech.test.js | 2 +- tests/lib/model/nns/onnx/layer/reu.test.js | 2 +- .../nns/onnx/layer/right_bitshift.test.js | 4 +- .../lib/model/nns/onnx/layer/rootsig.test.js | 4 +- tests/lib/model/nns/onnx/layer/round.test.js | 2 +- tests/lib/model/nns/onnx/layer/rrelu.test.js | 4 +- tests/lib/model/nns/onnx/layer/rtrelu.test.js | 2 +- tests/lib/model/nns/onnx/layer/selu.test.js | 4 +- tests/lib/model/nns/onnx/layer/shape.test.js | 2 +- .../lib/model/nns/onnx/layer/sigmoid.test.js | 4 +- tests/lib/model/nns/onnx/layer/sign.test.js | 2 +- tests/lib/model/nns/onnx/layer/silu.test.js | 2 +- tests/lib/model/nns/onnx/layer/sin.test.js | 2 +- tests/lib/model/nns/onnx/layer/sinh.test.js | 2 +- tests/lib/model/nns/onnx/layer/slaf.test.js | 2 +- tests/lib/model/nns/onnx/layer/slu.test.js | 4 +- .../model/nns/onnx/layer/soft_shrink.test.js | 4 +- .../lib/model/nns/onnx/layer/softmax.test.js | 4 +- .../lib/model/nns/onnx/layer/softmin.test.js | 4 +- .../lib/model/nns/onnx/layer/softplus.test.js | 4 +- .../lib/model/nns/onnx/layer/softsign.test.js | 2 +- tests/lib/model/nns/onnx/layer/sqrt.test.js | 2 +- tests/lib/model/nns/onnx/layer/square.test.js | 2 +- tests/lib/model/nns/onnx/layer/srelu.test.js | 4 +- tests/lib/model/nns/onnx/layer/srs.test.js | 4 +- .../lib/model/nns/onnx/layer/ssigmoid.test.js | 2 +- tests/lib/model/nns/onnx/layer/stanh.test.js | 4 +- tests/lib/model/nns/onnx/layer/std.test.js | 2 +- tests/lib/model/nns/onnx/layer/sub.test.js | 4 +- tests/lib/model/nns/onnx/layer/sum.test.js | 2 +- tests/lib/model/nns/onnx/layer/swish.test.js | 4 +- tests/lib/model/nns/onnx/layer/taf.test.js | 4 +- tests/lib/model/nns/onnx/layer/tan.test.js | 2 +- tests/lib/model/nns/onnx/layer/tanh.test.js | 2 +- .../lib/model/nns/onnx/layer/tanhexp.test.js | 2 +- .../model/nns/onnx/layer/tanhshrink.test.js | 2 +- .../nns/onnx/layer/thresholded_relu.test.js | 4 +- .../model/nns/onnx/layer/transpose.test.js | 4 +- .../model/nns/onnx/layer/up_sampling.test.js | 2 +- .../lib/model/nns/onnx/layer/variance.test.js | 2 +- tests/lib/model/nns/onnx/layer/xor.test.js | 4 +- .../lib/model/nns/onnx/onnx_exporter.test.js | 5 +- .../lib/model/nns/onnx/onnx_importer.test.js | 4 +- tests/lib/model/nns/onnx/onnx_models.test.js | 2 +- .../lib/model/nns/optimizer/adabelief.test.js | 5 +- .../lib/model/nns/optimizer/adabound.test.js | 5 +- .../lib/model/nns/optimizer/adadelta.test.js | 5 +- tests/lib/model/nns/optimizer/adagrad.test.js | 5 +- tests/lib/model/nns/optimizer/adam.test.js | 5 +- tests/lib/model/nns/optimizer/adamax.test.js | 5 +- .../lib/model/nns/optimizer/amsbound.test.js | 5 +- tests/lib/model/nns/optimizer/amsgrad.test.js | 5 +- tests/lib/model/nns/optimizer/nadam.test.js | 5 +- tests/lib/model/nns/optimizer/rmsprop.test.js | 7 +- .../model/nns/optimizer/rmspropgraves.test.js | 5 +- tests/lib/model/nns/optimizer/santae.test.js | 11 +- .../lib/model/nns/optimizer/santasss.test.js | 5 +- tests/lib/model/nns/optimizer/smorms3.test.js | 5 +- tests/lib/model/ocsvm.test.js | 9 +- tests/lib/model/odin.test.js | 7 +- tests/lib/model/optics.test.js | 7 +- tests/lib/model/orclus.test.js | 5 +- tests/lib/model/ordered_probit.test.js | 5 +- tests/lib/model/particle_filter.test.js | 2 +- tests/lib/model/passing_bablok.test.js | 2 +- tests/lib/model/passive_aggressive.test.js | 2 +- tests/lib/model/pca.test.js | 5 +- tests/lib/model/pcm.test.js | 5 +- tests/lib/model/pelt.test.js | 7 +- tests/lib/model/plsa.test.js | 5 +- tests/lib/model/poisson.test.js | 5 +- tests/lib/model/policy_gradient.test.js | 5 +- tests/lib/model/polynomial_histogram.test.js | 7 +- .../model/polynomial_interpolation.test.js | 5 +- tests/lib/model/ppr.test.js | 5 +- tests/lib/model/principal_curve.test.js | 2 +- tests/lib/model/probabilistic_pca.test.js | 7 +- tests/lib/model/probit.test.js | 7 +- tests/lib/model/proclus.test.js | 9 +- tests/lib/model/projectron.test.js | 19 +- tests/lib/model/ptile.test.js | 2 +- tests/lib/model/quantile_regression.test.js | 2 +- tests/lib/model/radius_neighbor.test.js | 5 +- tests/lib/model/random_projection.test.js | 5 +- tests/lib/model/ranknet.test.js | 2 +- tests/lib/model/rbf.test.js | 5 +- tests/lib/model/rbm.test.js | 9 +- tests/lib/model/rbp.test.js | 5 +- tests/lib/model/rdf.test.js | 5 +- tests/lib/model/rdos.test.js | 5 +- tests/lib/model/ridge.test.js | 7 +- tests/lib/model/rkof.test.js | 31 +- tests/lib/model/rnn.test.js | 7 +- tests/lib/model/romma.test.js | 7 +- tests/lib/model/s3vm.test.js | 43 +- tests/lib/model/segmented.test.js | 2 +- .../model/selective_sampling_winnow.test.js | 5 +- tests/lib/model/shifting_perceptron.test.js | 5 +- tests/lib/model/silk.test.js | 9 +- tests/lib/model/sir.test.js | 5 +- tests/lib/model/slerp.test.js | 5 +- tests/lib/model/slice_sampling.test.js | 5 +- tests/lib/model/smoothstep.test.js | 5 +- tests/lib/model/som.test.js | 11 +- tests/lib/model/spectral.test.js | 2 +- tests/lib/model/split_merge.test.js | 2 +- tests/lib/model/squared_loss_mi.test.js | 5 +- tests/lib/model/sst.test.js | 5 +- .../model/statistical_region_merging.test.js | 2 +- tests/lib/model/stoptron.test.js | 6 +- tests/lib/model/svc.test.js | 7 +- tests/lib/model/svm.test.js | 2 +- tests/lib/model/svr.test.js | 9 +- tests/lib/model/tighter_perceptron.test.js | 7 +- tests/lib/model/tightest_perceptron.test.js | 9 +- tests/lib/model/tsne.test.js | 7 +- tests/lib/model/tukey_regression.test.js | 7 +- tests/lib/model/ulsif.test.js | 5 +- tests/lib/model/umap.test.js | 7 +- tests/lib/model/vae.test.js | 5 +- tests/lib/model/var.test.js | 5 +- tests/lib/model/vbgmm.test.js | 5 +- tests/lib/model/voted_perceptron.test.js | 5 +- tests/lib/model/winnow.test.js | 9 +- tests/lib/model/word_to_vec.test.js | 3 - tests/lib/model/xgboost.test.js | 11 +- tests/lib/model/yeo_johnson.test.js | 10 +- tests/lib/model/yinyang_kmeans.test.js | 5 +- tests/lib/model/zinb.test.js | 5 +- tests/lib/model/zip.test.js | 5 +- tests/lib/model/ztp.test.js | 5 +- tests/lib/rl/breaker.test.js | 2 +- tests/lib/rl/draughts.test.js | 14 +- tests/lib/rl/gomoku.test.js | 8 +- tests/lib/rl/maze.test.js | 4 +- tests/lib/rl/reversi.test.js | 14 +- tests/lib/rl/waterball.test.js | 2 +- tests/lib/util/graph.test.js | 19 +- tests/lib/util/matrix.test.js | 131 ++-- tests/lib/util/tensor.test.js | 38 +- 443 files changed, 1627 insertions(+), 1655 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9f36cddf3..7822760a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.24.0", "license": "MIT", "devDependencies": { + "@vitest/coverage-v8": "^4.0.8", "esbuild": "^0.25.3", "eslint": "^9.26.0", "eslint-config-prettier": "^10.1.2", @@ -24,7 +25,8 @@ "rollup": "^4.40.1", "typedoc": "^0.28.4", "typescript": "^5.8.3", - "v8-to-istanbul": "^9.3.0" + "v8-to-istanbul": "^9.3.0", + "vitest": "^4.0.8" } }, "node_modules/@babel/code-frame": { @@ -2180,6 +2182,13 @@ "@sinonjs/commons": "^3.0.0" } }, + "node_modules/@standard-schema/spec": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.0.0.tgz", + "integrity": "sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -2225,6 +2234,24 @@ "@babel/types": "^7.28.2" } }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", @@ -2495,6 +2522,174 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@vitest/coverage-v8": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.0.8.tgz", + "integrity": "sha512-wQgmtW6FtPNn4lWUXi8ZSYLpOIb92j3QCujxX3sQ81NTfQ/ORnE0HtK7Kqf2+7J9jeveMGyGyc4NWc5qy3rC4A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@bcoe/v8-coverage": "^1.0.2", + "@vitest/utils": "4.0.8", + "ast-v8-to-istanbul": "^0.3.8", + "debug": "^4.4.3", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-lib-source-maps": "^5.0.6", + "istanbul-reports": "^3.2.0", + "magicast": "^0.5.1", + "std-env": "^3.10.0", + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "4.0.8", + "vitest": "4.0.8" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, + "node_modules/@vitest/coverage-v8/node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@vitest/coverage-v8/node_modules/istanbul-lib-source-maps": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.6.tgz", + "integrity": "sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.23", + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@vitest/expect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.8.tgz", + "integrity": "sha512-Rv0eabdP/xjAHQGr8cjBm+NnLHNoL268lMDK85w2aAGLFoVKLd8QGnVon5lLtkXQCoYaNL0wg04EGnyKkkKhPA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.0.0", + "@types/chai": "^5.2.2", + "@vitest/spy": "4.0.8", + "@vitest/utils": "4.0.8", + "chai": "^6.2.0", + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.8.tgz", + "integrity": "sha512-9FRM3MZCedXH3+pIh+ME5Up2NBBHDq0wqwhOKkN4VnvCiKbVxddqH9mSGPZeawjd12pCOGnl+lo/ZGHt0/dQSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "4.0.8", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.21" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^6.0.0 || ^7.0.0-0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.8.tgz", + "integrity": "sha512-qRrjdRkINi9DaZHAimV+8ia9Gq6LeGz2CgIEmMLz3sBDYV53EsnLZbJMR1q84z1HZCMsf7s0orDgZn7ScXsZKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.8.tgz", + "integrity": "sha512-mdY8Sf1gsM8hKJUQfiPT3pn1n8RF4QBcJYFslgWh41JTfrK1cbqY8whpGCFzBl45LN028g0njLCYm0d7XxSaQQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "4.0.8", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.8.tgz", + "integrity": "sha512-Nar9OTU03KGiubrIOFhcfHg8FYaRaNT+bh5VUlNz8stFhCZPNrJvmZkhsr1jtaYvuefYFwK2Hwrq026u4uPWCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.0.8", + "magic-string": "^0.30.21", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.8.tgz", + "integrity": "sha512-nvGVqUunyCgZH7kmo+Ord4WgZ7lN0sOULYXUOYuHr55dvg9YvMz3izfB189Pgp28w0vWFbEEfNc/c3VTrqrXeA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.8.tgz", + "integrity": "sha512-pdk2phO5NDvEFfUTxcTP8RFYjVj/kfLSPIN5ebP2Mu9kcIMeAQTbknqcFEyBcC4z2pJlJI9aS5UQjcYfhmKAow==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.0.8", + "tinyrainbow": "^3.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/acorn": { "version": "8.15.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", @@ -2608,6 +2803,35 @@ "dev": true, "license": "Python-2.0" }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/ast-v8-to-istanbul": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-0.3.8.tgz", + "integrity": "sha512-szgSZqUxI5T8mLKvS7WTjF9is+MVbOeLADU73IseOcrqhxr/VAvy6wfoVE39KnKzA7JRhjF5eUagNlHwvZPlKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.31", + "estree-walker": "^3.0.3", + "js-tokens": "^9.0.1" + } + }, + "node_modules/ast-v8-to-istanbul/node_modules/js-tokens": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", + "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", + "dev": true, + "license": "MIT" + }, "node_modules/babel-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", @@ -2878,6 +3102,16 @@ ], "license": "CC-BY-4.0" }, + "node_modules/chai": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.0.tgz", + "integrity": "sha512-aUTnJc/JipRzJrNADXVvpVqi6CO0dn3nx4EVPxijri+fj3LUUDyZQOgVeW54Ob3Y1Xh9Iz8f+CgaCl8v0mn9bA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -3182,6 +3416,13 @@ "is-arrayish": "^0.2.1" } }, + "node_modules/es-module-lexer": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "dev": true, + "license": "MIT" + }, "node_modules/esbuild": { "version": "0.25.12", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", @@ -3472,6 +3713,16 @@ "node": ">=4.0" } }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -3532,6 +3783,16 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/expect-type": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.2.2.tgz", + "integrity": "sha512-JhFGDVJ7tmDJItKhYgJCGLOWjuK9vPxiXoUFLwLDc99NlmklilbiQJwoctZtt13+xMw91MCk/REan6MWHqDjyA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -4908,6 +5169,28 @@ "dev": true, "license": "MIT" }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/magicast": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.1.tgz", + "integrity": "sha512-xrHS24IxaLrvuo613F719wvOIv9xPHFWQHuvGUBmPnCA/3MQxKI3b+r7n1jAoDHmsbC5bRhTZYR77invLAxVnw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.28.5", + "@babel/types": "^7.28.5", + "source-map-js": "^1.2.1" + } + }, "node_modules/make-dir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", @@ -5020,6 +5303,25 @@ "dev": true, "license": "MIT" }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -5278,6 +5580,13 @@ "dev": true, "license": "MIT" }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -5431,6 +5740,35 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -5786,6 +6124,13 @@ "node": ">=8" } }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -5820,6 +6165,16 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-support": { "version": "0.5.13", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", @@ -5886,6 +6241,20 @@ "node": ">=8" } }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", + "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", + "dev": true, + "license": "MIT" + }, "node_modules/string-length": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", @@ -6002,6 +6371,78 @@ "node": ">=8" } }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/tinyrainbow": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", + "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -6225,6 +6666,203 @@ "node": ">=10.12.0" } }, + "node_modules/vite": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.2.2.tgz", + "integrity": "sha512-BxAKBWmIbrDgrokdGZH1IgkIk/5mMHDreLDmCJ0qpyJaAteP8NvMhkwr/ZCQNqNH97bw/dANTE9PDzqwJghfMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/vitest": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.8.tgz", + "integrity": "sha512-urzu3NCEV0Qa0Y2PwvBtRgmNtxhj5t5ULw7cuKhIHh3OrkKTLlut0lnBOv9qe5OvbkMH2g38G7KPDCTpIytBVg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "4.0.8", + "@vitest/mocker": "4.0.8", + "@vitest/pretty-format": "4.0.8", + "@vitest/runner": "4.0.8", + "@vitest/snapshot": "4.0.8", + "@vitest/spy": "4.0.8", + "@vitest/utils": "4.0.8", + "debug": "^4.4.3", + "es-module-lexer": "^1.7.0", + "expect-type": "^1.2.2", + "magic-string": "^0.30.21", + "pathe": "^2.0.3", + "picomatch": "^4.0.3", + "std-env": "^3.10.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.2", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.0.3", + "vite": "^6.0.0 || ^7.0.0", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^20.0.0 || ^22.0.0 || >=24.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/debug": "^4.1.12", + "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "4.0.8", + "@vitest/browser-preview": "4.0.8", + "@vitest/browser-webdriverio": "4.0.8", + "@vitest/ui": "4.0.8", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/debug": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/vitest/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", @@ -6251,6 +6889,23 @@ "node": ">= 8" } }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", diff --git a/package.json b/package.json index 40978d12d..0f9e3260a 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "format": "prettier --write './**/*.js'", "lint": "eslint ./lib ./tests", "check-types": "npm run create-entry && tsc ./lib/**.js ./lib/**/*.js --allowJs --checkJs --target esnext --noEmit --skipLibCheck", - "test:lib": "npm run create-entry && NODE_OPTIONS=--experimental-vm-modules npx jest --testMatch '**/lib/**/?(*.)+(spec|test).[jt]s?(x)' --coverage --coveragePathIgnorePatterns '/node_modules/' 'onnx/onnx_pb.js' --reporters default ./tests/retry-test.js ./tests/slow-test.js --maxWorkers=100% --workerIdleMemoryLimit=100MB", + "test:lib": "npm run create-entry && npx vitest run --globals --coverage --coverage.exclude=onnx/onnx_pb.js --maxWorkers=100% --vmMemoryLimit=100MB --dir tests/lib", "test:js": "NODE_OPTIONS=--experimental-vm-modules npx jest --config ./tests/jest-js.config.js", "test:gui": "NODE_OPTIONS=--experimental-vm-modules npx jest --testMatch '**/gui/**/?(*.)+(spec|test).[jt]s?(x)' --coveragePathIgnorePatterns '/node_modules/' 'onnx/onnx_pb.js' --reporters default ./tests/retry-test.js ./tests/slow-test.js ./tests/gui-coverage-reporter.js --testTimeout=20000 --maxWorkers=100% --workerIdleMemoryLimit=100MB", "types": "npm run create-entry && find lib -name \\*.d.ts -delete && tsc ./lib/**.js ./lib/**/*.js --declaration --allowJs --emitDeclarationOnly", @@ -57,6 +57,7 @@ }, "homepage": "https://ai-on-browser.github.io/docs", "devDependencies": { + "@vitest/coverage-v8": "^4.0.8", "esbuild": "^0.25.3", "eslint": "^9.26.0", "eslint-config-prettier": "^10.1.2", @@ -72,6 +73,7 @@ "rollup": "^4.40.1", "typedoc": "^0.28.4", "typescript": "^5.8.3", - "v8-to-istanbul": "^9.3.0" + "v8-to-istanbul": "^9.3.0", + "vitest": "^4.0.8" } } diff --git a/tests/lib/model/a2c.test.js b/tests/lib/model/a2c.test.js index b42ff6954..7e1bf2c2d 100644 --- a/tests/lib/model/a2c.test.js +++ b/tests/lib/model/a2c.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(20) - import A2CAgent from '../../../lib/model/a2c.js' import CartPoleRLEnvironment from '../../../lib/rl/cartpole.js' import InHypercubeRLEnvironment from '../../../lib/rl/inhypercube.js' import PendulumRLEnvironment from '../../../lib/rl/pendulum.js' import ReversiRLEnvironment from '../../../lib/rl/reversi.js' -test('update', () => { +test('update', { retry: 20 }, () => { const env = new InHypercubeRLEnvironment(2) const agent = new A2CAgent(env, 10, 10, [{ type: 'full', out_size: 10, activation: 'tanh' }], 'adam') @@ -56,7 +53,7 @@ test('array state action', () => { expect(best_action).toHaveLength(1) }) -test('get_score', () => { +test('get_score', { retry: 20 }, () => { const env = new CartPoleRLEnvironment() const agent = new A2CAgent(env, 20, 10, [{ type: 'full', out_size: 5, activation: 'tanh' }], 'adam') diff --git a/tests/lib/model/abod.test.js b/tests/lib/model/abod.test.js index 9f1f8c1f8..626a81879 100644 --- a/tests/lib/model/abod.test.js +++ b/tests/lib/model/abod.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import ABOD, { LBABOD } from '../../../lib/model/abod.js' describe('anomaly detection', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new ABOD() const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) @@ -17,7 +14,7 @@ describe('anomaly detection', () => { expect(y[y.length - 1]).toBe(true) }) - test('FastABOD', () => { + test('FastABOD', { retry: 3 }, () => { const model = new ABOD(10) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) @@ -29,7 +26,7 @@ describe('anomaly detection', () => { expect(y[y.length - 1]).toBe(true) }) - test('LB-ABOD', () => { + test('LB-ABOD', { retry: 3 }, () => { const model = new LBABOD(10, 2) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) @@ -42,7 +39,7 @@ describe('anomaly detection', () => { expect(y[y.length - 1]).toBe(true) }) - test('LB-ABOD default', () => { + test('LB-ABOD default', { retry: 3 }, () => { const model = new LBABOD() const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) diff --git a/tests/lib/model/adaptive_thresholding.test.js b/tests/lib/model/adaptive_thresholding.test.js index c5626480b..a9e332ee7 100644 --- a/tests/lib/model/adaptive_thresholding.test.js +++ b/tests/lib/model/adaptive_thresholding.test.js @@ -6,8 +6,8 @@ test('default', () => { expect(model._method).toBe('mean') }) -describe.each([undefined, 'mean', 'gaussian', 'median', 'midgray'])('predict %p', method => { - test.each([undefined, 0.2])('%p', c => { +describe.each([undefined, 'mean', 'gaussian', 'median', 'midgray'])('predict %j', method => { + test.each([undefined, 0.2])('%j', c => { const model = new AdaptiveThresholding(method, undefined, c) const x = Tensor.random([10, 10]).toArray() diff --git a/tests/lib/model/affinity_propagation.test.js b/tests/lib/model/affinity_propagation.test.js index 189a6cb0d..180f7353c 100644 --- a/tests/lib/model/affinity_propagation.test.js +++ b/tests/lib/model/affinity_propagation.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import AffinityPropagation from '../../../lib/model/affinity_propagation.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test('predict', () => { +test('predict', { retry: 3 }, () => { const model = new AffinityPropagation() const n = 10 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() diff --git a/tests/lib/model/agglomerative.test.js b/tests/lib/model/agglomerative.test.js index 5db7b8acb..b4cd510fd 100644 --- a/tests/lib/model/agglomerative.test.js +++ b/tests/lib/model/agglomerative.test.js @@ -19,7 +19,7 @@ describe.each([ CentroidAgglomerativeClustering, WeightedAverageAgglomerativeClustering, MedianAgglomerativeClustering, -])('clustering %p', agglomerativeCls => { +])('clustering %j', agglomerativeCls => { test.each([ undefined, 'euclid', diff --git a/tests/lib/model/akima.test.js b/tests/lib/model/akima.test.js index 0c73df8dc..26a8f6f73 100644 --- a/tests/lib/model/akima.test.js +++ b/tests/lib/model/akima.test.js @@ -3,7 +3,7 @@ import AkimaInterpolation from '../../../lib/model/akima.js' import { rmse } from '../../../lib/evaluate/regression.js' -test.each([undefined, true, false])('interpolation %p', modify => { +test.each([undefined, true, false])('interpolation %j', modify => { const model = new AkimaInterpolation(modify) const x = Matrix.random(20, 1, -2, 2).value const t = [] diff --git a/tests/lib/model/ar.test.js b/tests/lib/model/ar.test.js index 0e226a986..97a1ddce3 100644 --- a/tests/lib/model/ar.test.js +++ b/tests/lib/model/ar.test.js @@ -1,9 +1,6 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import AR from '../../../lib/model/ar.js' -test.each([undefined, 'lsm', 'householder'])('linear %s', method => { +test.each([undefined, 'lsm', 'householder'])('linear %s', { retry: 5 }, method => { const model = new AR(5, method) const x = [] for (let i = 0; i < 100; i++) { diff --git a/tests/lib/model/arma.test.js b/tests/lib/model/arma.test.js index 23155c6a0..bcfa4da13 100644 --- a/tests/lib/model/arma.test.js +++ b/tests/lib/model/arma.test.js @@ -1,9 +1,6 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import ARMA from '../../../lib/model/arma.js' -test('linear', () => { +test('linear', { retry: 5 }, () => { const model = new ARMA(5, 2) const x = [] for (let i = 0; i < 100; i++) { @@ -20,7 +17,7 @@ test('linear', () => { } }) -test('sin', () => { +test('sin', { retry: 5 }, () => { const model = new ARMA(15, 2) const x = [] for (let i = 0; i < 100; i++) { diff --git a/tests/lib/model/art.test.js b/tests/lib/model/art.test.js index 43961a47f..1d44608ea 100644 --- a/tests/lib/model/art.test.js +++ b/tests/lib/model/art.test.js @@ -3,7 +3,7 @@ import ART from '../../../lib/model/art.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test.each([undefined, 0.5])('clustering %p', th => { +test.each([undefined, 0.5])('clustering %j', th => { const model = new ART(th) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/autoencoder.test.js b/tests/lib/model/autoencoder.test.js index c0c28e339..1de55982e 100644 --- a/tests/lib/model/autoencoder.test.js +++ b/tests/lib/model/autoencoder.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import Autoencoder from '../../../lib/model/autoencoder.js' import { rmse } from '../../../lib/evaluate/regression.js' -test('reconstruct', () => { +test('reconstruct', { retry: 3 }, () => { const x = Matrix.randn(1000, 3, 0, 0.2).toArray() const model = new Autoencoder( 3, diff --git a/tests/lib/model/ballseptron.test.js b/tests/lib/model/ballseptron.test.js index 063523be7..3b2fee9ba 100644 --- a/tests/lib/model/ballseptron.test.js +++ b/tests/lib/model/ballseptron.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import Ballseptron from '../../../lib/model/ballseptron.js' import { accuracy } from '../../../lib/evaluate/classification.js' -test('predict', () => { +test('predict', { retry: 3 }, () => { const model = new Ballseptron(1) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/banditron.test.js b/tests/lib/model/banditron.test.js index 09e74eb79..3535af330 100644 --- a/tests/lib/model/banditron.test.js +++ b/tests/lib/model/banditron.test.js @@ -3,7 +3,7 @@ import Banditron from '../../../lib/model/banditron.js' import { accuracy } from '../../../lib/evaluate/classification.js' -test.each([undefined, 0.1])('predict gamma: %p', gamma => { +test.each([undefined, 0.1])('predict gamma: %j', { retry: 3 }, gamma => { const model = new Banditron(gamma) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/bessel.test.js b/tests/lib/model/bessel.test.js index 6c5f04abf..8e7c3e120 100644 --- a/tests/lib/model/bessel.test.js +++ b/tests/lib/model/bessel.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import BesselFilter from '../../../lib/model/bessel.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('smoothing', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const x = [] const t = [] for (let i = 0; i < 100; i++) { @@ -19,7 +16,7 @@ describe('smoothing', () => { const err = rmse(y, t) expect(err).toBeLessThan(rmse(x, t)) }) - test('dft', () => { + test('dft', { retry: 3 }, () => { const x = [] const t = [] for (let i = 0; i < 100; i++) { @@ -33,7 +30,7 @@ describe('smoothing', () => { expect(err).toBeLessThan(rmse(x, t)) }) - test('fft', () => { + test('fft', { retry: 3 }, () => { const x = [] const t = [] for (let i = 0; i < 128; i++) { diff --git a/tests/lib/model/birch.test.js b/tests/lib/model/birch.test.js index 35b51dd2c..e12a20c5b 100644 --- a/tests/lib/model/birch.test.js +++ b/tests/lib/model/birch.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import BIRCH from '../../../lib/model/birch.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('parameters', () => { + test('parameters', { retry: 3 }, () => { const model = new BIRCH(null, 20, 0.2, 10000) const n = 50 const x = Matrix.concat( @@ -27,7 +24,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.9) }) - test('default', () => { + test('default', { retry: 3 }, () => { const model = new BIRCH() const n = 50 const x = Matrix.concat(Matrix.random(n, 2, 0, 1), Matrix.random(n, 2, 3, 4)).toArray() diff --git a/tests/lib/model/bisecting_kmeans.test.js b/tests/lib/model/bisecting_kmeans.test.js index 56d8e2a54..d976ce2cc 100644 --- a/tests/lib/model/bisecting_kmeans.test.js +++ b/tests/lib/model/bisecting_kmeans.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import BisectingKMeans from '../../../lib/model/bisecting_kmeans.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new BisectingKMeans() const n = 20 const x = Matrix.concat( diff --git a/tests/lib/model/bogd.test.js b/tests/lib/model/bogd.test.js index c85e72ab7..00ed3ee6f 100644 --- a/tests/lib/model/bogd.test.js +++ b/tests/lib/model/bogd.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import BOGD from '../../../lib/model/bogd.js' @@ -30,7 +27,7 @@ describe('classification', () => { 'gaussian', { name: 'gaussian', s: 0.8 }, (a, b) => Math.exp(-(a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2)), - ])('kernel %s', kernel => { + ])('kernel %s', { retry: 10 }, kernel => { const model = new BOGD(10, 0.1, 0.1, 10, sampling, kernel, loss) const n = 50 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() @@ -50,7 +47,7 @@ describe('classification', () => { describe.each([undefined, 'uniform', 'nonuniform'])('sampling %s', sampling => { describe.each(['zero_one'])('loss %s', loss => { - test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', kernel => { + test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', { retry: 10 }, kernel => { const model = new BOGD(10, 0.2, 0.2, 5, sampling, kernel, loss) const n = 50 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() diff --git a/tests/lib/model/box_cox.test.js b/tests/lib/model/box_cox.test.js index 07deb197b..8916dd007 100644 --- a/tests/lib/model/box_cox.test.js +++ b/tests/lib/model/box_cox.test.js @@ -68,7 +68,7 @@ describe('fit', () => { }) describe('predict', () => { - test.each([[[0, 1]]])('mat %p', lambda => { + test.each([[[0, 1]]])('mat %j', lambda => { const model = new BoxCox(lambda) const x = Matrix.map(Matrix.randn(50, 2, 1, 0.2), Math.exp).toArray() const y = model.predict(x) @@ -80,7 +80,7 @@ describe('predict', () => { } }) - test.each([-1, 0, 1])('mat %p', lambda => { + test.each([-1, 0, 1])('mat %j', lambda => { const model = new BoxCox(lambda) const x = Matrix.map(Matrix.randn(50, 2, 1, 0.2), Math.exp).toArray() const y = model.predict(x) @@ -92,7 +92,7 @@ describe('predict', () => { } }) - test.each([[[0, 1]]])('arr %p', lambda => { + test.each([[[0, 1]]])('arr %j', lambda => { const model = new BoxCox(lambda) const x = Matrix.map(Matrix.randn(50, 1, 1, 0.2), Math.exp).value const y = model.predict(x) @@ -102,7 +102,7 @@ describe('predict', () => { } }) - test.each([-1, 0, 1])('arr %p', lambda => { + test.each([-1, 0, 1])('arr %j', lambda => { const model = new BoxCox(lambda) const x = Matrix.map(Matrix.randn(50, 1, 1, 0.2), Math.exp).value const y = model.predict(x) @@ -170,7 +170,7 @@ describe('inverse', () => { } }) - test.each([-1, 0, 1])('arr %p', lambda => { + test.each([-1, 0, 1])('arr %j', lambda => { const model = new BoxCox(lambda) const x = Matrix.map(Matrix.randn(50, 1, 1, 0.2), Math.exp).value const y = model.predict(x) diff --git a/tests/lib/model/bpa.test.js b/tests/lib/model/bpa.test.js index 43fcee873..afca3589f 100644 --- a/tests/lib/model/bpa.test.js +++ b/tests/lib/model/bpa.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import BPA from '../../../lib/model/bpa.js' @@ -23,7 +20,7 @@ describe('classification', () => { }) describe.each([undefined, 'simple', 'projecting', 'nn'])('version %s', version => { - test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', kernel => { + test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', { retry: 10 }, kernel => { const model = new BPA(1, 10, version, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -38,7 +35,7 @@ describe('classification', () => { expect(acc).toBeGreaterThan(0.8) }) - test('custom kernel', () => { + test('custom kernel', { retry: 10 }, () => { const model = new BPA(1, 10, version, (a, b) => Math.exp(-(a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2) / 0.01) ) @@ -56,7 +53,7 @@ describe('classification', () => { }) }) - test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', kernel => { + test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', { retry: 10 }, kernel => { const model = new BPA(1, 10, 'simple', kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/bridge.test.js b/tests/lib/model/bridge.test.js index eecd31cec..20929ef76 100644 --- a/tests/lib/model/bridge.test.js +++ b/tests/lib/model/bridge.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import BRIDGE from '../../../lib/model/bridge.js' @@ -26,7 +23,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.9) }) - test.each([2, 3, 4])('%d', dim => { + test.each([2, 3, 4])('%d', { retry: 5 }, dim => { const model = new BRIDGE(2, 0.2, 1) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/bsgd.test.js b/tests/lib/model/bsgd.test.js index 9d605cede..051139f9f 100644 --- a/tests/lib/model/bsgd.test.js +++ b/tests/lib/model/bsgd.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import BSGD, { MulticlassBSGD } from '../../../lib/model/bsgd.js' @@ -23,7 +20,7 @@ describe('classification', () => { }) describe.each([undefined, 'removal', 'projection', 'merging'])('maintenance %s', maintenance => { - test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', kernel => { + test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', { retry: 10 }, kernel => { const model = new BSGD(10, 1, 0.01, maintenance, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -38,7 +35,7 @@ describe('classification', () => { expect(acc).toBeGreaterThan(0.9) }) - test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', kernel => { + test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', { retry: 10 }, kernel => { const model = new BSGD(10, 1, 0.01, maintenance, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -53,7 +50,7 @@ describe('classification', () => { expect(acc).toBeGreaterThan(0.7) }) - test('custom kernel', () => { + test('custom kernel', { retry: 10 }, () => { const model = new BSGD(10, 1, 0.01, maintenance, (a, b) => Math.exp(-2 * a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2) ) @@ -104,7 +101,7 @@ describe('multiclass classification', () => { expect(acc).toBeGreaterThan(0.9) }) - test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', kernel => { + test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', { retry: 10 }, kernel => { const model = new MulticlassBSGD(10, 1, 0.01, maintenance, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/budget_perceptron.test.js b/tests/lib/model/budget_perceptron.test.js index 4b4a057ba..49303c4ca 100644 --- a/tests/lib/model/budget_perceptron.test.js +++ b/tests/lib/model/budget_perceptron.test.js @@ -18,7 +18,7 @@ test.each([undefined, 0, 2])('fit %i', n => { expect(acc).toBeGreaterThan(0.95) }) -test.each([0, 2])('fit replace sv n: %p', n => { +test.each([0, 2])('fit replace sv n: %j', n => { const model = new BudgetPerceptron(1, n) const x = [ [0.44, 0.43], diff --git a/tests/lib/model/catmull_rom.test.js b/tests/lib/model/catmull_rom.test.js index 1945952d9..0a6ee415d 100644 --- a/tests/lib/model/catmull_rom.test.js +++ b/tests/lib/model/catmull_rom.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import { CatmullRomSplines, CentripetalCatmullRomSplines } from '../../../lib/model/catmull_rom.js' @@ -28,7 +25,7 @@ describe('CatmullRomSplines', () => { expect(err).toBeLessThan(0.1) }) - test('cover all pattern', () => { + test('cover all pattern', { retry: 5 }, () => { const model = new CatmullRomSplines() const x = [-0.43, 1.43, -1.45] const t = [] diff --git a/tests/lib/model/chameleon.test.js b/tests/lib/model/chameleon.test.js index 42ddadf53..9ee570af0 100644 --- a/tests/lib/model/chameleon.test.js +++ b/tests/lib/model/chameleon.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(20) - import Matrix from '../../../lib/util/matrix.js' import CHAMELEON from '../../../lib/model/chameleon.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test.each([undefined, 5])('clustering %p', k => { +test.each([undefined, 5])('clustering %j', { retry: 20 }, k => { const model = new CHAMELEON(k) const n = 20 const x = Matrix.concat( diff --git a/tests/lib/model/chebyshev.test.js b/tests/lib/model/chebyshev.test.js index 452bbbcc0..1ec0cad21 100644 --- a/tests/lib/model/chebyshev.test.js +++ b/tests/lib/model/chebyshev.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import ChebyshevFilter from '../../../lib/model/chebyshev.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('smoothing', () => { - test('default', () => { + test('default', { retry: 10 }, () => { const x = [] const t = [] for (let i = 0; i < 100; i++) { @@ -30,7 +27,7 @@ describe('smoothing', () => { [2, 2], [2, 3], [2, 4], - ])('dft %i %i', (type, n) => { + ])('dft %i %i', { retry: 10 }, (type, n) => { const x = [] const t = [] for (let i = 0; i < 100; i++) { diff --git a/tests/lib/model/clique.test.js b/tests/lib/model/clique.test.js index cfee09079..1a65a42fa 100644 --- a/tests/lib/model/clique.test.js +++ b/tests/lib/model/clique.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import CLIQUE from '../../../lib/model/clique.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('scalar xi', () => { + test('scalar xi', { retry: 3 }, () => { const model = new CLIQUE(0.3, 0.001) const n = 100 const x = Matrix.concat( @@ -28,7 +25,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.8) }) - test('array xi', () => { + test('array xi', { retry: 3 }, () => { const model = new CLIQUE([0.3, 0.2, 0.3, 0.2], 0.001) const n = 100 const x = Matrix.concat( diff --git a/tests/lib/model/clues.test.js b/tests/lib/model/clues.test.js index d326dcfa0..3d22a41b8 100644 --- a/tests/lib/model/clues.test.js +++ b/tests/lib/model/clues.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import CLUES from '../../../lib/model/clues.js' @@ -25,7 +22,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.5) }) - test('parameter', () => { + test('parameter', { retry: 5 }, () => { const model = new CLUES(0.4) const n = 100 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() @@ -43,7 +40,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.9) }) - test('small data', () => { + test('small data', { retry: 5 }, () => { const model = new CLUES(0.8) const x = Matrix.random(5, 2, -0.1, 0.1).toArray() diff --git a/tests/lib/model/coll.test.js b/tests/lib/model/coll.test.js index ea956bfe6..12d6ab4c6 100644 --- a/tests/lib/model/coll.test.js +++ b/tests/lib/model/coll.test.js @@ -5,7 +5,7 @@ import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }, 'polynomial', { name: 'polynomial', d: 3 }])( - 'kernel %p', + 'kernel %j', kernel => { const model = new COLL(3, undefined, kernel) const n = 50 diff --git a/tests/lib/model/confidence_weighted.test.js b/tests/lib/model/confidence_weighted.test.js index b28dcc74f..0baf5197a 100644 --- a/tests/lib/model/confidence_weighted.test.js +++ b/tests/lib/model/confidence_weighted.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import { ConfidenceWeighted, SoftConfidenceWeighted } from '../../../lib/model/confidence_weighted.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('ConfidenceWeighted', () => { - test('normal eta', () => { + test('normal eta', { retry: 3 }, () => { const model = new ConfidenceWeighted(0.9) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -21,7 +18,7 @@ describe('ConfidenceWeighted', () => { expect(acc).toBeGreaterThan(0.95) }) - test.each([1, 0.5, 0])('eta %p', eta => { + test.each([1, 0.5, 0])('eta %j', eta => { const model = new ConfidenceWeighted(eta) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/crf.test.js b/tests/lib/model/crf.test.js index 4ade6c594..733ee3806 100644 --- a/tests/lib/model/crf.test.js +++ b/tests/lib/model/crf.test.js @@ -1,9 +1,6 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import CRF from '../../../lib/model/crf.js' -test('fit', () => { +test('fit', { retry: 3 }, () => { const model = new CRF() const x = [['a', 'b', 'c', 'c', 'b', 'a', 'd']] const y = [[2, 0, 1, 1, 2, 1, 0]] @@ -21,7 +18,7 @@ test('fit', () => { expect(prob).toBeLessThanOrEqual(1) }) -test('fit unknown predict label', () => { +test('fit unknown predict label', { retry: 3 }, () => { const model = new CRF() const x = [['a', 'b', 'c']] const y = [[2, 0, 1]] diff --git a/tests/lib/model/dbclasd.test.js b/tests/lib/model/dbclasd.test.js index 0926b30c7..78eecf595 100644 --- a/tests/lib/model/dbclasd.test.js +++ b/tests/lib/model/dbclasd.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import DBCLASD from '../../../lib/model/dbclasd.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test('clustering', () => { +test('clustering', { retry: 3 }, () => { const model = new DBCLASD() const n = 100 const x = Matrix.concat( diff --git a/tests/lib/model/delaunay_interpolation.test.js b/tests/lib/model/delaunay_interpolation.test.js index 3d524ac61..346bc28c6 100644 --- a/tests/lib/model/delaunay_interpolation.test.js +++ b/tests/lib/model/delaunay_interpolation.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import DelaunayInterpolation from '../../../lib/model/delaunay_interpolation.js' import { rmse } from '../../../lib/evaluate/regression.js' -test('fit', () => { +test('fit', { retry: 3 }, () => { const model = new DelaunayInterpolation() const x = [ [1, 1], diff --git a/tests/lib/model/denclue.test.js b/tests/lib/model/denclue.test.js index d4525b1ba..09691eceb 100644 --- a/tests/lib/model/denclue.test.js +++ b/tests/lib/model/denclue.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import DENCLUE from '../../../lib/model/denclue.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test.each([undefined, 1, 2])('version %p', version => { + test.each([undefined, 1, 2])('version %j', { retry: 3 }, version => { const model = new DENCLUE(0.2, version) const n = 50 const x = Matrix.concat( @@ -31,7 +28,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.9) }) - test.each(['gaussian', { name: 'gaussian' }])('kernel %p', kernel => { + test.each(['gaussian', { name: 'gaussian' }])('kernel %j', { retry: 3 }, kernel => { const model = new DENCLUE(0.2, undefined, kernel) const n = 50 const x = Matrix.concat( @@ -55,7 +52,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.9) }) - test('custom kernel', () => { + test('custom kernel', { retry: 3 }, () => { const model = new DENCLUE(2, 1, a => (Math.sqrt(a.reduce((s, v) => s + v ** 2, 0)) < 1 ? 1 : 0)) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/diffusion_map.test.js b/tests/lib/model/diffusion_map.test.js index 6dce461a1..8a3d22eaf 100644 --- a/tests/lib/model/diffusion_map.test.js +++ b/tests/lib/model/diffusion_map.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import DiffusionMap from '../../../lib/model/diffusion_map.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('dimensionality reduction', () => { - test.each([undefined, 'gaussian', { name: 'gaussian' }])('kernel %p', kernel => { + test.each([undefined, 'gaussian', { name: 'gaussian' }])('kernel %j', { retry: 10, timeout: 30000 }, kernel => { const x = Matrix.concat(Matrix.random(40, 5, -2, 1), Matrix.random(40, 5, 3, 5)).toArray() const y = new DiffusionMap(3, 2, kernel).predict(x) diff --git a/tests/lib/model/diffusion_model.test.js b/tests/lib/model/diffusion_model.test.js index b51e51fd5..fa897eb99 100644 --- a/tests/lib/model/diffusion_model.test.js +++ b/tests/lib/model/diffusion_model.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import Tensor from '../../../lib/util/tensor.js' import DiffusionModel from '../../../lib/model/diffusion_model.js' describe('sample', () => { - test('2d custom layers', async () => { + test('2d custom layers', { retry: 3, timeout: 180000 }, async () => { const model = new DiffusionModel(100, [ { type: 'full', out_size: 8, l2_decay: 0.001, activation: 'tanh' }, { type: 'full', out_size: 4, l2_decay: 0.001, activation: 'tanh' }, diff --git a/tests/lib/model/doc.test.js b/tests/lib/model/doc.test.js index f56a7e4e7..e2e842e8b 100644 --- a/tests/lib/model/doc.test.js +++ b/tests/lib/model/doc.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import { DOC, FastDOC } from '../../../lib/model/doc.js' @@ -36,7 +33,7 @@ describe('doc', () => { }) describe('fastdoc', () => { - test('small alpha', () => { + test('small alpha', { retry: 3 }, () => { const model = new FastDOC(0.1, 0.2, 1.0, 100, 2) const n = 100 const x = Matrix.concat(Matrix.randn(n, 3, [0, 5, 0], 0.1), Matrix.randn(n, 3, [10, 5, 10], 0.1)).toArray() @@ -53,7 +50,7 @@ describe('fastdoc', () => { expect(ri).toBeGreaterThan(0.9) }) - test('small d0', () => { + test('small d0', { retry: 3 }, () => { const model = new FastDOC(0.1, 0.2, 1.0, 100, 1) const n = 200 const x = Matrix.concat(Matrix.randn(n, 3, 0, 0.1), Matrix.randn(n, 3, 5, 0.1)).toArray() @@ -70,7 +67,7 @@ describe('fastdoc', () => { expect(ri).toBeGreaterThan(0.9) }) - test('large d0', () => { + test('large d0', { retry: 3 }, () => { const model = new FastDOC(0.1, 0.2, 1.0, 100, 100) const n = 100 const x = Matrix.concat(Matrix.randn(n, 3, 0, 0.1), Matrix.randn(n, 3, 5, 0.1)).toArray() diff --git a/tests/lib/model/dqn.test.js b/tests/lib/model/dqn.test.js index d6dbc001b..c74ed4869 100644 --- a/tests/lib/model/dqn.test.js +++ b/tests/lib/model/dqn.test.js @@ -1,13 +1,10 @@ -import { expect, jest } from '@jest/globals' -jest.retryTimes(5) - import DQNAgent from '../../../lib/model/dqn.js' import ReversiRLEnvironment from '../../../lib/rl/reversi.js' import CartPoleRLEnvironment from '../../../lib/rl/cartpole.js' import InHypercubeRLEnvironment from '../../../lib/rl/inhypercube.js' import PendulumRLEnvironment from '../../../lib/rl/pendulum.js' -test('update dqn', () => { +test('update dqn', { retry: 5, timeout: 10000 }, () => { const env = new InHypercubeRLEnvironment(2) const agent = new DQNAgent(env, 10, [{ type: 'full', out_size: 3, activation: 'tanh' }], 'adam') @@ -34,7 +31,7 @@ test('update dqn', () => { agent.terminate() }) -test('update ddqn', () => { +test('update ddqn', { retry: 5, timeout: 10000 }, () => { const env = new InHypercubeRLEnvironment(2) const agent = new DQNAgent(env, 10, [{ type: 'full', out_size: 3, activation: 'tanh' }], 'adam') agent.method = 'DDQN' diff --git a/tests/lib/model/drake_kmeans.test.js b/tests/lib/model/drake_kmeans.test.js index 7917cbe2a..0b950ffa5 100644 --- a/tests/lib/model/drake_kmeans.test.js +++ b/tests/lib/model/drake_kmeans.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import DrakeKMeans from '../../../lib/model/drake_kmeans.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new DrakeKMeans(8) const n = 20 const x = Array.from({ length: 8 }, (_, i) => i * 2) diff --git a/tests/lib/model/elkan_kmeans.test.js b/tests/lib/model/elkan_kmeans.test.js index 3a378ae2b..d5caa8f89 100644 --- a/tests/lib/model/elkan_kmeans.test.js +++ b/tests/lib/model/elkan_kmeans.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import ElkanKMeans from '../../../lib/model/elkan_kmeans.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new ElkanKMeans(8) const n = 20 const x = Array.from({ length: 8 }, (_, i) => i * 2) diff --git a/tests/lib/model/elm.test.js b/tests/lib/model/elm.test.js index 659e5da87..e89f65c39 100644 --- a/tests/lib/model/elm.test.js +++ b/tests/lib/model/elm.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import { ELMClassifier, ELMRegressor } from '../../../lib/model/elm.js' @@ -18,7 +15,7 @@ describe('regression', () => { 'softsign', 'tanh', x => Math.sin(x), - ])('%s', activation => { + ])('%s', { retry: 5 }, activation => { const model = new ELMRegressor(20, activation) const x = Matrix.randn(30, 2, 0, 5).toArray() const t = [] @@ -44,7 +41,7 @@ describe('classifier', () => { 'tanh', 'identity', x => Math.sin(x), - ])('%s', activation => { + ])('%s', { retry: 10 }, activation => { const model = new ELMClassifier(3, activation) const x = Matrix.concat(Matrix.randn(20, 2, 0, 0.2), Matrix.randn(20, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/enn.test.js b/tests/lib/model/enn.test.js index 8a945e53d..a00f4d3d7 100644 --- a/tests/lib/model/enn.test.js +++ b/tests/lib/model/enn.test.js @@ -19,7 +19,7 @@ describe('classification', () => { expect(acc).toBeGreaterThan(0.9) }) - describe.each([undefined, 0, 1, 2])('version %p', version => { + describe.each([undefined, 0, 1, 2])('version %j', version => { test.each([ undefined, 'euclid', diff --git a/tests/lib/model/findit.test.js b/tests/lib/model/findit.test.js index b4610202f..855c93460 100644 --- a/tests/lib/model/findit.test.js +++ b/tests/lib/model/findit.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import FINDIT from '../../../lib/model/findit.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test('clustering', () => { +test('clustering', { retry: 3 }, () => { const model = new FINDIT(20, 4) const n = 100 const x = Matrix.concat( diff --git a/tests/lib/model/forgetron.test.js b/tests/lib/model/forgetron.test.js index e7783c496..387e25dc2 100644 --- a/tests/lib/model/forgetron.test.js +++ b/tests/lib/model/forgetron.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import Forgetron from '../../../lib/model/forgetron.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('classification', () => { - test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', kernel => { + test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', { retry: 10 }, kernel => { const model = new Forgetron(10, kernel) const s = 2 const x = [] @@ -31,7 +28,7 @@ describe('classification', () => { expect(acc).toBeGreaterThan(0.95) }) - test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', kernel => { + test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', { retry: 10 }, kernel => { const model = new Forgetron(100, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/gan.test.js b/tests/lib/model/gan.test.js index ae310a46e..f817733c7 100644 --- a/tests/lib/model/gan.test.js +++ b/tests/lib/model/gan.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import GAN from '../../../lib/model/gan.js' -test('sample', () => { +test('sample', { retry: 10, timeout: 10000 }, () => { const model = new GAN( 3, [{ type: 'full', out_size: 5, activation: 'tanh' }], @@ -31,7 +28,7 @@ test('sample', () => { expect(p[1][1]).toBeGreaterThan(p[0][1]) }) -test('conditional', () => { +test('conditional', { retry: 10, timeout: 30000 }, () => { const model = new GAN( 2, [{ type: 'full', out_size: 3, activation: 'tanh' }], diff --git a/tests/lib/model/gaussian_process.test.js b/tests/lib/model/gaussian_process.test.js index 19e453773..33803be1f 100644 --- a/tests/lib/model/gaussian_process.test.js +++ b/tests/lib/model/gaussian_process.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import GaussianProcess from '../../../lib/model/gaussian_process.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('regression', () => { - test('fit default', () => { + test('fit default', { retry: 3 }, () => { const model = new GaussianProcess(undefined, 10) const x = [ [0, 0], @@ -23,7 +20,7 @@ describe('regression', () => { expect(err).toBeLessThan(0.5) }) - test('fit with param', () => { + test('fit with param', { retry: 3 }, () => { const model = new GaussianProcess() const x = Matrix.random(50, 2, -2, 2).toArray() const t = [] diff --git a/tests/lib/model/gbdt.test.js b/tests/lib/model/gbdt.test.js index f63104311..0ec798f23 100644 --- a/tests/lib/model/gbdt.test.js +++ b/tests/lib/model/gbdt.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import { GBDT, GBDTClassifier } from '../../../lib/model/gbdt.js' @@ -8,7 +5,7 @@ import { accuracy } from '../../../lib/evaluate/classification.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('classifier', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new GBDTClassifier() const x = Matrix.concat(Matrix.randn(10, 3, 0, 0.2), Matrix.randn(10, 3, 5, 0.2)).toArray() const t = [] @@ -26,7 +23,7 @@ describe('classifier', () => { expect(acc).toBeGreaterThan(0.9) }) - test.each([0.5, 0])('classifier %d', lr => { + test.each([0.5, 0])('classifier %d', { retry: 3 }, lr => { const model = new GBDTClassifier(10, 0.8, lr) const x = Matrix.randn(20, 10).toArray() const t = [] @@ -46,7 +43,7 @@ describe('classifier', () => { }) describe('regression', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new GBDT() const x = Matrix.random(20, 10, -2, 2).toArray() const t = [] @@ -62,7 +59,7 @@ describe('regression', () => { expect(err).toBeLessThan(0.5) }) - test.each([0.5, 0])('regression %d', lr => { + test.each([0.5, 0])('regression %d', { retry: 3 }, lr => { const model = new GBDT(10, 0.8, lr) const x = Matrix.random(20, 10, -2, 2).toArray() const t = [] diff --git a/tests/lib/model/genetic_algorithm.test.js b/tests/lib/model/genetic_algorithm.test.js index b8234f8bd..8c105a5dc 100644 --- a/tests/lib/model/genetic_algorithm.test.js +++ b/tests/lib/model/genetic_algorithm.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import GeneticAlgorithmGeneration from '../../../lib/model/genetic_algorithm.js' import CartPoleRLEnvironment from '../../../lib/rl/cartpole.js' describe('constructor', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const env = new CartPoleRLEnvironment() const agent = new GeneticAlgorithmGeneration(env) diff --git a/tests/lib/model/gmeans.test.js b/tests/lib/model/gmeans.test.js index 4fda32f59..738c8b324 100644 --- a/tests/lib/model/gmeans.test.js +++ b/tests/lib/model/gmeans.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import GMeans from '../../../lib/model/gmeans.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test('predict', () => { +test('predict', { retry: 3 }, () => { const model = new GMeans() const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/gmm.test.js b/tests/lib/model/gmm.test.js index 012c96004..877f58c10 100644 --- a/tests/lib/model/gmm.test.js +++ b/tests/lib/model/gmm.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(20) - import Matrix from '../../../lib/util/matrix.js' import { GMM, GMR, SemiSupervisedGMM } from '../../../lib/model/gmm.js' @@ -9,7 +6,7 @@ import { accuracy } from '../../../lib/evaluate/classification.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('clustering', () => { - test('predict', () => { + test('predict', { retry: 20 }, () => { const model = new GMM() const n = 50 const x = Matrix.concat( @@ -61,7 +58,7 @@ describe('clustering', () => { expect(model._k).toBe(0) }) - test('probability', () => { + test('probability', { retry: 20 }, () => { const model = new GMM() const n = 50 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() @@ -83,7 +80,7 @@ describe('clustering', () => { }) describe('regression', () => { - test('predict', () => { + test('predict', { retry: 20 }, () => { const model = new GMR() const x = Matrix.randn(50, 2, 0, 5).toArray() const t = [] diff --git a/tests/lib/model/gplvm.test.js b/tests/lib/model/gplvm.test.js index 0d18757ea..4f323e8fd 100644 --- a/tests/lib/model/gplvm.test.js +++ b/tests/lib/model/gplvm.test.js @@ -4,7 +4,7 @@ import GPLVM from '../../../lib/model/gplvm.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('dimension reduction', () => { - test('default', () => { + test('default', { timeout: 10000 }, () => { const model = new GPLVM(3, 1) const x = Matrix.randn(50, 10, 0, Matrix.diag([1.0, 0.5, 1.0, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 0.5])).toArray() @@ -19,7 +19,7 @@ describe('dimension reduction', () => { expect(q).toBeGreaterThan(0.9) }) - test('kernel with params', () => { + test('kernel with params', { timeout: 10000 }, () => { const model = new GPLVM(3, 1, 1, 0.005, 0.1, { name: 'gaussian', a: 0.2, b: 1 }) const x = Matrix.randn(50, 10, 0, Matrix.diag([1.0, 0.1, 1.0, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 0.1])).toArray() @@ -35,7 +35,7 @@ describe('dimension reduction', () => { }) }) -test('reconstruct', () => { +test('reconstruct', { timeout: 10000 }, () => { const model = new GPLVM(3, 1) const x = Matrix.randn(50, 10, 0, Matrix.diag([1.0, 0.1, 1.0, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 0.1])).toArray() diff --git a/tests/lib/model/growing_neural_gas.test.js b/tests/lib/model/growing_neural_gas.test.js index d9c4e666b..a59d4cecd 100644 --- a/tests/lib/model/growing_neural_gas.test.js +++ b/tests/lib/model/growing_neural_gas.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import GrowingNeuralGas from '../../../lib/model/growing_neural_gas.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test('clustering', () => { +test('clustering', { retry: 3 }, () => { const model = new GrowingNeuralGas(1, 0.9999) const n = 50 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() diff --git a/tests/lib/model/growing_som.test.js b/tests/lib/model/growing_som.test.js index bce54733b..d7640f9e0 100644 --- a/tests/lib/model/growing_som.test.js +++ b/tests/lib/model/growing_som.test.js @@ -1,7 +1,7 @@ import Matrix from '../../../lib/util/matrix.js' import GSOM from '../../../lib/model/growing_som.js' -test.each([undefined, 0.9])('clustering %p', sf => { +test.each([undefined, 0.9])('clustering %j', sf => { const model = new GSOM(sf) const n = 50 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() diff --git a/tests/lib/model/gtm.test.js b/tests/lib/model/gtm.test.js index 77d929ac9..358d58462 100644 --- a/tests/lib/model/gtm.test.js +++ b/tests/lib/model/gtm.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import GTM from '../../../lib/model/gtm.js' @@ -116,7 +113,7 @@ describe('clustering', () => { }) }) -test('dimensionality reduction', () => { +test('dimensionality reduction', { retry: 3 }, () => { const x = Matrix.concat(Matrix.randn(50, 5, 0, 0.2), Matrix.randn(50, 5, 5, 0.2)).toArray() const model = new GTM(5, 2, 3) diff --git a/tests/lib/model/hamelry_kmeans.test.js b/tests/lib/model/hamelry_kmeans.test.js index e1e22be86..ed5bdeff4 100644 --- a/tests/lib/model/hamelry_kmeans.test.js +++ b/tests/lib/model/hamelry_kmeans.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import HamelryKMeans from '../../../lib/model/hamelry_kmeans.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new HamelryKMeans(8) const n = 20 const x = Array.from({ length: 8 }, (_, i) => i * 2) diff --git a/tests/lib/model/hampel.test.js b/tests/lib/model/hampel.test.js index c926e6731..f411629f6 100644 --- a/tests/lib/model/hampel.test.js +++ b/tests/lib/model/hampel.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import HampelFilter from '../../../lib/model/hampel.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('smoothing', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const x = [] const t = [] for (let i = 0; i < 100; i++) { diff --git a/tests/lib/model/hdbscan.test.js b/tests/lib/model/hdbscan.test.js index 54da5cfff..a34918edd 100644 --- a/tests/lib/model/hdbscan.test.js +++ b/tests/lib/model/hdbscan.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import HDBSCAN from '../../../lib/model/hdbscan.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('default', () => { + test('default', { retry: 10 }, () => { const model = new HDBSCAN() const n = 50 const x = Matrix.concat( @@ -28,7 +25,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.7) }) - test.each([undefined, 'euclid', 'manhattan', 'chebyshev'])('%s', metric => { + test.each([undefined, 'euclid', 'manhattan', 'chebyshev'])('%s', { retry: 10 }, metric => { const model = new HDBSCAN(undefined, 2, metric) const n = 50 const x = Matrix.concat( @@ -49,7 +46,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.9) }) - test.each([(a, b) => a.reduce((s, v, i) => s + Math.exp((v - b[i]) ** 2) - 1, 0)])('%s', metric => { + test.each([(a, b) => a.reduce((s, v, i) => s + Math.exp((v - b[i]) ** 2) - 1, 0)])('%s', { retry: 10 }, metric => { const model = new HDBSCAN(undefined, 2, metric) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/histogram.test.js b/tests/lib/model/histogram.test.js index e532e85c3..db81c2380 100644 --- a/tests/lib/model/histogram.test.js +++ b/tests/lib/model/histogram.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import Histogram from '../../../lib/model/histogram.js' @@ -151,7 +148,7 @@ describe('count', () => { }) }) -test.each(['fd', 'scott', 'rice', 'sturges', 'doane', 'sqrt'])('bin method %s', method => { +test.each(['fd', 'scott', 'rice', 'sturges', 'doane', 'sqrt'])('bin method %s', { retry: 3 }, method => { const model = new Histogram({ binMethod: method }) const n = 1000 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.5), Matrix.randn(n, 2, 5, 0.5)).toArray() diff --git a/tests/lib/model/hlle.test.js b/tests/lib/model/hlle.test.js index 6e1129652..3415c09d0 100644 --- a/tests/lib/model/hlle.test.js +++ b/tests/lib/model/hlle.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import HLLE from '../../../lib/model/hlle.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('dimensionality reduction', () => { - test('default', () => { + test('default', { retry: 5 }, () => { const x = Matrix.concat(Matrix.randn(30, 5, 0, 0.2), Matrix.randn(30, 5, 5, 0.2)).toArray() const y = new HLLE(9).predict(x) expect(y[0]).toHaveLength(5) @@ -15,7 +12,7 @@ describe('dimensionality reduction', () => { expect(q).toBeGreaterThan(0.85) }) - test('10', () => { + test('10', { retry: 5 }, () => { const x = Matrix.concat(Matrix.randn(30, 5, 0, 0.2), Matrix.randn(30, 5, 5, 0.2)).toArray() const y = new HLLE(10, 2).predict(x) expect(y[0]).toHaveLength(2) diff --git a/tests/lib/model/hmm.test.js b/tests/lib/model/hmm.test.js index 4d2203b16..5a809ab8f 100644 --- a/tests/lib/model/hmm.test.js +++ b/tests/lib/model/hmm.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import Tensor from '../../../lib/util/tensor.js' import { HMM, ContinuousHMM } from '../../../lib/model/hmm.js' describe('hmm', () => { - test.each([undefined, true, false])('scaled:%p', scaled => { + test.each([undefined, true, false])('scaled:%j', scaled => { const model = new HMM(5) const x = [['sunny', 'cloudy', 'rainy', 'sunny', 'sunny']] model.fit(x, scaled) @@ -36,7 +33,7 @@ describe('hmm', () => { }) describe('continuous hmm', () => { - test.each([undefined, true, false])('continuous hmm scaled:%p', scaled => { + test.each([undefined, true, false])('continuous hmm scaled:%j', { retry: 10 }, scaled => { const model = new ContinuousHMM(3) const x = Tensor.randn([10, 7, 2]).toArray() model.fit(x, scaled) @@ -48,7 +45,7 @@ describe('continuous hmm', () => { expect(newProb).toBeGreaterThan(oldProb) }) - test.each([undefined, true, false])('continuous hmm matrix scaled:%p', scaled => { + test.each([undefined, true, false])('continuous hmm matrix scaled:%j', { retry: 10 }, scaled => { const model = new ContinuousHMM(3) const x = Matrix.randn(10, 7).toArray() model.fit(x, scaled) @@ -76,7 +73,7 @@ describe('continuous hmm', () => { } }) - test('generate', () => { + test('generate', { retry: 10 }, () => { const model = new ContinuousHMM(5) const x = Tensor.randn([10, 7, 2]).toArray() model.fit(x, true) diff --git a/tests/lib/model/holt_winters.test.js b/tests/lib/model/holt_winters.test.js index 46a660d77..31a83d5ec 100644 --- a/tests/lib/model/holt_winters.test.js +++ b/tests/lib/model/holt_winters.test.js @@ -1,9 +1,6 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import HoltWinters from '../../../lib/model/holt_winters.js' -test('default', () => { +test('default', { retry: 3 }, () => { const model = new HoltWinters(0.5) const x = [] for (let i = 0; i < 100; i++) { @@ -18,7 +15,7 @@ test('default', () => { } }) -test('linear', () => { +test('linear', { retry: 3 }, () => { const model = new HoltWinters(0.2, 0.9, 0.1, 2) const x = [] for (let i = 0; i < 100; i++) { @@ -33,7 +30,7 @@ test('linear', () => { } }) -test('sin', () => { +test('sin', { retry: 3 }, () => { const model = new HoltWinters(0, 0, 0.9, 66) const x = [] for (let i = 0; i < 100; i++) { diff --git a/tests/lib/model/huber_regression.test.js b/tests/lib/model/huber_regression.test.js index 78f5241f7..80d7e148b 100644 --- a/tests/lib/model/huber_regression.test.js +++ b/tests/lib/model/huber_regression.test.js @@ -4,7 +4,7 @@ import HuberRegression from '../../../lib/model/huber_regression.js' import { rmse } from '../../../lib/evaluate/regression.js' describe.each([undefined, 'rls', 'gd'])('fit %s', method => { - test.each([undefined, 1.0e-5])('e: %p', e => { + test.each([undefined, 1.0e-5])('e: %j', e => { const model = new HuberRegression(e, method) const x = Matrix.randn(50, 2, 0, 5).toArray() const t = [] diff --git a/tests/lib/model/ica.test.js b/tests/lib/model/ica.test.js index 82f7bf6da..d3ccccbbb 100644 --- a/tests/lib/model/ica.test.js +++ b/tests/lib/model/ica.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import ICA from '../../../lib/model/ica.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('dimensionality reduction', () => { - test('2d', () => { + test('2d', { retry: 3 }, () => { const x = Matrix.concat( Matrix.randn(50, 5, 0, Matrix.randn(5, 5).gram().toArray()), Matrix.randn(50, 5, 5, Matrix.randn(5, 5).gram().toArray()) diff --git a/tests/lib/model/inflo.test.js b/tests/lib/model/inflo.test.js index 49c09b8e0..0e24dd3ef 100644 --- a/tests/lib/model/inflo.test.js +++ b/tests/lib/model/inflo.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import INFLO from '../../../lib/model/inflo.js' -test('anomaly detection', () => { +test('anomaly detection', { retry: 3 }, () => { const model = new INFLO(5) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) diff --git a/tests/lib/model/isodata.test.js b/tests/lib/model/isodata.test.js index 45943a13a..3342d66f6 100644 --- a/tests/lib/model/isodata.test.js +++ b/tests/lib/model/isodata.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import ISODATA from '../../../lib/model/isodata.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test('clustering', () => { +test('clustering', { retry: 3 }, () => { const model = new ISODATA(5, 1, 20, 10, 1, 0.8) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/isomap.test.js b/tests/lib/model/isomap.test.js index 853648315..1922e2da9 100644 --- a/tests/lib/model/isomap.test.js +++ b/tests/lib/model/isomap.test.js @@ -13,7 +13,7 @@ describe('dimensionality reduction', () => { expect(q).toBeGreaterThan(0.9) }) - test.each([undefined, 10])('n: %p', n => { + test.each([undefined, 10])('n: %j', n => { const x = Matrix.randn(50, 5, 0, 0.2).toArray() const y = new Isomap(n, 2).predict(x) diff --git a/tests/lib/model/kalman_filter.test.js b/tests/lib/model/kalman_filter.test.js index 649b5eab1..6677ad02c 100644 --- a/tests/lib/model/kalman_filter.test.js +++ b/tests/lib/model/kalman_filter.test.js @@ -17,7 +17,7 @@ describe('smoothing', () => { expect(err).toBeLessThan(rmse(x, t)[0]) }) - test('large dim', () => { + test('large dim', { retry: 3 }, () => { const x = [] const t = [] for (let i = 0; i < 100; i++) { diff --git a/tests/lib/model/kdeos.test.js b/tests/lib/model/kdeos.test.js index b6129a744..2e19212b7 100644 --- a/tests/lib/model/kdeos.test.js +++ b/tests/lib/model/kdeos.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import KDEOS from '../../../lib/model/kdeos.js' describe('anomaly detection', () => { - test.each([undefined, 'gaussian', { name: 'gaussian' }])('kernel %p', kernel => { + test.each([undefined, 'gaussian', { name: 'gaussian' }])('kernel %j', { retry: 10 }, kernel => { const model = new KDEOS(5, 10, kernel) const x = Matrix.randn(100, 2, 0, 0.1).toArray() x.push([10, 10]) @@ -21,7 +18,7 @@ describe('anomaly detection', () => { expect(y[y.length - 1]).toBe(true) }) - test.each(['epanechnikov', { name: 'epanechnikov' }])('kernel %p', kernel => { + test.each(['epanechnikov', { name: 'epanechnikov' }])('kernel %j', kernel => { const model = new KDEOS(5, 10, kernel) const x = Matrix.randn(100, 2, 0, 0.1).toArray() const y = model.predict(x) diff --git a/tests/lib/model/kernel_density_estimator.test.js b/tests/lib/model/kernel_density_estimator.test.js index f93516c3a..56b7bb1be 100644 --- a/tests/lib/model/kernel_density_estimator.test.js +++ b/tests/lib/model/kernel_density_estimator.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import KernelDensityEstimator from '../../../lib/model/kernel_density_estimator.js' import { correlation } from '../../../lib/evaluate/regression.js' describe('density estimation', () => { - test('default', () => { + test('default', { retry: 5 }, () => { const model = new KernelDensityEstimator() const n = 500 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() @@ -38,7 +35,7 @@ describe('density estimation', () => { { name: 'biweight' }, 'triweight', { name: 'triweight' }, - ])('kernel %s', kernel => { + ])('kernel %s', { retry: 5 }, kernel => { const model = new KernelDensityEstimator(0, kernel) const n = 500 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() @@ -76,7 +73,7 @@ describe('density estimation', () => { expect(corr).toBeGreaterThan(0.8) }) - test('custom kernel', () => { + test('custom kernel', { retry: 5 }, () => { const model = new KernelDensityEstimator(1.0, v => 1 / (v + 1.0e-8)) const n = 500 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() diff --git a/tests/lib/model/kernel_kmeans.test.js b/tests/lib/model/kernel_kmeans.test.js index 87c78727d..afc1f808b 100644 --- a/tests/lib/model/kernel_kmeans.test.js +++ b/tests/lib/model/kernel_kmeans.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import KernelKMeans from '../../../lib/model/kernel_kmeans.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test.each([undefined, 3])('clustering k: %p', k => { +test.each([undefined, 3])('clustering k: %j', { retry: 3 }, k => { const model = new KernelKMeans(k) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/kernelized_pegasos.test.js b/tests/lib/model/kernelized_pegasos.test.js index b02ad0eee..e35b3b9b6 100644 --- a/tests/lib/model/kernelized_pegasos.test.js +++ b/tests/lib/model/kernelized_pegasos.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(20) - import Matrix from '../../../lib/util/matrix.js' import KernelizedPegasos from '../../../lib/model/kernelized_pegasos.js' @@ -9,6 +6,7 @@ import { accuracy } from '../../../lib/evaluate/classification.js' describe('classification', () => { test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }, 'polynomial', { name: 'polynomial', d: 3 }])( 'kernel %s', + { retry: 20 }, kernel => { const model = new KernelizedPegasos(0.1, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() diff --git a/tests/lib/model/kernelized_perceptron.test.js b/tests/lib/model/kernelized_perceptron.test.js index 38b509010..ec0dcb75b 100644 --- a/tests/lib/model/kernelized_perceptron.test.js +++ b/tests/lib/model/kernelized_perceptron.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import KernelizedPerceptron from '../../../lib/model/kernelized_perceptron.js' @@ -9,6 +6,7 @@ import { accuracy } from '../../../lib/evaluate/classification.js' describe('classification', () => { test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }, 'polynomial', { name: 'polynomial', d: 3 }])( 'kernel %s', + { retry: 10 }, kernel => { const model = new KernelizedPerceptron(1, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() diff --git a/tests/lib/model/kliep.test.js b/tests/lib/model/kliep.test.js index 6490b0e9c..385f607d6 100644 --- a/tests/lib/model/kliep.test.js +++ b/tests/lib/model/kliep.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import KLIEP from '../../../lib/model/kliep.js' -test('kliep', () => { +test('kliep', { retry: 5, timeout: 30000 }, () => { const sigmas = [] for (let i = -3; i <= 3; i += 0.5) { sigmas.push(10 ** i) @@ -21,7 +18,7 @@ test('kliep', () => { } }) -test('kliep single sigma', () => { +test('kliep single sigma', { retry: 5 }, () => { const model = new KLIEP([3], 5, 50) const x1 = Matrix.randn(300, 1, 0).toArray() diff --git a/tests/lib/model/kmeans.test.js b/tests/lib/model/kmeans.test.js index 48f3f4933..4e23d6736 100644 --- a/tests/lib/model/kmeans.test.js +++ b/tests/lib/model/kmeans.test.js @@ -4,8 +4,8 @@ import { KMeans, KMeanspp, KMedoids, KMedians, SemiSupervisedKMeansModel } from import { randIndex } from '../../../lib/evaluate/clustering.js' import { accuracy } from '../../../lib/evaluate/classification.js' -describe.each([KMeans, KMeanspp, KMedoids, KMedians])('%p', methodCls => { - test.each([50, 51])('predict %p', n => { +describe.each([KMeans, KMeanspp, KMedoids, KMedians])('%j', methodCls => { + test.each([50, 51])('predict %j', n => { const model = new methodCls() const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() diff --git a/tests/lib/model/kmodes.test.js b/tests/lib/model/kmodes.test.js index 7cce8db01..80ba4d600 100644 --- a/tests/lib/model/kmodes.test.js +++ b/tests/lib/model/kmodes.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import KModes from '../../../lib/model/kmodes.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('predict', () => { - test('fit', () => { + test('fit', { retry: 5 }, () => { const model = new KModes() const n = 50 const x = [] diff --git a/tests/lib/model/knearestneighbor.test.js b/tests/lib/model/knearestneighbor.test.js index ed4f41add..45444d6fe 100644 --- a/tests/lib/model/knearestneighbor.test.js +++ b/tests/lib/model/knearestneighbor.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import { KNN, KNNRegression, @@ -21,7 +18,7 @@ describe.each([ 'minkowski', (a, b) => a.reduce((s, v, i) => s + Math.exp((v - b[i]) ** 2) - 1, 0), ])('classifier %s', metric => { - test.each([undefined, 5])('k %p', k => { + test.each([undefined, 5])('k %j', k => { const model = new KNN(k, metric) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -94,7 +91,7 @@ describe.each([ 'minkowski', (a, b) => a.reduce((s, v, i) => s + Math.exp((v - b[i]) ** 2) - 1, 0), ])('semi-classifier %s', metric => { - test.each([undefined, 5])('k %p', k => { + test.each([undefined, 5])('k %j', k => { const model = new SemiSupervisedKNN(k, metric) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -120,7 +117,7 @@ describe.each([ 'minkowski', (a, b) => a.reduce((s, v, i) => s + Math.exp((v - b[i]) ** 2) - 1, 0), ])('anomaly detection %s', metric => { - test.each([undefined, 5])('k %p', k => { + test.each([undefined, 5])('k %j', k => { const model = new KNNAnomaly(k, metric) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) @@ -136,7 +133,7 @@ describe.each([ describe('density estimation', () => { describe.each([undefined, 'euclid', 'manhattan', 'chebyshev', 'minkowski'])('%s', metric => { - test.each([3, 4])('k 50, d%p', d => { + test.each([3, 4])('k 50, d%j', { retry: 5 }, d => { const model = new KNNDensityEstimation(50, metric) const n = 100 const x = Matrix.concat(Matrix.randn(n, d, 0, 0.1), Matrix.randn(n, d, 5, 0.1)).toArray() @@ -155,7 +152,7 @@ describe('density estimation', () => { expect(corr).toBeGreaterThan(0.9) }) - test.each([3, 4])('k undefined, d%p', d => { + test.each([3, 4])('k undefined, d%j', { retry: 5 }, d => { const model = new KNNDensityEstimation(undefined, metric) const n = 100 const x = Matrix.concat(Matrix.randn(n, d, 0, 0.1), Matrix.randn(n, d, 5, 0.1)).toArray() @@ -176,7 +173,7 @@ describe('density estimation', () => { }) describe.each([(a, b) => a.reduce((s, v, i) => s + Math.exp((v - b[i]) ** 2) - 1, 0)])('%s', metric => { - test.each([3, 4])('k 50, d%p', d => { + test.each([3, 4])('k 50, d%j', { retry: 5 }, d => { const model = new KNNDensityEstimation(50, metric) const n = 100 const x = Matrix.concat(Matrix.randn(n, d, 0, 0.1), Matrix.randn(n, d, 5, 0.1)).toArray() @@ -195,7 +192,7 @@ describe('density estimation', () => { expect(corr).toBeGreaterThan(0.8) }) - test.each([3, 4])('k undefined, d%p', d => { + test.each([3, 4])('k undefined, d%j', { retry: 10 }, d => { const model = new KNNDensityEstimation(undefined, metric) const n = 100 const x = Matrix.concat(Matrix.randn(n, d, 0, 0.1), Matrix.randn(n, d, 5, 0.1)).toArray() diff --git a/tests/lib/model/kprototypes.test.js b/tests/lib/model/kprototypes.test.js index cfbc8d91c..2b45291f6 100644 --- a/tests/lib/model/kprototypes.test.js +++ b/tests/lib/model/kprototypes.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import KPrototypes from '../../../lib/model/kprototypes.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('predict', () => { - test('fit', () => { + test('fit', { retry: 3 }, () => { const iscat = [true, false, true, false, true] const model = new KPrototypes(0.5, iscat) const n = 50 diff --git a/tests/lib/model/ksvd.test.js b/tests/lib/model/ksvd.test.js index 2d2604204..1e7505452 100644 --- a/tests/lib/model/ksvd.test.js +++ b/tests/lib/model/ksvd.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import KSVD from '../../../lib/model/ksvd.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' -test('dimensionality reduction', () => { +test('dimensionality reduction', { retry: 3 }, () => { const x = Matrix.concat(Matrix.randn(50, 5, 0, 0.2), Matrix.randn(50, 5, 5, 0.2)).toArray() const model = new KSVD(x, 2) diff --git a/tests/lib/model/label_propagation.test.js b/tests/lib/model/label_propagation.test.js index 80be4ce85..acf8a0872 100644 --- a/tests/lib/model/label_propagation.test.js +++ b/tests/lib/model/label_propagation.test.js @@ -3,7 +3,7 @@ import LabelPropagation from '../../../lib/model/label_propagation.js' import { accuracy } from '../../../lib/evaluate/classification.js' -test.each([undefined, 'rbf', { name: 'rbf', sigma: 0.2 }, { name: 'knn', k: 10 }])('semi-classifier %p', method => { +test.each([undefined, 'rbf', { name: 'rbf', sigma: 0.2 }, { name: 'knn', k: 10 }])('semi-classifier %j', method => { const model = new LabelPropagation(method) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/label_spreading.test.js b/tests/lib/model/label_spreading.test.js index 1339a2547..65f33e567 100644 --- a/tests/lib/model/label_spreading.test.js +++ b/tests/lib/model/label_spreading.test.js @@ -7,7 +7,7 @@ test.each([ [undefined, undefined], [0.5, { name: 'rbf', sigma: 0.2 }], [0.8, { name: 'knn', k: 10 }], -])('semi-classifier %p %p', (alpha, method) => { +])('semi-classifier %j %j', (alpha, method) => { const model = new LabelSpreading(alpha, method) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/ladder_network.test.js b/tests/lib/model/ladder_network.test.js index 953325928..132bced43 100644 --- a/tests/lib/model/ladder_network.test.js +++ b/tests/lib/model/ladder_network.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LadderNetwork from '../../../lib/model/ladder_network.js' import { accuracy } from '../../../lib/evaluate/classification.js' -test('semi-classifier', () => { +test('semi-classifier', { retry: 3, timeout: 30000 }, () => { const model = new LadderNetwork([5], [0.001, 0.0001, 0.0001], 'tanh', 'adam') const n = 20 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.2), Matrix.randn(n, 2, 5, 0.2)).toArray() diff --git a/tests/lib/model/lagrange.test.js b/tests/lib/model/lagrange.test.js index 04d4723b1..01c379f24 100644 --- a/tests/lib/model/lagrange.test.js +++ b/tests/lib/model/lagrange.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LagrangeInterpolation from '../../../lib/model/lagrange.js' import { rmse } from '../../../lib/evaluate/regression.js' -test.each([undefined, '', 'weighted', 'newton'])('interpolation %s', method => { +test.each([undefined, '', 'weighted', 'newton'])('interpolation %s', { retry: 3 }, method => { const model = new LagrangeInterpolation(method) const x = Matrix.random(20, 1, -2, 2).value const t = [] diff --git a/tests/lib/model/laplacian.test.js b/tests/lib/model/laplacian.test.js index da22c61ed..0990ff04b 100644 --- a/tests/lib/model/laplacian.test.js +++ b/tests/lib/model/laplacian.test.js @@ -1,7 +1,7 @@ import Matrix from '../../../lib/util/matrix.js' import Laplacian from '../../../lib/model/laplacian.js' -test.each([undefined, 4, 8])('predict %p', k => { +test.each([undefined, 4, 8])('predict %j', k => { const model = new Laplacian(128, k) const n = 100 const x = Matrix.zeros(n, n).toArray() diff --git a/tests/lib/model/laplacian_eigenmaps.test.js b/tests/lib/model/laplacian_eigenmaps.test.js index 88922b80f..1d7481082 100644 --- a/tests/lib/model/laplacian_eigenmaps.test.js +++ b/tests/lib/model/laplacian_eigenmaps.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LaplacianEigenmaps from '../../../lib/model/laplacian_eigenmaps.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' -describe.each([undefined, 'knn', { name: 'rbf' }])('dimensionality reduction affinity:%p', affinity => { - test.each([undefined, 'normalized'])('laplacian: %p', laplacian => { +describe.each([undefined, 'knn', { name: 'rbf' }])('dimensionality reduction affinity:%j', affinity => { + test.each([undefined, 'normalized'])('laplacian: %j', laplacian => { const x = Matrix.concat(Matrix.randn(30, 5, 0, 0.2), Matrix.randn(30, 5, 5, 0.2)).toArray() const model = new LaplacianEigenmaps(2, affinity, laplacian) @@ -18,7 +15,7 @@ describe.each([undefined, 'knn', { name: 'rbf' }])('dimensionality reduction aff }) }) -test('dimensionality k=0', () => { +test('dimensionality k=0', { retry: 5 }, () => { const x = Matrix.concat(Matrix.randn(30, 5, 0, 0.2), Matrix.randn(30, 5, 5, 0.2)).toArray() const model = new LaplacianEigenmaps(2, { name: 'rbf', k: 0 }) diff --git a/tests/lib/model/lasso.test.js b/tests/lib/model/lasso.test.js index b1947f73f..d3acb94c7 100644 --- a/tests/lib/model/lasso.test.js +++ b/tests/lib/model/lasso.test.js @@ -42,7 +42,7 @@ describe('LARS', () => { expect(min_err).toBeLessThan(0.5) }) - test('fit negative gc_tilde', () => { + test('fit negative gc_tilde', { retry: 3 }, () => { const x = [ [2.7, 3.7], [-0.7, 1.7], diff --git a/tests/lib/model/latent_dirichlet_allocation.test.js b/tests/lib/model/latent_dirichlet_allocation.test.js index b09a921b5..96f3e6c89 100644 --- a/tests/lib/model/latent_dirichlet_allocation.test.js +++ b/tests/lib/model/latent_dirichlet_allocation.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LatentDirichletAllocation from '../../../lib/model/latent_dirichlet_allocation.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test.each([undefined, 2])('lda t: %p', tp => { +test.each([undefined, 2])('lda t: %j', { retry: 3 }, tp => { const model = new LatentDirichletAllocation(tp) const n = 50 const x = Matrix.map(Matrix.concat(Matrix.random(n, 10, 0, 5), Matrix.random(n, 10, 4, 9)), v => diff --git a/tests/lib/model/lda.test.js b/tests/lib/model/lda.test.js index 232f807cf..2a361e5b0 100644 --- a/tests/lib/model/lda.test.js +++ b/tests/lib/model/lda.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import { LinearDiscriminant, @@ -13,7 +10,7 @@ import { accuracy } from '../../../lib/evaluate/classification.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('classification', () => { - test('lda', () => { + test('lda', { retry: 3 }, () => { const model = new LinearDiscriminant() const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -29,7 +26,7 @@ describe('classification', () => { expect(acc).toBeGreaterThan(0.95) }) - test('fda', () => { + test('fda', { retry: 3 }, () => { const model = new FishersLinearDiscriminant() const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -45,7 +42,7 @@ describe('classification', () => { expect(acc).toBeGreaterThan(0.95) }) - test('multiclass', () => { + test('multiclass', { retry: 3 }, () => { const model = new MulticlassLinearDiscriminant() const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -64,7 +61,7 @@ describe('classification', () => { }) describe('dimensionality reduction', () => { - test.each([undefined, 0, 1, 3])('%d', d => { + test.each([undefined, 0, 1, 3])('%d', { retry: 3 }, d => { const n = 50 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.2), Matrix.randn(n, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/ldof.test.js b/tests/lib/model/ldof.test.js index fe960c5de..84d60154b 100644 --- a/tests/lib/model/ldof.test.js +++ b/tests/lib/model/ldof.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LDOF from '../../../lib/model/ldof.js' -test('anomaly detection', () => { +test('anomaly detection', { retry: 3 }, () => { const model = new LDOF(5) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) diff --git a/tests/lib/model/lerp.test.js b/tests/lib/model/lerp.test.js index 19fa18c7a..dfc3c6a85 100644 --- a/tests/lib/model/lerp.test.js +++ b/tests/lib/model/lerp.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LinearInterpolation from '../../../lib/model/lerp.js' import { rmse } from '../../../lib/evaluate/regression.js' -test('interpolation', () => { +test('interpolation', { retry: 3 }, () => { const model = new LinearInterpolation() const x = Matrix.random(20, 1, -2, 2).value const t = [] diff --git a/tests/lib/model/lle.test.js b/tests/lib/model/lle.test.js index 11c5cf9a9..4ec995159 100644 --- a/tests/lib/model/lle.test.js +++ b/tests/lib/model/lle.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LLE from '../../../lib/model/lle.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('dimensionality reduction', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const x = Matrix.concat(Matrix.randn(30, 5, 0, 0.2), Matrix.randn(30, 5, 5, 0.2)).toArray() const y = new LLE().predict(x) expect(y[0]).toHaveLength(5) diff --git a/tests/lib/model/lmclus.test.js b/tests/lib/model/lmclus.test.js index eb532192b..69ee4ce4f 100644 --- a/tests/lib/model/lmclus.test.js +++ b/tests/lib/model/lmclus.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import LMCLUS from '../../../lib/model/lmclus.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test('clustering', () => { +test('clustering', { retry: 5 }, () => { const model = new LMCLUS(5, 1.5, 0.4) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/lmeds.test.js b/tests/lib/model/lmeds.test.js index 593ec32e4..53fd6c4c6 100644 --- a/tests/lib/model/lmeds.test.js +++ b/tests/lib/model/lmeds.test.js @@ -3,7 +3,7 @@ import LeastMedianSquaresRegression from '../../../lib/model/lmeds.js' import { rmse } from '../../../lib/evaluate/regression.js' -test.each([50, 49])('fit n:%p', n => { +test.each([50, 49])('fit n:%j', n => { const model = new LeastMedianSquaresRegression() const x = Matrix.randn(n, 2, 0, 5).toArray() const t = [] diff --git a/tests/lib/model/loci.test.js b/tests/lib/model/loci.test.js index 37f31c0b7..18343d66d 100644 --- a/tests/lib/model/loci.test.js +++ b/tests/lib/model/loci.test.js @@ -1,7 +1,7 @@ import Matrix from '../../../lib/util/matrix.js' import LOCI from '../../../lib/model/loci.js' -test.each([undefined, 0.5])('anomaly detection alpha: %p', alpha => { +test.each([undefined, 0.5])('anomaly detection alpha: %j', alpha => { const model = new LOCI(alpha) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) diff --git a/tests/lib/model/loess.test.js b/tests/lib/model/loess.test.js index 9a89ca24b..5b44c8b1f 100644 --- a/tests/lib/model/loess.test.js +++ b/tests/lib/model/loess.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LOESS from '../../../lib/model/loess.js' import { rmse } from '../../../lib/evaluate/regression.js' -test('fit', () => { +test('fit', { retry: 3 }, () => { const model = new LOESS() const x = Matrix.random(50, 2, -2, 2).toArray() const t = [] diff --git a/tests/lib/model/lof.test.js b/tests/lib/model/lof.test.js index 63cf6a481..03f91be90 100644 --- a/tests/lib/model/lof.test.js +++ b/tests/lib/model/lof.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LOF from '../../../lib/model/lof.js' -test('anomaly detection', () => { +test('anomaly detection', { retry: 3 }, () => { const model = new LOF(5) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) diff --git a/tests/lib/model/logarithmic_interpolation.test.js b/tests/lib/model/logarithmic_interpolation.test.js index 41b7fae37..a7d1b54bc 100644 --- a/tests/lib/model/logarithmic_interpolation.test.js +++ b/tests/lib/model/logarithmic_interpolation.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LogarithmicInterpolation from '../../../lib/model/logarithmic_interpolation.js' import { rmse } from '../../../lib/evaluate/regression.js' -test('interpolation', () => { +test('interpolation', { retry: 3 }, () => { const model = new LogarithmicInterpolation() const x = Matrix.random(20, 1, -2, 2).value const t = [] diff --git a/tests/lib/model/lowess.test.js b/tests/lib/model/lowess.test.js index 01aca2ca8..b756df864 100644 --- a/tests/lib/model/lowess.test.js +++ b/tests/lib/model/lowess.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LOWESS from '../../../lib/model/lowess.js' import { rmse } from '../../../lib/evaluate/regression.js' -test('fit', () => { +test('fit', { retry: 3 }, () => { const model = new LOWESS() const x = Matrix.random(50, 2, -2, 2).toArray() const t = [] diff --git a/tests/lib/model/lowpass.test.js b/tests/lib/model/lowpass.test.js index e55275328..ec7a36303 100644 --- a/tests/lib/model/lowpass.test.js +++ b/tests/lib/model/lowpass.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import LowpassFilter from '../../../lib/model/lowpass.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('smoothing', () => { - test('dft', () => { + test('dft', { retry: 3 }, () => { const x = [] const t = [] for (let i = 0; i < 100; i++) { @@ -20,7 +17,7 @@ describe('smoothing', () => { expect(err).toBeLessThan(rmse(x, t)) }) - test.each([undefined, 0.8])('fft %p', c => { + test.each([undefined, 0.8])('fft %j', { retry: 3 }, c => { const x = [] const t = [] for (let i = 0; i < 128; i++) { diff --git a/tests/lib/model/lsa.test.js b/tests/lib/model/lsa.test.js index c679aae79..a15037769 100644 --- a/tests/lib/model/lsa.test.js +++ b/tests/lib/model/lsa.test.js @@ -13,7 +13,7 @@ describe('dimensionality reduction', () => { expect(q).toBeGreaterThan(0.9) }) - test.each([undefined, 0, 5])('dim %p', rd => { + test.each([undefined, 0, 5])('dim %j', rd => { const x = Matrix.concat(Matrix.randn(50, 5, 0, 0.2), Matrix.randn(50, 5, 5, 0.2)).toArray() const y = new LSA(rd).predict(x) diff --git a/tests/lib/model/lsdd.test.js b/tests/lib/model/lsdd.test.js index 4fe0f6ed0..d418d4b82 100644 --- a/tests/lib/model/lsdd.test.js +++ b/tests/lib/model/lsdd.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import { LSDD, LSDDCPD } from '../../../lib/model/lsdd.js' -test('lsdd', () => { +test('lsdd', { retry: 5, timeout: 10000 }, () => { const sigmas = [] const lambdas = [] for (let i = -2; i <= 0; i += 0.5) { @@ -25,7 +22,7 @@ test('lsdd', () => { expect(r1).toBeGreaterThan(r2) }) -test('change point detection', () => { +test('change point detection', { retry: 10 }, () => { const w = 10 const model = new LSDDCPD(w) const n = 50 diff --git a/tests/lib/model/lsif.test.js b/tests/lib/model/lsif.test.js index 2039aecac..866549c62 100644 --- a/tests/lib/model/lsif.test.js +++ b/tests/lib/model/lsif.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import LSIF from '../../../lib/model/lsif.js' describe('LSIF', () => { - test('some candidates', () => { + test('some candidates', { retry: 3, timeout: 10000 }, () => { const sigmas = [] const lambdas = [] for (let i = -3; i <= 3; i += 1) { diff --git a/tests/lib/model/ltsa.test.js b/tests/lib/model/ltsa.test.js index bf0ad5cb8..c37dec14c 100644 --- a/tests/lib/model/ltsa.test.js +++ b/tests/lib/model/ltsa.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import LTSA from '../../../lib/model/ltsa.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('dimensionality reduction', () => { - test('default', () => { + test('default', { retry: 5 }, () => { const x = Matrix.concat(Matrix.randn(30, 5, 0, 0.5), Matrix.randn(30, 5, 5, 0.5)).toArray() const y = new LTSA(4).predict(x) expect(y[0]).toHaveLength(5) @@ -15,7 +12,7 @@ describe('dimensionality reduction', () => { expect(q).toBeGreaterThan(0.75) }) - test('k: 6', () => { + test('k: 6', { retry: 5 }, () => { const x = Matrix.concat(Matrix.randn(30, 5, 0, 0.5), Matrix.randn(30, 5, 5, 0.5)).toArray() const y = new LTSA(6, 2).predict(x) expect(y[0]).toHaveLength(2) diff --git a/tests/lib/model/lvq.test.js b/tests/lib/model/lvq.test.js index a9f1a27d3..9cfbab335 100644 --- a/tests/lib/model/lvq.test.js +++ b/tests/lib/model/lvq.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import { LVQClassifier, LVQCluster } from '../../../lib/model/lvq.js' @@ -8,7 +5,7 @@ import { randIndex } from '../../../lib/evaluate/clustering.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('clustering', () => { - test('fit predict', () => { + test('fit predict', { retry: 5 }, () => { const model = new LVQCluster(3) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/macqueen_kmeans.test.js b/tests/lib/model/macqueen_kmeans.test.js index fd7b69dad..93613a765 100644 --- a/tests/lib/model/macqueen_kmeans.test.js +++ b/tests/lib/model/macqueen_kmeans.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import MacQueenKMeans from '../../../lib/model/macqueen_kmeans.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('default', () => { + test('default', { retry: 10 }, () => { const model = new MacQueenKMeans(3) const n = 20 const x = Matrix.concat( diff --git a/tests/lib/model/madaline.test.js b/tests/lib/model/madaline.test.js index 8896fb8bb..2782718e6 100644 --- a/tests/lib/model/madaline.test.js +++ b/tests/lib/model/madaline.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import MADALINE from '../../../lib/model/madaline.js' @@ -50,8 +47,8 @@ describe('rule 1', () => { }) }) -describe.each([undefined, 2])('rule %p', rule => { - test('fit', () => { +describe.each([undefined, 2])('rule %j', rule => { + test('fit', { retry: 3 }, () => { const model = new MADALINE([5, 4], rule, 0.01) const n = 20 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.2), Matrix.randn(n, 2, 5, 0.2)).toArray() @@ -72,7 +69,7 @@ describe.each([undefined, 2])('rule %p', rule => { }) describe('rule 3', () => { - test('fit', () => { + test('fit', { retry: 3 }, () => { const model = new MADALINE([5, 4], 3, 0.01) const n = 20 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.2), Matrix.randn(n, 2, 5, 0.2)).toArray() diff --git a/tests/lib/model/markov_switching.test.js b/tests/lib/model/markov_switching.test.js index f68355dbf..fb48d596a 100644 --- a/tests/lib/model/markov_switching.test.js +++ b/tests/lib/model/markov_switching.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import MarkovSwitching from '../../../lib/model/markov_switching.js' -test('anomaly detection', () => { +test('anomaly detection', { retry: 3 }, () => { const model = new MarkovSwitching(2) const n = 50 const x = Matrix.concat(Matrix.random(n, 2, 0, 1), Matrix.random(n, 2, 2, 3)).toArray() diff --git a/tests/lib/model/mars.test.js b/tests/lib/model/mars.test.js index 9c03ef1a4..23a1ce799 100644 --- a/tests/lib/model/mars.test.js +++ b/tests/lib/model/mars.test.js @@ -3,7 +3,7 @@ import MARS from '../../../lib/model/mars.js' import { rmse } from '../../../lib/evaluate/regression.js' -test('fit', () => { +test('fit', { timeout: 30000 }, () => { const model = new MARS(20) const x = Matrix.randn(50, 2, 0, 5).toArray() const t = [] diff --git a/tests/lib/model/maximum_likelihood.test.js b/tests/lib/model/maximum_likelihood.test.js index 83e674c58..79bcb6437 100644 --- a/tests/lib/model/maximum_likelihood.test.js +++ b/tests/lib/model/maximum_likelihood.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import MaximumLikelihoodEstimator from '../../../lib/model/maximum_likelihood.js' -test('density estimation', () => { +test('density estimation', { retry: 3 }, () => { const model = new MaximumLikelihoodEstimator() const n = 10000 const x = Matrix.randn(n, 2, 0, 0.1).toArray() diff --git a/tests/lib/model/mh.test.js b/tests/lib/model/mh.test.js index 9459375c8..4288b920a 100644 --- a/tests/lib/model/mh.test.js +++ b/tests/lib/model/mh.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import MetropolisHastings from '../../../lib/model/mh.js' describe('sample', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new MetropolisHastings(x => Math.exp(-((x[0] - 3) ** 2) / 2), 1) const s = Matrix.fromArray(model.sample(1000)) diff --git a/tests/lib/model/mlle.test.js b/tests/lib/model/mlle.test.js index 79bdab142..dd8634ebf 100644 --- a/tests/lib/model/mlle.test.js +++ b/tests/lib/model/mlle.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import MLLE from '../../../lib/model/mlle.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('dimensionality reduction', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const x = Matrix.concat(Matrix.randn(30, 5, 0, 0.2), Matrix.randn(30, 5, 5, 0.2)).toArray() const y = new MLLE(8).predict(x) expect(y[0]).toHaveLength(5) diff --git a/tests/lib/model/mlp.test.js b/tests/lib/model/mlp.test.js index e8e4be9c6..e87a6c161 100644 --- a/tests/lib/model/mlp.test.js +++ b/tests/lib/model/mlp.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import { MLPClassifier, MLPRegressor } from '../../../lib/model/mlp.js' import NeuralNetwork from '../../../lib/model/neuralnetwork.js' @@ -20,7 +17,7 @@ describe('regression', () => { 'softsign', 'tanh', 'identity', - ])('%s', activation => { + ])('%s', { retry: 5 }, activation => { const model = new MLPRegressor([5], activation) const x = Matrix.randn(30, 2, 0, 5).toArray() const t = [] @@ -70,7 +67,7 @@ describe('classifier', () => { 'softsign', 'tanh', 'identity', - ])('%s', activation => { + ])('%s', { retry: 5 }, activation => { const model = new MLPClassifier([3], activation) const x = Matrix.concat(Matrix.randn(20, 2, 0, 0.2), Matrix.randn(20, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/mod.test.js b/tests/lib/model/mod.test.js index 95c8be9a2..05d832133 100644 --- a/tests/lib/model/mod.test.js +++ b/tests/lib/model/mod.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import MOD from '../../../lib/model/mod.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' -test('dimensionality reduction', () => { +test('dimensionality reduction', { retry: 3 }, () => { const x = Matrix.concat(Matrix.randn(50, 5, 0, 0.2), Matrix.randn(50, 5, 5, 0.2)).toArray() const model = new MOD(x, 2) diff --git a/tests/lib/model/monte_carlo.test.js b/tests/lib/model/monte_carlo.test.js index 208713554..b7e202aba 100644 --- a/tests/lib/model/monte_carlo.test.js +++ b/tests/lib/model/monte_carlo.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import MCAgent from '../../../lib/model/monte_carlo.js' import GridRLEnvironment from '../../../lib/rl/grid.js' import InHypercubeRLEnvironment from '../../../lib/rl/inhypercube.js' @@ -21,7 +18,7 @@ describe('constructor', () => { }) }) -test('update', () => { +test('update', { retry: 3 }, () => { const env = new GridRLEnvironment() const agent = new MCAgent(env, env.size[0]) diff --git a/tests/lib/model/mountain.test.js b/tests/lib/model/mountain.test.js index 546a5294f..dda2bd6e3 100644 --- a/tests/lib/model/mountain.test.js +++ b/tests/lib/model/mountain.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import Mountain from '../../../lib/model/mountain.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test('clustering', () => { +test('clustering', { retry: 3 }, () => { const model = new Mountain(100, 5.4, 5.4) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/moving_average.test.js b/tests/lib/model/moving_average.test.js index 247f61046..75fb05db2 100644 --- a/tests/lib/model/moving_average.test.js +++ b/tests/lib/model/moving_average.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import { SimpleMovingAverage, LinearWeightedMovingAverage, @@ -35,7 +32,7 @@ test('linearWeightedMovingAverage', () => { expect(err).toBeLessThan(rmse(x, t)) }) -test('triangularMovingAverage', () => { +test('triangularMovingAverage', { retry: 10 }, () => { const x = [] const t = [] for (let i = 0; i < 100; i++) { diff --git a/tests/lib/model/mt.test.js b/tests/lib/model/mt.test.js index bef11ea4b..36eac8128 100644 --- a/tests/lib/model/mt.test.js +++ b/tests/lib/model/mt.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import MT from '../../../lib/model/mt.js' -test('anomaly detection', () => { +test('anomaly detection', { retry: 3 }, () => { const model = new MT() const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) diff --git a/tests/lib/model/multivariate_kernel_density_estimator.test.js b/tests/lib/model/multivariate_kernel_density_estimator.test.js index f8e13383a..18000eff0 100644 --- a/tests/lib/model/multivariate_kernel_density_estimator.test.js +++ b/tests/lib/model/multivariate_kernel_density_estimator.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import MultivariateKernelDensityEstimator from '../../../lib/model/multivariate_kernel_density_estimator.js' import { correlation } from '../../../lib/evaluate/regression.js' describe('density estimation', () => { - test.each([undefined, 'silverman', 'scott'])('%p', method => { + test.each([undefined, 'silverman', 'scott'])('%j', { retry: 3 }, method => { const model = new MultivariateKernelDensityEstimator(method) const sgm = Matrix.fromArray([ [0.1, 0], diff --git a/tests/lib/model/mutual_information.test.js b/tests/lib/model/mutual_information.test.js index a913eef46..edc3b7592 100644 --- a/tests/lib/model/mutual_information.test.js +++ b/tests/lib/model/mutual_information.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import MutualInformationFeatureSelection from '../../../lib/model/mutual_information.js' -test('feature selection', () => { +test('feature selection', { retry: 3 }, () => { const model = new MutualInformationFeatureSelection(2) const x = Matrix.random(500, 8, -1, 1).toArray() const slct = [0, 2, 5] diff --git a/tests/lib/model/mutual_knn.test.js b/tests/lib/model/mutual_knn.test.js index a1e8a1049..81cbd04a5 100644 --- a/tests/lib/model/mutual_knn.test.js +++ b/tests/lib/model/mutual_knn.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import MutualKNN from '../../../lib/model/mutual_knn.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new MutualKNN() const n = 100 const x = Matrix.concat( @@ -28,7 +25,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.8) }) - test('k: 10', () => { + test('k: 10', { retry: 3 }, () => { const model = new MutualKNN(10) const n = 100 const x = Matrix.concat( diff --git a/tests/lib/model/n_cubic_interpolation.test.js b/tests/lib/model/n_cubic_interpolation.test.js index c2e54a87b..4bbf25eb6 100644 --- a/tests/lib/model/n_cubic_interpolation.test.js +++ b/tests/lib/model/n_cubic_interpolation.test.js @@ -1,9 +1,6 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NCubicInterpolation from '../../../lib/model/n_cubic_interpolation.js' -test('interpolation 1d', () => { +test('interpolation 1d', { retry: 3 }, () => { const model = new NCubicInterpolation() const n = 10 const x = [] diff --git a/tests/lib/model/narow.test.js b/tests/lib/model/narow.test.js index ed58538d1..19f2a8a2a 100644 --- a/tests/lib/model/narow.test.js +++ b/tests/lib/model/narow.test.js @@ -3,7 +3,7 @@ import NAROW from '../../../lib/model/narow.js' import { accuracy } from '../../../lib/evaluate/classification.js' -test.each([undefined, 20])('fit %p', b => { +test.each([undefined, 20])('fit %j', b => { const model = new NAROW(b) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/natural_neighbor_interpolation.test.js b/tests/lib/model/natural_neighbor_interpolation.test.js index 6adee8799..2d5709173 100644 --- a/tests/lib/model/natural_neighbor_interpolation.test.js +++ b/tests/lib/model/natural_neighbor_interpolation.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import NaturalNeighborInterpolation from '../../../lib/model/natural_neighbor_interpolation.js' @@ -30,7 +27,7 @@ test('fit 1D', () => { expect(err).toBeLessThan(0.1) }) -test('fit 2D', () => { +test('fit 2D', { retry: 3 }, () => { const model = new NaturalNeighborInterpolation() const x = [ [1, 1], diff --git a/tests/lib/model/nca.test.js b/tests/lib/model/nca.test.js index 9a8dd3943..17486f17b 100644 --- a/tests/lib/model/nca.test.js +++ b/tests/lib/model/nca.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import NeighbourhoodComponentsAnalysis from '../../../lib/model/nca.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('dimensionality reduction', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new NeighbourhoodComponentsAnalysis() const n = 50 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.2), Matrix.randn(n, 2, 5, 0.2)).toArray() diff --git a/tests/lib/model/nice.test.js b/tests/lib/model/nice.test.js index ada3fdebe..d115bd757 100644 --- a/tests/lib/model/nice.test.js +++ b/tests/lib/model/nice.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import NICE from '../../../lib/model/nice.js' -test('generate', () => { +test('generate', { retry: 5, timeout: 30000 }, () => { const model = new NICE(2, 'adam') const xmean = [4, -2, -5] const xvar = 2 diff --git a/tests/lib/model/nlmeans.test.js b/tests/lib/model/nlmeans.test.js index 5d8dbe750..d13e6efed 100644 --- a/tests/lib/model/nlmeans.test.js +++ b/tests/lib/model/nlmeans.test.js @@ -1,7 +1,7 @@ import Matrix from '../../../lib/util/matrix.js' import NLMeans from '../../../lib/model/nlmeans.js' -test('predict', () => { +test('predict', { timeout: 30000 }, () => { const model = new NLMeans(4, 5) const n = 50 const x = Matrix.zeros(n, n).toArray() diff --git a/tests/lib/model/nns/layer/apl.test.js b/tests/lib/model/nns/layer/apl.test.js index 0a88fe877..29c33f756 100644 --- a/tests/lib/model/nns/layer/apl.test.js +++ b/tests/lib/model/nns/layer/apl.test.js @@ -1,6 +1,3 @@ -import { expect, jest, test } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -136,7 +133,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/argmax.test.js b/tests/lib/model/nns/layer/argmax.test.js index 2e20debfe..7d9d185fb 100644 --- a/tests/lib/model/nns/layer/argmax.test.js +++ b/tests/lib/model/nns/layer/argmax.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -15,7 +12,7 @@ describe('layer', () => { describe('calc', () => { describe('matrix', () => { - test.each([undefined, 1, -1])('axis %p', axis => { + test.each([undefined, 1, -1])('axis %j', axis => { const layer = new ArgmaxLayer({ axis, keepdims: false }) const x = Matrix.randn(100, 10) @@ -27,7 +24,7 @@ describe('layer', () => { } }) - test.each([0, -2])('axis %p', axis => { + test.each([0, -2])('axis %j', axis => { const layer = new ArgmaxLayer({ axis, keepdims: false }) const x = Matrix.randn(100, 10) @@ -41,7 +38,7 @@ describe('layer', () => { }) describe('matrix keepdims', () => { - test.each([undefined, 1, -1])('axis %p', axis => { + test.each([undefined, 1, -1])('axis %j', axis => { const layer = new ArgmaxLayer({ axis }) const x = Matrix.randn(100, 10) @@ -53,7 +50,7 @@ describe('layer', () => { } }) - test.each([0, -2])('axis %p', axis => { + test.each([0, -2])('axis %j', axis => { const layer = new ArgmaxLayer({ axis }) const x = Matrix.randn(100, 10) @@ -67,7 +64,7 @@ describe('layer', () => { }) describe('tensor', () => { - test.each([undefined, 2, -1])('axis %p', axis => { + test.each([undefined, 2, -1])('axis %j', axis => { const layer = new ArgmaxLayer({ axis, keepdims: false }) const x = Tensor.randn([15, 10, 7]) @@ -88,7 +85,7 @@ describe('layer', () => { } }) - test.each([1, -2])('axis %p', axis => { + test.each([1, -2])('axis %j', axis => { const layer = new ArgmaxLayer({ axis, keepdims: false }) const x = Tensor.randn([15, 10, 7]) @@ -109,7 +106,7 @@ describe('layer', () => { } }) - test.each([0, -3])('axis %p', axis => { + test.each([0, -3])('axis %j', axis => { const layer = new ArgmaxLayer({ axis, keepdims: false }) const x = Tensor.randn([15, 10, 7]) @@ -132,7 +129,7 @@ describe('layer', () => { }) describe('tensor keepdims', () => { - test.each([undefined, 2, -1])('axis %p', axis => { + test.each([undefined, 2, -1])('axis %j', axis => { const layer = new ArgmaxLayer({ axis }) const x = Tensor.randn([15, 10, 7]) @@ -153,7 +150,7 @@ describe('layer', () => { } }) - test.each([1, -2])('axis %p', axis => { + test.each([1, -2])('axis %j', axis => { const layer = new ArgmaxLayer({ axis }) const x = Tensor.randn([15, 10, 7]) @@ -174,7 +171,7 @@ describe('layer', () => { } }) - test.each([0, -3])('axis %p', axis => { + test.each([0, -3])('axis %j', axis => { const layer = new ArgmaxLayer({ axis }) const x = Tensor.randn([15, 10, 7]) @@ -199,7 +196,7 @@ describe('layer', () => { describe('grad', () => { describe('matrix', () => { - test.each([undefined, 1, -1])('axis %p', axis => { + test.each([undefined, 1, -1])('axis %j', axis => { const layer = new ArgmaxLayer({ axis }) const x = Matrix.randn(100, 10) @@ -212,7 +209,7 @@ describe('layer', () => { }) describe('tensor', () => { - test.each([undefined, 2, -1])('axis %p', axis => { + test.each([undefined, 2, -1])('axis %j', axis => { const layer = new ArgmaxLayer({ axis }) const x = Tensor.randn([15, 10, 7]) @@ -252,7 +249,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 5 }, { type: 'argmax' }], 'mse', diff --git a/tests/lib/model/nns/layer/argmin.test.js b/tests/lib/model/nns/layer/argmin.test.js index 66db008f5..b4b282e18 100644 --- a/tests/lib/model/nns/layer/argmin.test.js +++ b/tests/lib/model/nns/layer/argmin.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -15,7 +12,7 @@ describe('layer', () => { describe('calc', () => { describe('matrix', () => { - test.each([undefined, 1, -1])('axis %p', axis => { + test.each([undefined, 1, -1])('axis %j', axis => { const layer = new ArgminLayer({ axis, keepdims: false }) const x = Matrix.randn(100, 10) @@ -27,7 +24,7 @@ describe('layer', () => { } }) - test.each([0, -2])('axis %p', axis => { + test.each([0, -2])('axis %j', axis => { const layer = new ArgminLayer({ axis, keepdims: false }) const x = Matrix.randn(100, 10) @@ -41,7 +38,7 @@ describe('layer', () => { }) describe('matrix keepdims', () => { - test.each([undefined, 1, -1])('axis %p', axis => { + test.each([undefined, 1, -1])('axis %j', axis => { const layer = new ArgminLayer({ axis }) const x = Matrix.randn(100, 10) @@ -53,7 +50,7 @@ describe('layer', () => { } }) - test.each([0, -2])('axis %p', axis => { + test.each([0, -2])('axis %j', axis => { const layer = new ArgminLayer({ axis }) const x = Matrix.randn(100, 10) @@ -67,7 +64,7 @@ describe('layer', () => { }) describe('tensor', () => { - test.each([undefined, 2, -1])('axis %p', axis => { + test.each([undefined, 2, -1])('axis %j', axis => { const layer = new ArgminLayer({ axis, keepdims: false }) const x = Tensor.randn([15, 10, 7]) @@ -88,7 +85,7 @@ describe('layer', () => { } }) - test.each([1, -2])('axis %p', axis => { + test.each([1, -2])('axis %j', axis => { const layer = new ArgminLayer({ axis, keepdims: false }) const x = Tensor.randn([15, 10, 7]) @@ -109,7 +106,7 @@ describe('layer', () => { } }) - test.each([0, -3])('axis %p', axis => { + test.each([0, -3])('axis %j', axis => { const layer = new ArgminLayer({ axis, keepdims: false }) const x = Tensor.randn([15, 10, 7]) @@ -132,7 +129,7 @@ describe('layer', () => { }) describe('tensor keepdims', () => { - test.each([undefined, 2, -1])('axis %p', axis => { + test.each([undefined, 2, -1])('axis %j', axis => { const layer = new ArgminLayer({ axis }) const x = Tensor.randn([15, 10, 7]) @@ -153,7 +150,7 @@ describe('layer', () => { } }) - test.each([1, -2])('axis %p', axis => { + test.each([1, -2])('axis %j', axis => { const layer = new ArgminLayer({ axis }) const x = Tensor.randn([15, 10, 7]) @@ -174,7 +171,7 @@ describe('layer', () => { } }) - test.each([0, -3])('axis %p', axis => { + test.each([0, -3])('axis %j', axis => { const layer = new ArgminLayer({ axis }) const x = Tensor.randn([15, 10, 7]) @@ -199,7 +196,7 @@ describe('layer', () => { describe('grad', () => { describe('matrix', () => { - test.each([undefined, 1, -1])('axis %p', axis => { + test.each([undefined, 1, -1])('axis %j', axis => { const layer = new ArgminLayer({ axis }) const x = Matrix.randn(100, 10) @@ -212,7 +209,7 @@ describe('layer', () => { }) describe('tensor', () => { - test.each([undefined, 2, -1])('axis %p', axis => { + test.each([undefined, 2, -1])('axis %j', axis => { const layer = new ArgminLayer({ axis }) const x = Tensor.randn([15, 10, 7]) @@ -252,7 +249,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 5 }, { type: 'argmin' }], 'mse', diff --git a/tests/lib/model/nns/layer/attention.test.js b/tests/lib/model/nns/layer/attention.test.js index 00960393f..1c576fa42 100644 --- a/tests/lib/model/nns/layer/attention.test.js +++ b/tests/lib/model/nns/layer/attention.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -117,7 +114,7 @@ describe('nn', () => { expect(y.sizes).toEqual([5, 10, 12]) }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'x' }, @@ -154,7 +151,7 @@ describe('nn', () => { } }) - test('grad self', () => { + test('grad self', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'x' }, @@ -187,7 +184,7 @@ describe('nn', () => { } }) - test('string parameters', () => { + test('string parameters', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'x' }, @@ -219,7 +216,7 @@ describe('nn', () => { } }) - test('self string parameters', () => { + test('self string parameters', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'x' }, diff --git a/tests/lib/model/nns/layer/averagepool.test.js b/tests/lib/model/nns/layer/averagepool.test.js index 57c50dfcd..1fd4d5e64 100644 --- a/tests/lib/model/nns/layer/averagepool.test.js +++ b/tests/lib/model/nns/layer/averagepool.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -266,7 +263,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', () => { + test('update', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/batch_normalization.test.js b/tests/lib/model/nns/layer/batch_normalization.test.js index f31bac533..a4a1f6f46 100644 --- a/tests/lib/model/nns/layer/batch_normalization.test.js +++ b/tests/lib/model/nns/layer/batch_normalization.test.js @@ -197,7 +197,7 @@ describe('nn', () => { } }) - test.each([undefined, 1])('grad ch:%p', ch => { + test.each([undefined, 1])('grad ch:%j', ch => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'batch_normalization', channel_dim: ch }], 'mse', diff --git a/tests/lib/model/nns/layer/blu.test.js b/tests/lib/model/nns/layer/blu.test.js index f6782ab7e..d8b4866e4 100644 --- a/tests/lib/model/nns/layer/blu.test.js +++ b/tests/lib/model/nns/layer/blu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -103,7 +100,7 @@ describe('nn', () => { } }) - test.each([undefined, -10, 10])('grad beta:%p', beta => { + test.each([undefined, -10, 10])('grad beta:%j', { retry: 3 }, beta => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'blu', beta }], 'mse', diff --git a/tests/lib/model/nns/layer/brelu.test.js b/tests/lib/model/nns/layer/brelu.test.js index 385163b7e..0b0db5b80 100644 --- a/tests/lib/model/nns/layer/brelu.test.js +++ b/tests/lib/model/nns/layer/brelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -101,7 +98,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/celu.test.js b/tests/lib/model/nns/layer/celu.test.js index dc611a948..2c6e1efaf 100644 --- a/tests/lib/model/nns/layer/celu.test.js +++ b/tests/lib/model/nns/layer/celu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -103,7 +100,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'celu' }], 'mse', diff --git a/tests/lib/model/nns/layer/cloglog.test.js b/tests/lib/model/nns/layer/cloglog.test.js index 2e952b7e3..fabea496c 100644 --- a/tests/lib/model/nns/layer/cloglog.test.js +++ b/tests/lib/model/nns/layer/cloglog.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -101,7 +98,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/cloglogm.test.js b/tests/lib/model/nns/layer/cloglogm.test.js index 9cde080bc..a12d43421 100644 --- a/tests/lib/model/nns/layer/cloglogm.test.js +++ b/tests/lib/model/nns/layer/cloglogm.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -103,7 +100,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/conv.test.js b/tests/lib/model/nns/layer/conv.test.js index b8b0b7bbb..e4d9446eb 100644 --- a/tests/lib/model/nns/layer/conv.test.js +++ b/tests/lib/model/nns/layer/conv.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -449,7 +446,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', () => { + test('update', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'conv', kernel: 3, padding: 1 }, { type: 'flatten' }], 'mse', @@ -471,7 +468,7 @@ describe('nn', () => { } }) - test('named weight', () => { + test('named weight', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/layer/div.test.js b/tests/lib/model/nns/layer/div.test.js index cdcb3ecba..7040cc021 100644 --- a/tests/lib/model/nns/layer/div.test.js +++ b/tests/lib/model/nns/layer/div.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -221,7 +218,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'a' }, @@ -255,7 +252,7 @@ describe('nn', () => { } }) - test('grad diff size', () => { + test('grad diff size', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'a' }, diff --git a/tests/lib/model/nns/layer/eelu.test.js b/tests/lib/model/nns/layer/eelu.test.js index a98de5862..7797745e1 100644 --- a/tests/lib/model/nns/layer/eelu.test.js +++ b/tests/lib/model/nns/layer/eelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -103,7 +100,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/equal.test.js b/tests/lib/model/nns/layer/equal.test.js index c01e3715a..b7d09c598 100644 --- a/tests/lib/model/nns/layer/equal.test.js +++ b/tests/lib/model/nns/layer/equal.test.js @@ -11,7 +11,7 @@ describe('layer', () => { }) describe('calc', () => { - test.each([2, 3])('matrix %p', n => { + test.each([2, 3])('matrix %j', n => { const layer = Layer.fromObject({ type: 'equal' }) const x = [] diff --git a/tests/lib/model/nns/layer/erelu.test.js b/tests/lib/model/nns/layer/erelu.test.js index 7e45038a8..1607834cd 100644 --- a/tests/lib/model/nns/layer/erelu.test.js +++ b/tests/lib/model/nns/layer/erelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -131,7 +128,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3, timeout: 10000 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/erf.test.js b/tests/lib/model/nns/layer/erf.test.js index 90644ea28..1b49cb1a5 100644 --- a/tests/lib/model/nns/layer/erf.test.js +++ b/tests/lib/model/nns/layer/erf.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -115,7 +112,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'erf' }], 'mse', diff --git a/tests/lib/model/nns/layer/felu.test.js b/tests/lib/model/nns/layer/felu.test.js index a48a7b809..49b9b2f30 100644 --- a/tests/lib/model/nns/layer/felu.test.js +++ b/tests/lib/model/nns/layer/felu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -109,7 +106,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/frelu.test.js b/tests/lib/model/nns/layer/frelu.test.js index 7b8ac9fca..62af771dc 100644 --- a/tests/lib/model/nns/layer/frelu.test.js +++ b/tests/lib/model/nns/layer/frelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -101,7 +98,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/function.test.js b/tests/lib/model/nns/layer/function.test.js index 8910c9e47..84b57bb6e 100644 --- a/tests/lib/model/nns/layer/function.test.js +++ b/tests/lib/model/nns/layer/function.test.js @@ -85,7 +85,7 @@ describe('layer', () => { ['tanh(x)', v => Math.tanh(v)], ['2 * (x + 1)', v => 2 * (v + 1)], ['min(x + 1, 0)', v => (v + 1 < 0 ? v + 1 : 0)], - ])('%p', (fs, fn) => { + ])('%j', (fs, fn) => { const layer = new FunctionLayer({ func: fs }) const x = Matrix.randn(13, 7) @@ -102,7 +102,7 @@ describe('layer', () => { ['log(x)', v => Math.log(v)], ['log10(x)', v => Math.log10(v)], ['log2(x)', v => Math.log2(v)], - ])('%p', (fs, fn) => { + ])('%j', (fs, fn) => { const layer = new FunctionLayer({ func: fs }) const x = Matrix.randn(13, 7) @@ -119,7 +119,7 @@ describe('layer', () => { ['acos(x)', v => Math.acos(v)], ['asin(x)', v => Math.asin(v)], ['atanh(x)', v => Math.atanh(v)], - ])('%p', (fs, fn) => { + ])('%j', (fs, fn) => { const layer = new FunctionLayer({ func: fs }) const x = Matrix.random(13, 7, -1, 1) @@ -131,7 +131,7 @@ describe('layer', () => { } }) - test.each([['acosh(x)', v => Math.acosh(v)]])('%p', (fs, fn) => { + test.each([['acosh(x)', v => Math.acosh(v)]])('%j', (fs, fn) => { const layer = new FunctionLayer({ func: fs }) const x = Matrix.randn(13, 7) @@ -153,7 +153,7 @@ describe('layer', () => { ['pi', () => Math.PI], ['sqrt1_2', () => Math.SQRT1_2], ['sqrt2', () => Math.SQRT2], - ])('%p', (fs, fn) => { + ])('%j', (fs, fn) => { const layer = new FunctionLayer({ func: fs }) const x = Matrix.randn(13, 7) @@ -256,7 +256,7 @@ describe('layer', () => { ['tanh(x)', v => 1 - Math.tanh(v) ** 2], ['2 * (x + 1)', () => 2], ['min(x + 1, 0)', v => (v + 1 < 0 ? 1 : 0)], - ])('%p', (fs, fn) => { + ])('%j', (fs, fn) => { const layer = new FunctionLayer({ func: fs }) const x = Matrix.randn(13, 7) @@ -276,7 +276,7 @@ describe('layer', () => { ['log(x)', v => 1 / v], ['log10(x)', v => 1 / (v * Math.log(10))], ['log2(x)', v => 1 / (v * Math.log(2))], - ])('%p', (fs, fn) => { + ])('%j', (fs, fn) => { const layer = new FunctionLayer({ func: fs }) const x = Matrix.randn(13, 7) @@ -296,7 +296,7 @@ describe('layer', () => { ['acos(x)', v => -1 / (Math.sqrt(1 - v ** 2) + 1.0e-4)], ['asin(x)', v => 1 / (Math.sqrt(1 - v ** 2) + 1.0e-4)], ['atanh(x)', v => 1 / (1 - v ** 2)], - ])('%p', (fs, fn) => { + ])('%j', (fs, fn) => { const layer = new FunctionLayer({ func: fs }) const x = Matrix.random(13, 7, -1, 1) @@ -311,7 +311,7 @@ describe('layer', () => { } }) - test.each([['acosh(x)', v => 1 / (Math.sqrt(v ** 2 - 1) + 1.0e-4)]])('%p', (fs, fn) => { + test.each([['acosh(x)', v => 1 / (Math.sqrt(v ** 2 - 1) + 1.0e-4)]])('%j', (fs, fn) => { const layer = new FunctionLayer({ func: fs }) const x = Matrix.randn(13, 7) @@ -327,7 +327,7 @@ describe('layer', () => { } }) - test.each(['e', 'ln2', 'ln10', 'log2e', 'log10e', 'pi', 'sqrt1_2', 'sqrt2'])('%p', fs => { + test.each(['e', 'ln2', 'ln10', 'log2e', 'log10e', 'pi', 'sqrt1_2', 'sqrt2'])('%j', fs => { const layer = new FunctionLayer({ func: fs }) const x = Matrix.randn(13, 7) @@ -450,7 +450,7 @@ describe('nn', () => { 'sinh(x)', 'tan(x)', 'tanh(x)', - ])('grad %p', fs => { + ])('grad %j', fs => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'function', func: fs }], 'mse', @@ -464,7 +464,7 @@ describe('nn', () => { expect(loss1[0]).toBeLessThan(loss0[0]) }) - test.each(['sqrt(x)', 'log(x)', 'log10(x)', 'log2(x)'])('grad %p', fs => { + test.each(['sqrt(x)', 'log(x)', 'log10(x)', 'log2(x)'])('grad %j', fs => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, @@ -483,7 +483,7 @@ describe('nn', () => { expect(loss1[0]).toBeLessThan(loss0[0]) }) - test.each(['acos(x)', 'asin(x)', 'atanh(x)'])('grad %p', fs => { + test.each(['acos(x)', 'asin(x)', 'atanh(x)'])('grad %j', fs => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, @@ -501,7 +501,7 @@ describe('nn', () => { expect(loss1[0]).toBeLessThan(loss0[0]) }) - test.each(['acosh(x)'])('grad %p', fs => { + test.each(['acosh(x)'])('grad %j', fs => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/global_averagepool.test.js b/tests/lib/model/nns/layer/global_averagepool.test.js index d7a76c8fe..1b3dc2b51 100644 --- a/tests/lib/model/nns/layer/global_averagepool.test.js +++ b/tests/lib/model/nns/layer/global_averagepool.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -116,7 +113,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', () => { + test('update', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/global_lppool.test.js b/tests/lib/model/nns/layer/global_lppool.test.js index 049292fd1..553fee0b8 100644 --- a/tests/lib/model/nns/layer/global_lppool.test.js +++ b/tests/lib/model/nns/layer/global_lppool.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -120,7 +117,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', () => { + test('update', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/global_maxpool.test.js b/tests/lib/model/nns/layer/global_maxpool.test.js index 6a26f7a77..076a83008 100644 --- a/tests/lib/model/nns/layer/global_maxpool.test.js +++ b/tests/lib/model/nns/layer/global_maxpool.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -142,7 +139,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', () => { + test('update', { retry: 3, timeout: 10000 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/graph_conv.test.js b/tests/lib/model/nns/layer/graph_conv.test.js index a2429df6d..df1410537 100644 --- a/tests/lib/model/nns/layer/graph_conv.test.js +++ b/tests/lib/model/nns/layer/graph_conv.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Graph from '../../../../../lib/util/graph.js' @@ -182,7 +179,7 @@ describe('nn', () => { } }) - test('activation', () => { + test('activation', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, @@ -258,7 +255,7 @@ describe('nn', () => { } }) - test('grad decay', () => { + test('grad decay', { retry: 3, timeout: 10000 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'graph_conv', out_size: 3, l2_decay: 0.001 }, { type: 'readout' }], 'mse', diff --git a/tests/lib/model/nns/layer/graph_sage.test.js b/tests/lib/model/nns/layer/graph_sage.test.js index 490912d7e..ee00a0f0c 100644 --- a/tests/lib/model/nns/layer/graph_sage.test.js +++ b/tests/lib/model/nns/layer/graph_sage.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Graph from '../../../../../lib/util/graph.js' @@ -182,7 +179,7 @@ describe('nn', () => { } }) - test('activation', () => { + test('activation', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/greater.test.js b/tests/lib/model/nns/layer/greater.test.js index 81d7191a9..81ff48437 100644 --- a/tests/lib/model/nns/layer/greater.test.js +++ b/tests/lib/model/nns/layer/greater.test.js @@ -11,7 +11,7 @@ describe('layer', () => { }) describe('calc', () => { - test.each([2, 3])('matrix %p', n => { + test.each([2, 3])('matrix %j', n => { const layer = Layer.fromObject({ type: 'greater' }) const x = [] diff --git a/tests/lib/model/nns/layer/greater_or_equal.test.js b/tests/lib/model/nns/layer/greater_or_equal.test.js index 609b3f86c..cff3855d5 100644 --- a/tests/lib/model/nns/layer/greater_or_equal.test.js +++ b/tests/lib/model/nns/layer/greater_or_equal.test.js @@ -11,7 +11,7 @@ describe('layer', () => { }) describe('calc', () => { - test.each([2, 3])('matrix %p', n => { + test.each([2, 3])('matrix %j', n => { const layer = Layer.fromObject({ type: 'greater_or_equal' }) const x = [] diff --git a/tests/lib/model/nns/layer/hard_shrink.test.js b/tests/lib/model/nns/layer/hard_shrink.test.js index 5efef9ddc..00c69afcd 100644 --- a/tests/lib/model/nns/layer/hard_shrink.test.js +++ b/tests/lib/model/nns/layer/hard_shrink.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -103,7 +100,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/hexpo.test.js b/tests/lib/model/nns/layer/hexpo.test.js index 6affcb8ac..489826221 100644 --- a/tests/lib/model/nns/layer/hexpo.test.js +++ b/tests/lib/model/nns/layer/hexpo.test.js @@ -4,7 +4,7 @@ import Tensor from '../../../../../lib/util/tensor.js' import HexpoLayer from '../../../../../lib/model/nns/layer/hexpo.js' -describe.each([{}, { a: 2, b: 2, c: 2, d: 2 }])('layer %p', opt => { +describe.each([{}, { a: 2, b: 2, c: 2, d: 2 }])('layer %j', opt => { test('construct', () => { const layer = new HexpoLayer(opt) expect(layer).toBeDefined() @@ -101,7 +101,7 @@ describe.each([{}, { a: 2, b: 2, c: 2, d: 2 }])('layer %p', opt => { }) }) -describe.each([{}, { a: 2, b: 2, c: 2, d: 2 }])('nn %p', opt => { +describe.each([{}, { a: 2, b: 2, c: 2, d: 2 }])('nn %j', opt => { test('calc', () => { const net = NeuralNetwork.fromObject([{ type: 'input' }, { type: 'hexpo', ...opt }]) const x = Matrix.randn(10, 10) diff --git a/tests/lib/model/nns/layer/input.test.js b/tests/lib/model/nns/layer/input.test.js index 853e7baf6..1dcb701c2 100644 --- a/tests/lib/model/nns/layer/input.test.js +++ b/tests/lib/model/nns/layer/input.test.js @@ -16,7 +16,7 @@ describe('layer', () => { [2, null], [null, 3], [2, 3], - ])('valid dim length [%p, %p]', (...size) => { + ])('valid dim length [%j, %j]', (...size) => { expect.assertions(0) const layer = new InputLayer({ size }) diff --git a/tests/lib/model/nns/layer/isigmoid.test.js b/tests/lib/model/nns/layer/isigmoid.test.js index 969e4246a..80185c2d9 100644 --- a/tests/lib/model/nns/layer/isigmoid.test.js +++ b/tests/lib/model/nns/layer/isigmoid.test.js @@ -4,7 +4,7 @@ import Tensor from '../../../../../lib/util/tensor.js' import ImprovedSigmoidLayer from '../../../../../lib/model/nns/layer/isigmoid.js' -describe.each([{}, { a: 2, alpha: 2 }])('layer %p', opt => { +describe.each([{}, { a: 2, alpha: 2 }])('layer %j', opt => { test('construct', () => { const layer = new ImprovedSigmoidLayer(opt) expect(layer).toBeDefined() @@ -106,7 +106,7 @@ describe.each([{}, { a: 2, alpha: 2 }])('layer %p', opt => { }) }) -describe.each([{}, { a: 2, alpha: 2 }])('nn %p', opt => { +describe.each([{}, { a: 2, alpha: 2 }])('nn %j', opt => { test('calc', () => { const net = NeuralNetwork.fromObject([{ type: 'input' }, { type: 'isigmoid', ...opt }]) const x = Matrix.randn(10, 10) diff --git a/tests/lib/model/nns/layer/layer_normalization.test.js b/tests/lib/model/nns/layer/layer_normalization.test.js index 7782252e2..fecf62813 100644 --- a/tests/lib/model/nns/layer/layer_normalization.test.js +++ b/tests/lib/model/nns/layer/layer_normalization.test.js @@ -187,7 +187,7 @@ describe('nn', () => { } }) - test.each([undefined, 1])('grad axis: %p', axis => { + test.each([undefined, 1])('grad axis: %j', axis => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'layer_normalization', axis }], 'mse', diff --git a/tests/lib/model/nns/layer/less.test.js b/tests/lib/model/nns/layer/less.test.js index 3a2008358..8a9684adc 100644 --- a/tests/lib/model/nns/layer/less.test.js +++ b/tests/lib/model/nns/layer/less.test.js @@ -11,7 +11,7 @@ describe('layer', () => { }) describe('calc', () => { - test.each([2, 3])('matrix %p', n => { + test.each([2, 3])('matrix %j', n => { const layer = Layer.fromObject({ type: 'less' }) const x = [] diff --git a/tests/lib/model/nns/layer/less_or_equal.test.js b/tests/lib/model/nns/layer/less_or_equal.test.js index 49ebcb506..6af7ce029 100644 --- a/tests/lib/model/nns/layer/less_or_equal.test.js +++ b/tests/lib/model/nns/layer/less_or_equal.test.js @@ -11,7 +11,7 @@ describe('layer', () => { }) describe('calc', () => { - test.each([2, 3])('matrix %p', n => { + test.each([2, 3])('matrix %j', n => { const layer = Layer.fromObject({ type: 'less_or_equal' }) const x = [] diff --git a/tests/lib/model/nns/layer/loglog.test.js b/tests/lib/model/nns/layer/loglog.test.js index 2828702ed..46f28d617 100644 --- a/tests/lib/model/nns/layer/loglog.test.js +++ b/tests/lib/model/nns/layer/loglog.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -101,7 +98,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/logsoftmax.test.js b/tests/lib/model/nns/layer/logsoftmax.test.js index 310958abc..a6f65e74a 100644 --- a/tests/lib/model/nns/layer/logsoftmax.test.js +++ b/tests/lib/model/nns/layer/logsoftmax.test.js @@ -11,7 +11,7 @@ describe('layer', () => { }) describe('calc', () => { - test.each([undefined, -1, 1])('matrix axis:%p', axis => { + test.each([undefined, -1, 1])('matrix axis:%j', axis => { const layer = new LogSoftmaxLayer({ axis }) const x = Matrix.randn(100, 10) @@ -27,7 +27,7 @@ describe('layer', () => { } }) - test.each([undefined, -1, 2])('tensor axis:%p', axis => { + test.each([undefined, -1, 2])('tensor axis:%j', axis => { const layer = new LogSoftmaxLayer({ axis }) const x = Tensor.randn([15, 10, 7]) @@ -48,7 +48,7 @@ describe('layer', () => { }) describe('grad', () => { - test.each([undefined, -1, 1])('matrix axis:%p', axis => { + test.each([undefined, -1, 1])('matrix axis:%j', axis => { const layer = new LogSoftmaxLayer({ axis }) const x = Matrix.randn(100, 10) @@ -59,7 +59,7 @@ describe('layer', () => { expect(bi.sizes).toEqual([100, 10]) }) - test.each([undefined, -1, 2])('tensor axis:%p', axis => { + test.each([undefined, -1, 2])('tensor axis:%j', axis => { const layer = new LogSoftmaxLayer({ axis }) const x = Tensor.randn([15, 10, 7]) diff --git a/tests/lib/model/nns/layer/lppool.test.js b/tests/lib/model/nns/layer/lppool.test.js index a529112fb..f31a1e5c7 100644 --- a/tests/lib/model/nns/layer/lppool.test.js +++ b/tests/lib/model/nns/layer/lppool.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -314,7 +311,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', () => { + test('update', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/lrn.test.js b/tests/lib/model/nns/layer/lrn.test.js index 5473e33dd..3084db7e9 100644 --- a/tests/lib/model/nns/layer/lrn.test.js +++ b/tests/lib/model/nns/layer/lrn.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -116,7 +113,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', () => { + test('update', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/lstm.test.js b/tests/lib/model/nns/layer/lstm.test.js index 97afe4600..cc18d45cd 100644 --- a/tests/lib/model/nns/layer/lstm.test.js +++ b/tests/lib/model/nns/layer/lstm.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -177,7 +174,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', () => { + test('update', { retry: 5 }, () => { const net = NeuralNetwork.fromObject([{ type: 'input' }, { type: 'lstm', size: 4 }], 'mse', 'adam') const x = Tensor.random([1, 7, 5], -0.1, 0.1) const t = Matrix.random(1, 4, -0.8, 0.8) @@ -195,7 +192,7 @@ describe('nn', () => { } }) - test('string parameters', () => { + test('string parameters', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/layer/max.test.js b/tests/lib/model/nns/layer/max.test.js index f4ff527e6..49060d9f1 100644 --- a/tests/lib/model/nns/layer/max.test.js +++ b/tests/lib/model/nns/layer/max.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -240,7 +237,7 @@ describe('nn', () => { } }) - test('grad diff size', () => { + test('grad diff size', { retry: 5, timeout: 10000 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'a' }, diff --git a/tests/lib/model/nns/layer/maxpool.test.js b/tests/lib/model/nns/layer/maxpool.test.js index 5ed5bf552..85152f2a1 100644 --- a/tests/lib/model/nns/layer/maxpool.test.js +++ b/tests/lib/model/nns/layer/maxpool.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -319,7 +316,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', () => { + test('update', { retry: 3, timeout: 10000 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/mean.test.js b/tests/lib/model/nns/layer/mean.test.js index 22051a73e..4d4bd1a93 100644 --- a/tests/lib/model/nns/layer/mean.test.js +++ b/tests/lib/model/nns/layer/mean.test.js @@ -18,7 +18,7 @@ describe('layer', () => { describe('calc', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test('keepdims true', () => { const layer = new MeanLayer({ axis }) @@ -42,7 +42,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new MeanLayer({ axis }) @@ -70,7 +70,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new MeanLayer({ axis }) @@ -100,7 +100,7 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test('keepdims true', () => { const layer = new MeanLayer({ axis }) @@ -124,7 +124,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new MeanLayer({ axis }) @@ -156,7 +156,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new MeanLayer({ axis }) @@ -192,12 +192,12 @@ describe('layer', () => { describe('grad', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 1)], [true, Matrix.ones(1, 1)], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new MeanLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -212,12 +212,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 10)], [true, Matrix.ones(1, 10)], [false, Tensor.ones([10])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new MeanLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -232,12 +232,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(100, 1)], [true, Matrix.ones(100, 1)], [false, Tensor.ones([100])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new MeanLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -254,12 +254,12 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 1, 1])], [true, Tensor.ones([1, 1, 1])], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new MeanLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -274,12 +274,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 10, 7])], [true, Tensor.ones([1, 10, 7])], [false, Tensor.ones([10, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new MeanLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -296,12 +296,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([15, 1, 7])], [true, Tensor.ones([15, 1, 7])], [false, Tensor.ones([15, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new MeanLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -392,7 +392,7 @@ describe('nn', () => { [1, undefined, Matrix.random(4, 1, -0.1, 0.1)], [1, true, Matrix.random(4, 1, -0.1, 0.1)], [1, false, Tensor.random([4], -0.1, 0.1)], - ])('grad %p keepdims %p', (axis, keepdims, t) => { + ])('grad %j keepdims %j', (axis, keepdims, t) => { test('value', () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'mean', axis, keepdims }], diff --git a/tests/lib/model/nns/layer/min.test.js b/tests/lib/model/nns/layer/min.test.js index ba2e18afa..0dbc6f697 100644 --- a/tests/lib/model/nns/layer/min.test.js +++ b/tests/lib/model/nns/layer/min.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -240,7 +237,7 @@ describe('nn', () => { } }) - test('grad diff size', () => { + test('grad diff size', { retry: 5 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'a' }, diff --git a/tests/lib/model/nns/layer/mish.test.js b/tests/lib/model/nns/layer/mish.test.js index 529ff7d45..98cd56e95 100644 --- a/tests/lib/model/nns/layer/mish.test.js +++ b/tests/lib/model/nns/layer/mish.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -119,7 +116,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/mpelu.test.js b/tests/lib/model/nns/layer/mpelu.test.js index dcf7f36f6..916d4bf90 100644 --- a/tests/lib/model/nns/layer/mpelu.test.js +++ b/tests/lib/model/nns/layer/mpelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -103,7 +100,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/nlrelu.test.js b/tests/lib/model/nns/layer/nlrelu.test.js index 38b692414..6b6038b25 100644 --- a/tests/lib/model/nns/layer/nlrelu.test.js +++ b/tests/lib/model/nns/layer/nlrelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -101,7 +98,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/pau.test.js b/tests/lib/model/nns/layer/pau.test.js index 9e63018c5..45b3e9adc 100644 --- a/tests/lib/model/nns/layer/pau.test.js +++ b/tests/lib/model/nns/layer/pau.test.js @@ -32,7 +32,7 @@ describe('layer', () => { [1, 2, 3], [4, 5], ], - ])('matrix a:%p, b:%p', (a, b) => { + ])('matrix a:%j, b:%j', (a, b) => { const layer = new PAULayer({ a, b }) const x = Matrix.randn(100, 10) @@ -87,7 +87,7 @@ describe('layer', () => { [1, 2, 3], [4, 5], ], - ])('matrix a:%p, b:%p', (a, b) => { + ])('matrix a:%j, b:%j', (a, b) => { const layer = new PAULayer({ a, b }) const x = Matrix.randn(100, 10) diff --git a/tests/lib/model/nns/layer/pdelu.test.js b/tests/lib/model/nns/layer/pdelu.test.js index 26707493f..f04f57da7 100644 --- a/tests/lib/model/nns/layer/pdelu.test.js +++ b/tests/lib/model/nns/layer/pdelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -107,7 +104,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/pelu.test.js b/tests/lib/model/nns/layer/pelu.test.js index 46b320b9f..fdd760d5d 100644 --- a/tests/lib/model/nns/layer/pelu.test.js +++ b/tests/lib/model/nns/layer/pelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -106,7 +103,7 @@ describe('nn', () => { test.each([ [undefined, undefined], [-10, -10], - ])('grad a:%p, b:%p', (a, b) => { + ])('grad a:%j, b:%j', { retry: 5 }, (a, b) => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/power.test.js b/tests/lib/model/nns/layer/power.test.js index d60b5fe46..4018df71c 100644 --- a/tests/lib/model/nns/layer/power.test.js +++ b/tests/lib/model/nns/layer/power.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -142,7 +139,7 @@ describe('nn', () => { } }) - test('grad exp', () => { + test('grad exp', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/layer/prelu.test.js b/tests/lib/model/nns/layer/prelu.test.js index f79169aaa..6f9ce9097 100644 --- a/tests/lib/model/nns/layer/prelu.test.js +++ b/tests/lib/model/nns/layer/prelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -178,7 +175,7 @@ describe('nn', () => { } }) - test('string parameters', () => { + test('string parameters', { retry: 10 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/preu.test.js b/tests/lib/model/nns/layer/preu.test.js index 0b6695a18..2477016c7 100644 --- a/tests/lib/model/nns/layer/preu.test.js +++ b/tests/lib/model/nns/layer/preu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -105,7 +102,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/prod.test.js b/tests/lib/model/nns/layer/prod.test.js index 59da9ecd7..db83e10ec 100644 --- a/tests/lib/model/nns/layer/prod.test.js +++ b/tests/lib/model/nns/layer/prod.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -21,7 +18,7 @@ describe('layer', () => { describe('calc', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test('keepdims true', () => { const layer = new ProdLayer({ axis }) @@ -45,7 +42,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new ProdLayer({ axis }) @@ -73,7 +70,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new ProdLayer({ axis }) @@ -103,7 +100,7 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test('keepdims true', () => { const layer = new ProdLayer({ axis }) @@ -127,7 +124,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new ProdLayer({ axis }) @@ -159,7 +156,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new ProdLayer({ axis }) @@ -195,12 +192,12 @@ describe('layer', () => { describe('grad', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 1)], [true, Matrix.ones(1, 1)], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ProdLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -216,12 +213,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 10)], [true, Matrix.ones(1, 10)], [false, Tensor.ones([10])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ProdLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -237,12 +234,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(100, 1)], [true, Matrix.ones(100, 1)], [false, Tensor.ones([100])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ProdLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -260,12 +257,12 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 1, 1])], [true, Tensor.ones([1, 1, 1])], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ProdLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -283,12 +280,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 10, 7])], [true, Tensor.ones([1, 10, 7])], [false, Tensor.ones([10, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ProdLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -306,12 +303,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([15, 1, 7])], [true, Tensor.ones([15, 1, 7])], [false, Tensor.ones([15, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ProdLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -403,7 +400,7 @@ describe('nn', () => { [1, undefined, Matrix.random(4, 1, -0.1, 0.1)], [1, true, Matrix.random(4, 1, -0.1, 0.1)], [1, false, Tensor.random([4], -0.1, 0.1)], - ])('grad %p keepdims %p', (axis, keepdims, t) => { + ])('grad %j keepdims %j', (axis, keepdims, t) => { test('value', () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'prod', axis, keepdims }], @@ -427,7 +424,7 @@ describe('nn', () => { } }) - test('string parameters', () => { + test('string parameters', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/psf.test.js b/tests/lib/model/nns/layer/psf.test.js index 86185311d..61bdbd300 100644 --- a/tests/lib/model/nns/layer/psf.test.js +++ b/tests/lib/model/nns/layer/psf.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' import PSFLayer from '../../../../../lib/model/nns/layer/psf.js' -describe.each([undefined, 3])('layer %p', m => { +describe.each([undefined, 3])('layer %j', m => { test('construct', () => { const layer = new PSFLayer({ m }) expect(layer).toBeDefined() @@ -90,7 +87,7 @@ describe.each([undefined, 3])('layer %p', m => { }) }) -describe.each([undefined, 3])('nn %p', m => { +describe.each([undefined, 3])('nn %j', m => { test('calc', () => { const net = NeuralNetwork.fromObject([{ type: 'input' }, { type: 'psf', m }]) const x = Matrix.randn(10, 10) @@ -103,7 +100,7 @@ describe.each([undefined, 3])('nn %p', m => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'psf', m }], 'mse', diff --git a/tests/lib/model/nns/layer/ptanh.test.js b/tests/lib/model/nns/layer/ptanh.test.js index 013cc70a8..553900464 100644 --- a/tests/lib/model/nns/layer/ptanh.test.js +++ b/tests/lib/model/nns/layer/ptanh.test.js @@ -4,7 +4,7 @@ import Tensor from '../../../../../lib/util/tensor.js' import PenalizedTanhLayer from '../../../../../lib/model/nns/layer/ptanh.js' -describe.each([undefined, 0.1])('layer %p', a => { +describe.each([undefined, 0.1])('layer %j', a => { test('construct', () => { const layer = new PenalizedTanhLayer({ a }) expect(layer).toBeDefined() @@ -89,7 +89,7 @@ describe.each([undefined, 0.1])('layer %p', a => { }) }) -describe.each([undefined, 0.1])('nn %p', a => { +describe.each([undefined, 0.1])('nn %j', a => { test('calc', () => { const net = NeuralNetwork.fromObject([{ type: 'input' }, { type: 'ptanh', a }]) const x = Matrix.randn(10, 10) diff --git a/tests/lib/model/nns/layer/ptelu.test.js b/tests/lib/model/nns/layer/ptelu.test.js index a6fa5541e..5e78b5cb5 100644 --- a/tests/lib/model/nns/layer/ptelu.test.js +++ b/tests/lib/model/nns/layer/ptelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -101,7 +98,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', w: new Matrix(5, 3, 0.1), b: [[-0.1, 0.1, 0]] }, { type: 'ptelu' }], 'mse', @@ -126,7 +123,7 @@ describe('nn', () => { test.each([ [-1, 1], [1, -1], - ])('grad alpha:%p, beta:%p', (alpha, beta) => { + ])('grad alpha:%j, beta:%j', (alpha, beta) => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/reduce_max.test.js b/tests/lib/model/nns/layer/reduce_max.test.js index 9e2d03729..0023dbaae 100644 --- a/tests/lib/model/nns/layer/reduce_max.test.js +++ b/tests/lib/model/nns/layer/reduce_max.test.js @@ -18,7 +18,7 @@ describe('layer', () => { describe('calc', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMaxLayer({ axis }) @@ -42,7 +42,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMaxLayer({ axis }) @@ -70,7 +70,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMaxLayer({ axis }) @@ -100,7 +100,7 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMaxLayer({ axis }) @@ -124,7 +124,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMaxLayer({ axis }) @@ -156,7 +156,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMaxLayer({ axis }) @@ -192,12 +192,12 @@ describe('layer', () => { describe('grad', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 1)], [true, Matrix.ones(1, 1)], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMaxLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -213,12 +213,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 10)], [true, Matrix.ones(1, 10)], [false, Tensor.ones([10])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMaxLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -234,12 +234,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(100, 1)], [true, Matrix.ones(100, 1)], [false, Tensor.ones([100])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMaxLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -257,12 +257,12 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 1, 1])], [true, Tensor.ones([1, 1, 1])], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMaxLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -280,12 +280,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 10, 7])], [true, Tensor.ones([1, 10, 7])], [false, Tensor.ones([10, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMaxLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -304,12 +304,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([15, 1, 7])], [true, Tensor.ones([15, 1, 7])], [false, Tensor.ones([15, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMaxLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -402,7 +402,7 @@ describe('nn', () => { [1, undefined, Matrix.random(4, 1, -0.1, 0.1)], [1, true, Matrix.random(4, 1, -0.1, 0.1)], [1, false, Tensor.random([4], -0.1, 0.1)], - ])('grad %p keepdims %p', (axis, keepdims, t) => { + ])('grad %j keepdims %j', (axis, keepdims, t) => { test('value', () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'reduce_max', axis, keepdims }], diff --git a/tests/lib/model/nns/layer/reduce_min.test.js b/tests/lib/model/nns/layer/reduce_min.test.js index 04e249635..b49f97b4f 100644 --- a/tests/lib/model/nns/layer/reduce_min.test.js +++ b/tests/lib/model/nns/layer/reduce_min.test.js @@ -18,7 +18,7 @@ describe('layer', () => { describe('calc', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMinLayer({ axis }) @@ -42,7 +42,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMinLayer({ axis }) @@ -70,7 +70,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMinLayer({ axis }) @@ -100,7 +100,7 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMinLayer({ axis }) @@ -124,7 +124,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMinLayer({ axis }) @@ -156,7 +156,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new ReduceMinLayer({ axis }) @@ -192,12 +192,12 @@ describe('layer', () => { describe('grad', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 1)], [true, Matrix.ones(1, 1)], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMinLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -213,12 +213,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 10)], [true, Matrix.ones(1, 10)], [false, Tensor.ones([10])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMinLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -234,12 +234,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(100, 1)], [true, Matrix.ones(100, 1)], [false, Tensor.ones([100])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMinLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -257,12 +257,12 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 1, 1])], [true, Tensor.ones([1, 1, 1])], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMinLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -280,12 +280,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 10, 7])], [true, Tensor.ones([1, 10, 7])], [false, Tensor.ones([10, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMinLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -304,12 +304,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([15, 1, 7])], [true, Tensor.ones([15, 1, 7])], [false, Tensor.ones([15, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new ReduceMinLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -402,7 +402,7 @@ describe('nn', () => { [1, undefined, Matrix.random(4, 1, -0.1, 0.1)], [1, true, Matrix.random(4, 1, -0.1, 0.1)], [1, false, Tensor.random([4], -0.1, 0.1)], - ])('grad %p keepdims %p', (axis, keepdims, t) => { + ])('grad %j keepdims %j', (axis, keepdims, t) => { test('value', () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'reduce_min', axis, keepdims }], diff --git a/tests/lib/model/nns/layer/relu.test.js b/tests/lib/model/nns/layer/relu.test.js index 2591b2567..1643a2f0e 100644 --- a/tests/lib/model/nns/layer/relu.test.js +++ b/tests/lib/model/nns/layer/relu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -101,7 +98,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/resech.test.js b/tests/lib/model/nns/layer/resech.test.js index 727ab13ed..f0a1562e2 100644 --- a/tests/lib/model/nns/layer/resech.test.js +++ b/tests/lib/model/nns/layer/resech.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -106,7 +103,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/rnn.test.js b/tests/lib/model/nns/layer/rnn.test.js index 148ac3f7e..8a841a545 100644 --- a/tests/lib/model/nns/layer/rnn.test.js +++ b/tests/lib/model/nns/layer/rnn.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -195,7 +192,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', () => { + test('update', { retry: 3, timeout: 10000 }, () => { const net = NeuralNetwork.fromObject([{ type: 'input' }, { type: 'rnn', size: 4 }], 'mse', 'adam') const x = Tensor.randn([1, 10, 6]) const t = Matrix.random(1, 4, -0.9, 0.9) @@ -213,7 +210,7 @@ describe('nn', () => { } }) - test('string parameters', () => { + test('string parameters', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/layer/rrelu.test.js b/tests/lib/model/nns/layer/rrelu.test.js index 16c0199c3..ab75c526b 100644 --- a/tests/lib/model/nns/layer/rrelu.test.js +++ b/tests/lib/model/nns/layer/rrelu.test.js @@ -128,7 +128,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { timeout: 10000 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'rrelu' }], 'mse', diff --git a/tests/lib/model/nns/layer/rtrelu.test.js b/tests/lib/model/nns/layer/rtrelu.test.js index 052ba37b1..2951cc491 100644 --- a/tests/lib/model/nns/layer/rtrelu.test.js +++ b/tests/lib/model/nns/layer/rtrelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -91,7 +88,7 @@ describe('layer', () => { }) describe('grad', () => { - test('matrix', () => { + test('matrix', { retry: 5 }, () => { const layer = new RandomTranslationReluLayer({}) layer.bind({ training: true }) @@ -181,7 +178,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 5 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/selu.test.js b/tests/lib/model/nns/layer/selu.test.js index d03f5f48e..08e2670cd 100644 --- a/tests/lib/model/nns/layer/selu.test.js +++ b/tests/lib/model/nns/layer/selu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -112,7 +109,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'selu' }], 'mse', diff --git a/tests/lib/model/nns/layer/silu.test.js b/tests/lib/model/nns/layer/silu.test.js index 930b26873..c46bb9057 100644 --- a/tests/lib/model/nns/layer/silu.test.js +++ b/tests/lib/model/nns/layer/silu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -105,7 +102,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3, w: new Matrix(5, 3, 0.01) }, { type: 'silu' }], 'mse', diff --git a/tests/lib/model/nns/layer/slu.test.js b/tests/lib/model/nns/layer/slu.test.js index d7739866c..971a40c1b 100644 --- a/tests/lib/model/nns/layer/slu.test.js +++ b/tests/lib/model/nns/layer/slu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -105,7 +102,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/soft_shrink.test.js b/tests/lib/model/nns/layer/soft_shrink.test.js index 471f5499c..1c9f32d68 100644 --- a/tests/lib/model/nns/layer/soft_shrink.test.js +++ b/tests/lib/model/nns/layer/soft_shrink.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -107,7 +104,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/softargmax.test.js b/tests/lib/model/nns/layer/softargmax.test.js index 110b53c13..4da9321ba 100644 --- a/tests/lib/model/nns/layer/softargmax.test.js +++ b/tests/lib/model/nns/layer/softargmax.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -14,7 +11,7 @@ describe('layer', () => { }) describe('calc', () => { - test('matrix', () => { + test('matrix', { retry: 3 }, () => { const layer = new SoftargmaxLayer({}) const x = Matrix.randn(100, 10) @@ -58,7 +55,7 @@ describe('layer', () => { }) describe('nn', () => { - test('calc', () => { + test('calc', { retry: 3 }, () => { const net = NeuralNetwork.fromObject([{ type: 'input' }, { type: 'softargmax' }]) const x = Matrix.random(10, 10, 0, 1) @@ -71,7 +68,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 5 }, { type: 'softargmax' }], 'mse', diff --git a/tests/lib/model/nns/layer/softmax.test.js b/tests/lib/model/nns/layer/softmax.test.js index c869b9783..89a2672c3 100644 --- a/tests/lib/model/nns/layer/softmax.test.js +++ b/tests/lib/model/nns/layer/softmax.test.js @@ -11,7 +11,7 @@ describe('layer', () => { }) describe('calc', () => { - test.each([undefined, -1, 1])('matrix axis:%p', axis => { + test.each([undefined, -1, 1])('matrix axis:%j', axis => { const layer = new SoftmaxLayer({ axis }) const x = Matrix.randn(100, 10) @@ -26,7 +26,7 @@ describe('layer', () => { } }) - test.each([undefined, -1, 2])('tensor axis:%p', axis => { + test.each([undefined, -1, 2])('tensor axis:%j', axis => { const layer = new SoftmaxLayer({ axis }) const x = Tensor.randn([15, 10, 7]) @@ -47,7 +47,7 @@ describe('layer', () => { }) describe('grad', () => { - test.each([undefined, -1, 1])('matrix axis:%p', axis => { + test.each([undefined, -1, 1])('matrix axis:%j', axis => { const layer = new SoftmaxLayer({ axis }) const x = Matrix.randn(100, 10) @@ -58,7 +58,7 @@ describe('layer', () => { expect(bi.sizes).toEqual([100, 10]) }) - test.each([undefined, -1, 2])('tensor axis:%p', axis => { + test.each([undefined, -1, 2])('tensor axis:%j', axis => { const layer = new SoftmaxLayer({ axis }) const x = Tensor.randn([15, 10, 7]) diff --git a/tests/lib/model/nns/layer/softmin.test.js b/tests/lib/model/nns/layer/softmin.test.js index 4e37f7720..da01c86c6 100644 --- a/tests/lib/model/nns/layer/softmin.test.js +++ b/tests/lib/model/nns/layer/softmin.test.js @@ -11,7 +11,7 @@ describe('layer', () => { }) describe('calc', () => { - test.each([undefined, -1, 1])('matrix axis:%p', axis => { + test.each([undefined, -1, 1])('matrix axis:%j', axis => { const layer = new SoftminLayer({ axis }) const x = Matrix.randn(100, 10) @@ -26,7 +26,7 @@ describe('layer', () => { } }) - test.each([undefined, -1, 2])('tensor axis:%p', axis => { + test.each([undefined, -1, 2])('tensor axis:%j', axis => { const layer = new SoftminLayer({ axis }) const x = Tensor.randn([15, 10, 7]) @@ -47,7 +47,7 @@ describe('layer', () => { }) describe('grad', () => { - test.each([undefined, -1, 1])('matrix axis:%p', axis => { + test.each([undefined, -1, 1])('matrix axis:%j', axis => { const layer = new SoftminLayer({ axis }) const x = Matrix.randn(100, 10) @@ -58,7 +58,7 @@ describe('layer', () => { expect(bi.sizes).toEqual([100, 10]) }) - test.each([undefined, -1, 2])('tensor axis:%p', axis => { + test.each([undefined, -1, 2])('tensor axis:%j', axis => { const layer = new SoftminLayer({ axis }) const x = Tensor.randn([15, 10, 7]) diff --git a/tests/lib/model/nns/layer/sparse.test.js b/tests/lib/model/nns/layer/sparse.test.js index fbf273897..d4cd3a56a 100644 --- a/tests/lib/model/nns/layer/sparse.test.js +++ b/tests/lib/model/nns/layer/sparse.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -80,7 +77,7 @@ describe('nn', () => { } }) - test.skip('grad', () => { + test.skip('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'sparsity', rho: 0.02, beta: 1 }], 'mse', diff --git a/tests/lib/model/nns/layer/srelu.test.js b/tests/lib/model/nns/layer/srelu.test.js index 26c3fb7af..f90c5bd83 100644 --- a/tests/lib/model/nns/layer/srelu.test.js +++ b/tests/lib/model/nns/layer/srelu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -101,7 +98,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/srs.test.js b/tests/lib/model/nns/layer/srs.test.js index b03006241..594e54eee 100644 --- a/tests/lib/model/nns/layer/srs.test.js +++ b/tests/lib/model/nns/layer/srs.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' import SoftRootSignLayer from '../../../../../lib/model/nns/layer/srs.js' -describe.each([{}, { alpha: 3, beta: 2 }, { alpha: 5, beta: 3 }])('layer %p', opt => { +describe.each([{}, { alpha: 3, beta: 2 }, { alpha: 5, beta: 3 }])('layer %j', opt => { test('construct', () => { const layer = new SoftRootSignLayer(opt) expect(layer).toBeDefined() @@ -99,7 +96,7 @@ describe.each([{}, { alpha: 3, beta: 2 }, { alpha: 5, beta: 3 }])('layer %p', op }) }) -describe.each([{}, { alpha: 3, beta: 2 }, { alpha: 5, beta: 3 }])('nn %p', opt => { +describe.each([{}, { alpha: 3, beta: 2 }, { alpha: 5, beta: 3 }])('nn %j', opt => { test('calc', () => { const net = NeuralNetwork.fromObject([{ type: 'input' }, { type: 'srs', ...opt }]) const x = Matrix.randn(10, 10) @@ -114,7 +111,7 @@ describe.each([{}, { alpha: 3, beta: 2 }, { alpha: 5, beta: 3 }])('nn %p', opt = } }) - test('grad', () => { + test('grad', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3, w: new Matrix(5, 3, 0.01) }, { type: 'srs', ...opt }], 'mse', diff --git a/tests/lib/model/nns/layer/stanh.test.js b/tests/lib/model/nns/layer/stanh.test.js index bbaa05cf6..3178d6f87 100644 --- a/tests/lib/model/nns/layer/stanh.test.js +++ b/tests/lib/model/nns/layer/stanh.test.js @@ -4,7 +4,7 @@ import Tensor from '../../../../../lib/util/tensor.js' import ScaledTanhLayer from '../../../../../lib/model/nns/layer/stanh.js' -describe.each([{}, { a: 1, b: 2 }, { a: 2, b: 1 }])('layer %p', opt => { +describe.each([{}, { a: 1, b: 2 }, { a: 2, b: 1 }])('layer %j', opt => { test('construct', () => { const layer = new ScaledTanhLayer(opt) expect(layer).toBeDefined() @@ -89,7 +89,7 @@ describe.each([{}, { a: 1, b: 2 }, { a: 2, b: 1 }])('layer %p', opt => { }) }) -describe.each([{}, { a: 1, b: 2 }, { a: 2, b: 1 }])('nn %p', opt => { +describe.each([{}, { a: 1, b: 2 }, { a: 2, b: 1 }])('nn %j', opt => { test('calc', () => { const net = NeuralNetwork.fromObject([{ type: 'input' }, { type: 'stanh', ...opt }]) const x = Matrix.randn(10, 10) diff --git a/tests/lib/model/nns/layer/std.test.js b/tests/lib/model/nns/layer/std.test.js index dbfb07c00..cc282cd6d 100644 --- a/tests/lib/model/nns/layer/std.test.js +++ b/tests/lib/model/nns/layer/std.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -21,7 +18,7 @@ describe('layer', () => { describe('calc', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test('keepdims true', () => { const layer = new StdLayer({ axis }) @@ -45,7 +42,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new StdLayer({ axis }) @@ -73,7 +70,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new StdLayer({ axis }) @@ -103,7 +100,7 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test('keepdims true', () => { const layer = new StdLayer({ axis }) @@ -129,7 +126,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new StdLayer({ axis }) @@ -167,7 +164,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new StdLayer({ axis }) @@ -209,12 +206,12 @@ describe('layer', () => { describe('grad', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 1)], [true, Matrix.ones(1, 1)], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new StdLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -230,12 +227,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 10)], [true, Matrix.ones(1, 10)], [false, Tensor.ones([10])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new StdLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -253,12 +250,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(100, 1)], [true, Matrix.ones(100, 1)], [false, Tensor.ones([100])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new StdLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -278,12 +275,12 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 1, 1])], [true, Tensor.ones([1, 1, 1])], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new StdLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -301,12 +298,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 10, 7])], [true, Tensor.ones([1, 10, 7])], [false, Tensor.ones([10, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new StdLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -328,12 +325,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([15, 1, 7])], [true, Tensor.ones([15, 1, 7])], [false, Tensor.ones([15, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new StdLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -429,8 +426,8 @@ describe('nn', () => { [1, undefined, Matrix.random(4, 1, 0.5, 1)], [1, true, Matrix.random(4, 1, 0.5, 1)], [1, false, Tensor.random([4], 0.5, 1)], - ])('grad %p keepdims %p', (axis, keepdims, t) => { - test('value', () => { + ])('grad %j keepdims %j', (axis, keepdims, t) => { + test('value', { retry: 5 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'variance', axis, keepdims }], 'mse', @@ -453,7 +450,7 @@ describe('nn', () => { } }) - test('string parameters', () => { + test('string parameters', { retry: 5 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/sum.test.js b/tests/lib/model/nns/layer/sum.test.js index a4a4ddc30..ef147977f 100644 --- a/tests/lib/model/nns/layer/sum.test.js +++ b/tests/lib/model/nns/layer/sum.test.js @@ -18,7 +18,7 @@ describe('layer', () => { describe('calc', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test('keepdims true', () => { const layer = new SumLayer({ axis }) @@ -42,7 +42,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new SumLayer({ axis }) @@ -70,7 +70,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new SumLayer({ axis }) @@ -100,7 +100,7 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test('keepdims true', () => { const layer = new SumLayer({ axis }) @@ -124,7 +124,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new SumLayer({ axis }) @@ -156,7 +156,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new SumLayer({ axis }) @@ -192,12 +192,12 @@ describe('layer', () => { describe('grad', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 1)], [true, Matrix.ones(1, 1)], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new SumLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -212,12 +212,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 10)], [true, Matrix.ones(1, 10)], [false, Tensor.ones([10])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new SumLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -232,12 +232,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(100, 1)], [true, Matrix.ones(100, 1)], [false, Tensor.ones([100])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new SumLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -254,12 +254,12 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 1, 1])], [true, Tensor.ones([1, 1, 1])], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new SumLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -276,12 +276,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 10, 7])], [true, Tensor.ones([1, 10, 7])], [false, Tensor.ones([10, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new SumLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -298,12 +298,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([15, 1, 7])], [true, Tensor.ones([15, 1, 7])], [false, Tensor.ones([15, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new SumLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -394,7 +394,7 @@ describe('nn', () => { [1, undefined, Matrix.random(4, 1, -0.1, 0.1)], [1, true, Matrix.random(4, 1, -0.1, 0.1)], [1, false, Tensor.random([4], -0.1, 0.1)], - ])('grad %p keepdims %p', (axis, keepdims, t) => { + ])('grad %j keepdims %j', (axis, keepdims, t) => { test('value', () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'sum', axis, keepdims }], diff --git a/tests/lib/model/nns/layer/thresholded_relu.test.js b/tests/lib/model/nns/layer/thresholded_relu.test.js index 5c8772f96..759bbdf49 100644 --- a/tests/lib/model/nns/layer/thresholded_relu.test.js +++ b/tests/lib/model/nns/layer/thresholded_relu.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -101,7 +98,7 @@ describe('nn', () => { } }) - test('grad', () => { + test('grad', { retry: 5 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/upsampling.test.js b/tests/lib/model/nns/layer/upsampling.test.js index 9c5e9acc6..63edf0096 100644 --- a/tests/lib/model/nns/layer/upsampling.test.js +++ b/tests/lib/model/nns/layer/upsampling.test.js @@ -1,6 +1,3 @@ -import { expect, jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' import Tensor from '../../../../../lib/util/tensor.js' @@ -20,7 +17,7 @@ describe('layer', () => { }) describe('calc', () => { - test.each([[2, 2], 2])('size:%p', size => { + test.each([[2, 2], 2])('size:%j', size => { const layer = new UpSamplingLayer({ size }) const x = Tensor.randn([10, 2, 2, 3]) @@ -158,7 +155,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', () => { + test('update', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, diff --git a/tests/lib/model/nns/layer/variance.test.js b/tests/lib/model/nns/layer/variance.test.js index c36199d74..1645974c5 100644 --- a/tests/lib/model/nns/layer/variance.test.js +++ b/tests/lib/model/nns/layer/variance.test.js @@ -18,7 +18,7 @@ describe('layer', () => { describe('calc', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test('keepdims true', () => { const layer = new VarianceLayer({ axis }) @@ -42,7 +42,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new VarianceLayer({ axis }) @@ -70,7 +70,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new VarianceLayer({ axis }) @@ -100,7 +100,7 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test('keepdims true', () => { const layer = new VarianceLayer({ axis }) @@ -126,7 +126,7 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('keepdims true', () => { const layer = new VarianceLayer({ axis }) @@ -164,7 +164,7 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('keepdims true', () => { const layer = new VarianceLayer({ axis }) @@ -206,12 +206,12 @@ describe('layer', () => { describe('grad', () => { describe('matrix', () => { - describe.each([undefined, -1, [-1], [0, 1]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 1)], [true, Matrix.ones(1, 1)], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new VarianceLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -227,12 +227,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(1, 10)], [true, Matrix.ones(1, 10)], [false, Tensor.ones([10])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new VarianceLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -248,12 +248,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Matrix.ones(100, 1)], [true, Matrix.ones(100, 1)], [false, Tensor.ones([100])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new VarianceLayer({ axis, keepdims }) const x = Matrix.randn(100, 10) @@ -271,12 +271,12 @@ describe('layer', () => { }) describe('tensor', () => { - describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %p', axis => { + describe.each([undefined, -1, [-1], [0, 1, 2]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 1, 1])], [true, Tensor.ones([1, 1, 1])], [false, Tensor.ones([])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new VarianceLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -294,12 +294,12 @@ describe('layer', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([1, 10, 7])], [true, Tensor.ones([1, 10, 7])], [false, Tensor.ones([10, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new VarianceLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -318,12 +318,12 @@ describe('layer', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test.each([ [undefined, Tensor.ones([15, 1, 7])], [true, Tensor.ones([15, 1, 7])], [false, Tensor.ones([15, 7])], - ])('keepdims %p', (keepdims, bo) => { + ])('keepdims %j', (keepdims, bo) => { const layer = new VarianceLayer({ axis, keepdims }) const x = Tensor.randn([15, 10, 7]) @@ -416,7 +416,7 @@ describe('nn', () => { [1, undefined, Matrix.random(4, 1, 0.1, 1)], [1, true, Matrix.random(4, 1, 0.1, 1)], [1, false, Tensor.random([4], 0.1, 1)], - ])('grad %p keepdims %p', (axis, keepdims, t) => { + ])('grad %j keepdims %j', (axis, keepdims, t) => { test('value', () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'full', out_size: 3 }, { type: 'variance', axis, keepdims }], diff --git a/tests/lib/model/nns/onnx/layer/abs.test.js b/tests/lib/model/nns/onnx/layer/abs.test.js index 71dfe22fe..6623b558b 100644 --- a/tests/lib/model/nns/onnx/layer/abs.test.js +++ b/tests/lib/model/nns/onnx/layer/abs.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() abs.export(model, { type: 'abs', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/acos.test.js b/tests/lib/model/nns/onnx/layer/acos.test.js index 5e21f33ab..f25d7ef3c 100644 --- a/tests/lib/model/nns/onnx/layer/acos.test.js +++ b/tests/lib/model/nns/onnx/layer/acos.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() acos.export(model, { type: 'acos', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/acosh.test.js b/tests/lib/model/nns/onnx/layer/acosh.test.js index 34036c4f7..0ed7520c9 100644 --- a/tests/lib/model/nns/onnx/layer/acosh.test.js +++ b/tests/lib/model/nns/onnx/layer/acosh.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() acosh.export(model, { type: 'acosh', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/add.test.js b/tests/lib/model/nns/onnx/layer/add.test.js index c5961519a..dae275198 100644 --- a/tests/lib/model/nns/onnx/layer/add.test.js +++ b/tests/lib/model/nns/onnx/layer/add.test.js @@ -15,7 +15,7 @@ describe('export', () => { expect(nodes[0].getOpType()).toBe('Add') }) - test.each([1, 3, 4])('array input %p', length => { + test.each([1, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() add.export(model, { type: 'add', input }) @@ -42,7 +42,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('add %p', async ins => { + ])('add %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/and.test.js b/tests/lib/model/nns/onnx/layer/and.test.js index fd58ecfca..bdfe1c148 100644 --- a/tests/lib/model/nns/onnx/layer/and.test.js +++ b/tests/lib/model/nns/onnx/layer/and.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() const types = Object.fromEntries( @@ -53,7 +53,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('and %p', async ins => { + ])('and %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/apl.test.js b/tests/lib/model/nns/onnx/layer/apl.test.js index f0e8e5d9f..21abe0654 100644 --- a/tests/lib/model/nns/onnx/layer/apl.test.js +++ b/tests/lib/model/nns/onnx/layer/apl.test.js @@ -7,7 +7,7 @@ import APLLayer from '../../../../../../lib/model/nns/layer/apl.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 1, b: 0.5 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 1, b: 0.5 }])('%j', param => { const model = ONNXExporter.createONNXModel() apl.export(model, { type: 'apl', ...param }) const nodes = model.getGraph().getNodeList() @@ -39,7 +39,7 @@ describe('runtime', () => { test.each([ { a: 2.0, b: 1.0 }, { s: 3, a: [1, 2, 3], b: [-1, 0, 1] }, - ])('apl %p', async param => { + ])('apl %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'apl', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/aranda.test.js b/tests/lib/model/nns/onnx/layer/aranda.test.js index e4738eb8d..0c97cb8bf 100644 --- a/tests/lib/model/nns/onnx/layer/aranda.test.js +++ b/tests/lib/model/nns/onnx/layer/aranda.test.js @@ -7,7 +7,7 @@ import ArandaLayer from '../../../../../../lib/model/nns/layer/aranda.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], l: 1.5 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], l: 1.5 }])('%j', param => { const model = ONNXExporter.createONNXModel() aranda.export(model, { type: 'aranda', ...param }) const nodes = model.getGraph().getNodeList() @@ -33,7 +33,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { l: 1.0 }, { l: 2.0 }])('aranda %p', async param => { + test.each([{}, { l: 1.0 }, { l: 2.0 }])('aranda %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'aranda', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/argmax.test.js b/tests/lib/model/nns/onnx/layer/argmax.test.js index 026684f24..93dfbabda 100644 --- a/tests/lib/model/nns/onnx/layer/argmax.test.js +++ b/tests/lib/model/nns/onnx/layer/argmax.test.js @@ -52,7 +52,7 @@ describe('runtime', () => { [{}, [null, 3], [100, 3], [100, 1]], [{ axis: 0 }, [null, 3], [100, 3], [1, 3]], [{ keepdims: false }, [null, 3], [100, 3], [100]], - ])('argmax %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('argmax %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'argmax', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/argmin.test.js b/tests/lib/model/nns/onnx/layer/argmin.test.js index 964fe0093..cb0b9599f 100644 --- a/tests/lib/model/nns/onnx/layer/argmin.test.js +++ b/tests/lib/model/nns/onnx/layer/argmin.test.js @@ -52,7 +52,7 @@ describe('runtime', () => { [{}, [null, 3], [100, 3], [100, 1]], [{ axis: 0 }, [null, 3], [100, 3], [1, 3]], [{ keepdims: false }, [null, 3], [100, 3], [100]], - ])('argmin %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('argmin %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'argmin', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/asin.test.js b/tests/lib/model/nns/onnx/layer/asin.test.js index 397161892..e5f7774ac 100644 --- a/tests/lib/model/nns/onnx/layer/asin.test.js +++ b/tests/lib/model/nns/onnx/layer/asin.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() asin.export(model, { type: 'asin', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/asinh.test.js b/tests/lib/model/nns/onnx/layer/asinh.test.js index c61cdfc2c..ee3734f99 100644 --- a/tests/lib/model/nns/onnx/layer/asinh.test.js +++ b/tests/lib/model/nns/onnx/layer/asinh.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() asinh.export(model, { type: 'asinh', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/atan.test.js b/tests/lib/model/nns/onnx/layer/atan.test.js index 8fbebfe00..1693b6b49 100644 --- a/tests/lib/model/nns/onnx/layer/atan.test.js +++ b/tests/lib/model/nns/onnx/layer/atan.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() atan.export(model, { type: 'atan', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/atanh.test.js b/tests/lib/model/nns/onnx/layer/atanh.test.js index f75d63ca9..e71e4d0f3 100644 --- a/tests/lib/model/nns/onnx/layer/atanh.test.js +++ b/tests/lib/model/nns/onnx/layer/atanh.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() atanh.export(model, { type: 'atanh', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/average_pool.test.js b/tests/lib/model/nns/onnx/layer/average_pool.test.js index 4635c7d33..1a8851ec9 100644 --- a/tests/lib/model/nns/onnx/layer/average_pool.test.js +++ b/tests/lib/model/nns/onnx/layer/average_pool.test.js @@ -7,7 +7,7 @@ import AveragePoolLayer from '../../../../../../lib/model/nns/layer/averagepool. import Tensor from '../../../../../../lib/util/tensor.js' describe('export', () => { - test.each([{ input: 'x', channel_dim: -1 }, { input: ['x'] }])('last channel %p', param => { + test.each([{ input: 'x', channel_dim: -1 }, { input: ['x'] }])('last channel %j', param => { const model = ONNXExporter.createONNXModel() const info = averagePool.export(model, { type: 'average_pool', ...param }, { x: { size: [null, 10, 3] } }) expect(info.size).toEqual([null, null, 3]) @@ -75,7 +75,7 @@ describe('runtime', () => { [1, 3, 4, 4], [1, 3, 2, 3], ], - ])('average pool %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('average pool %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'average_pool', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/batch_normalization.test.js b/tests/lib/model/nns/onnx/layer/batch_normalization.test.js index e2c22a72f..45307e8c8 100644 --- a/tests/lib/model/nns/onnx/layer/batch_normalization.test.js +++ b/tests/lib/model/nns/onnx/layer/batch_normalization.test.js @@ -7,7 +7,7 @@ import BatchNormalizationLayer from '../../../../../../lib/model/nns/layer/batch import Tensor from '../../../../../../lib/util/tensor.js' describe('export', () => { - test.each([{ input: 'x', channel_dim: -1 }, { input: ['x'] }])('last channel %p', param => { + test.each([{ input: 'x', channel_dim: -1 }, { input: ['x'] }])('last channel %j', param => { const model = ONNXExporter.createONNXModel() batch_normalization.export(model, { type: 'batch_normalization', ...param }, { x: { size: [null, 10, 3] } }) const nodes = model.getGraph().getNodeList() @@ -113,7 +113,7 @@ describe('runtime', () => { [{}, [null, 3, 3, 3], [1, 3, 3, 3]], [{ channel_dim: 1 }, [null, 3, 3], [1, 3, 3]], [{ scale: [1, 2, 3], offset: [3, 2, 1] }, [null, 3, 3, 3], [1, 3, 3, 3]], - ])('batch normalization %p %p %p', async (param, inSize, actualSize) => { + ])('batch normalization %j %j %j', { retry: 3, timeout: 10000 }, async (param, inSize, actualSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'batch_normalization', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/bdaa.test.js b/tests/lib/model/nns/onnx/layer/bdaa.test.js index 50bda3268..9d6c3562b 100644 --- a/tests/lib/model/nns/onnx/layer/bdaa.test.js +++ b/tests/lib/model/nns/onnx/layer/bdaa.test.js @@ -7,7 +7,7 @@ import BDAALayer from '../../../../../../lib/model/nns/layer/bdaa.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], alpha: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], alpha: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() bdaa.export(model, { type: 'bdaa', ...param }) const nodes = model.getGraph().getNodeList() @@ -37,7 +37,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { alpha: 2.0 }])('bdaa %p', async param => { + test.each([{}, { alpha: 2.0 }])('bdaa %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'bdaa', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/bent_identity.test.js b/tests/lib/model/nns/onnx/layer/bent_identity.test.js index e9446d8cb..1f256a2b4 100644 --- a/tests/lib/model/nns/onnx/layer/bent_identity.test.js +++ b/tests/lib/model/nns/onnx/layer/bent_identity.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() bent_identity.export(model, { type: 'bent_identity', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/bitwise_and.test.js b/tests/lib/model/nns/onnx/layer/bitwise_and.test.js index 9a9629228..8ae4c81a5 100644 --- a/tests/lib/model/nns/onnx/layer/bitwise_and.test.js +++ b/tests/lib/model/nns/onnx/layer/bitwise_and.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() const types = Object.fromEntries( @@ -55,7 +55,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('bitwise_and %p', async ins => { + ])('bitwise_and %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/bitwise_or.test.js b/tests/lib/model/nns/onnx/layer/bitwise_or.test.js index e2fb705d6..e5303e982 100644 --- a/tests/lib/model/nns/onnx/layer/bitwise_or.test.js +++ b/tests/lib/model/nns/onnx/layer/bitwise_or.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() const types = Object.fromEntries( @@ -53,7 +53,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('bitwise_or %p', async ins => { + ])('bitwise_or %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/bitwise_xor.test.js b/tests/lib/model/nns/onnx/layer/bitwise_xor.test.js index 76c05840e..5f7aa1c4c 100644 --- a/tests/lib/model/nns/onnx/layer/bitwise_xor.test.js +++ b/tests/lib/model/nns/onnx/layer/bitwise_xor.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() const types = Object.fromEntries( @@ -55,7 +55,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('bitwise_xor %p', async ins => { + ])('bitwise_xor %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/blu.test.js b/tests/lib/model/nns/onnx/layer/blu.test.js index 51d400baa..07825b0fe 100644 --- a/tests/lib/model/nns/onnx/layer/blu.test.js +++ b/tests/lib/model/nns/onnx/layer/blu.test.js @@ -7,7 +7,7 @@ import BLULayer from '../../../../../../lib/model/nns/layer/blu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], beta: 0.2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], beta: 0.2 }])('%j', param => { const model = ONNXExporter.createONNXModel() blu.export(model, { type: 'blu', ...param }) const nodes = model.getGraph().getNodeList() @@ -33,7 +33,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { beta: 0.5 }])('blu %p', async param => { + test.each([{}, { beta: 0.5 }])('blu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'blu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/brelu.test.js b/tests/lib/model/nns/onnx/layer/brelu.test.js index 0ef4c5004..daaad9e0b 100644 --- a/tests/lib/model/nns/onnx/layer/brelu.test.js +++ b/tests/lib/model/nns/onnx/layer/brelu.test.js @@ -7,7 +7,7 @@ import BReluLayer from '../../../../../../lib/model/nns/layer/brelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() brelu.export(model, { type: 'brelu', ...param }) const nodes = model.getGraph().getNodeList() @@ -25,7 +25,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 2 }])('brelu %p', async param => { + test.each([{}, { a: 2 }])('brelu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'brelu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/ceil.test.js b/tests/lib/model/nns/onnx/layer/ceil.test.js index 55489e91b..055c50044 100644 --- a/tests/lib/model/nns/onnx/layer/ceil.test.js +++ b/tests/lib/model/nns/onnx/layer/ceil.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() ceil.export(model, { type: 'ceil', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/celu.test.js b/tests/lib/model/nns/onnx/layer/celu.test.js index 8d5ee21ba..782525bb5 100644 --- a/tests/lib/model/nns/onnx/layer/celu.test.js +++ b/tests/lib/model/nns/onnx/layer/celu.test.js @@ -7,7 +7,7 @@ import CeluLayer from '../../../../../../lib/model/nns/layer/celu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() celu.export(model, { type: 'celu', ...param }) const nodes = model.getGraph().getNodeList() @@ -24,7 +24,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 2 }])('celu %p', async param => { + test.each([{}, { a: 2 }])('celu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'celu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/clip.test.js b/tests/lib/model/nns/onnx/layer/clip.test.js index cc973d9d7..e8d6377be 100644 --- a/tests/lib/model/nns/onnx/layer/clip.test.js +++ b/tests/lib/model/nns/onnx/layer/clip.test.js @@ -58,7 +58,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { min: -1, max: 1 }, { max: 0 }])('clip %p', async param => { + test.each([{}, { min: -1, max: 1 }, { max: 0 }])('clip %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'clip', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/cloglog.test.js b/tests/lib/model/nns/onnx/layer/cloglog.test.js index 04d41471d..aa31189b1 100644 --- a/tests/lib/model/nns/onnx/layer/cloglog.test.js +++ b/tests/lib/model/nns/onnx/layer/cloglog.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() cloglog.export(model, { type: 'cloglog', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/cloglogm.test.js b/tests/lib/model/nns/onnx/layer/cloglogm.test.js index 48ba59695..37e1c0177 100644 --- a/tests/lib/model/nns/onnx/layer/cloglogm.test.js +++ b/tests/lib/model/nns/onnx/layer/cloglogm.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() cloglogm.export(model, { type: 'cloglogm', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/cond.test.js b/tests/lib/model/nns/onnx/layer/cond.test.js index 4f885aa7a..0b8532424 100644 --- a/tests/lib/model/nns/onnx/layer/cond.test.js +++ b/tests/lib/model/nns/onnx/layer/cond.test.js @@ -34,7 +34,7 @@ describe('export', () => { expect(nodes[0].getOpType()).toBe('Where') }) - test.each(['x', ['a', 'b']])('invalid input %p', i => { + test.each(['x', ['a', 'b']])('invalid input %j', i => { const model = ONNXExporter.createONNXModel() expect(() => cond.export(model, { type: 'cond', input: i })).toThrow("Invalid attribute 'input'") }) diff --git a/tests/lib/model/nns/onnx/layer/conv.test.js b/tests/lib/model/nns/onnx/layer/conv.test.js index 1dd63466a..6fb32eafb 100644 --- a/tests/lib/model/nns/onnx/layer/conv.test.js +++ b/tests/lib/model/nns/onnx/layer/conv.test.js @@ -10,7 +10,7 @@ describe('export', () => { test.each([ { input: 'x', channel_dim: -1, w: Tensor.randn([5, 3, 2]) }, { input: ['x'], w: Tensor.randn([5, 3, 2]) }, - ])('last channel %p', param => { + ])('last channel %j', param => { const model = ONNXExporter.createONNXModel() const info = conv.export(model, { type: 'conv', ...param }, { x: { size: [null, 10, 3] } }) expect(info.size).toEqual([null, null, 5]) @@ -124,7 +124,7 @@ describe('runtime', () => { [1, 3, 4, 4], [1, 2, 4, 4], ], - ])('conv %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('conv %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([{ type: 'input', size: inSize }, { type: 'conv', ...param }, { type: 'output' }]) session = await ort.InferenceSession.create(buf) diff --git a/tests/lib/model/nns/onnx/layer/cos.test.js b/tests/lib/model/nns/onnx/layer/cos.test.js index 4d5faeb96..a2a15f655 100644 --- a/tests/lib/model/nns/onnx/layer/cos.test.js +++ b/tests/lib/model/nns/onnx/layer/cos.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() cos.export(model, { type: 'cos', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/cosh.test.js b/tests/lib/model/nns/onnx/layer/cosh.test.js index 0de1e1e76..632e1488f 100644 --- a/tests/lib/model/nns/onnx/layer/cosh.test.js +++ b/tests/lib/model/nns/onnx/layer/cosh.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() cosh.export(model, { type: 'cosh', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/div.test.js b/tests/lib/model/nns/onnx/layer/div.test.js index 1e533a0d7..1578725ac 100644 --- a/tests/lib/model/nns/onnx/layer/div.test.js +++ b/tests/lib/model/nns/onnx/layer/div.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() div.export(model, { type: 'div', input }) @@ -45,7 +45,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('div %p', async ins => { + ])('div %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/eelu.test.js b/tests/lib/model/nns/onnx/layer/eelu.test.js index c4af08f28..e73f66591 100644 --- a/tests/lib/model/nns/onnx/layer/eelu.test.js +++ b/tests/lib/model/nns/onnx/layer/eelu.test.js @@ -7,7 +7,7 @@ import EeluLayer from '../../../../../../lib/model/nns/layer/eelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], alpha: 2, beta: 3, k: 4 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], alpha: 2, beta: 3, k: 4 }])('%j', param => { const model = ONNXExporter.createONNXModel() eelu.export(model, { type: 'eelu', ...param }) const nodes = model.getGraph().getNodeList() @@ -33,7 +33,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { alpha: 2, beta: 2, k: 2 }])('eelu %p', async param => { + test.each([{}, { alpha: 2, beta: 2, k: 2 }])('eelu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'eelu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/elish.test.js b/tests/lib/model/nns/onnx/layer/elish.test.js index 49a7902b8..b9a437270 100644 --- a/tests/lib/model/nns/onnx/layer/elish.test.js +++ b/tests/lib/model/nns/onnx/layer/elish.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() elish.export(model, { type: 'elish', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/elliott.test.js b/tests/lib/model/nns/onnx/layer/elliott.test.js index c6b59418e..9e1e224b6 100644 --- a/tests/lib/model/nns/onnx/layer/elliott.test.js +++ b/tests/lib/model/nns/onnx/layer/elliott.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() elliott.export(model, { type: 'elliott', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/elu.test.js b/tests/lib/model/nns/onnx/layer/elu.test.js index d56498238..f2ff77f5f 100644 --- a/tests/lib/model/nns/onnx/layer/elu.test.js +++ b/tests/lib/model/nns/onnx/layer/elu.test.js @@ -7,7 +7,7 @@ import EluLayer from '../../../../../../lib/model/nns/layer/elu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() elu.export(model, { type: 'elu', ...param }) const nodes = model.getGraph().getNodeList() @@ -23,7 +23,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 2 }])('elu %p', async param => { + test.each([{}, { a: 2 }])('elu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'elu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/equal.test.js b/tests/lib/model/nns/onnx/layer/equal.test.js index 7c922f9bd..933608640 100644 --- a/tests/lib/model/nns/onnx/layer/equal.test.js +++ b/tests/lib/model/nns/onnx/layer/equal.test.js @@ -74,7 +74,7 @@ describe('runtime', () => { x3: { a: [100, 3], s: [null, 3] }, x4: { a: [100, 3], s: [null, 3] }, }, - ])('equal %p', async ins => { + ])('equal %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/erelu.test.js b/tests/lib/model/nns/onnx/layer/erelu.test.js index 600a510c0..6d71c3435 100644 --- a/tests/lib/model/nns/onnx/layer/erelu.test.js +++ b/tests/lib/model/nns/onnx/layer/erelu.test.js @@ -7,7 +7,7 @@ import EreluLayer from '../../../../../../lib/model/nns/layer/erelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() erelu.export(model, { type: 'erelu', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/erf.test.js b/tests/lib/model/nns/onnx/layer/erf.test.js index ff6d87648..2427a636a 100644 --- a/tests/lib/model/nns/onnx/layer/erf.test.js +++ b/tests/lib/model/nns/onnx/layer/erf.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() erf.export(model, { type: 'erf', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/eswish.test.js b/tests/lib/model/nns/onnx/layer/eswish.test.js index 25316a62e..79d55b947 100644 --- a/tests/lib/model/nns/onnx/layer/eswish.test.js +++ b/tests/lib/model/nns/onnx/layer/eswish.test.js @@ -7,7 +7,7 @@ import EswishLayer from '../../../../../../lib/model/nns/layer/eswish.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], beta: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], beta: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() eswish.export(model, { type: 'eswish', ...param }) const nodes = model.getGraph().getNodeList() @@ -28,7 +28,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { beta: 2 }])('eswish %p', async param => { + test.each([{}, { beta: 2 }])('eswish %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'eswish', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/exp.test.js b/tests/lib/model/nns/onnx/layer/exp.test.js index 5fab9259f..ac77192fd 100644 --- a/tests/lib/model/nns/onnx/layer/exp.test.js +++ b/tests/lib/model/nns/onnx/layer/exp.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() exp.export(model, { type: 'exp', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/felu.test.js b/tests/lib/model/nns/onnx/layer/felu.test.js index 6a975f153..d542070ac 100644 --- a/tests/lib/model/nns/onnx/layer/felu.test.js +++ b/tests/lib/model/nns/onnx/layer/felu.test.js @@ -7,7 +7,7 @@ import FEluLayer from '../../../../../../lib/model/nns/layer/felu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() felu.export(model, { type: 'felu', ...param }) const nodes = model.getGraph().getNodeList() @@ -24,7 +24,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 2 }])('felu %p', async param => { + test.each([{}, { a: 2 }])('felu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'felu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/floor.test.js b/tests/lib/model/nns/onnx/layer/floor.test.js index cfca22c27..6bb22229b 100644 --- a/tests/lib/model/nns/onnx/layer/floor.test.js +++ b/tests/lib/model/nns/onnx/layer/floor.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() floor.export(model, { type: 'floor', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/frelu.test.js b/tests/lib/model/nns/onnx/layer/frelu.test.js index 907f36844..ce5411702 100644 --- a/tests/lib/model/nns/onnx/layer/frelu.test.js +++ b/tests/lib/model/nns/onnx/layer/frelu.test.js @@ -7,7 +7,7 @@ import FreluLayer from '../../../../../../lib/model/nns/layer/frelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], b: 1 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], b: 1 }])('%j', param => { const model = ONNXExporter.createONNXModel() frelu.export(model, { type: 'frelu', ...param }) const nodes = model.getGraph().getNodeList() @@ -27,7 +27,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { b: 1 }])('frelu %p', async param => { + test.each([{}, { b: 1 }])('frelu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'frelu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/full.test.js b/tests/lib/model/nns/onnx/layer/full.test.js index a2547c874..6ccc5b6fc 100644 --- a/tests/lib/model/nns/onnx/layer/full.test.js +++ b/tests/lib/model/nns/onnx/layer/full.test.js @@ -170,7 +170,7 @@ describe('runtime', () => { ]), activation: 'tanh', }, - ])('full %p', async param => { + ])('full %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 5] }, { diff --git a/tests/lib/model/nns/onnx/layer/gaussian.test.js b/tests/lib/model/nns/onnx/layer/gaussian.test.js index cb1054597..a6b5ab55e 100644 --- a/tests/lib/model/nns/onnx/layer/gaussian.test.js +++ b/tests/lib/model/nns/onnx/layer/gaussian.test.js @@ -7,7 +7,7 @@ import GaussianLayer from '../../../../../../lib/model/nns/layer/gaussian.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() gaussian.export(model, { type: 'gaussian', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/gelu.test.js b/tests/lib/model/nns/onnx/layer/gelu.test.js index 2438b468c..e8c5da663 100644 --- a/tests/lib/model/nns/onnx/layer/gelu.test.js +++ b/tests/lib/model/nns/onnx/layer/gelu.test.js @@ -8,7 +8,7 @@ import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { describe('opset version 19', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() gelu.export(model, { type: 'gelu', input }) const nodes = model.getGraph().getNodeList() @@ -50,7 +50,7 @@ describe('export', () => { }) describe('opset version 20', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() model.getOpsetImportList()[0].setVersion(20) gelu.export(model, { type: 'gelu', input }) diff --git a/tests/lib/model/nns/onnx/layer/global_average_pool.test.js b/tests/lib/model/nns/onnx/layer/global_average_pool.test.js index 7cf729763..d8cf90726 100644 --- a/tests/lib/model/nns/onnx/layer/global_average_pool.test.js +++ b/tests/lib/model/nns/onnx/layer/global_average_pool.test.js @@ -7,7 +7,7 @@ import GlobalAveragePoolLayer from '../../../../../../lib/model/nns/layer/global import Tensor from '../../../../../../lib/util/tensor.js' describe('export', () => { - test.each([{ input: 'x', channel_dim: -1 }, { input: ['x'] }])('last channel %p', param => { + test.each([{ input: 'x', channel_dim: -1 }, { input: ['x'] }])('last channel %j', param => { const model = ONNXExporter.createONNXModel() const info = globalAveragePool.export( model, @@ -58,7 +58,7 @@ describe('runtime', () => { [{ channel_dim: 1 }, [null, 3, 3, 3], [1, 3, 3, 3], [1, 3, 1, 1]], [{}, [null, 3, 3, 3], [1, 3, 3, 3], [1, 1, 1, 3]], [{ channel_dim: 1 }, [null, 3, 3], [1, 3, 3], [1, 3, 1]], - ])('global average pool %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('global average pool %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'global_average_pool', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/global_lp_pool.test.js b/tests/lib/model/nns/onnx/layer/global_lp_pool.test.js index 90c695bb6..197dab254 100644 --- a/tests/lib/model/nns/onnx/layer/global_lp_pool.test.js +++ b/tests/lib/model/nns/onnx/layer/global_lp_pool.test.js @@ -10,7 +10,7 @@ describe('export', () => { test.each([ { input: 'x', channel_dim: -1 }, { input: ['x'], p: 3 }, - ])('last channel %p', param => { + ])('last channel %j', param => { const model = ONNXExporter.createONNXModel() const info = globalLpPool.export(model, { type: 'global_lp_pool', ...param }, { x: { size: [null, 10, 3] } }) expect(info.size).toEqual([null, 1, 3]) @@ -57,7 +57,7 @@ describe('runtime', () => { [{ channel_dim: 1 }, [null, 3, 3, 3], [1, 3, 3, 3], [1, 3, 1, 1]], [{ p: 3 }, [null, 3, 3, 3], [1, 3, 3, 3], [1, 1, 1, 3]], [{ channel_dim: 1, p: 4 }, [null, 3, 3], [1, 3, 3], [1, 3, 1]], - ])('global lp pool %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('global lp pool %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'global_lp_pool', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/global_max_pool.test.js b/tests/lib/model/nns/onnx/layer/global_max_pool.test.js index 96fbfd267..752515e91 100644 --- a/tests/lib/model/nns/onnx/layer/global_max_pool.test.js +++ b/tests/lib/model/nns/onnx/layer/global_max_pool.test.js @@ -7,7 +7,7 @@ import GlobalMaxPoolLayer from '../../../../../../lib/model/nns/layer/global_max import Tensor from '../../../../../../lib/util/tensor.js' describe('export', () => { - test.each([{ input: 'x', channel_dim: -1 }, { input: ['x'] }])('last channel %p', param => { + test.each([{ input: 'x', channel_dim: -1 }, { input: ['x'] }])('last channel %j', param => { const model = ONNXExporter.createONNXModel() const info = globalMaxPool.export(model, { type: 'global_max_pool', ...param }, { x: { size: [null, 10, 3] } }) expect(info.size).toEqual([null, 1, 3]) @@ -54,7 +54,7 @@ describe('runtime', () => { [{ channel_dim: 1 }, [null, 3, 3, 3], [1, 3, 3, 3], [1, 3, 1, 1]], [{}, [null, 3, 3, 3], [1, 3, 3, 3], [1, 1, 1, 3]], [{ channel_dim: 1 }, [null, 3, 3], [1, 3, 3], [1, 3, 1]], - ])('global max pool %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('global max pool %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'global_max_pool', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/greater.test.js b/tests/lib/model/nns/onnx/layer/greater.test.js index 0c22436b1..76a406a5d 100644 --- a/tests/lib/model/nns/onnx/layer/greater.test.js +++ b/tests/lib/model/nns/onnx/layer/greater.test.js @@ -74,7 +74,7 @@ describe('runtime', () => { x3: { a: [100, 3], s: [null, 3] }, x4: { a: [100, 3], s: [null, 3] }, }, - ])('greater %p', async ins => { + ])('greater %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/greater_or_equal.test.js b/tests/lib/model/nns/onnx/layer/greater_or_equal.test.js index e72fc5c91..dc4f5217c 100644 --- a/tests/lib/model/nns/onnx/layer/greater_or_equal.test.js +++ b/tests/lib/model/nns/onnx/layer/greater_or_equal.test.js @@ -76,7 +76,7 @@ describe('runtime', () => { x3: { a: [100, 3], s: [null, 3] }, x4: { a: [100, 3], s: [null, 3] }, }, - ])('greater_or_equal %p', async ins => { + ])('greater_or_equal %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/hard_elish.test.js b/tests/lib/model/nns/onnx/layer/hard_elish.test.js index cb48cae29..7d4d33824 100644 --- a/tests/lib/model/nns/onnx/layer/hard_elish.test.js +++ b/tests/lib/model/nns/onnx/layer/hard_elish.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() hard_elish.export(model, { type: 'hard_elish', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/hard_shrink.test.js b/tests/lib/model/nns/onnx/layer/hard_shrink.test.js index 497810040..d00167653 100644 --- a/tests/lib/model/nns/onnx/layer/hard_shrink.test.js +++ b/tests/lib/model/nns/onnx/layer/hard_shrink.test.js @@ -7,7 +7,7 @@ import HardShrinkLayer from '../../../../../../lib/model/nns/layer/hard_shrink.j import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], l: 1 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], l: 1 }])('%j', param => { const model = ONNXExporter.createONNXModel() hard_shrink.export(model, { type: 'hard_shrink', ...param }) const nodes = model.getGraph().getNodeList() @@ -23,7 +23,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { l: 1 }])('hard_shrink %p', async param => { + test.each([{}, { l: 1 }])('hard_shrink %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'hard_shrink', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/hard_sigmoid.test.js b/tests/lib/model/nns/onnx/layer/hard_sigmoid.test.js index 1fedb9340..db495ee6b 100644 --- a/tests/lib/model/nns/onnx/layer/hard_sigmoid.test.js +++ b/tests/lib/model/nns/onnx/layer/hard_sigmoid.test.js @@ -7,7 +7,7 @@ import HardSigmoidLayer from '../../../../../../lib/model/nns/layer/hard_sigmoid import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], alpha: 1, beta: 1 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], alpha: 1, beta: 1 }])('%j', param => { const model = ONNXExporter.createONNXModel() hard_sigmoid.export(model, { type: 'hard_sigmoid', ...param }) const nodes = model.getGraph().getNodeList() @@ -23,7 +23,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { alpha: 1, beta: 1 }])('hard_sigmoid %p', async param => { + test.each([{}, { alpha: 1, beta: 1 }])('hard_sigmoid %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'hard_sigmoid', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/hard_swish.test.js b/tests/lib/model/nns/onnx/layer/hard_swish.test.js index 776d88e79..c83181481 100644 --- a/tests/lib/model/nns/onnx/layer/hard_swish.test.js +++ b/tests/lib/model/nns/onnx/layer/hard_swish.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() hard_swish.export(model, { type: 'hard_swish', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/hard_tanh.test.js b/tests/lib/model/nns/onnx/layer/hard_tanh.test.js index 07ed054e1..d598b1352 100644 --- a/tests/lib/model/nns/onnx/layer/hard_tanh.test.js +++ b/tests/lib/model/nns/onnx/layer/hard_tanh.test.js @@ -7,7 +7,7 @@ import HardTanhLayer from '../../../../../../lib/model/nns/layer/hard_tanh.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], v: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], v: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() hard_tanh.export(model, { type: 'hard_tanh', ...param }) const nodes = model.getGraph().getNodeList() @@ -27,7 +27,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { v: 2 }])('hard_tanh %p', async param => { + test.each([{}, { v: 2 }])('hard_tanh %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'hard_tanh', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/hexpo.test.js b/tests/lib/model/nns/onnx/layer/hexpo.test.js index 368d1865b..21d9c8a2b 100644 --- a/tests/lib/model/nns/onnx/layer/hexpo.test.js +++ b/tests/lib/model/nns/onnx/layer/hexpo.test.js @@ -7,7 +7,7 @@ import HexpoLayer from '../../../../../../lib/model/nns/layer/hexpo.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 2, b: 3, c: 4, d: 5 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 2, b: 3, c: 4, d: 5 }])('%j', param => { const model = ONNXExporter.createONNXModel() hexpo.export(model, { type: 'hexpo', ...param }) const nodes = model.getGraph().getNodeList() @@ -37,7 +37,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 2, b: 2, c: 2, d: 2 }])('hexpo %p', async param => { + test.each([{}, { a: 2, b: 2, c: 2, d: 2 }])('hexpo %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'hexpo', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/identity.test.js b/tests/lib/model/nns/onnx/layer/identity.test.js index c33ad3ba2..a241e8578 100644 --- a/tests/lib/model/nns/onnx/layer/identity.test.js +++ b/tests/lib/model/nns/onnx/layer/identity.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() identity.export(model, { type: 'identity', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/is_inf.test.js b/tests/lib/model/nns/onnx/layer/is_inf.test.js index 2b1e135ce..b8bb39210 100644 --- a/tests/lib/model/nns/onnx/layer/is_inf.test.js +++ b/tests/lib/model/nns/onnx/layer/is_inf.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() const info = is_inf.export(model, { type: 'is_inf', input }) expect(info).toEqual({ type: onnx.TensorProto.DataType.BOOL }) diff --git a/tests/lib/model/nns/onnx/layer/is_nan.test.js b/tests/lib/model/nns/onnx/layer/is_nan.test.js index 3cf62d5dc..4804b117c 100644 --- a/tests/lib/model/nns/onnx/layer/is_nan.test.js +++ b/tests/lib/model/nns/onnx/layer/is_nan.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() const info = is_nan.export(model, { type: 'is_nan', input }) expect(info).toEqual({ type: onnx.TensorProto.DataType.BOOL }) diff --git a/tests/lib/model/nns/onnx/layer/isigmoid.test.js b/tests/lib/model/nns/onnx/layer/isigmoid.test.js index e2fe6fd41..bd093d763 100644 --- a/tests/lib/model/nns/onnx/layer/isigmoid.test.js +++ b/tests/lib/model/nns/onnx/layer/isigmoid.test.js @@ -48,7 +48,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 2, alpha: 3 }])('isigmoid %p', async param => { + test.each([{}, { a: 2, alpha: 3 }])('isigmoid %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'isigmoid', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/leaky_relu.test.js b/tests/lib/model/nns/onnx/layer/leaky_relu.test.js index 389970e38..62fbdb060 100644 --- a/tests/lib/model/nns/onnx/layer/leaky_relu.test.js +++ b/tests/lib/model/nns/onnx/layer/leaky_relu.test.js @@ -7,7 +7,7 @@ import LeakyReluLayer from '../../../../../../lib/model/nns/layer/leaky_relu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 1 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 1 }])('%j', param => { const model = ONNXExporter.createONNXModel() leaky_relu.export(model, { type: 'leaky_relu', ...param }) const nodes = model.getGraph().getNodeList() @@ -23,7 +23,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 1 }])('leaky_relu %p', async param => { + test.each([{}, { a: 1 }])('leaky_relu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'leaky_relu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/left_bitshift.test.js b/tests/lib/model/nns/onnx/layer/left_bitshift.test.js index 1c324eb12..5c0db6dd9 100644 --- a/tests/lib/model/nns/onnx/layer/left_bitshift.test.js +++ b/tests/lib/model/nns/onnx/layer/left_bitshift.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() const types = Object.fromEntries( @@ -59,7 +59,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('left_bitshift %p', async ins => { + ])('left_bitshift %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/less.test.js b/tests/lib/model/nns/onnx/layer/less.test.js index ac82a9330..5f3422b7d 100644 --- a/tests/lib/model/nns/onnx/layer/less.test.js +++ b/tests/lib/model/nns/onnx/layer/less.test.js @@ -74,7 +74,7 @@ describe('runtime', () => { x3: { a: [100, 3], s: [null, 3] }, x4: { a: [100, 3], s: [null, 3] }, }, - ])('less %p', async ins => { + ])('less %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/less_or_equal.test.js b/tests/lib/model/nns/onnx/layer/less_or_equal.test.js index 6a9c25a4c..559026555 100644 --- a/tests/lib/model/nns/onnx/layer/less_or_equal.test.js +++ b/tests/lib/model/nns/onnx/layer/less_or_equal.test.js @@ -76,7 +76,7 @@ describe('runtime', () => { x3: { a: [100, 3], s: [null, 3] }, x4: { a: [100, 3], s: [null, 3] }, }, - ])('less_or_equal %p', async ins => { + ])('less_or_equal %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/lisht.test.js b/tests/lib/model/nns/onnx/layer/lisht.test.js index 7fe2618a3..fee312ffd 100644 --- a/tests/lib/model/nns/onnx/layer/lisht.test.js +++ b/tests/lib/model/nns/onnx/layer/lisht.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() lisht.export(model, { type: 'lisht', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/log.test.js b/tests/lib/model/nns/onnx/layer/log.test.js index f948db099..8cfbcb3c8 100644 --- a/tests/lib/model/nns/onnx/layer/log.test.js +++ b/tests/lib/model/nns/onnx/layer/log.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() log.export(model, { type: 'log', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/log_softmax.test.js b/tests/lib/model/nns/onnx/layer/log_softmax.test.js index c0481c6da..be8084b98 100644 --- a/tests/lib/model/nns/onnx/layer/log_softmax.test.js +++ b/tests/lib/model/nns/onnx/layer/log_softmax.test.js @@ -7,7 +7,7 @@ import LogSoftmaxLayer from '../../../../../../lib/model/nns/layer/logsoftmax.js import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], axis: 0 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], axis: 0 }])('%j', param => { const model = ONNXExporter.createONNXModel() log_softmax.export(model, { type: 'log_softmax', ...param }) const nodes = model.getGraph().getNodeList() @@ -23,7 +23,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { axis: 0 }])('log_softmax %p', async param => { + test.each([{}, { axis: 0 }])('log_softmax %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'log_softmax', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/loglog.test.js b/tests/lib/model/nns/onnx/layer/loglog.test.js index 1c2b0d729..4ad2f4f1c 100644 --- a/tests/lib/model/nns/onnx/layer/loglog.test.js +++ b/tests/lib/model/nns/onnx/layer/loglog.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() loglog.export(model, { type: 'loglog', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/logsigmoid.test.js b/tests/lib/model/nns/onnx/layer/logsigmoid.test.js index 71220b3d9..2ae47eaa4 100644 --- a/tests/lib/model/nns/onnx/layer/logsigmoid.test.js +++ b/tests/lib/model/nns/onnx/layer/logsigmoid.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() logsigmoid.export(model, { type: 'logsigmoid', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/lp_pool.test.js b/tests/lib/model/nns/onnx/layer/lp_pool.test.js index 59f37d734..5674441cb 100644 --- a/tests/lib/model/nns/onnx/layer/lp_pool.test.js +++ b/tests/lib/model/nns/onnx/layer/lp_pool.test.js @@ -10,7 +10,7 @@ describe('export', () => { test.each([ { input: 'x', channel_dim: -1 }, { input: ['x'], p: 3 }, - ])('last channel %p', param => { + ])('last channel %j', param => { const model = ONNXExporter.createONNXModel() const info = lpPool.export(model, { type: 'lp_pool', ...param }, { x: { size: [null, 10, 3] } }) expect(info.size).toEqual([null, null, 3]) @@ -74,7 +74,7 @@ describe('runtime', () => { [1, 3, 4, 4], [1, 3, 2, 3], ], - ])('lp pool %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('lp pool %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'lp_pool', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/lrn.test.js b/tests/lib/model/nns/onnx/layer/lrn.test.js index 00bb3734d..5f1648c27 100644 --- a/tests/lib/model/nns/onnx/layer/lrn.test.js +++ b/tests/lib/model/nns/onnx/layer/lrn.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import * as ort from 'onnxruntime-web' ort.env.wasm.numThreads = 1 @@ -13,7 +10,7 @@ describe('export', () => { test.each([ { input: 'x', channel_dim: -1, n: 3 }, { input: ['x'], n: 3 }, - ])('last channel %p', param => { + ])('last channel %j', param => { const model = ONNXExporter.createONNXModel() lrn.export(model, { type: 'lrn', ...param }, { x: { size: [null, 10, 3] } }) const nodes = model.getGraph().getNodeList() @@ -57,7 +54,7 @@ describe('runtime', () => { [{ channel_dim: 1, n: 3 }, [null, 4, 3, 3], [1, 4, 3, 3]], [{ n: 5 }, [null, 4, 4, 10], [1, 4, 4, 10]], [{ alpha: 0.0002, beta: 0.7, k: 2, n: 5 }, [null, 3, 3, 5], [1, 3, 3, 5]], - ])('lrn %p %p %p', async (param, inSize, actualSize) => { + ])('lrn %j %j %j', { retry: 3 }, async (param, inSize, actualSize) => { const buf = ONNXExporter.dump([{ type: 'input', size: inSize }, { type: 'lrn', ...param }, { type: 'output' }]) session = await ort.InferenceSession.create(buf) diff --git a/tests/lib/model/nns/onnx/layer/matmul.test.js b/tests/lib/model/nns/onnx/layer/matmul.test.js index b491a3785..fd8e8f818 100644 --- a/tests/lib/model/nns/onnx/layer/matmul.test.js +++ b/tests/lib/model/nns/onnx/layer/matmul.test.js @@ -60,7 +60,7 @@ describe('runtime', () => { { x1: { a: [100, 5], s: [null, 5] }, x2: { a: [5, 3], s: [5, 3] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 7], s: [null, 7] }, x2: { a: [7, 5], s: [7, 5] }, x3: { a: [5, 3], s: [5, 3] } }, - ])('matmul %p', async ins => { + ])('matmul %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/max_pool.test.js b/tests/lib/model/nns/onnx/layer/max_pool.test.js index b1897f79f..a6513f229 100644 --- a/tests/lib/model/nns/onnx/layer/max_pool.test.js +++ b/tests/lib/model/nns/onnx/layer/max_pool.test.js @@ -7,7 +7,7 @@ import MaxPoolLayer from '../../../../../../lib/model/nns/layer/maxpool.js' import Tensor from '../../../../../../lib/util/tensor.js' describe('export', () => { - test.each([{ input: 'x', channel_dim: -1 }, { input: ['x'] }])('last channel %p', param => { + test.each([{ input: 'x', channel_dim: -1 }, { input: ['x'] }])('last channel %j', param => { const model = ONNXExporter.createONNXModel() const info = maxPool.export(model, { type: 'max_pool', ...param }, { x: { size: [null, 10, 3] } }) expect(info.size).toEqual([null, null, 3]) @@ -71,7 +71,7 @@ describe('runtime', () => { [1, 3, 4, 4], [1, 3, 2, 3], ], - ])('max pool %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('max pool %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'max_pool', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/mean.test.js b/tests/lib/model/nns/onnx/layer/mean.test.js index 80cac8715..5c323bd4b 100644 --- a/tests/lib/model/nns/onnx/layer/mean.test.js +++ b/tests/lib/model/nns/onnx/layer/mean.test.js @@ -96,7 +96,7 @@ describe('runtime', () => { [{}, [null, 3], [100, 3], [1, 1]], [{ axis: 0 }, [null, 3], [100, 3], [1, 3]], [{ keepdims: false }, [null, 3], [100, 3], []], - ])('mean %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('mean %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([{ type: 'input', size: inSize }, { type: 'mean', ...param }, { type: 'output' }]) session = await ort.InferenceSession.create(buf) diff --git a/tests/lib/model/nns/onnx/layer/mish.test.js b/tests/lib/model/nns/onnx/layer/mish.test.js index 86fa708fe..2e661c5ae 100644 --- a/tests/lib/model/nns/onnx/layer/mish.test.js +++ b/tests/lib/model/nns/onnx/layer/mish.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() mish.export(model, { type: 'mish', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/mod.test.js b/tests/lib/model/nns/onnx/layer/mod.test.js index f7000ae99..619e308e6 100644 --- a/tests/lib/model/nns/onnx/layer/mod.test.js +++ b/tests/lib/model/nns/onnx/layer/mod.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() const types = Object.fromEntries( @@ -53,7 +53,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('mod %p', async ins => { + ])('mod %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/mpelu.test.js b/tests/lib/model/nns/onnx/layer/mpelu.test.js index ed24a7625..93f674708 100644 --- a/tests/lib/model/nns/onnx/layer/mpelu.test.js +++ b/tests/lib/model/nns/onnx/layer/mpelu.test.js @@ -7,7 +7,7 @@ import MpeluLayer from '../../../../../../lib/model/nns/layer/mpelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], alpha: 2, beta: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], alpha: 2, beta: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() mpelu.export(model, { type: 'mpelu', ...param }) const nodes = model.getGraph().getNodeList() @@ -25,7 +25,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { alpha: 2, beta: 2 }])('mpelu %p', async param => { + test.each([{}, { alpha: 2, beta: 2 }])('mpelu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'mpelu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/mult.test.js b/tests/lib/model/nns/onnx/layer/mult.test.js index 10081fd8f..1813f6760 100644 --- a/tests/lib/model/nns/onnx/layer/mult.test.js +++ b/tests/lib/model/nns/onnx/layer/mult.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() mult.export(model, { type: 'mult', input }) @@ -44,7 +44,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('mult %p', async ins => { + ])('mult %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/negative.test.js b/tests/lib/model/nns/onnx/layer/negative.test.js index 6841701c8..eae70e4e2 100644 --- a/tests/lib/model/nns/onnx/layer/negative.test.js +++ b/tests/lib/model/nns/onnx/layer/negative.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() negative.export(model, { type: 'negative', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/nlrelu.test.js b/tests/lib/model/nns/onnx/layer/nlrelu.test.js index 45a4bfd6a..ba78905d0 100644 --- a/tests/lib/model/nns/onnx/layer/nlrelu.test.js +++ b/tests/lib/model/nns/onnx/layer/nlrelu.test.js @@ -7,7 +7,7 @@ import NLReluLayer from '../../../../../../lib/model/nns/layer/nlrelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], beta: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], beta: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() nlrelu.export(model, { type: 'nlrelu', ...param }) const nodes = model.getGraph().getNodeList() @@ -30,7 +30,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { beta: 2 }])('nlrelu %p', async param => { + test.each([{}, { beta: 2 }])('nlrelu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'nlrelu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/or.test.js b/tests/lib/model/nns/onnx/layer/or.test.js index 98f2f81a1..c6c5e3495 100644 --- a/tests/lib/model/nns/onnx/layer/or.test.js +++ b/tests/lib/model/nns/onnx/layer/or.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() const types = Object.fromEntries( @@ -53,7 +53,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('or %p', async ins => { + ])('or %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/pau.test.js b/tests/lib/model/nns/onnx/layer/pau.test.js index 0fe959a0d..a690af279 100644 --- a/tests/lib/model/nns/onnx/layer/pau.test.js +++ b/tests/lib/model/nns/onnx/layer/pau.test.js @@ -86,7 +86,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { m: 2, n: 4 }, { a: [2, 3, 4, 5], b: [1, 2, 3] }, { m: 2, n: 0 }])('pau %p', async param => { + test.each([{}, { m: 2, n: 4 }, { a: [2, 3, 4, 5], b: [1, 2, 3] }, { m: 2, n: 0 }])('pau %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'pau', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/pdelu.test.js b/tests/lib/model/nns/onnx/layer/pdelu.test.js index 9acf01e70..cd1728374 100644 --- a/tests/lib/model/nns/onnx/layer/pdelu.test.js +++ b/tests/lib/model/nns/onnx/layer/pdelu.test.js @@ -7,7 +7,7 @@ import PdeluLayer from '../../../../../../lib/model/nns/layer/pdelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], t: 0.2, alpha: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], t: 0.2, alpha: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() pdelu.export(model, { type: 'pdelu', ...param }) const nodes = model.getGraph().getNodeList() @@ -37,7 +37,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { t: 2, alpha: 0.2 }])('pdelu %p', async param => { + test.each([{}, { t: 2, alpha: 0.2 }])('pdelu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'pdelu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/pelu.test.js b/tests/lib/model/nns/onnx/layer/pelu.test.js index da8ee9569..0e03246e8 100644 --- a/tests/lib/model/nns/onnx/layer/pelu.test.js +++ b/tests/lib/model/nns/onnx/layer/pelu.test.js @@ -7,7 +7,7 @@ import PeluLayer from '../../../../../../lib/model/nns/layer/pelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 2, b: 3 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 2, b: 3 }])('%j', param => { const model = ONNXExporter.createONNXModel() pelu.export(model, { type: 'pelu', ...param }) const nodes = model.getGraph().getNodeList() @@ -29,7 +29,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 2, b: 3 }])('pelu %p', async param => { + test.each([{}, { a: 2, b: 3 }])('pelu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'pelu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/plu.test.js b/tests/lib/model/nns/onnx/layer/plu.test.js index 9d480c2a8..0f1cd73dc 100644 --- a/tests/lib/model/nns/onnx/layer/plu.test.js +++ b/tests/lib/model/nns/onnx/layer/plu.test.js @@ -7,7 +7,7 @@ import PluLayer from '../../../../../../lib/model/nns/layer/plu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], alpha: 0.2, c: 3 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], alpha: 0.2, c: 3 }])('%j', param => { const model = ONNXExporter.createONNXModel() plu.export(model, { type: 'plu', ...param }) const nodes = model.getGraph().getNodeList() @@ -34,7 +34,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { alpha: 0.2, c: 3 }])('plu %p', async param => { + test.each([{}, { alpha: 0.2, c: 3 }])('plu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'plu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/power.test.js b/tests/lib/model/nns/onnx/layer/power.test.js index 4ea829265..1094acd99 100644 --- a/tests/lib/model/nns/onnx/layer/power.test.js +++ b/tests/lib/model/nns/onnx/layer/power.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() power.export(model, { type: 'power', input }) @@ -44,7 +44,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('mult %p', async ins => { + ])('mult %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/prelu.test.js b/tests/lib/model/nns/onnx/layer/prelu.test.js index 6e1e614aa..2eba9f6bd 100644 --- a/tests/lib/model/nns/onnx/layer/prelu.test.js +++ b/tests/lib/model/nns/onnx/layer/prelu.test.js @@ -7,7 +7,7 @@ import PreluLayer from '../../../../../../lib/model/nns/layer/prelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 1 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 1 }])('%j', param => { const model = ONNXExporter.createONNXModel() prelu.export(model, { type: 'prelu', ...param }) const nodes = model.getGraph().getNodeList() @@ -36,7 +36,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 2 }, { a: [1, 2, 3] }])('prelu %p', async param => { + test.each([{}, { a: 2 }, { a: [1, 2, 3] }])('prelu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'prelu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/preu.test.js b/tests/lib/model/nns/onnx/layer/preu.test.js index 458ebc36c..a0e79d5b4 100644 --- a/tests/lib/model/nns/onnx/layer/preu.test.js +++ b/tests/lib/model/nns/onnx/layer/preu.test.js @@ -7,7 +7,7 @@ import PreuLayer from '../../../../../../lib/model/nns/layer/preu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], alpha: 2, beta: 3 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], alpha: 2, beta: 3 }])('%j', param => { const model = ONNXExporter.createONNXModel() preu.export(model, { type: 'preu', ...param }) const nodes = model.getGraph().getNodeList() @@ -32,7 +32,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { alpha: 2, beta: 3 }])('preu %p', async param => { + test.each([{}, { alpha: 2, beta: 3 }])('preu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'preu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/prod.test.js b/tests/lib/model/nns/onnx/layer/prod.test.js index e1affb8f3..e02151257 100644 --- a/tests/lib/model/nns/onnx/layer/prod.test.js +++ b/tests/lib/model/nns/onnx/layer/prod.test.js @@ -96,7 +96,7 @@ describe('runtime', () => { [{}, [null, 3], [100, 3], [1, 1]], [{ axis: 0 }, [null, 3], [100, 3], [1, 3]], [{ keepdims: false }, [null, 3], [100, 3], []], - ])('prod %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('prod %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([{ type: 'input', size: inSize }, { type: 'prod', ...param }, { type: 'output' }]) session = await ort.InferenceSession.create(buf) diff --git a/tests/lib/model/nns/onnx/layer/psf.test.js b/tests/lib/model/nns/onnx/layer/psf.test.js index a458b15bd..f2adec374 100644 --- a/tests/lib/model/nns/onnx/layer/psf.test.js +++ b/tests/lib/model/nns/onnx/layer/psf.test.js @@ -7,7 +7,7 @@ import PsfLayer from '../../../../../../lib/model/nns/layer/psf.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], m: 3 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], m: 3 }])('%j', param => { const model = ONNXExporter.createONNXModel() psf.export(model, { type: 'psf', ...param }) const nodes = model.getGraph().getNodeList() @@ -27,7 +27,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { m: 3 }])('psf %p', async param => { + test.each([{}, { m: 3 }])('psf %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'psf', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/ptanh.test.js b/tests/lib/model/nns/onnx/layer/ptanh.test.js index 9a77b2bc5..7c8abb98b 100644 --- a/tests/lib/model/nns/onnx/layer/ptanh.test.js +++ b/tests/lib/model/nns/onnx/layer/ptanh.test.js @@ -7,7 +7,7 @@ import PtanhLayer from '../../../../../../lib/model/nns/layer/ptanh.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 0.5 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 0.5 }])('%j', param => { const model = ONNXExporter.createONNXModel() ptanh.export(model, { type: 'ptanh', ...param }) const nodes = model.getGraph().getNodeList() @@ -31,7 +31,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 0.5 }])('ptanh %p', async param => { + test.each([{}, { a: 0.5 }])('ptanh %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'ptanh', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/ptelu.test.js b/tests/lib/model/nns/onnx/layer/ptelu.test.js index c7db05410..214d0d398 100644 --- a/tests/lib/model/nns/onnx/layer/ptelu.test.js +++ b/tests/lib/model/nns/onnx/layer/ptelu.test.js @@ -7,7 +7,7 @@ import PteluLayer from '../../../../../../lib/model/nns/layer/ptelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], alpha: 0.5, beta: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], alpha: 0.5, beta: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() ptelu.export(model, { type: 'ptelu', ...param }) const nodes = model.getGraph().getNodeList() @@ -32,7 +32,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { alpha: 0.5, beta: 2 }])('ptelu %p', async param => { + test.each([{}, { alpha: 0.5, beta: 2 }])('ptelu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'ptelu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/reciprocal.test.js b/tests/lib/model/nns/onnx/layer/reciprocal.test.js index 09ca5f863..b7979f437 100644 --- a/tests/lib/model/nns/onnx/layer/reciprocal.test.js +++ b/tests/lib/model/nns/onnx/layer/reciprocal.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() reciprocal.export(model, { type: 'reciprocal', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/reduce_max.test.js b/tests/lib/model/nns/onnx/layer/reduce_max.test.js index 3947b64e9..c65292cc0 100644 --- a/tests/lib/model/nns/onnx/layer/reduce_max.test.js +++ b/tests/lib/model/nns/onnx/layer/reduce_max.test.js @@ -108,7 +108,7 @@ describe('runtime', () => { [{}, [null, 3], [100, 3], [1, 1]], [{ axis: 0 }, [null, 3], [100, 3], [1, 3]], [{ keepdims: false }, [null, 3], [100, 3], []], - ])('reduce_max %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('reduce_max %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'reduce_max', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/reduce_min.test.js b/tests/lib/model/nns/onnx/layer/reduce_min.test.js index 738f0259d..84f0f7ba4 100644 --- a/tests/lib/model/nns/onnx/layer/reduce_min.test.js +++ b/tests/lib/model/nns/onnx/layer/reduce_min.test.js @@ -108,7 +108,7 @@ describe('runtime', () => { [{}, [null, 3], [100, 3], [1, 1]], [{ axis: 0 }, [null, 3], [100, 3], [1, 3]], [{ keepdims: false }, [null, 3], [100, 3], []], - ])('reduce_min %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('reduce_min %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'reduce_min', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/relu.test.js b/tests/lib/model/nns/onnx/layer/relu.test.js index 25c6ca0d0..7ab2eb721 100644 --- a/tests/lib/model/nns/onnx/layer/relu.test.js +++ b/tests/lib/model/nns/onnx/layer/relu.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() relu.export(model, { type: 'relu', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/repu.test.js b/tests/lib/model/nns/onnx/layer/repu.test.js index 88520e1b9..5b2de51f3 100644 --- a/tests/lib/model/nns/onnx/layer/repu.test.js +++ b/tests/lib/model/nns/onnx/layer/repu.test.js @@ -7,7 +7,7 @@ import RepuLayer from '../../../../../../lib/model/nns/layer/repu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], s: 3 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], s: 3 }])('%j', param => { const model = ONNXExporter.createONNXModel() repu.export(model, { type: 'repu', ...param }) const nodes = model.getGraph().getNodeList() @@ -27,7 +27,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { s: 3 }])('repu %p', async param => { + test.each([{}, { s: 3 }])('repu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'repu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/resech.test.js b/tests/lib/model/nns/onnx/layer/resech.test.js index 019b85cdb..f2f07e150 100644 --- a/tests/lib/model/nns/onnx/layer/resech.test.js +++ b/tests/lib/model/nns/onnx/layer/resech.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() resech.export(model, { type: 'resech', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/reu.test.js b/tests/lib/model/nns/onnx/layer/reu.test.js index 0dc2740a6..63ec6f7e9 100644 --- a/tests/lib/model/nns/onnx/layer/reu.test.js +++ b/tests/lib/model/nns/onnx/layer/reu.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() reu.export(model, { type: 'reu', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/right_bitshift.test.js b/tests/lib/model/nns/onnx/layer/right_bitshift.test.js index ce3af6202..b24ee68c2 100644 --- a/tests/lib/model/nns/onnx/layer/right_bitshift.test.js +++ b/tests/lib/model/nns/onnx/layer/right_bitshift.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() const types = Object.fromEntries( @@ -59,7 +59,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('right_bitshift %p', async ins => { + ])('right_bitshift %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/rootsig.test.js b/tests/lib/model/nns/onnx/layer/rootsig.test.js index fcb5ac1da..1ce943aa6 100644 --- a/tests/lib/model/nns/onnx/layer/rootsig.test.js +++ b/tests/lib/model/nns/onnx/layer/rootsig.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() rootsig.export(model, { type: 'rootsig', input }) const nodes = model.getGraph().getNodeList() @@ -29,7 +29,7 @@ describe('runtime', () => { session = null }) - test('rootsig', async () => { + test('rootsig', { retry: 3 }, async () => { const buf = ONNXExporter.dump([{ type: 'input', size: [null, 3] }, { type: 'rootsig' }, { type: 'output' }]) session = await ort.InferenceSession.create(buf) diff --git a/tests/lib/model/nns/onnx/layer/round.test.js b/tests/lib/model/nns/onnx/layer/round.test.js index 968589d29..f904445ef 100644 --- a/tests/lib/model/nns/onnx/layer/round.test.js +++ b/tests/lib/model/nns/onnx/layer/round.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() round.export(model, { type: 'round', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/rrelu.test.js b/tests/lib/model/nns/onnx/layer/rrelu.test.js index f67c8beed..a59255298 100644 --- a/tests/lib/model/nns/onnx/layer/rrelu.test.js +++ b/tests/lib/model/nns/onnx/layer/rrelu.test.js @@ -7,7 +7,7 @@ import RreluLayer from '../../../../../../lib/model/nns/layer/rrelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], l: 1, u: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], l: 1, u: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() rrelu.export(model, { type: 'rrelu', ...param }) const nodes = model.getGraph().getNodeList() @@ -23,7 +23,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { l: 1, u: 2 }])('rrelu %p', async param => { + test.each([{}, { l: 1, u: 2 }])('rrelu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'rrelu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/rtrelu.test.js b/tests/lib/model/nns/onnx/layer/rtrelu.test.js index b11de5a79..dfcad73cc 100644 --- a/tests/lib/model/nns/onnx/layer/rtrelu.test.js +++ b/tests/lib/model/nns/onnx/layer/rtrelu.test.js @@ -7,7 +7,7 @@ import RtreluLayer from '../../../../../../lib/model/nns/layer/rtrelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() rtrelu.export(model, { type: 'rtrelu', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/selu.test.js b/tests/lib/model/nns/onnx/layer/selu.test.js index 88c1825f3..eeaa91e60 100644 --- a/tests/lib/model/nns/onnx/layer/selu.test.js +++ b/tests/lib/model/nns/onnx/layer/selu.test.js @@ -7,7 +7,7 @@ import SeluLayer from '../../../../../../lib/model/nns/layer/selu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 2, g: 1.5 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 2, g: 1.5 }])('%j', param => { const model = ONNXExporter.createONNXModel() selu.export(model, { type: 'selu', ...param }) const nodes = model.getGraph().getNodeList() @@ -27,7 +27,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 2, g: 1.5 }])('selu %p', async param => { + test.each([{}, { a: 2, g: 1.5 }])('selu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'selu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/shape.test.js b/tests/lib/model/nns/onnx/layer/shape.test.js index c37bdf2b2..d556e9ed2 100644 --- a/tests/lib/model/nns/onnx/layer/shape.test.js +++ b/tests/lib/model/nns/onnx/layer/shape.test.js @@ -7,7 +7,7 @@ import ShapeLayer from '../../../../../../lib/model/nns/layer/shape.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() shape.export(model, { type: 'shape', input }, { x: { size: [null, 2, 3] } }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/sigmoid.test.js b/tests/lib/model/nns/onnx/layer/sigmoid.test.js index 41ea3a5e2..d92651bfd 100644 --- a/tests/lib/model/nns/onnx/layer/sigmoid.test.js +++ b/tests/lib/model/nns/onnx/layer/sigmoid.test.js @@ -7,7 +7,7 @@ import SigmoidLayer from '../../../../../../lib/model/nns/layer/sigmoid.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() sigmoid.export(model, { type: 'sigmoid', ...param }) const nodes = model.getGraph().getNodeList() @@ -27,7 +27,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 2 }])('sigmoid %p', async param => { + test.each([{}, { a: 2 }])('sigmoid %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'sigmoid', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/sign.test.js b/tests/lib/model/nns/onnx/layer/sign.test.js index 239d9262c..08a6aa2e3 100644 --- a/tests/lib/model/nns/onnx/layer/sign.test.js +++ b/tests/lib/model/nns/onnx/layer/sign.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() sign.export(model, { type: 'sign', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/silu.test.js b/tests/lib/model/nns/onnx/layer/silu.test.js index 23d6d6484..bba042969 100644 --- a/tests/lib/model/nns/onnx/layer/silu.test.js +++ b/tests/lib/model/nns/onnx/layer/silu.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() silu.export(model, { type: 'silu', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/sin.test.js b/tests/lib/model/nns/onnx/layer/sin.test.js index 73fb0b152..8ae4bcc37 100644 --- a/tests/lib/model/nns/onnx/layer/sin.test.js +++ b/tests/lib/model/nns/onnx/layer/sin.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() sin.export(model, { type: 'sin', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/sinh.test.js b/tests/lib/model/nns/onnx/layer/sinh.test.js index d2343e05e..76f772d4b 100644 --- a/tests/lib/model/nns/onnx/layer/sinh.test.js +++ b/tests/lib/model/nns/onnx/layer/sinh.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() sinh.export(model, { type: 'sinh', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/slaf.test.js b/tests/lib/model/nns/onnx/layer/slaf.test.js index 028bb1910..73a2beb65 100644 --- a/tests/lib/model/nns/onnx/layer/slaf.test.js +++ b/tests/lib/model/nns/onnx/layer/slaf.test.js @@ -50,7 +50,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { n: 4, a: 2 }])('slaf %p', async param => { + test.each([{}, { n: 4, a: 2 }])('slaf %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'slaf', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/slu.test.js b/tests/lib/model/nns/onnx/layer/slu.test.js index 479efdcbe..65ed66868 100644 --- a/tests/lib/model/nns/onnx/layer/slu.test.js +++ b/tests/lib/model/nns/onnx/layer/slu.test.js @@ -7,7 +7,7 @@ import SluLayer from '../../../../../../lib/model/nns/layer/slu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], alpha: 3, beta: 4, gamma: 5 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], alpha: 3, beta: 4, gamma: 5 }])('%j', param => { const model = ONNXExporter.createONNXModel() slu.export(model, { type: 'slu', ...param }) const nodes = model.getGraph().getNodeList() @@ -34,7 +34,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { alpha: 3, beta: 4, gamma: 5 }])('slu %p', async param => { + test.each([{}, { alpha: 3, beta: 4, gamma: 5 }])('slu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'slu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/soft_shrink.test.js b/tests/lib/model/nns/onnx/layer/soft_shrink.test.js index 7cbaf1239..fb05ab781 100644 --- a/tests/lib/model/nns/onnx/layer/soft_shrink.test.js +++ b/tests/lib/model/nns/onnx/layer/soft_shrink.test.js @@ -7,7 +7,7 @@ import SoftShrinkLayer from '../../../../../../lib/model/nns/layer/soft_shrink.j import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], l: 1 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], l: 1 }])('%j', param => { const model = ONNXExporter.createONNXModel() soft_shrink.export(model, { type: 'soft_shrink', ...param }) const nodes = model.getGraph().getNodeList() @@ -23,7 +23,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { l: 1 }])('soft_shrink %p', async param => { + test.each([{}, { l: 1 }])('soft_shrink %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'soft_shrink', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/softmax.test.js b/tests/lib/model/nns/onnx/layer/softmax.test.js index cab7cf279..e28481cee 100644 --- a/tests/lib/model/nns/onnx/layer/softmax.test.js +++ b/tests/lib/model/nns/onnx/layer/softmax.test.js @@ -7,7 +7,7 @@ import SoftmaxLayer from '../../../../../../lib/model/nns/layer/softmax.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], axis: 0 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], axis: 0 }])('%j', param => { const model = ONNXExporter.createONNXModel() softmax.export(model, { type: 'softmax', ...param }) const nodes = model.getGraph().getNodeList() @@ -23,7 +23,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { axis: 0 }])('softmax %p', async param => { + test.each([{}, { axis: 0 }])('softmax %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'softmax', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/softmin.test.js b/tests/lib/model/nns/onnx/layer/softmin.test.js index a432f6b6a..b65747528 100644 --- a/tests/lib/model/nns/onnx/layer/softmin.test.js +++ b/tests/lib/model/nns/onnx/layer/softmin.test.js @@ -7,7 +7,7 @@ import SoftminLayer from '../../../../../../lib/model/nns/layer/softmin.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], axis: 0 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], axis: 0 }])('%j', param => { const model = ONNXExporter.createONNXModel() softmin.export(model, { type: 'softmin', ...param }) const nodes = model.getGraph().getNodeList() @@ -24,7 +24,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { axis: 0 }])('softmin %p', async param => { + test.each([{}, { axis: 0 }])('softmin %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'softmin', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/softplus.test.js b/tests/lib/model/nns/onnx/layer/softplus.test.js index f08da4995..6b81fb64f 100644 --- a/tests/lib/model/nns/onnx/layer/softplus.test.js +++ b/tests/lib/model/nns/onnx/layer/softplus.test.js @@ -7,7 +7,7 @@ import SoftplusLayer from '../../../../../../lib/model/nns/layer/softplus.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], beta: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], beta: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() softplus.export(model, { type: 'softplus', ...param }) const nodes = model.getGraph().getNodeList() @@ -28,7 +28,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { beta: 2 }])('softplus %p', async param => { + test.each([{}, { beta: 2 }])('softplus %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'softplus', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/softsign.test.js b/tests/lib/model/nns/onnx/layer/softsign.test.js index df43eb8c9..c0005830f 100644 --- a/tests/lib/model/nns/onnx/layer/softsign.test.js +++ b/tests/lib/model/nns/onnx/layer/softsign.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() softsign.export(model, { type: 'softsign', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/sqrt.test.js b/tests/lib/model/nns/onnx/layer/sqrt.test.js index d4a207874..549552322 100644 --- a/tests/lib/model/nns/onnx/layer/sqrt.test.js +++ b/tests/lib/model/nns/onnx/layer/sqrt.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() sqrt.export(model, { type: 'sqrt', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/square.test.js b/tests/lib/model/nns/onnx/layer/square.test.js index 8022f0826..172f46ea6 100644 --- a/tests/lib/model/nns/onnx/layer/square.test.js +++ b/tests/lib/model/nns/onnx/layer/square.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() square.export(model, { type: 'square', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/srelu.test.js b/tests/lib/model/nns/onnx/layer/srelu.test.js index 028bc5d34..c0ab6d32e 100644 --- a/tests/lib/model/nns/onnx/layer/srelu.test.js +++ b/tests/lib/model/nns/onnx/layer/srelu.test.js @@ -7,7 +7,7 @@ import SreluLayer from '../../../../../../lib/model/nns/layer/srelu.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], d: 1 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], d: 1 }])('%j', param => { const model = ONNXExporter.createONNXModel() srelu.export(model, { type: 'srelu', ...param }) const nodes = model.getGraph().getNodeList() @@ -26,7 +26,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { d: 1 }])('srelu %p', async param => { + test.each([{}, { d: 1 }])('srelu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'srelu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/srs.test.js b/tests/lib/model/nns/onnx/layer/srs.test.js index d54d2ea28..fc3d8f6d6 100644 --- a/tests/lib/model/nns/onnx/layer/srs.test.js +++ b/tests/lib/model/nns/onnx/layer/srs.test.js @@ -7,7 +7,7 @@ import SrsLayer from '../../../../../../lib/model/nns/layer/srs.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], alpha: 2, beta: 3 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], alpha: 2, beta: 3 }])('%j', param => { const model = ONNXExporter.createONNXModel() srs.export(model, { type: 'srs', ...param }) const nodes = model.getGraph().getNodeList() @@ -32,7 +32,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { alpha: 3, beta: 4 }])('srs %p', async param => { + test.each([{}, { alpha: 3, beta: 4 }])('srs %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'srs', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/ssigmoid.test.js b/tests/lib/model/nns/onnx/layer/ssigmoid.test.js index 3c6479c94..c37ac1ae1 100644 --- a/tests/lib/model/nns/onnx/layer/ssigmoid.test.js +++ b/tests/lib/model/nns/onnx/layer/ssigmoid.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() ssigmoid.export(model, { type: 'ssigmoid', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/stanh.test.js b/tests/lib/model/nns/onnx/layer/stanh.test.js index 17c119a85..3b23936fb 100644 --- a/tests/lib/model/nns/onnx/layer/stanh.test.js +++ b/tests/lib/model/nns/onnx/layer/stanh.test.js @@ -7,7 +7,7 @@ import StanhLayer from '../../../../../../lib/model/nns/layer/stanh.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 2, b: 3 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 2, b: 3 }])('%j', param => { const model = ONNXExporter.createONNXModel() stanh.export(model, { type: 'stanh', ...param }) const nodes = model.getGraph().getNodeList() @@ -29,7 +29,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 3, b: 4 }])('stanh %p', async param => { + test.each([{}, { a: 3, b: 4 }])('stanh %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'stanh', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/std.test.js b/tests/lib/model/nns/onnx/layer/std.test.js index ef89f4c89..697347f90 100644 --- a/tests/lib/model/nns/onnx/layer/std.test.js +++ b/tests/lib/model/nns/onnx/layer/std.test.js @@ -120,7 +120,7 @@ describe('runtime', () => { [{}, [null, 3], [100, 3], [1, 1]], [{ axis: 0 }, [null, 3], [100, 3], [1, 3]], [{ keepdims: false }, [null, 3], [100, 3], []], - ])('std %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('std %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([{ type: 'input', size: inSize }, { type: 'std', ...param }, { type: 'output' }]) session = await ort.InferenceSession.create(buf) diff --git a/tests/lib/model/nns/onnx/layer/sub.test.js b/tests/lib/model/nns/onnx/layer/sub.test.js index 8a3045bce..7903f322f 100644 --- a/tests/lib/model/nns/onnx/layer/sub.test.js +++ b/tests/lib/model/nns/onnx/layer/sub.test.js @@ -23,7 +23,7 @@ describe('export', () => { expect(nodes[0].getOpType()).toBe('Identity') }) - test.each([3, 4])('array input %p', length => { + test.each([3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() sub.export(model, { type: 'sub', input }) @@ -51,7 +51,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('sub %p', async ins => { + ])('sub %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/layer/sum.test.js b/tests/lib/model/nns/onnx/layer/sum.test.js index 6edb4b838..bfd4f7945 100644 --- a/tests/lib/model/nns/onnx/layer/sum.test.js +++ b/tests/lib/model/nns/onnx/layer/sum.test.js @@ -96,7 +96,7 @@ describe('runtime', () => { [{}, [null, 3], [100, 3], [1, 1]], [{ axis: 0 }, [null, 3], [100, 3], [1, 3]], [{ keepdims: false }, [null, 3], [100, 3], []], - ])('sum %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('sum %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([{ type: 'input', size: inSize }, { type: 'sum', ...param }, { type: 'output' }]) session = await ort.InferenceSession.create(buf) diff --git a/tests/lib/model/nns/onnx/layer/swish.test.js b/tests/lib/model/nns/onnx/layer/swish.test.js index be9a871b2..f19dd80ac 100644 --- a/tests/lib/model/nns/onnx/layer/swish.test.js +++ b/tests/lib/model/nns/onnx/layer/swish.test.js @@ -7,7 +7,7 @@ import SwishLayer from '../../../../../../lib/model/nns/layer/swish.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], beta: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], beta: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() swish.export(model, { type: 'swish', ...param }) const nodes = model.getGraph().getNodeList() @@ -28,7 +28,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { beta: 2 }])('swish %p', async param => { + test.each([{}, { beta: 2 }])('swish %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'swish', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/taf.test.js b/tests/lib/model/nns/onnx/layer/taf.test.js index 9aaecc4c3..8698ebe05 100644 --- a/tests/lib/model/nns/onnx/layer/taf.test.js +++ b/tests/lib/model/nns/onnx/layer/taf.test.js @@ -7,7 +7,7 @@ import TafLayer from '../../../../../../lib/model/nns/layer/taf.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 1, b: 2 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 1, b: 2 }])('%j', param => { const model = ONNXExporter.createONNXModel() taf.export(model, { type: 'taf', ...param }) const nodes = model.getGraph().getNodeList() @@ -31,7 +31,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 1, b: 2 }])('taf %p', async param => { + test.each([{}, { a: 1, b: 2 }])('taf %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'taf', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/tan.test.js b/tests/lib/model/nns/onnx/layer/tan.test.js index 2aeb8f464..a4a872d0c 100644 --- a/tests/lib/model/nns/onnx/layer/tan.test.js +++ b/tests/lib/model/nns/onnx/layer/tan.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() tan.export(model, { type: 'tan', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/tanh.test.js b/tests/lib/model/nns/onnx/layer/tanh.test.js index 274a98044..19c0c6b3c 100644 --- a/tests/lib/model/nns/onnx/layer/tanh.test.js +++ b/tests/lib/model/nns/onnx/layer/tanh.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() tanh.export(model, { type: 'tanh', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/tanhexp.test.js b/tests/lib/model/nns/onnx/layer/tanhexp.test.js index 9e051aaab..f875f7b6a 100644 --- a/tests/lib/model/nns/onnx/layer/tanhexp.test.js +++ b/tests/lib/model/nns/onnx/layer/tanhexp.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() tanhexp.export(model, { type: 'tanhexp', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/tanhshrink.test.js b/tests/lib/model/nns/onnx/layer/tanhshrink.test.js index f6f96ef45..b15f2318b 100644 --- a/tests/lib/model/nns/onnx/layer/tanhshrink.test.js +++ b/tests/lib/model/nns/onnx/layer/tanhshrink.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each(['x', ['x']])('input %p', input => { + test.each(['x', ['x']])('input %j', input => { const model = ONNXExporter.createONNXModel() tanhshrink.export(model, { type: 'tanhshrink', input }) const nodes = model.getGraph().getNodeList() diff --git a/tests/lib/model/nns/onnx/layer/thresholded_relu.test.js b/tests/lib/model/nns/onnx/layer/thresholded_relu.test.js index fc39a0a40..8aef6f063 100644 --- a/tests/lib/model/nns/onnx/layer/thresholded_relu.test.js +++ b/tests/lib/model/nns/onnx/layer/thresholded_relu.test.js @@ -7,7 +7,7 @@ import ThresholdedReluLayer from '../../../../../../lib/model/nns/layer/threshol import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([{ input: 'x' }, { input: ['x'], a: 1 }])('%p', param => { + test.each([{ input: 'x' }, { input: ['x'], a: 1 }])('%j', param => { const model = ONNXExporter.createONNXModel() thresholded_relu.export(model, { type: 'thresholded_relu', ...param }) const nodes = model.getGraph().getNodeList() @@ -23,7 +23,7 @@ describe('runtime', () => { session = null }) - test.each([{}, { a: 1 }])('thresholded_relu %p', async param => { + test.each([{}, { a: 1 }])('thresholded_relu %j', async param => { const buf = ONNXExporter.dump([ { type: 'input', size: [null, 3] }, { type: 'thresholded_relu', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/transpose.test.js b/tests/lib/model/nns/onnx/layer/transpose.test.js index 604b66ad2..f172e27c0 100644 --- a/tests/lib/model/nns/onnx/layer/transpose.test.js +++ b/tests/lib/model/nns/onnx/layer/transpose.test.js @@ -10,7 +10,7 @@ describe('export', () => { test.each([ [{ input: 'x', axis: [1, 0] }, [2, 3], [3, 2]], [{ input: ['x'], axis: [1, 2, 0] }, [2, 3, 4], [3, 4, 2]], - ])('%p', (param, inSize, outSize) => { + ])('%j', (param, inSize, outSize) => { const model = ONNXExporter.createONNXModel() const info = transpose.export(model, { type: 'transpose', ...param }, { x: { size: inSize } }) expect(info.size).toEqual(outSize) @@ -32,7 +32,7 @@ describe('runtime', () => { [{ axis: [1, 0] }, [null, 3], [100, 3], [3, 100]], [{ axis: [2, 1, 0] }, [1, 2, 3], [1, 2, 3], [3, 2, 1]], [{ axis: [2, 0, 1] }, [1, 2, 3], [1, 2, 3], [3, 1, 2]], - ])('transpose %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('transpose %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'transpose', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/up_sampling.test.js b/tests/lib/model/nns/onnx/layer/up_sampling.test.js index e746526fb..d0c0f6465 100644 --- a/tests/lib/model/nns/onnx/layer/up_sampling.test.js +++ b/tests/lib/model/nns/onnx/layer/up_sampling.test.js @@ -11,7 +11,7 @@ describe('export', () => { [{ input: 'x', size: [2, 2] }, [1, 2, 2, 3], [1, 4, 4, 3], [1, 2, 2, 1]], [{ input: ['x'], size: 2 }, [1, 2, 2, 3], [1, 4, 4, 3], [1, 2, 2, 1]], [{ input: 'x', size: [2, 2], channel_dim: 1 }, [1, 3, 2, 2], [1, 3, 4, 4], [1, 1, 2, 2]], - ])('%p', (param, inSize, outSize, scale) => { + ])('%j', (param, inSize, outSize, scale) => { const model = ONNXExporter.createONNXModel() const info = upsamplinlg.export(model, { type: 'up_samplinlg', ...param }, { x: { size: inSize } }) expect(info.size).toEqual(outSize) diff --git a/tests/lib/model/nns/onnx/layer/variance.test.js b/tests/lib/model/nns/onnx/layer/variance.test.js index 2f49b02d7..62ee1f573 100644 --- a/tests/lib/model/nns/onnx/layer/variance.test.js +++ b/tests/lib/model/nns/onnx/layer/variance.test.js @@ -122,7 +122,7 @@ describe('runtime', () => { [{}, [null, 3], [100, 3], [1, 1]], [{ axis: 0 }, [null, 3], [100, 3], [1, 3]], [{ keepdims: false }, [null, 3], [100, 3], []], - ])('variance %p %p %p %p', async (param, inSize, actualSize, outSize) => { + ])('variance %j %j %j %j', async (param, inSize, actualSize, outSize) => { const buf = ONNXExporter.dump([ { type: 'input', size: inSize }, { type: 'variance', ...param }, diff --git a/tests/lib/model/nns/onnx/layer/xor.test.js b/tests/lib/model/nns/onnx/layer/xor.test.js index b9b49ee9a..b4398b62e 100644 --- a/tests/lib/model/nns/onnx/layer/xor.test.js +++ b/tests/lib/model/nns/onnx/layer/xor.test.js @@ -7,7 +7,7 @@ import Layer from '../../../../../../lib/model/nns/layer/base.js' import Matrix from '../../../../../../lib/util/matrix.js' describe('export', () => { - test.each([2, 3, 4])('array input %p', length => { + test.each([2, 3, 4])('array input %j', length => { const input = Array.from({ length }, (_, i) => String.fromCharCode('a'.charCodeAt(0) + i)) const model = ONNXExporter.createONNXModel() const types = Object.fromEntries( @@ -53,7 +53,7 @@ describe('runtime', () => { { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 1], s: [null, 1] } }, { x1: { a: [100, 3], s: [null, 3] } }, { x1: { a: [100, 3], s: [null, 3] }, x2: { a: [100, 3], s: [null, 3] }, x3: { a: [100, 3], s: [null, 3] } }, - ])('xor %p', async ins => { + ])('xor %j', async ins => { const inputNames = Object.keys(ins) const buf = ONNXExporter.dump([ ...inputNames.map(i => ({ type: 'input', name: i, size: ins[i].s })), diff --git a/tests/lib/model/nns/onnx/onnx_exporter.test.js b/tests/lib/model/nns/onnx/onnx_exporter.test.js index 8a3e2b4a2..33403a149 100644 --- a/tests/lib/model/nns/onnx/onnx_exporter.test.js +++ b/tests/lib/model/nns/onnx/onnx_exporter.test.js @@ -1,4 +1,3 @@ -import { jest } from '@jest/globals' import * as ort from 'onnxruntime-web' ort.env.wasm.numThreads = 1 @@ -85,7 +84,7 @@ describe('export', () => { }) describe('broadcast size', () => { - test.each([[[1, 3]], [[3]]])('dimension %p', async x1size => { + test.each([[[1, 3]], [[3]]])('dimension %j', async x1size => { const nodes = [ { type: 'input', size: x1size, name: 'x1' }, { type: 'input', size: [5, 3], name: 'x2' }, @@ -140,7 +139,7 @@ describe('export', () => { let orgConsoleError = null beforeAll(() => { orgConsoleError = console.error - console.error = jest.fn() + console.error = vi.fn() }) afterAll(() => { diff --git a/tests/lib/model/nns/onnx/onnx_importer.test.js b/tests/lib/model/nns/onnx/onnx_importer.test.js index fc8153935..2f014b0c7 100644 --- a/tests/lib/model/nns/onnx/onnx_importer.test.js +++ b/tests/lib/model/nns/onnx/onnx_importer.test.js @@ -3,8 +3,6 @@ import path from 'path' import url from 'url' import { Blob } from 'buffer' -import { jest } from '@jest/globals' - import ONNXImporter from '../../../../../lib/model/nns/onnx/onnx_importer' const filepath = path.dirname(url.fileURLToPath(import.meta.url)) @@ -67,7 +65,7 @@ describe('import', () => { let orgConsoleError = null beforeAll(() => { orgConsoleError = console.error - console.error = jest.fn() + console.error = vi.fn() }) afterAll(() => { diff --git a/tests/lib/model/nns/onnx/onnx_models.test.js b/tests/lib/model/nns/onnx/onnx_models.test.js index 64ce03a42..87cade3b6 100644 --- a/tests/lib/model/nns/onnx/onnx_models.test.js +++ b/tests/lib/model/nns/onnx/onnx_models.test.js @@ -20,7 +20,7 @@ describe('import', () => { } }) - test('squeezenet1.0-12.onnx', async () => { + test('squeezenet1.0-12.onnx', { timeout: 60000 }, async () => { const buf = await fs.promises.readFile(`${filepath}/models/squeezenet1.0-12.onnx`) const net = await NeuralNetwork.fromONNX(buf) expect(net).toBeDefined() diff --git a/tests/lib/model/nns/optimizer/adabelief.test.js b/tests/lib/model/nns/optimizer/adabelief.test.js index 36419db19..80345315a 100644 --- a/tests/lib/model/nns/optimizer/adabelief.test.js +++ b/tests/lib/model/nns/optimizer/adabelief.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -89,7 +86,7 @@ describe('adabelief', () => { }) }) -test('nn', () => { +test('nn', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/adabound.test.js b/tests/lib/model/nns/optimizer/adabound.test.js index 8cd7bbcfc..693ab0c5c 100644 --- a/tests/lib/model/nns/optimizer/adabound.test.js +++ b/tests/lib/model/nns/optimizer/adabound.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -97,7 +94,7 @@ describe('adabound', () => { }) }) -test('nn', () => { +test('nn', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/adadelta.test.js b/tests/lib/model/nns/optimizer/adadelta.test.js index d85795531..90e81b604 100644 --- a/tests/lib/model/nns/optimizer/adadelta.test.js +++ b/tests/lib/model/nns/optimizer/adadelta.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -82,7 +79,7 @@ describe('adadelta', () => { }) }) -test('nn', () => { +test('nn', { retry: 3, timeout: 10000 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/adagrad.test.js b/tests/lib/model/nns/optimizer/adagrad.test.js index f097667d4..a7863f9f4 100644 --- a/tests/lib/model/nns/optimizer/adagrad.test.js +++ b/tests/lib/model/nns/optimizer/adagrad.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -69,7 +66,7 @@ describe('adagrad', () => { }) }) -test('nn', () => { +test('nn', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/adam.test.js b/tests/lib/model/nns/optimizer/adam.test.js index 2ff227d0e..3f9c3f2ee 100644 --- a/tests/lib/model/nns/optimizer/adam.test.js +++ b/tests/lib/model/nns/optimizer/adam.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -87,7 +84,7 @@ describe('adam', () => { }) }) -test('nn', () => { +test('nn', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/adamax.test.js b/tests/lib/model/nns/optimizer/adamax.test.js index 285ebd722..690381a28 100644 --- a/tests/lib/model/nns/optimizer/adamax.test.js +++ b/tests/lib/model/nns/optimizer/adamax.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -83,7 +80,7 @@ describe('adamax', () => { }) }) -test('nn', () => { +test('nn', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/amsbound.test.js b/tests/lib/model/nns/optimizer/amsbound.test.js index 885e5c578..dd6ffbc2e 100644 --- a/tests/lib/model/nns/optimizer/amsbound.test.js +++ b/tests/lib/model/nns/optimizer/amsbound.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -104,7 +101,7 @@ describe('amsbound', () => { }) }) -test('nn', () => { +test('nn', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/amsgrad.test.js b/tests/lib/model/nns/optimizer/amsgrad.test.js index 55d5657cb..4c0be55c9 100644 --- a/tests/lib/model/nns/optimizer/amsgrad.test.js +++ b/tests/lib/model/nns/optimizer/amsgrad.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -59,7 +56,7 @@ describe('amsgrad', () => { } }) - test('tensor', () => { + test('tensor', { retry: 3 }, () => { const opt = new AMSGradOptimizer(0.1) const manager = opt.manager() const beta1 = 0.9 diff --git a/tests/lib/model/nns/optimizer/nadam.test.js b/tests/lib/model/nns/optimizer/nadam.test.js index 1028e06a8..3122c42de 100644 --- a/tests/lib/model/nns/optimizer/nadam.test.js +++ b/tests/lib/model/nns/optimizer/nadam.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -95,7 +92,7 @@ describe('nadam', () => { }) }) -test('nn', () => { +test('nn', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/rmsprop.test.js b/tests/lib/model/nns/optimizer/rmsprop.test.js index 785d47756..8f4beebaf 100644 --- a/tests/lib/model/nns/optimizer/rmsprop.test.js +++ b/tests/lib/model/nns/optimizer/rmsprop.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -49,7 +46,7 @@ describe('rmsprop', () => { } }) - test('tensor', () => { + test('tensor', { retry: 3 }, () => { const opt = new RMSPropOptimizer(0.1) const manager = opt.manager() const beta = 0.999 @@ -72,7 +69,7 @@ describe('rmsprop', () => { }) }) -test('nn', () => { +test('nn', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/rmspropgraves.test.js b/tests/lib/model/nns/optimizer/rmspropgraves.test.js index 8e85edf7f..5847c1545 100644 --- a/tests/lib/model/nns/optimizer/rmspropgraves.test.js +++ b/tests/lib/model/nns/optimizer/rmspropgraves.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -80,7 +77,7 @@ describe('rmspropgraves', () => { }) }) -test('nn', () => { +test('nn', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/santae.test.js b/tests/lib/model/nns/optimizer/santae.test.js index 26f445027..2fc9d7e9f 100644 --- a/tests/lib/model/nns/optimizer/santae.test.js +++ b/tests/lib/model/nns/optimizer/santae.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(20) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -15,7 +12,7 @@ describe('santae', () => { }) describe('delta', () => { - test('scalar', () => { + test('scalar', { retry: 20 }, () => { const opt = new SantaEOptimizer(0.1, 0.95, 5) opt._z = () => 0.02 const manager = opt.manager() @@ -50,7 +47,7 @@ describe('santae', () => { } }) - test('matrix', () => { + test('matrix', { retry: 20 }, () => { const opt = new SantaEOptimizer(0.1, 0.95, 5) opt._z = () => 0.02 const manager = opt.manager() @@ -94,7 +91,7 @@ describe('santae', () => { } }) - test('tensor', () => { + test('tensor', { retry: 20 }, () => { const opt = new SantaEOptimizer(0.1, 0.95, 5) opt._z = () => 0.02 const manager = opt.manager() @@ -142,7 +139,7 @@ describe('santae', () => { }) }) -test('nn', () => { +test('nn', { retry: 20 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/santasss.test.js b/tests/lib/model/nns/optimizer/santasss.test.js index ca783775f..3db802edc 100644 --- a/tests/lib/model/nns/optimizer/santasss.test.js +++ b/tests/lib/model/nns/optimizer/santasss.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -160,7 +157,7 @@ describe('santasss', () => { }) }) -test('nn', () => { +test('nn', { retry: 10 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/nns/optimizer/smorms3.test.js b/tests/lib/model/nns/optimizer/smorms3.test.js index 3b0c0b4da..a2ba64fb8 100644 --- a/tests/lib/model/nns/optimizer/smorms3.test.js +++ b/tests/lib/model/nns/optimizer/smorms3.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import NeuralNetwork from '../../../../../lib/model/neuralnetwork.js' import Matrix from '../../../../../lib/util/matrix.js' @@ -93,7 +90,7 @@ describe('SMORMS3', () => { }) }) -test('nn', () => { +test('nn', { retry: 3 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/ocsvm.test.js b/tests/lib/model/ocsvm.test.js index e70f53ae0..6909fdcc6 100644 --- a/tests/lib/model/ocsvm.test.js +++ b/tests/lib/model/ocsvm.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import OCSVM from '../../../lib/model/ocsvm.js' describe('anomaly detection', () => { - test.each(['gaussian', { name: 'gaussian', d: 0.8 }])('%p', kernel => { + test.each(['gaussian', { name: 'gaussian', d: 0.8 }])('%j', kernel => { const model = new OCSVM(1, kernel) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) @@ -25,7 +22,7 @@ describe('anomaly detection', () => { expect(y[y.length - 1]).toBe(true) }) - test.each(['linear', { name: 'linear' }])('%p', kernel => { + test.each(['linear', { name: 'linear' }])('%j', kernel => { const model = new OCSVM(1, kernel) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([-10, -10]) @@ -37,7 +34,7 @@ describe('anomaly detection', () => { expect(y).toHaveLength(x.length) }) - test('custom kernel', () => { + test('custom kernel', { retry: 5 }, () => { const model = new OCSVM(1, (a, b) => Math.exp(-4 * a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2)) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) diff --git a/tests/lib/model/odin.test.js b/tests/lib/model/odin.test.js index 22b376f90..42c8e75c9 100644 --- a/tests/lib/model/odin.test.js +++ b/tests/lib/model/odin.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import ODIN from '../../../lib/model/odin.js' describe('anomaly detection', () => { - test('default', () => { + test('default', { retry: 5 }, () => { const model = new ODIN() const x = Matrix.random(100, 2, 0, 0.2).toArray() x.push([10, 10]) @@ -16,7 +13,7 @@ describe('anomaly detection', () => { expect(y[y.length - 1]).toBe(true) }) - test('parameter', () => { + test('parameter', { retry: 5 }, () => { const model = new ODIN(5, 0) const x = Matrix.random(100, 2, 0, 0.2).toArray() x.push([10, 10]) diff --git a/tests/lib/model/optics.test.js b/tests/lib/model/optics.test.js index adec0de6d..12574a898 100644 --- a/tests/lib/model/optics.test.js +++ b/tests/lib/model/optics.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import OPTICS from '../../../lib/model/optics.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test.each([undefined, 'euclid', 'manhattan', 'chebyshev'])('%s', metric => { + test.each([undefined, 'euclid', 'manhattan', 'chebyshev'])('%s', { retry: 5 }, metric => { const model = new OPTICS(0.4, undefined, undefined, metric) const n = 100 const x = Matrix.concat( @@ -27,7 +24,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.9) }) - test.each([(a, b) => a.reduce((s, v, i) => s + Math.exp((v - b[i]) ** 2) - 1, 0)])('%s', metric => { + test.each([(a, b) => a.reduce((s, v, i) => s + Math.exp((v - b[i]) ** 2) - 1, 0)])('%s', { retry: 5 }, metric => { const model = new OPTICS(0.3, undefined, undefined, metric) const n = 100 const x = Matrix.concat( diff --git a/tests/lib/model/orclus.test.js b/tests/lib/model/orclus.test.js index d819f81e8..5f77de345 100644 --- a/tests/lib/model/orclus.test.js +++ b/tests/lib/model/orclus.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import ORCLUS from '../../../lib/model/orclus.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test('clustering', () => { +test('clustering', { retry: 3 }, () => { const model = new ORCLUS(3, 20, 4) const n = 100 const x = Matrix.concat( diff --git a/tests/lib/model/ordered_probit.test.js b/tests/lib/model/ordered_probit.test.js index 7c53fc552..21b770f9a 100644 --- a/tests/lib/model/ordered_probit.test.js +++ b/tests/lib/model/ordered_probit.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import OrderedProbitRegression from '../../../lib/model/ordered_probit.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('ordinal', () => { - test('fit', () => { + test('fit', { retry: 5 }, () => { const model = new OrderedProbitRegression() const x = Matrix.concat( Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 2, 0.2)), diff --git a/tests/lib/model/particle_filter.test.js b/tests/lib/model/particle_filter.test.js index 28030a784..048725148 100644 --- a/tests/lib/model/particle_filter.test.js +++ b/tests/lib/model/particle_filter.test.js @@ -2,7 +2,7 @@ import ParticleFilter from '../../../lib/model/particle_filter.js' import { rmse } from '../../../lib/evaluate/regression.js' -test('smoothing', () => { +test('smoothing', { timeout: 10000 }, () => { const x = [] const t = [] for (let i = 0; i < 100; i++) { diff --git a/tests/lib/model/passing_bablok.test.js b/tests/lib/model/passing_bablok.test.js index 129f23681..304a37c23 100644 --- a/tests/lib/model/passing_bablok.test.js +++ b/tests/lib/model/passing_bablok.test.js @@ -3,7 +3,7 @@ import PassingBablok from '../../../lib/model/passing_bablok.js' import { rmse } from '../../../lib/evaluate/regression.js' -test.each([50, 49])('fit n:%p', n => { +test.each([50, 49])('fit n:%j', n => { const model = new PassingBablok() const x = Matrix.randn(n, 1, 0, 5).value const t = [] diff --git a/tests/lib/model/passive_aggressive.test.js b/tests/lib/model/passive_aggressive.test.js index 95447caff..d68603218 100644 --- a/tests/lib/model/passive_aggressive.test.js +++ b/tests/lib/model/passive_aggressive.test.js @@ -3,7 +3,7 @@ import PA from '../../../lib/model/passive_aggressive' import { accuracy } from '../../../lib/evaluate/classification.js' -describe.each([undefined, 0, 1, 2])('version %p', v => { +describe.each([undefined, 0, 1, 2])('version %j', v => { test('default', () => { const model = new PA(v) expect(model._c).toBe(0.1) diff --git a/tests/lib/model/pca.test.js b/tests/lib/model/pca.test.js index 90ddd5fa2..7b2f9b52f 100644 --- a/tests/lib/model/pca.test.js +++ b/tests/lib/model/pca.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import { PCA, DualPCA, KernelPCA, AnomalyPCA } from '../../../lib/model/pca.js' @@ -99,7 +96,7 @@ describe.each(['gaussian', { name: 'gaussian', sigma: 1.0 }, 'polynomial', { nam ) describe('custom kernel', () => { - test('project', () => { + test('project', { retry: 3 }, () => { const model = new KernelPCA((a, b) => Math.exp(-2 * a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2)) const x = Matrix.concat(Matrix.random(20, 5, -2, 2), Matrix.random(20, 5, 5, 8)).toArray() diff --git a/tests/lib/model/pcm.test.js b/tests/lib/model/pcm.test.js index 32c91d110..f5a477ce2 100644 --- a/tests/lib/model/pcm.test.js +++ b/tests/lib/model/pcm.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(20) - import Matrix from '../../../lib/util/matrix.js' import PossibilisticCMeans from '../../../lib/model/pcm.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test.each([undefined, 3])('predict %p', m => { +test.each([undefined, 3])('predict %j', { retry: 20 }, m => { const model = new PossibilisticCMeans(m) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/pelt.test.js b/tests/lib/model/pelt.test.js index 1ff293306..ab6d4dd75 100644 --- a/tests/lib/model/pelt.test.js +++ b/tests/lib/model/pelt.test.js @@ -1,11 +1,8 @@ -import { jest, test } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import PELT from '../../../lib/model/pelt.js' describe('change point detection', () => { - test.each([undefined, 'rbf'])('cost %p', cost => { + test.each([undefined, 'rbf'])('cost %j', { retry: 3 }, cost => { const model = new PELT(0, cost) const n = 50 const x = Matrix.concat( @@ -26,7 +23,7 @@ describe('change point detection', () => { const mean = Array.from(d[0], (_, i) => d.slice(s, e).reduce((s, v) => s + v[i], 0) / (e - s)) return d.slice(s, e).reduce((s, r) => s + r.reduce((t, v, i) => t + Math.abs(v - mean[i]), 0), 0) }, - ])('cost %p', cost => { + ])('cost %j', { retry: 3 }, cost => { const model = new PELT(1.0, cost) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/plsa.test.js b/tests/lib/model/plsa.test.js index 4278901f1..9850c849d 100644 --- a/tests/lib/model/plsa.test.js +++ b/tests/lib/model/plsa.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import PLSA from '../../../lib/model/plsa.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test.each([undefined, 2])('plsa %p', k => { +test.each([undefined, 2])('plsa %j', { retry: 3 }, k => { const model = new PLSA(k) const n = 50 const x = Matrix.map(Matrix.concat(Matrix.random(n, 10, 0, 5), Matrix.random(n, 10, 4, 9)), v => diff --git a/tests/lib/model/poisson.test.js b/tests/lib/model/poisson.test.js index 27cd3c6a0..0e683ce92 100644 --- a/tests/lib/model/poisson.test.js +++ b/tests/lib/model/poisson.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import PoissonRegression from '../../../lib/model/poisson.js' import { rmse } from '../../../lib/evaluate/regression.js' -test('fit', () => { +test('fit', { retry: 3 }, () => { const model = new PoissonRegression(0.1) const x = Matrix.random(50, 2, 0, 2).toArray() const t = [] diff --git a/tests/lib/model/policy_gradient.test.js b/tests/lib/model/policy_gradient.test.js index e31e16aeb..a945b65c1 100644 --- a/tests/lib/model/policy_gradient.test.js +++ b/tests/lib/model/policy_gradient.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import PGAgent from '../../../lib/model/policy_gradient.js' import GridRLEnvironment from '../../../lib/rl/grid.js' import InHypercubeRLEnvironment from '../../../lib/rl/inhypercube.js' @@ -21,7 +18,7 @@ describe('constructor', () => { }) }) -test('update', () => { +test('update', { retry: 3 }, () => { const env = new GridRLEnvironment() env._size = [5, 5] const agent = new PGAgent(env, env.size[0]) diff --git a/tests/lib/model/polynomial_histogram.test.js b/tests/lib/model/polynomial_histogram.test.js index 82ab25104..24670533a 100644 --- a/tests/lib/model/polynomial_histogram.test.js +++ b/tests/lib/model/polynomial_histogram.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import PolynomialHistogram from '../../../lib/model/polynomial_histogram.js' @@ -17,7 +14,7 @@ describe('density estimation', () => { expect(y).toHaveLength(x.length) }) - test('1', () => { + test('1', { retry: 3 }, () => { const model = new PolynomialHistogram(1, 2) const n = 500 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() @@ -36,7 +33,7 @@ describe('density estimation', () => { expect(corr).toBeGreaterThan(0.1) }) - test.each([0, 2, undefined])('%p', p => { + test.each([0, 2, undefined])('%j', p => { const model = new PolynomialHistogram(p, 2) const n = 500 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() diff --git a/tests/lib/model/polynomial_interpolation.test.js b/tests/lib/model/polynomial_interpolation.test.js index 468fd9bf1..5ebfbeb45 100644 --- a/tests/lib/model/polynomial_interpolation.test.js +++ b/tests/lib/model/polynomial_interpolation.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import PolynomialInterpolation from '../../../lib/model/polynomial_interpolation.js' import { rmse } from '../../../lib/evaluate/regression.js' -test('interpolation', () => { +test('interpolation', { retry: 3 }, () => { const model = new PolynomialInterpolation() const x = Matrix.random(20, 1, -2, 2).value const t = [] diff --git a/tests/lib/model/ppr.test.js b/tests/lib/model/ppr.test.js index fff9d35a4..f18174aa4 100644 --- a/tests/lib/model/ppr.test.js +++ b/tests/lib/model/ppr.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import ProjectionPursuit from '../../../lib/model/ppr.js' import { rmse } from '../../../lib/evaluate/regression.js' -test.each([undefined, 5])('fit %p', r => { +test.each([undefined, 5])('fit %j', { retry: 3 }, r => { const model = new ProjectionPursuit(r) const x = Matrix.random(50, 2, -2, 2).toArray() const t = [] diff --git a/tests/lib/model/principal_curve.test.js b/tests/lib/model/principal_curve.test.js index 8f189e693..b99b3fbae 100644 --- a/tests/lib/model/principal_curve.test.js +++ b/tests/lib/model/principal_curve.test.js @@ -3,7 +3,7 @@ import PrincipalCurve from '../../../lib/model/principal_curve.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' -test('dimensionality reduction', () => { +test('dimensionality reduction', { timeout: 30000 }, () => { const x = Matrix.concat(Matrix.randn(50, 5, 0, 0.2), Matrix.randn(50, 5, 5, 0.2)).toArray() const model = new PrincipalCurve() diff --git a/tests/lib/model/probabilistic_pca.test.js b/tests/lib/model/probabilistic_pca.test.js index ed173ae4f..72189726b 100644 --- a/tests/lib/model/probabilistic_pca.test.js +++ b/tests/lib/model/probabilistic_pca.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import ProbabilisticPCA from '../../../lib/model/probabilistic_pca.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' -test.each([undefined, 'analysis'])('ppca %p', method => { +test.each([undefined, 'analysis'])('ppca %j', { retry: 3 }, method => { const model = new ProbabilisticPCA(method, 9) const x = Matrix.randn(300, 10, 0, Matrix.diag([1.0, 0.1, 1.0, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 0.1])).toArray() @@ -16,7 +13,7 @@ test.each([undefined, 'analysis'])('ppca %p', method => { expect(q).toBeGreaterThan(0.9) }) -test.each(['em', 'bayes'])('ppca %s', method => { +test.each(['em', 'bayes'])('ppca %s', { retry: 3 }, method => { const model = new ProbabilisticPCA(method, 8) const x = Matrix.randn(300, 10, 0, Matrix.diag([1.0, 0.1, 1.0, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 0.1])).toArray() diff --git a/tests/lib/model/probit.test.js b/tests/lib/model/probit.test.js index bcc7f90f9..46847789e 100644 --- a/tests/lib/model/probit.test.js +++ b/tests/lib/model/probit.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import { Probit, MultinomialProbit } from '../../../lib/model/probit.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('probit', () => { - test('fit', () => { + test('fit', { retry: 5 }, () => { const model = new Probit() const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -25,7 +22,7 @@ describe('probit', () => { }) describe('multinomial', () => { - test('fit', () => { + test('fit', { retry: 5 }, () => { const model = new MultinomialProbit() const n = 20 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() diff --git a/tests/lib/model/proclus.test.js b/tests/lib/model/proclus.test.js index 4b9efd47b..40a0f1060 100644 --- a/tests/lib/model/proclus.test.js +++ b/tests/lib/model/proclus.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import PROCLUS from '../../../lib/model/proclus.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('default', () => { + test('default', { retry: 5 }, () => { const model = new PROCLUS(3, 20, 2, 3) const n = 50 const x = Matrix.concat( @@ -30,7 +27,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.7) }) - test('high min deviation', () => { + test('high min deviation', { retry: 5 }, () => { const model = new PROCLUS(3, 20, 10, 3, 0.9) const n = 50 const x = Matrix.concat( @@ -54,7 +51,7 @@ describe('clustering', () => { }) }) -test('anomaly detection', () => { +test('anomaly detection', { retry: 5 }, () => { const model = new PROCLUS(3, 20, 10, 3, 0.9) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/projectron.test.js b/tests/lib/model/projectron.test.js index 70efbf97a..cc0acb360 100644 --- a/tests/lib/model/projectron.test.js +++ b/tests/lib/model/projectron.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(8) - import Matrix from '../../../lib/util/matrix.js' import { Projectron, Projectronpp } from '../../../lib/model/projectron.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('projectron', () => { - test('default', () => { + test('default', { retry: 8 }, () => { const model = new Projectron() const s = 5 const x = [] @@ -31,7 +28,7 @@ describe('projectron', () => { expect(acc).toBeGreaterThan(0.95) }) - test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', kernel => { + test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', { retry: 8 }, kernel => { const model = new Projectron(0.1, kernel) const s = 5 const x = [] @@ -55,7 +52,7 @@ describe('projectron', () => { expect(acc).toBeGreaterThan(0.95) }) - test.each(['polynomial', { name: 'polynomial' }])('kernel %s', kernel => { + test.each(['polynomial', { name: 'polynomial' }])('kernel %s', { retry: 8 }, kernel => { const model = new Projectron(0.1, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -70,7 +67,7 @@ describe('projectron', () => { expect(acc).toBeGreaterThan(0.55) }) - test('custom kernel', () => { + test('custom kernel', { retry: 8 }, () => { const model = new Projectron(0.1, (a, b) => Math.exp(-2 * a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2)) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -87,7 +84,7 @@ describe('projectron', () => { }) describe('projectron++', () => { - test('default', () => { + test('default', { retry: 8 }, () => { const model = new Projectronpp() const s = 5 const x = [] @@ -111,7 +108,7 @@ describe('projectron++', () => { expect(acc).toBeGreaterThan(0.95) }) - test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', kernel => { + test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', { retry: 8 }, kernel => { const model = new Projectronpp(0.1, kernel) const s = 5 const x = [] @@ -135,7 +132,7 @@ describe('projectron++', () => { expect(acc).toBeGreaterThan(0.95) }) - test.each(['polynomial', { name: 'polynomial' }])('kernel %s', kernel => { + test.each(['polynomial', { name: 'polynomial' }])('kernel %s', { retry: 8 }, kernel => { const model = new Projectronpp(0.1, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -150,7 +147,7 @@ describe('projectron++', () => { expect(acc).toBeGreaterThan(0.8) }) - test('custom kernel', () => { + test('custom kernel', { retry: 8 }, () => { const model = new Projectronpp(0.1, (a, b) => Math.exp(-2 * a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2)) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/ptile.test.js b/tests/lib/model/ptile.test.js index c168fd01c..f8a4775b7 100644 --- a/tests/lib/model/ptile.test.js +++ b/tests/lib/model/ptile.test.js @@ -4,7 +4,7 @@ import PTile from '../../../lib/model/ptile.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test.each([undefined, 0.5])('%p', p => { + test.each([undefined, 0.5])('%j', p => { const model = new PTile(p) const n = 50 const x = Matrix.concat(Matrix.randn(n, 1, 0, 0.1), Matrix.randn(n, 1, 5, 0.1)).value diff --git a/tests/lib/model/quantile_regression.test.js b/tests/lib/model/quantile_regression.test.js index 6b40619dd..7f21ba85c 100644 --- a/tests/lib/model/quantile_regression.test.js +++ b/tests/lib/model/quantile_regression.test.js @@ -3,7 +3,7 @@ import QuantileRegression from '../../../lib/model/quantile_regression.js' import { rmse } from '../../../lib/evaluate/regression.js' -test.each([undefined, 0.5])('fit %p', tau => { +test.each([undefined, 0.5])('fit %j', tau => { const model = new QuantileRegression(tau) const x = Matrix.random(100, 2, -2, 2).toArray() const t = [] diff --git a/tests/lib/model/radius_neighbor.test.js b/tests/lib/model/radius_neighbor.test.js index cd642e5eb..29d8b267a 100644 --- a/tests/lib/model/radius_neighbor.test.js +++ b/tests/lib/model/radius_neighbor.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import { RadiusNeighbor, RadiusNeighborRegression, @@ -135,7 +132,7 @@ describe('semi-classifier', () => { 'chebyshev', 'minkowski', (a, b) => a.reduce((s, v, i) => s + Math.exp((v - b[i]) ** 2) - 1, 0), - ])('%s', metric => { + ])('%s', { retry: 3 }, metric => { const model = new SemiSupervisedRadiusNeighbor(0.5, metric) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/random_projection.test.js b/tests/lib/model/random_projection.test.js index 907ee3c0b..d0ff2cd5d 100644 --- a/tests/lib/model/random_projection.test.js +++ b/tests/lib/model/random_projection.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import RandomProjection from '../../../lib/model/random_projection.js' @@ -15,7 +12,7 @@ describe('dimensionality reduction', () => { expect(q).toBeGreaterThan(0.9) }) - test.each([undefined, 'uniform', 'normal', 'root3'])('%s', method => { + test.each([undefined, 'uniform', 'normal', 'root3'])('%s', { retry: 3 }, method => { const x = Matrix.concat(Matrix.randn(50, 5, 0, 0.2), Matrix.randn(50, 5, 5, 0.2)).toArray() const y = new RandomProjection(method, 2).predict(x) expect(y[0]).toHaveLength(2) diff --git a/tests/lib/model/ranknet.test.js b/tests/lib/model/ranknet.test.js index 1950deb8e..52d221293 100644 --- a/tests/lib/model/ranknet.test.js +++ b/tests/lib/model/ranknet.test.js @@ -4,7 +4,7 @@ import RankNet from '../../../lib/model/ranknet.js' import { correlation } from '../../../lib/evaluate/regression.js' describe('learning to rank', () => { - test.each([undefined, 'identity', 'sigmoid', 'tanh', 'relu', ['tanh']])('%s', activation => { + test.each([undefined, 'identity', 'sigmoid', 'tanh', 'relu', ['tanh']])('%s', { retry: 3 }, activation => { const model = new RankNet([10], activation) let x = Matrix.zeros(30, 2) for (let i = 0; i < x.rows / 10; i++) { diff --git a/tests/lib/model/rbf.test.js b/tests/lib/model/rbf.test.js index 4213bd0db..44d206fd8 100644 --- a/tests/lib/model/rbf.test.js +++ b/tests/lib/model/rbf.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import RadialBasisFunctionNetwork from '../../../lib/model/rbf.js' @@ -32,7 +29,7 @@ describe.each([ expect(err).toBeLessThan(0.5) }) - test('l 0.01', () => { + test('l 0.01', { retry: 5 }, () => { const model = new RadialBasisFunctionNetwork(rbf, undefined, 0.01) const x = Matrix.random(50, 2, 0, 3).toArray() const t = [] diff --git a/tests/lib/model/rbm.test.js b/tests/lib/model/rbm.test.js index 2c8aabdcb..c6a7a1ea3 100644 --- a/tests/lib/model/rbm.test.js +++ b/tests/lib/model/rbm.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import { RBM, GBRBM } from '../../../lib/model/rbm.js' describe('reconstruct RBM', () => { - test('default', () => { + test('default', { retry: 5 }, () => { const model = new RBM(10) const x = [ [1, 1, 1, 1, 0, 0, 0], @@ -25,7 +22,7 @@ describe('reconstruct RBM', () => { expect(y).toEqual(x) }) - test('k=2', () => { + test('k=2', { retry: 5 }, () => { const model = new RBM(10) model._k = 2 const x = [ @@ -47,7 +44,7 @@ describe('reconstruct RBM', () => { }) }) -test('reconstruct GBRBM', () => { +test('reconstruct GBRBM', { retry: 5 }, () => { const model = new GBRBM(10) const x = Matrix.randn(50, 3, 1, 0.3).toArray() model.fit(x) diff --git a/tests/lib/model/rbp.test.js b/tests/lib/model/rbp.test.js index 1df1aa6dc..72eead105 100644 --- a/tests/lib/model/rbp.test.js +++ b/tests/lib/model/rbp.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import RBP from '../../../lib/model/rbp.js' @@ -21,7 +18,7 @@ test('fit', () => { expect(acc).toBeGreaterThan(0.95) }) -test('remove sv', () => { +test('remove sv', { retry: 3 }, () => { const model = new RBP(10) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() x[50] = [0.1, 0.1] diff --git a/tests/lib/model/rdf.test.js b/tests/lib/model/rdf.test.js index 1704945f6..31cbdb9a5 100644 --- a/tests/lib/model/rdf.test.js +++ b/tests/lib/model/rdf.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import RDF from '../../../lib/model/rdf.js' -test.each([undefined, 1])('anomaly detection %p', r => { +test.each([undefined, 1])('anomaly detection %j', { retry: 3 }, r => { const model = new RDF(r) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([1.2, 1.2]) diff --git a/tests/lib/model/rdos.test.js b/tests/lib/model/rdos.test.js index a372f95f9..5ed9ed87d 100644 --- a/tests/lib/model/rdos.test.js +++ b/tests/lib/model/rdos.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import RDOS from '../../../lib/model/rdos.js' describe('anomaly detection', () => { - test.each([undefined, 'gaussian', { name: 'gaussian' }])('kernel %s', kernel => { + test.each([undefined, 'gaussian', { name: 'gaussian' }])('kernel %s', { retry: 5 }, kernel => { const model = new RDOS(5, 0.5, kernel) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) diff --git a/tests/lib/model/ridge.test.js b/tests/lib/model/ridge.test.js index c7c63df80..0f410a319 100644 --- a/tests/lib/model/ridge.test.js +++ b/tests/lib/model/ridge.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import { Ridge, MulticlassRidge, KernelRidge } from '../../../lib/model/ridge.js' @@ -47,7 +44,7 @@ describe('multiclass ridge', () => { expect(model._lambda).toBe(0.1) }) - test('fit', () => { + test('fit', { retry: 5 }, () => { const model = new MulticlassRidge(0.001) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, [0, 5], 0.2)).toArray() const t = [] @@ -98,7 +95,7 @@ describe('kernel ridge', () => { expect(err).toBeLessThan(0.5) }) - test('custom kernel', () => { + test('custom kernel', { retry: 5 }, () => { const model = new KernelRidge(0.01, (a, b) => Math.exp(-2 * a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2)) const x = Matrix.randn(50, 2, 0, 5).toArray() const t = [] diff --git a/tests/lib/model/rkof.test.js b/tests/lib/model/rkof.test.js index 365fdb884..d47b125e1 100644 --- a/tests/lib/model/rkof.test.js +++ b/tests/lib/model/rkof.test.js @@ -1,23 +1,24 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import RKOF from '../../../lib/model/rkof.js' describe('anomaly detection', () => { - test.each([undefined, 'gaussian', { name: 'gaussian' }, 'volcano', { name: 'volcano' }])('kernel %s', kernel => { - const model = new RKOF(5, 0.5, 0.5, kernel) - const x = Matrix.randn(100, 2, 0, 0.2).toArray() - x.push([10, 10]) - const threshold = 5 - const y = model.predict(x).map(v => v > threshold) - for (let i = 0; i < y.length - 1; i++) { - expect(y[i]).toBe(false) + test.each([undefined, 'gaussian', { name: 'gaussian' }, 'volcano', { name: 'volcano' }])( + 'kernel %s', + { retry: 5 }, + kernel => { + const model = new RKOF(5, 0.5, 0.5, kernel) + const x = Matrix.randn(100, 2, 0, 0.2).toArray() + x.push([10, 10]) + const threshold = 5 + const y = model.predict(x).map(v => v > threshold) + for (let i = 0; i < y.length - 1; i++) { + expect(y[i]).toBe(false) + } + expect(y[y.length - 1]).toBe(true) } - expect(y[y.length - 1]).toBe(true) - }) + ) - test.each(['epanechnikov', { name: 'epanechnikov', beta: 0.9 }])('kernel %s', kernel => { + test.each(['epanechnikov', { name: 'epanechnikov', beta: 0.9 }])('kernel %s', { retry: 5 }, kernel => { const model = new RKOF(5, 0.5, 0.5, kernel) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) @@ -29,7 +30,7 @@ describe('anomaly detection', () => { expect(y[y.length - 1]).toBe(true) }) - test('custom kernel', () => { + test('custom kernel', { retry: 5 }, () => { const model = new RKOF(5, 0.5, 0.5, x => (x.reduce((s, v) => s + v ** 2, 0) < 1 ? 1 : 0)) const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) diff --git a/tests/lib/model/rnn.test.js b/tests/lib/model/rnn.test.js index 7793d7a2d..346c447d7 100644 --- a/tests/lib/model/rnn.test.js +++ b/tests/lib/model/rnn.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import RNN from '../../../lib/model/rnn.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('predict', () => { - test('default', () => { + test('default', { retry: 3, timeout: 30000 }, () => { const model = new RNN() expect(model.method).toBe('lstm') const n = 100 @@ -29,7 +26,7 @@ describe('predict', () => { expect(err).toBeLessThan(1.0) }) - test.each([undefined, 'rnn', 'lstm', 'gru'])('%s', method => { + test.each([undefined, 'rnn', 'lstm', 'gru'])('%s', { retry: 3, timeout: 10000 }, method => { const model = new RNN(method, 30, 3, 1, 'adam') expect(model.method).toBe(method ?? 'lstm') const n = 100 diff --git a/tests/lib/model/romma.test.js b/tests/lib/model/romma.test.js index 556b8ea8a..40736baa4 100644 --- a/tests/lib/model/romma.test.js +++ b/tests/lib/model/romma.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import { ROMMA, AggressiveROMMA } from '../../../lib/model/romma.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('romma', () => { - test('fit', () => { + test('fit', { retry: 3 }, () => { const model = new ROMMA() const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() x[49] = [4.9, 4.9] @@ -25,7 +22,7 @@ describe('romma', () => { }) describe('aggressive romma', () => { - test('fit', () => { + test('fit', { retry: 3 }, () => { const model = new AggressiveROMMA() const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/s3vm.test.js b/tests/lib/model/s3vm.test.js index de4587657..dbd30d3d2 100644 --- a/tests/lib/model/s3vm.test.js +++ b/tests/lib/model/s3vm.test.js @@ -1,33 +1,34 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import S3VM from '../../../lib/model/s3vm.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('semi-classifier', () => { - test.each(['gaussian', { name: 'gaussian', d: 0.8 }, 'linear', { name: 'linear' }])('kernel %s', kernel => { - const model = new S3VM(kernel) - const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() - const t = [] - const t_org = [] - for (let i = 0; i < x.length; i++) { - t_org[i] = t[i] = Math.floor(i / 50) * 2 - 1 - if (Math.random() < 0.5) { - t[i] = null + test.each(['gaussian', { name: 'gaussian', d: 0.8 }, 'linear', { name: 'linear' }])( + 'kernel %s', + { retry: 3 }, + kernel => { + const model = new S3VM(kernel) + const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() + const t = [] + const t_org = [] + for (let i = 0; i < x.length; i++) { + t_org[i] = t[i] = Math.floor(i / 50) * 2 - 1 + if (Math.random() < 0.5) { + t[i] = null + } } + model.init(x, t) + for (let i = 0; i < 1000; i++) { + model.fit() + } + const y = model.predict(x) + const acc = accuracy(y.map(Math.sign), t_org.map(Math.sign)) + expect(acc).toBeGreaterThan(0.95) } - model.init(x, t) - for (let i = 0; i < 1000; i++) { - model.fit() - } - const y = model.predict(x) - const acc = accuracy(y.map(Math.sign), t_org.map(Math.sign)) - expect(acc).toBeGreaterThan(0.95) - }) + ) - test('custom kernel', () => { + test('custom kernel', { retry: 3 }, () => { const model = new S3VM((a, b) => Math.exp(-2 * a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2)) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/segmented.test.js b/tests/lib/model/segmented.test.js index a36f9b759..9edb13247 100644 --- a/tests/lib/model/segmented.test.js +++ b/tests/lib/model/segmented.test.js @@ -3,7 +3,7 @@ import SegmentedRegression from '../../../lib/model/segmented.js' import { rmse } from '../../../lib/evaluate/regression.js' -test.each([undefined, 3])('fit seg: %p', seg => { +test.each([undefined, 3])('fit seg: %j', seg => { const model = new SegmentedRegression(seg) const x = Matrix.randn(50, 1, 0, 5).toArray() const t = [] diff --git a/tests/lib/model/selective_sampling_winnow.test.js b/tests/lib/model/selective_sampling_winnow.test.js index 8f11729d6..d7d0b9ef4 100644 --- a/tests/lib/model/selective_sampling_winnow.test.js +++ b/tests/lib/model/selective_sampling_winnow.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import SelectiveSamplingWinnow from '../../../lib/model/selective_sampling_winnow.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('classification', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new SelectiveSamplingWinnow(1) const x = [] const n = 50 diff --git a/tests/lib/model/shifting_perceptron.test.js b/tests/lib/model/shifting_perceptron.test.js index 2ab07e125..23c7727dc 100644 --- a/tests/lib/model/shifting_perceptron.test.js +++ b/tests/lib/model/shifting_perceptron.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import ShiftingPerceptron from '../../../lib/model/shifting_perceptron.js' import { accuracy } from '../../../lib/evaluate/classification.js' -test('fit', () => { +test('fit', { retry: 3 }, () => { const model = new ShiftingPerceptron(1) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/silk.test.js b/tests/lib/model/silk.test.js index b9901467b..6d2396803 100644 --- a/tests/lib/model/silk.test.js +++ b/tests/lib/model/silk.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import { ILK, SILK } from '../../../lib/model/silk.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('ilk classification', () => { - test('default', () => { + test('default', { retry: 5 }, () => { const model = new ILK() const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -28,7 +25,7 @@ describe('ilk classification', () => { 'gaussian', { name: 'gaussian', s: 0.8 }, (a, b) => Math.exp(-(a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2) / 0.01), - ])('kernel %s', kernel => { + ])('kernel %s', { retry: 5 }, kernel => { const model = new ILK(1, 1, 1, kernel, loss) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] @@ -86,7 +83,7 @@ describe('silk classification', () => { 'gaussian', { name: 'gaussian', s: 0.8 }, (a, b) => Math.exp(-(a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2) / 0.01), - ])('kernel %s', kernel => { + ])('kernel %s', { retry: 5 }, kernel => { const model = new SILK(1, 1, 1, 100, kernel, loss) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/sir.test.js b/tests/lib/model/sir.test.js index d2e65ddaf..4cbead5f5 100644 --- a/tests/lib/model/sir.test.js +++ b/tests/lib/model/sir.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import SlicedInverseRegression from '../../../lib/model/sir.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('dimensionality reduction', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const n = 50 const x = Matrix.concat(Matrix.randn(n, 5, 0, 0.2), Matrix.randn(n, 5, 5, 0.2)).toArray() const t = [] diff --git a/tests/lib/model/slerp.test.js b/tests/lib/model/slerp.test.js index d73150707..15404336f 100644 --- a/tests/lib/model/slerp.test.js +++ b/tests/lib/model/slerp.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import Slerp from '../../../lib/model/slerp.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('interpolation', () => { - test.each([undefined, 0])('%p', o => { + test.each([undefined, 0])('%j', { retry: 3 }, o => { const model = new Slerp(o) const x = Matrix.random(20, 1, -2, 2).value const t = [] diff --git a/tests/lib/model/slice_sampling.test.js b/tests/lib/model/slice_sampling.test.js index 51cc39b90..4ca6d2496 100644 --- a/tests/lib/model/slice_sampling.test.js +++ b/tests/lib/model/slice_sampling.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import SliceSampling from '../../../lib/model/slice_sampling.js' -test('sample', () => { +test('sample', { retry: 3 }, () => { const model = new SliceSampling(x => Math.exp(-((x[0] - 3) ** 2) / 2), 1) const s = Matrix.fromArray(model.sample(10000)) diff --git a/tests/lib/model/smoothstep.test.js b/tests/lib/model/smoothstep.test.js index 8756b20f2..51bde342e 100644 --- a/tests/lib/model/smoothstep.test.js +++ b/tests/lib/model/smoothstep.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import SmoothstepInterpolation from '../../../lib/model/smoothstep.js' import { rmse } from '../../../lib/evaluate/regression.js' -test('interpolation', () => { +test('interpolation', { retry: 3 }, () => { const model = new SmoothstepInterpolation() const x = Matrix.random(20, 1, -2, 2).value const t = [] diff --git a/tests/lib/model/som.test.js b/tests/lib/model/som.test.js index 0c6ff160d..de1946737 100644 --- a/tests/lib/model/som.test.js +++ b/tests/lib/model/som.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import SOM from '../../../lib/model/som.js' @@ -8,7 +5,7 @@ import { randIndex } from '../../../lib/evaluate/clustering.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('clustering', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new SOM(2, 1) const n = 50 const x = Matrix.concat( @@ -25,7 +22,7 @@ describe('clustering', () => { expect([...new Set(y)].length).toBeLessThanOrEqual(20) }) - test('init PCA', () => { + test('init PCA', { retry: 3 }, () => { const model = new SOM(2, 1, 3) const n = 50 const x = Matrix.concat( @@ -47,7 +44,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.9) }) - test('init random', () => { + test('init random', { retry: 3 }, () => { const model = new SOM(2, 1, 3) model._init_method = 'random' const n = 50 @@ -71,7 +68,7 @@ describe('clustering', () => { }) }) -test('dimension reduction', () => { +test('dimension reduction', { retry: 3 }, () => { const n = 50 const x = Matrix.concat(Matrix.randn(n, 5, 0, 0.2), Matrix.randn(n, 5, 5, 0.2)).toArray() const model = new SOM(5, 2, 10) diff --git a/tests/lib/model/spectral.test.js b/tests/lib/model/spectral.test.js index 83a79b8c8..ae6b094b7 100644 --- a/tests/lib/model/spectral.test.js +++ b/tests/lib/model/spectral.test.js @@ -3,7 +3,7 @@ import SpectralClustering from '../../../lib/model/spectral.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test.each([undefined, 'rbf', { name: 'rbf', sigma: 0.5 }, { name: 'knn', k: 4 }])('clustering %p', affinity => { +test.each([undefined, 'rbf', { name: 'rbf', sigma: 0.5 }, { name: 'knn', k: 4 }])('clustering %j', affinity => { const model = new SpectralClustering(affinity) const n = 5 const x = Matrix.concat( diff --git a/tests/lib/model/split_merge.test.js b/tests/lib/model/split_merge.test.js index 92432a90d..ab4fde5ff 100644 --- a/tests/lib/model/split_merge.test.js +++ b/tests/lib/model/split_merge.test.js @@ -3,7 +3,7 @@ import SplitAndMerge from '../../../lib/model/split_merge.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test.each([undefined, 'variance', 'uniformity'])('predict %s', method => { +test.each([undefined, 'variance', 'uniformity'])('predict %s', { timeout: 10000 }, method => { const model = new SplitAndMerge(method) const n = 100 const x = Matrix.zeros(n, n).toArray() diff --git a/tests/lib/model/squared_loss_mi.test.js b/tests/lib/model/squared_loss_mi.test.js index 2c291521a..160cf2f75 100644 --- a/tests/lib/model/squared_loss_mi.test.js +++ b/tests/lib/model/squared_loss_mi.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import SquaredLossMICPD from '../../../lib/model/squared_loss_mi.js' import { uLSIF } from '../../../lib/model/ulsif.js' -test('anomaly detection', () => { +test('anomaly detection', { retry: 5 }, () => { const sigmas = [] const lambdas = [] for (let i = -3; i <= 3; i += 0.5) { diff --git a/tests/lib/model/sst.test.js b/tests/lib/model/sst.test.js index 3eebbecd3..ff42a507e 100644 --- a/tests/lib/model/sst.test.js +++ b/tests/lib/model/sst.test.js @@ -1,10 +1,7 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import SST from '../../../lib/model/sst.js' -test('anomaly detection', () => { +test('anomaly detection', { retry: 3 }, () => { const w = 10 const model = new SST(w) const n = 50 diff --git a/tests/lib/model/statistical_region_merging.test.js b/tests/lib/model/statistical_region_merging.test.js index d4077feea..2605901e5 100644 --- a/tests/lib/model/statistical_region_merging.test.js +++ b/tests/lib/model/statistical_region_merging.test.js @@ -1,7 +1,7 @@ import Tensor from '../../../lib/util/tensor.js' import StatisticalRegionMerging from '../../../lib/model/statistical_region_merging.js' -test('predict', () => { +test('predict', { retry: 3 }, () => { const model = new StatisticalRegionMerging(0.5) const x = Tensor.random([100, 100, 3]).toArray() diff --git a/tests/lib/model/stoptron.test.js b/tests/lib/model/stoptron.test.js index b6930e49c..4f0e7124b 100644 --- a/tests/lib/model/stoptron.test.js +++ b/tests/lib/model/stoptron.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import Stoptron from '../../../lib/model/stoptron.js' @@ -24,6 +21,7 @@ describe('classification', () => { test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }, 'polynomial', { name: 'polynomial', d: 3 }])( 'kernel %s', + { retry: 10 }, kernel => { const model = new Stoptron(100, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() @@ -57,7 +55,7 @@ describe('classification', () => { expect(acc).toBeGreaterThan(0.9) }) - test('many sv', () => { + test('many sv', { retry: 10 }, () => { const model = new Stoptron() const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() x[50] = [0.1, 0.1] diff --git a/tests/lib/model/svc.test.js b/tests/lib/model/svc.test.js index e4ecbb20b..e4601365f 100644 --- a/tests/lib/model/svc.test.js +++ b/tests/lib/model/svc.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import SVC from '../../../lib/model/svc.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test.each(['gaussian', { name: 'gaussian', d: 0.8 }])('%p', kernel => { + test.each(['gaussian', { name: 'gaussian', d: 0.8 }])('%j', { retry: 5 }, kernel => { const model = new SVC(kernel) const n = 50 const x = Matrix.concat( @@ -31,7 +28,7 @@ describe('clustering', () => { expect(ri).toBeGreaterThan(0.8) }) - test.each(['linear', { name: 'linear' }])('%p', kernel => { + test.each(['linear', { name: 'linear' }])('%j', kernel => { const model = new SVC(kernel) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/svm.test.js b/tests/lib/model/svm.test.js index 2cacdbd0d..3d1c3979e 100644 --- a/tests/lib/model/svm.test.js +++ b/tests/lib/model/svm.test.js @@ -5,7 +5,7 @@ import { accuracy } from '../../../lib/evaluate/classification.js' describe('classification', () => { test.each(['gaussian', { name: 'gaussian' }, { name: 'gaussian', d: 0.2 }, 'linear', { name: 'linear' }])( - 'fit %p', + 'fit %j', kernel => { const model = new SVM(kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() diff --git a/tests/lib/model/svr.test.js b/tests/lib/model/svr.test.js index 563564951..ac2162d81 100644 --- a/tests/lib/model/svr.test.js +++ b/tests/lib/model/svr.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(20) - import Matrix from '../../../lib/util/matrix.js' import SVR from '../../../lib/model/svr.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('regression', () => { - test('kernel gaussian', () => { + test('kernel gaussian', { retry: 20 }, () => { const model = new SVR('gaussian') const x = Matrix.random(50, 2, -2, 2).toArray() const t = [] @@ -26,7 +23,7 @@ describe('regression', () => { expect(err).toBeLessThan(0.9) }) - test.each([{ name: 'gaussian', d: 2 }, 'linear'])('kernel %s', kernel => { + test.each([{ name: 'gaussian', d: 2 }, 'linear'])('kernel %s', { retry: 20 }, kernel => { const model = new SVR(kernel) const x = Matrix.random(50, 2, -2, 2).toArray() const t = [] @@ -45,7 +42,7 @@ describe('regression', () => { expect(err).toBeLessThan(0.5) }) - test('custom kernel', () => { + test('custom kernel', { retry: 20 }, () => { const model = new SVR((a, b) => Math.exp(-2 * a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0) ** 2)) const x = Matrix.random(50, 2, -2, 2).toArray() const t = [] diff --git a/tests/lib/model/tighter_perceptron.test.js b/tests/lib/model/tighter_perceptron.test.js index a0da58b5b..5254df2b7 100644 --- a/tests/lib/model/tighter_perceptron.test.js +++ b/tests/lib/model/tighter_perceptron.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import TighterPerceptron from '../../../lib/model/tighter_perceptron.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('classification', () => { - test('default', () => { + test('default', { retry: 10 }, () => { const model = new TighterPerceptron() const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() x[50] = [0.1, 0.1] @@ -23,7 +20,7 @@ describe('classification', () => { expect(acc).toBeGreaterThan(0.8) }) - test.each([undefined, 'perceptron', 'mira', 'nobias'])('update %s', update => { + test.each([undefined, 'perceptron', 'mira', 'nobias'])('update %s', { retry: 10 }, update => { const model = new TighterPerceptron(1, 10, update) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() x[50] = [0.1, 0.1] diff --git a/tests/lib/model/tightest_perceptron.test.js b/tests/lib/model/tightest_perceptron.test.js index 9dc9f4ab9..80bf7c1cd 100644 --- a/tests/lib/model/tightest_perceptron.test.js +++ b/tests/lib/model/tightest_perceptron.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Matrix from '../../../lib/util/matrix.js' import TightestPerceptron from '../../../lib/model/tightest_perceptron.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('classification', () => { - test('default', () => { + test('default', { retry: 5 }, () => { const model = new TightestPerceptron() const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() x[50] = [0.1, 0.1] @@ -24,7 +21,7 @@ describe('classification', () => { }) describe.each([undefined, 'zero_one', 'hinge'])('accuracyLoss %s', accuracyLoss => { - test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', kernel => { + test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', { retry: 5 }, kernel => { const model = new TightestPerceptron(10, kernel, accuracyLoss) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() x[50] = [0.1, 0.1] @@ -60,7 +57,7 @@ describe('classification', () => { }) }) - test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', kernel => { + test.each(['polynomial', { name: 'polynomial', d: 3 }])('kernel %s', { retry: 5 }, kernel => { const model = new TightestPerceptron(10, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() x[50] = [0.1, 0.1] diff --git a/tests/lib/model/tsne.test.js b/tests/lib/model/tsne.test.js index 0ac12b358..36e94d5dd 100644 --- a/tests/lib/model/tsne.test.js +++ b/tests/lib/model/tsne.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import { SNE, tSNE } from '../../../lib/model/tsne.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('SNE dimension reduction', () => { - test.each([undefined, 1, 2])('%p', d => { + test.each([undefined, 1, 2])('%j', { retry: 3 }, d => { const x = Matrix.concat(Matrix.randn(20, 5, 0, 0.2), Matrix.randn(20, 5, 5, 0.2)).toArray() const model = new SNE(x, d) model._perplexity = 30 @@ -34,7 +31,7 @@ describe('SNE dimension reduction', () => { }) describe('tSNE dimension reduction', () => { - test.each([undefined, 1, 2])('%p', d => { + test.each([undefined, 1, 2])('%j', d => { const x = Matrix.concat(Matrix.randn(20, 5, 0, 0.2), Matrix.randn(20, 5, 5, 0.2)).toArray() const model = new tSNE(x, d) diff --git a/tests/lib/model/tukey_regression.test.js b/tests/lib/model/tukey_regression.test.js index d20715ff1..c1e00ff30 100644 --- a/tests/lib/model/tukey_regression.test.js +++ b/tests/lib/model/tukey_regression.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import TukeyRegression from '../../../lib/model/tukey_regression.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('regression', () => { - test('fit', () => { + test('fit', { retry: 3 }, () => { const model = new TukeyRegression(1) const x = Matrix.randn(50, 2, 0, 5).toArray() const t = [] @@ -22,7 +19,7 @@ describe('regression', () => { expect(err).toBeLessThan(0.5) }) - test('small tol', () => { + test('small tol', { retry: 3 }, () => { const model = new TukeyRegression(0.01) const x = Matrix.randn(50, 2, 0, 5).toArray() const t = [] diff --git a/tests/lib/model/ulsif.test.js b/tests/lib/model/ulsif.test.js index 8a669688e..05bf6c878 100644 --- a/tests/lib/model/ulsif.test.js +++ b/tests/lib/model/ulsif.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import { uLSIF } from '../../../lib/model/ulsif.js' describe('uLSIF dimension reduction', () => { - test('many candidates', () => { + test('many candidates', { retry: 3, timeout: 30000 }, () => { const sigmas = [] const lambdas = [] for (let i = -3; i <= 3; i += 0.5) { diff --git a/tests/lib/model/umap.test.js b/tests/lib/model/umap.test.js index 193991490..7542f6d74 100644 --- a/tests/lib/model/umap.test.js +++ b/tests/lib/model/umap.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import Matrix from '../../../lib/util/matrix.js' import UMAP from '../../../lib/model/umap.js' import { coRankingMatrix } from '../../../lib/evaluate/dimensionality_reduction.js' describe('dimensionality reduction', () => { - test('default', () => { + test('default', { retry: 10 }, () => { const x = Matrix.concat(Matrix.randn(50, 10, 0, 0.2), Matrix.randn(50, 10, 5, 0.2)).toArray() const model = new UMAP(x, 2) @@ -19,7 +16,7 @@ describe('dimensionality reduction', () => { expect(q).toBeGreaterThan(0.9) }) - test('parameter', () => { + test('parameter', { retry: 10 }, () => { const x = Matrix.concat(Matrix.randn(50, 10, 0, 0.2), Matrix.randn(50, 10, 5, 0.2)).toArray() const model = new UMAP(x, 2, 2, 0.2) diff --git a/tests/lib/model/vae.test.js b/tests/lib/model/vae.test.js index 9a1c0f8ce..9634c770f 100644 --- a/tests/lib/model/vae.test.js +++ b/tests/lib/model/vae.test.js @@ -1,11 +1,8 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import VAE from '../../../lib/model/vae.js' describe('reconstruct', () => { - test('sample', () => { + test('sample', { retry: 3, timeout: 30000 }, () => { const model = new VAE( 3, 2, diff --git a/tests/lib/model/var.test.js b/tests/lib/model/var.test.js index e718169f3..d8cb3ee7e 100644 --- a/tests/lib/model/var.test.js +++ b/tests/lib/model/var.test.js @@ -1,9 +1,6 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import VAR from '../../../lib/model/var.js' -test('sin', () => { +test('sin', { retry: 3 }, () => { const model = new VAR(10) const x = [] for (let i = 0; i < 100; i++) { diff --git a/tests/lib/model/vbgmm.test.js b/tests/lib/model/vbgmm.test.js index cf0ae06f8..2c2bd9592 100644 --- a/tests/lib/model/vbgmm.test.js +++ b/tests/lib/model/vbgmm.test.js @@ -1,13 +1,10 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import VBGMM from '../../../lib/model/vbgmm.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('many data', () => { + test('many data', { retry: 3 }, () => { const model = new VBGMM(0.001, 0.001, 5) const n = 20 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.2), Matrix.randn(n, 2, 5, 0.2)).toArray() diff --git a/tests/lib/model/voted_perceptron.test.js b/tests/lib/model/voted_perceptron.test.js index 8d6b69a31..c2f490d4a 100644 --- a/tests/lib/model/voted_perceptron.test.js +++ b/tests/lib/model/voted_perceptron.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import VotedPerceptron from '../../../lib/model/voted_perceptron.js' import { accuracy } from '../../../lib/evaluate/classification.js' -test('fit', () => { +test('fit', { retry: 3 }, () => { const model = new VotedPerceptron() const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() x[50] = [0.1, 0.1] diff --git a/tests/lib/model/winnow.test.js b/tests/lib/model/winnow.test.js index 9c9da3139..3a2359ee6 100644 --- a/tests/lib/model/winnow.test.js +++ b/tests/lib/model/winnow.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import Winnow from '../../../lib/model/winnow.js' import { accuracy } from '../../../lib/evaluate/classification.js' -describe.each([undefined, 1, 2])('fit version %p', version => { - test.each([undefined, 1.1])('pos neg a: %p', alpha => { +describe.each([undefined, 1, 2])('fit version %j', version => { + test.each([undefined, 1.1])('pos neg a: %j', alpha => { const model = new Winnow(alpha, null, version) const x = [] const n = 50 @@ -29,7 +26,7 @@ describe.each([undefined, 1, 2])('fit version %p', version => { expect(acc).toBeGreaterThan(0.95) }) - test('neg pos', () => { + test('neg pos', { retry: 5 }, () => { const model = new Winnow(1.1, undefined, version) const x = [Array(10).fill(0)] const n = 50 diff --git a/tests/lib/model/word_to_vec.test.js b/tests/lib/model/word_to_vec.test.js index 1cdf65234..59dbb9483 100644 --- a/tests/lib/model/word_to_vec.test.js +++ b/tests/lib/model/word_to_vec.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Word2Vec from '../../../lib/model/word_to_vec.js' describe.each(['CBOW', 'skip-gram'])('embedding %s', method => { diff --git a/tests/lib/model/xgboost.test.js b/tests/lib/model/xgboost.test.js index e3088b065..2e06f6a8b 100644 --- a/tests/lib/model/xgboost.test.js +++ b/tests/lib/model/xgboost.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import { XGBoost, XGBoostClassifier } from '../../../lib/model/xgboost.js' @@ -8,7 +5,7 @@ import { accuracy } from '../../../lib/evaluate/classification.js' import { rmse } from '../../../lib/evaluate/regression.js' describe('classifier', () => { - test('deafult', () => { + test('deafult', { retry: 3 }, () => { const model = new XGBoostClassifier() const x = Matrix.randn(20, 10).toArray() const t = [] @@ -26,7 +23,7 @@ describe('classifier', () => { expect(acc).toBeGreaterThan(0.95) }) - test.each([0.5, 0])('%d', lr => { + test.each([0.5, 0])('%d', { retry: 3 }, lr => { const model = new XGBoostClassifier(10, 0.8, 0.1, lr) const x = Matrix.randn(20, 10).toArray() const t = [] @@ -46,7 +43,7 @@ describe('classifier', () => { }) describe('regression', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const model = new XGBoost() const x = Matrix.random(20, 10, -2, 2).toArray() const t = [] @@ -63,7 +60,7 @@ describe('regression', () => { expect(err).toBeLessThan(0.5) }) - test.each([0.5, 0])('%d', lr => { + test.each([0.5, 0])('%d', { retry: 3 }, lr => { const model = new XGBoost(10, 0.8, 0.1, lr) const x = Matrix.random(20, 10, -2, 2).toArray() const t = [] diff --git a/tests/lib/model/yeo_johnson.test.js b/tests/lib/model/yeo_johnson.test.js index f874a9ae2..b04d2578e 100644 --- a/tests/lib/model/yeo_johnson.test.js +++ b/tests/lib/model/yeo_johnson.test.js @@ -76,7 +76,7 @@ describe('fit', () => { }) describe('predict', () => { - test.each([[[0, 1]]])('mat %p', lambda => { + test.each([[[0, 1]]])('mat %j', lambda => { const model = new YeoJohnson(lambda) const x = Matrix.randn(50, 2, 1, 0.2).toArray() const y = model.predict(x) @@ -88,7 +88,7 @@ describe('predict', () => { } }) - test.each([-1, 0, 1, 2])('mat %p', lambda => { + test.each([-1, 0, 1, 2])('mat %j', lambda => { const model = new YeoJohnson(lambda) const x = Matrix.randn(50, 2, 1, 0.2).toArray() const y = model.predict(x) @@ -100,7 +100,7 @@ describe('predict', () => { } }) - test.each([[[0, 1]]])('arr %p', lambda => { + test.each([[[0, 1]]])('arr %j', lambda => { const model = new YeoJohnson(lambda) const x = Matrix.randn(50, 1, 1, 0.2).value const y = model.predict(x) @@ -110,7 +110,7 @@ describe('predict', () => { } }) - test.each([-1, 0, 1, 2])('arr %p', lambda => { + test.each([-1, 0, 1, 2])('arr %j', lambda => { const model = new YeoJohnson(lambda) const x = Matrix.randn(50, 1, 1, 0.2).value const y = model.predict(x) @@ -178,7 +178,7 @@ describe('inverse', () => { } }) - test.each([-1, 0, 1, 2])('arr %p', lambda => { + test.each([-1, 0, 1, 2])('arr %j', lambda => { const model = new YeoJohnson(lambda) const x = Matrix.randn(50, 1, 0, 0.2).value const y = model.predict(x) diff --git a/tests/lib/model/yinyang_kmeans.test.js b/tests/lib/model/yinyang_kmeans.test.js index fe2a1e3f1..75d3eb9c8 100644 --- a/tests/lib/model/yinyang_kmeans.test.js +++ b/tests/lib/model/yinyang_kmeans.test.js @@ -1,12 +1,9 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import YinyangKMeans from '../../../lib/model/yinyang_kmeans.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -describe('clustering', () => { +describe('clustering', { retry: 3 }, () => { test('default', () => { const model = new YinyangKMeans(20) const n = 20 diff --git a/tests/lib/model/zinb.test.js b/tests/lib/model/zinb.test.js index 5930406ce..47c17f197 100644 --- a/tests/lib/model/zinb.test.js +++ b/tests/lib/model/zinb.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import ZeroInflatedNegativeBinomial from '../../../lib/model/zinb.js' const random_negative_binomial = (r, p) => { @@ -20,7 +17,7 @@ const random_negative_binomial = (r, p) => { } } -test('density estimation', () => { +test('density estimation', { retry: 5 }, () => { const model = new ZeroInflatedNegativeBinomial() const r = 10 const prob = 0.5 diff --git a/tests/lib/model/zip.test.js b/tests/lib/model/zip.test.js index 1d400a3b2..1ef140c66 100644 --- a/tests/lib/model/zip.test.js +++ b/tests/lib/model/zip.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(10) - import ZeroInflatedPoisson from '../../../lib/model/zip.js' const random_poisson = l => { @@ -15,7 +12,7 @@ const random_poisson = l => { } describe('density estimation', () => { - test.each([undefined, 'moments', 'maximum_likelihood'])('%s', method => { + test.each([undefined, 'moments', 'maximum_likelihood'])('%s', { retry: 10 }, method => { const model = new ZeroInflatedPoisson(method) const x = [] for (let i = 0; i < 10000; i++) { diff --git a/tests/lib/model/ztp.test.js b/tests/lib/model/ztp.test.js index 0642096ff..12df9c18b 100644 --- a/tests/lib/model/ztp.test.js +++ b/tests/lib/model/ztp.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(5) - import ZeroTruncatedPoisson from '../../../lib/model/ztp.js' const random_zero_truncated_poisson = l => { @@ -16,7 +13,7 @@ const random_zero_truncated_poisson = l => { return k } -test.each([1, 2, 3])('density estimation %i', lambda => { +test.each([1, 2, 3])('density estimation %i', { retry: 5 }, lambda => { const model = new ZeroTruncatedPoisson() const x = [] for (let i = 0; i < 10000; i++) { diff --git a/tests/lib/rl/breaker.test.js b/tests/lib/rl/breaker.test.js index 86d54d70d..36f953bb1 100644 --- a/tests/lib/rl/breaker.test.js +++ b/tests/lib/rl/breaker.test.js @@ -114,7 +114,7 @@ describe('test', () => { test.each([ [1, -1], [-1, 1], - ])('hit paddle side: %p', (dx, dy) => { + ])('hit paddle side: %j', (dx, dy) => { const env = new BreakerRLEnvironment() const state = env.reset() state[0] = 100 - env._paddle_size[0] / 2 diff --git a/tests/lib/rl/draughts.test.js b/tests/lib/rl/draughts.test.js index f705ea4c1..eccb5d882 100644 --- a/tests/lib/rl/draughts.test.js +++ b/tests/lib/rl/draughts.test.js @@ -89,7 +89,7 @@ describe('env', () => { ) }) - test.each([1, 3])('failed %p', agent => { + test.each([1, 3])('failed %j', agent => { const env = new DraughtsRLEnvironment() env.reset() expect(() => env.state(agent)).toThrow('Unknown agent.') @@ -97,7 +97,7 @@ describe('env', () => { }) describe('step', () => { - test.each([undefined, DraughtsRLEnvironment.RED])('success agent: %p', agent => { + test.each([undefined, DraughtsRLEnvironment.RED])('success agent: %j', agent => { const env = new DraughtsRLEnvironment() env.reset() @@ -186,7 +186,7 @@ describe('env', () => { ) }) - test.each([1, 3])('failed %p', agent => { + test.each([1, 3])('failed %j', agent => { const env = new DraughtsRLEnvironment() env.reset() expect(() => env.step([{ from: [2, 0], path: [[3, 1]], jump: [] }], agent)).toThrow('Unknown agent.') @@ -194,7 +194,7 @@ describe('env', () => { }) describe('test', () => { - test.each([undefined, DraughtsRLEnvironment.RED])('step agent: %p', agent => { + test.each([undefined, DraughtsRLEnvironment.RED])('step agent: %j', agent => { const env = new DraughtsRLEnvironment() const orgstate = env.reset() @@ -444,14 +444,14 @@ o - o - o - o - }) describe('at', () => { - test.each([[0, 1], 1])('%p', p => { + test.each([[0, 1], 1])('%j', p => { const env = new DraughtsRLEnvironment() const board = env._board expect(board.at(p)).toBe(DraughtsRLEnvironment.RED) }) - test.each([[7, 0], 29])('%p', p => { + test.each([[7, 0], 29])('%j', p => { const env = new DraughtsRLEnvironment() const board = env._board @@ -463,7 +463,7 @@ o - o - o - o - test.each([ { from: [2, 1], path: [[3, 2]], jump: [] }, { from: 9, path: [14], jump: [] }, - ])('success %p', p => { + ])('success %j', p => { const env = new DraughtsRLEnvironment() const board = env._board diff --git a/tests/lib/rl/gomoku.test.js b/tests/lib/rl/gomoku.test.js index 0e092a2e2..96554f508 100644 --- a/tests/lib/rl/gomoku.test.js +++ b/tests/lib/rl/gomoku.test.js @@ -68,7 +68,7 @@ describe('env', () => { ) }) - test.each([1, 4])('failed %p', agent => { + test.each([1, 4])('failed %j', agent => { const env = new GomokuRLEnvironment() env.reset() expect(() => env.state(agent)).toThrow('Unknown agent.') @@ -76,7 +76,7 @@ describe('env', () => { }) describe('step', () => { - test.each([undefined, GomokuRLEnvironment.BLACK])('success agent: %p', agent => { + test.each([undefined, GomokuRLEnvironment.BLACK])('success agent: %j', agent => { const env = new GomokuRLEnvironment() env.reset() @@ -155,7 +155,7 @@ describe('env', () => { ) }) - test.each([1, 4])('failed %p', agent => { + test.each([1, 4])('failed %j', agent => { const env = new GomokuRLEnvironment() env.reset() expect(() => env.step(['3_5'], agent)).toThrow('Unknown agent.') @@ -163,7 +163,7 @@ describe('env', () => { }) describe('test', () => { - test.each([undefined, GomokuRLEnvironment.BLACK])('step agent: %p', agent => { + test.each([undefined, GomokuRLEnvironment.BLACK])('step agent: %j', agent => { const env = new GomokuRLEnvironment() const orgstate = env.reset() diff --git a/tests/lib/rl/maze.test.js b/tests/lib/rl/maze.test.js index 8c2083df3..afa6ad42e 100644 --- a/tests/lib/rl/maze.test.js +++ b/tests/lib/rl/maze.test.js @@ -100,7 +100,7 @@ describe('test', () => { [[20, 0, 0], [1], [10, 0, 0]], [[10, 20, 0], [2], [10, 20, 5]], [[10, 20, 0], [3], [10, 20, 355]], - ])('step %p, %i, %p', (pstate, act, nstate) => { + ])('step %j, %i, %j', (pstate, act, nstate) => { const env = new SmoothMazeRLEnvironment(100, 100) const info = env.test(pstate, act) expect(info.done).toBeFalsy() @@ -119,7 +119,7 @@ describe('test', () => { [0, [0, 7, 180]], [1, [4, 0, 90]], [0, [4, 0, 270]], - ])('edge %i %p', (act, state) => { + ])('edge %i %j', (act, state) => { const env = new SmoothMazeRLEnvironment(100, 100) const info = env.test(state, [act]) expect(info.done).toBeFalsy() diff --git a/tests/lib/rl/reversi.test.js b/tests/lib/rl/reversi.test.js index 19059d874..3bd81d366 100644 --- a/tests/lib/rl/reversi.test.js +++ b/tests/lib/rl/reversi.test.js @@ -40,7 +40,7 @@ describe('env', () => { }) describe('state', () => { - test.each([undefined, ReversiRLEnvironment.BLACK, ReversiRLEnvironment.WHITE])('success %p', agent => { + test.each([undefined, ReversiRLEnvironment.BLACK, ReversiRLEnvironment.WHITE])('success %j', agent => { const env = new ReversiRLEnvironment() env.reset(0, 1) @@ -76,7 +76,7 @@ describe('env', () => { ) }) - test.each([1, 4])('failed %p', agent => { + test.each([1, 4])('failed %j', agent => { const env = new ReversiRLEnvironment() env.reset() expect(() => env.state(agent)).toThrow('Unknown agent.') @@ -84,7 +84,7 @@ describe('env', () => { }) describe('step', () => { - test.each([undefined, ReversiRLEnvironment.BLACK])('success agent: %p', agent => { + test.each([undefined, ReversiRLEnvironment.BLACK])('success agent: %j', agent => { const env = new ReversiRLEnvironment() env.reset() @@ -199,7 +199,7 @@ describe('env', () => { ) }) - test.each([1, 4])('failed %p', agent => { + test.each([1, 4])('failed %j', agent => { const env = new ReversiRLEnvironment() env.reset() expect(() => env.step(['f4'], agent)).toThrow('Unknown agent.') @@ -207,7 +207,7 @@ describe('env', () => { }) describe('test', () => { - test.each([undefined, ReversiRLEnvironment.BLACK])('step agent: %p', agent => { + test.each([undefined, ReversiRLEnvironment.BLACK])('step agent: %j', agent => { const env = new ReversiRLEnvironment() const orgstate = env.reset() @@ -398,7 +398,7 @@ describe('board', () => { } }) - test.each([[3, 3], 'd4'])('at %p', p => { + test.each([[3, 3], 'd4'])('at %j', p => { const env = new ReversiRLEnvironment() const board = env._board @@ -406,7 +406,7 @@ describe('board', () => { }) describe('set', () => { - test.each([[2, 3], 'd3'])('success %p', p => { + test.each([[2, 3], 'd3'])('success %j', p => { const env = new ReversiRLEnvironment() const board = env._board diff --git a/tests/lib/rl/waterball.test.js b/tests/lib/rl/waterball.test.js index 6ac761bd1..54cd4a490 100644 --- a/tests/lib/rl/waterball.test.js +++ b/tests/lib/rl/waterball.test.js @@ -84,7 +84,7 @@ describe('state', () => { }) describe('step', () => { - test.each([0, 1, 2, 3])('step %p', action => { + test.each([0, 1, 2, 3])('step %j', action => { const env = new WaterballRLEnvironment(100, 100) const info = env.step([action]) expect(info.done).toBeFalsy() diff --git a/tests/lib/util/graph.test.js b/tests/lib/util/graph.test.js index d5c88b505..0af1204b4 100644 --- a/tests/lib/util/graph.test.js +++ b/tests/lib/util/graph.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(20) - import Graph, { Edge } from '../../../lib/util/graph.js' describe('graph', () => { @@ -78,13 +75,13 @@ describe('graph', () => { }) describe('1', () => { - test.each([0, false])('%p', e => { + test.each([0, false])('%j', e => { const graph = Graph.fromAdjacency([[e]]) expect(graph.order).toBe(1) expect(graph.size).toBe(0) }) - test.each([1, true])('%p', e => { + test.each([1, true])('%j', e => { const graph = Graph.fromAdjacency([[e]]) expect(graph.order).toBe(1) expect(graph.size).toBe(1) @@ -326,7 +323,7 @@ describe('graph', () => { [1, 2], ], ], - ])('size %p', edges => { + ])('size %j', edges => { const graph = new Graph(10, edges) expect(graph.size).toBe(edges.length) }) @@ -1119,7 +1116,7 @@ describe('graph', () => { expect(graph.nodes[0]).toBeUndefined() }) - test.each([1, 5, 'a'])('value %p', v => { + test.each([1, 5, 'a'])('value %j', v => { const graph = new Graph() graph.addNode(v) expect(graph.order).toBe(1) @@ -1162,7 +1159,7 @@ describe('graph', () => { expect(() => graph.getNode(n)).toThrow('Index out of bounds.') }) - test.each([[[-1, 0]], [[9, 10]]])('array fail %p', idx => { + test.each([[[-1, 0]], [[9, 10]]])('array fail %j', idx => { const graph = new Graph() for (let i = 0; i < 10; i++) { graph.addNode(i + 1) @@ -1241,7 +1238,7 @@ describe('graph', () => { expect(graph.edges[0].direct).toBeFalsy() }) - test.each([1, 6, 'b'])('value %p', v => { + test.each([1, 6, 'b'])('value %j', v => { const graph = new Graph(3) graph.addEdge(1, 2, v) expect(graph.order).toBe(3) @@ -4030,7 +4027,7 @@ describe('graph', () => { }) describe('bisectionSpectral', () => { - test('default', () => { + test('default', { retry: 20 }, () => { const graph = new Graph(6, [ [0, 1], [0, 2], @@ -4049,7 +4046,7 @@ describe('graph', () => { expect(nodes[1].sort()).toEqual(nodes[1].includes(0) ? [0, 1, 2] : [3, 4, 5]) }) - test('separated', () => { + test('separated', { retry: 20 }, () => { const graph = new Graph(7, [ [0, 1], [0, 2], diff --git a/tests/lib/util/matrix.test.js b/tests/lib/util/matrix.test.js index dc8f57b83..98e446b38 100644 --- a/tests/lib/util/matrix.test.js +++ b/tests/lib/util/matrix.test.js @@ -1,6 +1,3 @@ -import { jest } from '@jest/globals' -jest.retryTimes(3) - import Matrix from '../../../lib/util/matrix.js' import Tensor from '../../../lib/util/tensor.js' @@ -407,7 +404,7 @@ describe('Matrix', () => { } }) - test.each([[3, 5, 7], Matrix.randn(2, 2)])('fail invalid mean %p', m => { + test.each([[3, 5, 7], Matrix.randn(2, 2)])('fail invalid mean %j', m => { expect(() => Matrix.randn(100000, 2, m, 1)).toThrow("'myu' cols must be same as 'cols' and rows must be 1.") }) @@ -418,7 +415,7 @@ describe('Matrix', () => { [5, 6], ], Matrix.randn(2, 3), - ])('fail invalid mean %p', s => { + ])('fail invalid mean %j', s => { expect(() => Matrix.randn(100000, 2, 0, s)).toThrow("'sigma' cols and rows must be same as 'cols'.") }) }) @@ -595,7 +592,7 @@ describe('Matrix', () => { test.each([ [[1, 1], [0, 0], 0], [[2, 3], [1, 1], 4], - ])('size:%p, index:%p', (size, idx, pos) => { + ])('size:%j, index:%j', (size, idx, pos) => { const mat = new Matrix(size) const p = mat._to_position(...idx) expect(p).toBe(pos) @@ -614,7 +611,7 @@ describe('Matrix', () => { [3, 2], [2, 2], ], - ])('size:%p, fail[%p]', (size, idx) => { + ])('size:%j, fail[%j]', (size, idx) => { const mat = new Matrix(size) expect(() => mat._to_position(...idx)).toThrow('Index out of bounds.') }) @@ -624,7 +621,7 @@ describe('Matrix', () => { test.each([ [[1, 1], 0, [0, 0]], [[2, 3], 4, [1, 1]], - ])('size:%p, pos:%p', (size, pos, idx) => { + ])('size:%j, pos:%j', (size, pos, idx) => { const mat = new Matrix(size) const p = mat._to_index(pos) expect(p).toEqual(idx) @@ -797,7 +794,7 @@ describe('Matrix', () => { expect(() => mat.row(i)).toThrow('Index out of bounds.') }) - test.each([[[0, 1]], [[1, 2]], [[0, 2]]])('array %p', r => { + test.each([[[0, 1]], [[1, 2]], [[0, 2]]])('array %j', r => { const org = Matrix.randn(3, 5) const mat = org.row(r) expect(mat.sizes).toEqual([2, 5]) @@ -808,12 +805,12 @@ describe('Matrix', () => { } }) - test.each([[[-1, 0]], [[0, 3]]])('fail array %p', r => { + test.each([[[-1, 0]], [[0, 3]]])('fail array %j', r => { const mat = Matrix.randn(3, 5) expect(() => mat.row(r)).toThrow('Index out of bounds.') }) - test.each([[[false, true, false]], [[true, false, true]]])('boolean %p', r => { + test.each([[[false, true, false]], [[true, false, true]]])('boolean %j', r => { const org = Matrix.randn(3, 5) const mat = org.row(r) let p = 0 @@ -829,7 +826,7 @@ describe('Matrix', () => { expect(mat.sizes).toEqual([p, 5]) }) - test.each([[[false]], [[true, false]]])('fail boolean %p', r => { + test.each([[[false]], [[true, false]]])('fail boolean %j', r => { const mat = Matrix.randn(3, 5) expect(() => mat.row(r)).toThrow('Length is invalid.') }) @@ -850,7 +847,7 @@ describe('Matrix', () => { expect(() => mat.col(i)).toThrow('Index out of bounds.') }) - test.each([[[0, 1]], [[1, 2]], [[0, 2]]])('array %p', c => { + test.each([[[0, 1]], [[1, 2]], [[0, 2]]])('array %j', c => { const org = Matrix.randn(5, 3) const mat = org.col(c) expect(mat.sizes).toEqual([5, 2]) @@ -861,12 +858,12 @@ describe('Matrix', () => { } }) - test.each([[[-1, 0]], [[0, 3]]])('fail array %p', c => { + test.each([[[-1, 0]], [[0, 3]]])('fail array %j', c => { const mat = Matrix.randn(5, 3) expect(() => mat.col(c)).toThrow('Index out of bounds.') }) - test.each([[[false, true, false]], [[true, false, true]]])('boolean %p', c => { + test.each([[[false, true, false]], [[true, false, true]]])('boolean %j', c => { const org = Matrix.randn(5, 3) const mat = org.col(c) let p = 0 @@ -882,19 +879,19 @@ describe('Matrix', () => { expect(mat.sizes).toEqual([5, p]) }) - test.each([[[false]], [[true, false]]])('fail boolean %p', c => { + test.each([[[false]], [[true, false]]])('fail boolean %j', c => { const mat = Matrix.randn(5, 3) expect(() => mat.col(c)).toThrow('Length is invalid.') }) }) describe('slice', () => { - describe.each([undefined, 0])('row(%p)', axis => { + describe.each([undefined, 0])('row(%j)', axis => { test.each([ [1, 3], [0, 5], [8, 10], - ])('%p', (f, t) => { + ])('%j', (f, t) => { const mat = Matrix.randn(10, 3) const slice = mat.slice(f, t, axis) expect(slice.sizes).toEqual([t - f, 3]) @@ -909,7 +906,7 @@ describe('Matrix', () => { [null, null], [3, null], [null, 5], - ])('with null %p', (f, t) => { + ])('with null %j', (f, t) => { const mat = Matrix.randn(10, 3) const slice = mat.slice(f, t, axis) @@ -929,7 +926,7 @@ describe('Matrix', () => { [1, 3], [0, 5], [8, 10], - ])('col %p', (f, t) => { + ])('col %j', (f, t) => { const mat = Matrix.randn(3, 10) const slice = mat.slice(f, t, 1) expect(slice.sizes).toEqual([3, t - f]) @@ -944,7 +941,7 @@ describe('Matrix', () => { [null, null], [3, null], [null, 5], - ])('col with null %p', (f, t) => { + ])('col with null %j', (f, t) => { const mat = Matrix.randn(3, 10) const slice = mat.slice(f, t, 1) @@ -959,7 +956,7 @@ describe('Matrix', () => { } }) - test.each([-1, 2])('fail invalid axis %p', axis => { + test.each([-1, 2])('fail invalid axis %j', axis => { const mat = Matrix.randn(5, 10) expect(() => mat.slice(0, 3, axis)).toThrow('Invalid axis.') }) @@ -983,7 +980,7 @@ describe('Matrix', () => { [0, 0, 2, 2], [0, 1, 2, 3], [4, 5, 7, 9], - ])('%p', (rf, cf, rt, ct) => { + ])('%j', (rf, cf, rt, ct) => { const mat = Matrix.randn(8, 10) const block = mat.block(rf, cf, rt, ct) @@ -999,7 +996,7 @@ describe('Matrix', () => { [null, null, null, null], [null, null, 4, 5], [3, 2, null, null], - ])('with null %p', (rf, cf, rt, ct) => { + ])('with null %j', (rf, cf, rt, ct) => { const mat = Matrix.randn(8, 10) const block = mat.block(rf, cf, rt, ct) @@ -1038,7 +1035,7 @@ describe('Matrix', () => { }) describe('remove', () => { - describe.each([undefined, 0])('row(%p)', axis => { + describe.each([undefined, 0])('row(%j)', axis => { test.each([0, 1, 2])('scaler[%i]', r => { const data = [ [1, 2, 3], @@ -1064,7 +1061,7 @@ describe('Matrix', () => { expect(() => mat.remove(i, axis)).toThrow('Index out of bounds.') }) - test.each([[[0, 1]], [[1, 2]], [[0, 2]]])('array[%p]', r => { + test.each([[[0, 1]], [[1, 2]], [[0, 2]]])('array[%j]', r => { const mat = Matrix.randn(4, 5) const data = mat.toArray() mat.remove(r, axis) @@ -1080,7 +1077,7 @@ describe('Matrix', () => { } }) - test.each([[[-1, 0]], [[0, 3]]])('fail array[%p]', r => { + test.each([[[-1, 0]], [[0, 3]]])('fail array[%j]', r => { const mat = Matrix.randn(3, 5) expect(() => mat.remove(r, axis)).toThrow('Index out of bounds.') }) @@ -1112,7 +1109,7 @@ describe('Matrix', () => { expect(() => mat.remove(i, 1)).toThrow('Index out of bounds.') }) - test.each([[[0, 1]], [[1, 2]], [[0, 2]]])('array[%p]', c => { + test.each([[[0, 1]], [[1, 2]], [[0, 2]]])('array[%j]', c => { const mat = Matrix.randn(4, 5) const data = mat.toArray() mat.remove(c, 1) @@ -1128,20 +1125,20 @@ describe('Matrix', () => { } }) - test.each([[[-1, 0]], [[0, 3]]])('fail array[%p]', r => { + test.each([[[-1, 0]], [[0, 3]]])('fail array[%j]', r => { const mat = Matrix.randn(5, 3) expect(() => mat.remove(r, 1)).toThrow('Index out of bounds.') }) }) - test.each([-1, 2])('fail invalid axis %p', axis => { + test.each([-1, 2])('fail invalid axis %j', axis => { const mat = Matrix.randn(5, 10) expect(() => mat.remove(0, axis)).toThrow('Invalid axis.') }) }) describe('removeIf', () => { - test.each([undefined, 0])('row(%p)', axis => { + test.each([undefined, 0])('row(%j)', axis => { const org = Matrix.randn(100, 3) const mat = org.copy() mat.removeIf(r => r.some(v => v < 0), axis) @@ -1173,14 +1170,14 @@ describe('Matrix', () => { } }) - test.each([-1, 2])('fail invalid axis %p', axis => { + test.each([-1, 2])('fail invalid axis %j', axis => { const mat = Matrix.randn(5, 10) expect(() => mat.removeIf(() => false, axis)).toThrow('Invalid axis.') }) }) describe('sample', () => { - test.each([undefined, 0])('row(%p) index', axis => { + test.each([undefined, 0])('row(%j) index', axis => { const n = 3 const org = Matrix.randn(10, 5) const [mat, idx] = org.sample(n, axis) @@ -1203,7 +1200,7 @@ describe('Matrix', () => { expect(expidx).toEqual(idx) }) - test.each([undefined, 0])('row(%p) duplicate index', axis => { + test.each([undefined, 0])('row(%j) duplicate index', axis => { const n = 6 const org = Matrix.randn(3, 5) const [mat, idx] = org.sample(n, axis, true) @@ -1272,12 +1269,12 @@ describe('Matrix', () => { expect(expidx).toEqual(idx) }) - test('fail invalid sampled size %p', () => { + test('fail invalid sampled size %j', () => { const mat = Matrix.randn(5, 10) expect(() => mat.sample(6, 0)).toThrow('Invalid sampled size.') }) - test.each([-1, 2])('fail invalid axis %p', axis => { + test.each([-1, 2])('fail invalid axis %j', axis => { const mat = Matrix.randn(5, 10) expect(() => mat.sample(4, axis)).toThrow('Invalid axis.') }) @@ -1364,14 +1361,14 @@ describe('Matrix', () => { } }) - test.each([-1, 2])('fail invalid axis %p', axis => { + test.each([-1, 2])('fail invalid axis %j', axis => { const mat = Matrix.randn(5, 10) expect(() => mat.flip(axis)).toThrow('Invalid axis.') }) }) describe('swap', () => { - describe.each([undefined, 0])('axis=%p', axis => { + describe.each([undefined, 0])('axis=%j', axis => { test.each([ [0, 1], [0, 2], @@ -1429,14 +1426,14 @@ describe('Matrix', () => { expect(() => mat.swap(a, b, 1)).toThrow('Index out of bounds.') }) - test.each([-1, 2])('fail invalid axis %p', axis => { + test.each([-1, 2])('fail invalid axis %j', axis => { const mat = Matrix.randn(5, 10) expect(() => mat.swap(0, 1, axis)).toThrow('Invalid axis.') }) }) describe('sort', () => { - describe.each([undefined, 0])('axis %p', axis => { + describe.each([undefined, 0])('axis %j', axis => { test('default', () => { const org = Matrix.randn(10, 5) const mat = org.copy() @@ -1516,14 +1513,14 @@ describe('Matrix', () => { } }) - test.each([-1, 2])('fail invalid axis %p', axis => { + test.each([-1, 2])('fail invalid axis %j', axis => { const mat = Matrix.randn(5, 10) expect(() => mat.sort(axis)).toThrow('Invalid axis.') }) }) describe('shuffle', () => { - test.each([undefined, 0])('axis %p', axis => { + test.each([undefined, 0])('axis %j', axis => { const org = Matrix.randn(10, 5) const mat = org.copy() mat.shuffle(axis) @@ -1573,14 +1570,14 @@ describe('Matrix', () => { } }) - test.each([-1, 2])('fail invalid axis %p', axis => { + test.each([-1, 2])('fail invalid axis %j', axis => { const mat = Matrix.randn(5, 10) expect(() => mat.shuffle(axis)).toThrow('Invalid axis.') }) }) describe('unique', () => { - describe.each([undefined, 0])('axis %p', axis => { + describe.each([undefined, 0])('axis %j', axis => { test('default', () => { const org = Matrix.randn(10, 5) org.set(1, 0, org.row(3)) @@ -1650,7 +1647,7 @@ describe('Matrix', () => { } }) - test.each([-1, 2])('fail invalid axis %p', axis => { + test.each([-1, 2])('fail invalid axis %j', axis => { const mat = Matrix.randn(5, 10) expect(() => mat.unique(axis)).toThrow('Invalid axis.') }) @@ -1935,7 +1932,7 @@ describe('Matrix', () => { [1, 1], [[1], 1], [[1, 1], null], - ])('no repeat %p', (n, axis) => { + ])('no repeat %j', (n, axis) => { const org = Matrix.randn(4, 5) const mat = org.copy() mat.repeat(n, axis) @@ -1947,7 +1944,7 @@ describe('Matrix', () => { } }) - test.each([undefined, 0])('axis %p', axis => { + test.each([undefined, 0])('axis %j', axis => { const org = Matrix.randn(4, 5) const mat = org.copy() mat.repeat(3, axis) @@ -2005,7 +2002,7 @@ describe('Matrix', () => { [1, 1], [[1], 1], [[1, 1], null], - ])('no repeat %p', (n, axis) => { + ])('no repeat %j', (n, axis) => { const org = Matrix.randn(4, 5) const mat = Matrix.repeat(org, n, axis) expect(mat.sizes).toEqual([org.rows, org.cols]) @@ -2016,7 +2013,7 @@ describe('Matrix', () => { } }) - test.each([undefined, 0])('axis %p', axis => { + test.each([undefined, 0])('axis %j', axis => { const org = Matrix.randn(4, 5) const mat = Matrix.repeat(org, 3, axis) expect(mat.sizes).toEqual([org.rows * 3, org.cols]) @@ -2062,7 +2059,7 @@ describe('Matrix', () => { }) describe('concat', () => { - describe.each([undefined, 0])('axis %p', axis => { + describe.each([undefined, 0])('axis %j', axis => { test('default', () => { const a = Matrix.randn(3, 10) const b = Matrix.randn(5, 10) @@ -2102,7 +2099,7 @@ describe('Matrix', () => { expect(() => a.concat(b, 1)).toThrow('Size is different.') }) - test.each([-1, 2])('fail invalid axis %p', axis => { + test.each([-1, 2])('fail invalid axis %j', axis => { const a = Matrix.randn(10, 3) const b = Matrix.randn(9, 3) expect(() => a.concat(b, axis)).toThrow('Invalid axis.') @@ -2110,7 +2107,7 @@ describe('Matrix', () => { }) describe('static concat', () => { - describe.each([undefined, 0])('axis %p', axis => { + describe.each([undefined, 0])('axis %j', axis => { test('axis 0', () => { const a = Matrix.randn(3, 10) const b = Matrix.randn(5, 10) @@ -2148,7 +2145,7 @@ describe('Matrix', () => { expect(() => Matrix.concat(a, b, 1)).toThrow('Size is different.') }) - test.each([-1, 2])('fail invalid axis %p', axis => { + test.each([-1, 2])('fail invalid axis %j', axis => { const a = Matrix.randn(10, 3) const b = Matrix.randn(9, 3) expect(() => Matrix.concat(a, b, axis)).toThrow('Invalid axis.') @@ -2177,7 +2174,7 @@ describe('Matrix', () => { }) }) - describe.each([0, [0]])('axis %p', axis => { + describe.each([0, [0]])('axis %j', axis => { test('no init', () => { const mat = Matrix.randn(5, 7) const reduce = mat.reduce((s, v) => s + v, undefined, axis) @@ -2214,7 +2211,7 @@ describe('Matrix', () => { }) }) - describe.each([1, [1]])('axis %p', axis => { + describe.each([1, [1]])('axis %j', axis => { test('no init', () => { const mat = Matrix.randn(5, 7) const reduce = mat.reduce((s, v) => s + v, undefined, axis) @@ -3325,7 +3322,7 @@ describe('Matrix', () => { }) describe('isOrthogonal', () => { - test.each([0, 1, 2, 10])('expect true %i', n => { + test.each([0, 1, 2, 10])('expect true %i', { retry: 3 }, n => { const mat = Matrix.random(n, n) for (let i = 0; i < n; i++) { const a = mat.row(i) @@ -3357,7 +3354,7 @@ describe('Matrix', () => { }) describe('isUnitary', () => { - test.each([0, 1, 2, 10])('expect true %i', n => { + test.each([0, 1, 2, 10])('expect true %i', { retry: 3 }, n => { const mat = Matrix.random(n, n) for (let i = 0; i < n; i++) { const a = mat.row(i) @@ -3462,7 +3459,7 @@ describe('Matrix', () => { expect(norm).toBeCloseTo(Matrix.map(mat, Math.abs).sum(0).max()) }) - test.each([undefined, 2])('%p', axis => { + test.each([undefined, 2])('%j', axis => { const mat = Matrix.randn(10, 10) const norm = mat.normInduced(axis) expect(norm).toBeCloseTo(mat.singularValues()[0]) @@ -3493,7 +3490,7 @@ describe('Matrix', () => { expect(norm).toBeCloseTo(mat.value.reduce((s, v) => s + Math.abs(v), 0)) }) - test.each([undefined, 2])('%p', axis => { + test.each([undefined, 2])('%j', axis => { const mat = Matrix.randn(10, 10) const norm = mat.normEntrywise(axis) expect(norm).toBeCloseTo(Math.sqrt(mat.value.reduce((s, v) => s + v ** 2, 0))) @@ -3646,7 +3643,7 @@ describe('Matrix', () => { }) describe('spectralRadius', () => { - test('default', () => { + test('default', { retry: 3 }, () => { const mat = Matrix.randn(5, 5).gram() const r = mat.spectralRadius() expect(r).toBeGreaterThan(0) @@ -4223,7 +4220,7 @@ describe('Matrix', () => { [5, 4], [3, 4], ], - ])('a%p, b%p', (sa, sb, sc) => { + ])('a%j, b%j', (sa, sb, sc) => { const a = Matrix.randn(...sa) const b = Matrix.randn(...sb) const dot = a.dot(b) @@ -4299,7 +4296,7 @@ describe('Matrix', () => { [5, 4], [3, 4], ], - ])('a%p, b%p', (sa, sb, sc) => { + ])('a%j, b%j', (sa, sb, sc) => { const a = Matrix.randn(...sa) const b = Matrix.randn(...sb) const tDot = a.tDot(b) @@ -5022,7 +5019,7 @@ describe('Matrix', () => { } }) - test.each([-2, -3])('%i(symmetric)', p => { + test.each([-2, -3])('%i(symmetric)', { retry: 3 }, p => { const n = 3 const mat = Matrix.random(n, n, -0.5, 0.5).gram() const pow = mat.power(p) @@ -5038,7 +5035,7 @@ describe('Matrix', () => { } }) - test('-0.5', () => { + test('-0.5', { retry: 3 }, () => { const n = 3 const mat = Matrix.randn(n, n).gram() const pow = mat.power(-0.5) @@ -5829,7 +5826,7 @@ describe('Matrix', () => { } }) - test.each([9])('k %i', k => { + test.each([9])('k %i', { retry: 3 }, k => { const n = 10 const mat = Matrix.randn(n, n, 0, 0.1).gram() const tridiag = mat.tridiagLanczos(k) @@ -6837,7 +6834,7 @@ describe('Matrix', () => { } }) - test('low rank', () => { + test('low rank', { retry: 3 }, () => { const mat = Matrix.randn(7, 5) for (let i = 0; i < 3; i++) { for (let j = 0; j < mat.cols; j++) { @@ -7299,7 +7296,7 @@ describe('Matrix', () => { test('not converged', () => { const mat = Matrix.randn(10, 10).gram() - console.log = jest.fn() + console.log = vi.fn() mat.eigenJacobi(1) const msg = console.log.mock.calls[0][0] diff --git a/tests/lib/util/tensor.test.js b/tests/lib/util/tensor.test.js index 12437b80b..4307aacaf 100644 --- a/tests/lib/util/tensor.test.js +++ b/tests/lib/util/tensor.test.js @@ -207,17 +207,17 @@ describe('Tensor', () => { }) }) - test.each([[[2]], [[2, 3]], [[2, 3, 4]]])('dimension %p', size => { + test.each([[[2]], [[2, 3]], [[2, 3, 4]]])('dimension %j', size => { const ten = new Tensor(size) expect(ten.dimension).toBe(size.length) }) - test.each([[[2]], [[2, 3]], [[2, 3, 4]]])('sizes %p', size => { + test.each([[[2]], [[2, 3]], [[2, 3, 4]]])('sizes %j', size => { const ten = new Tensor(size) expect(ten.sizes).toEqual(size) }) - test.each([[[2]], [[2, 3]], [[2, 3, 4]]])('length %p', size => { + test.each([[[2]], [[2, 3]], [[2, 3, 4]]])('length %j', size => { const ten = new Tensor(size) expect(ten.length).toEqual(size.reduce((s, v) => s * v, 1)) }) @@ -278,20 +278,20 @@ describe('Tensor', () => { expect(mat.value).toEqual(ten.value) }) - test.each([[[2]], [[1, 2, 3]]])('fail %p', sizes => { + test.each([[[2]], [[1, 2, 3]]])('fail %j', sizes => { const ten = Tensor.randn(sizes) expect(() => ten.toMatrix()).toThrow('Only 2D tensor can convert to matrix.') }) }) describe('toScaler', () => { - test.each([[[]], [[1]], [[1, 1]], [[1, 1, 1]]])('success %p', sizes => { + test.each([[[]], [[1]], [[1, 1]], [[1, 1, 1]]])('success %j', sizes => { const ten = Tensor.randn(sizes) const value = ten.toScaler() expect(value).toBe(ten.at(Array(ten.dimension).fill(0))) }) - test.each([[[2]], [[1, 2]], [[1, 3, 1]]])('fail %p', sizes => { + test.each([[[2]], [[1, 2]], [[1, 3, 1]]])('fail %j', sizes => { const ten = new Tensor(sizes) expect(() => ten.toScaler()).toThrow('The tensor cannot convert to scaler.') }) @@ -483,7 +483,7 @@ describe('Tensor', () => { describe('select', () => { describe('axis 0', () => { - test.each([0, 1, 2])('scalar %p', k => { + test.each([0, 1, 2])('scalar %j', k => { const ten = Tensor.randn([3, 4, 5]) const slice = ten.select(k) expect(slice.sizes).toEqual([1, 4, 5]) @@ -494,7 +494,7 @@ describe('Tensor', () => { } }) - test.each([[[0]], [[1]], [[2]], [[0, 0]], [[1, 2]], [[2, 0]]])('array %p', k => { + test.each([[[0]], [[1]], [[2]], [[0, 0]], [[1, 2]], [[2, 0]]])('array %j', k => { const ten = Tensor.randn([3, 4, 5]) const slice = ten.select(k) expect(slice.sizes).toEqual([k.length, 4, 5]) @@ -509,7 +509,7 @@ describe('Tensor', () => { }) describe('axis 1', () => { - test.each([0, 1, 2])('scalar %p', k => { + test.each([0, 1, 2])('scalar %j', k => { const ten = Tensor.randn([3, 4, 5]) const slice = ten.select(k, 1) expect(slice.sizes).toEqual([3, 1, 5]) @@ -520,7 +520,7 @@ describe('Tensor', () => { } }) - test.each([[[0]], [[1]], [[2]], [[0, 0]], [[1, 2]], [[2, 0]]])('array %p', k => { + test.each([[[0]], [[1]], [[2]], [[0, 0]], [[1, 2]], [[2, 0]]])('array %j', k => { const ten = Tensor.randn([3, 4, 5]) const slice = ten.select(k, 1) expect(slice.sizes).toEqual([3, k.length, 5]) @@ -535,7 +535,7 @@ describe('Tensor', () => { }) describe('axis 2', () => { - test.each([0, 1, 2])('scalar %p', k => { + test.each([0, 1, 2])('scalar %j', k => { const ten = Tensor.randn([3, 4, 5]) const slice = ten.select(k, 2) expect(slice.sizes).toEqual([3, 4, 1]) @@ -546,7 +546,7 @@ describe('Tensor', () => { } }) - test.each([[[0]], [[1]], [[2]], [[0, 0]], [[1, 2]], [[2, 0]]])('array %p', k => { + test.each([[[0]], [[1]], [[2]], [[0, 0]], [[1, 2]], [[2, 0]]])('array %j', k => { const ten = Tensor.randn([3, 4, 5]) const slice = ten.select(k, 2) expect(slice.sizes).toEqual([3, 4, k.length]) @@ -567,7 +567,7 @@ describe('Tensor', () => { }) describe('slice', () => { - describe.each([undefined, 0])('axis %p', axis => { + describe.each([undefined, 0])('axis %j', axis => { test.each([ [0, 1], [0, 2], @@ -684,7 +684,7 @@ describe('Tensor', () => { }) describe('flip', () => { - test.each([undefined, 0])('axis %p', axis => { + test.each([undefined, 0])('axis %j', axis => { const org = Tensor.randn([2, 3, 4]) const ten = org.copy() ten.flip(axis) @@ -730,7 +730,7 @@ describe('Tensor', () => { }) describe('shuffle', () => { - test.each([undefined, 0])('axis %p', axis => { + test.each([undefined, 0])('axis %j', axis => { const org = Tensor.randn([3, 4, 5]) const ten = org.copy() ten.shuffle(axis) @@ -811,7 +811,7 @@ describe('Tensor', () => { } }) - test.each([-1, 3])('fail invalid axis %p', axis => { + test.each([-1, 3])('fail invalid axis %j', axis => { const mat = Tensor.randn([2, 3, 4]) expect(() => mat.shuffle(axis)).toThrow('Invalid axis.') }) @@ -891,7 +891,7 @@ describe('Tensor', () => { describe('repeat', () => { describe.each([undefined, 0, 0])('1d axis %i', axis => { - test.each([2, [2]])('repeat %p', rep => { + test.each([2, [2]])('repeat %j', rep => { const org = Tensor.randn([3]) const ten = org.copy() ten.repeat(rep, axis) @@ -1040,7 +1040,7 @@ describe('Tensor', () => { }) describe('concat', () => { - test.each([undefined, 0])('axis %p', axis => { + test.each([undefined, 0])('axis %j', axis => { const org = Tensor.randn([2, 3, 4]) const ten = org.copy() const t = new Tensor([1, 3, 4]) @@ -1390,7 +1390,7 @@ describe('Tensor', () => { [3, 4, 5], [6, 2, 15], ], - ])('tensor %p + tensor %p', (s1, s2) => { + ])('tensor %j + tensor %j', (s1, s2) => { const org = Tensor.randn(s1) const ten = org.copy() const o = Tensor.randn(s2) From 2e4d709454e9e7a8d74bc6bedb32abb4c1907178 Mon Sep 17 00:00:00 2001 From: ishii-norimi Date: Sun, 16 Nov 2025 15:55:00 +0900 Subject: [PATCH 2/9] =?UTF-8?q?=E3=82=AB=E3=83=90=E3=83=AC=E3=83=83?= =?UTF-8?q?=E3=82=B8=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E6=8C=87=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gh-pages.yml | 1 + .github/workflows/test.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 74921a8e8..5f11fe7b6 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -33,6 +33,7 @@ jobs: uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} + file: coverage/clover.xml continue-on-error: true test-js: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d679d374f..476fd0150 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,7 @@ jobs: uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} + file: coverage/clover.xml continue-on-error: true test-js: runs-on: ubuntu-latest From 8b21218f71f694c410a55397fe78804cf3db6b27 Mon Sep 17 00:00:00 2001 From: ishii-norimi Date: Sun, 16 Nov 2025 19:53:20 +0900 Subject: [PATCH 3/9] Fix test commandline options and improve test options --- .github/workflows/gh-pages.yml | 4 ++-- .github/workflows/npm.yml | 2 +- .github/workflows/test.yml | 4 ++-- tests/lib/model/kernelized_perceptron.test.js | 2 +- tests/lib/model/lmclus.test.js | 2 +- tests/lib/model/nns/layer/graph_sage.test.js | 2 +- tests/lib/model/nns/optimizer/rmsprop.test.js | 2 +- tests/lib/model/polynomial_histogram.test.js | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 5f11fe7b6..e0586344f 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -28,12 +28,12 @@ jobs: - name: Prepare ONNX run: npm run create-onnx -t - name: Test lib - run: npm run test:lib --bail + run: npm run test:lib -- --bail 1 - name: Coveralls uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} - file: coverage/clover.xml + files: coverage/clover.xml continue-on-error: true test-js: runs-on: ubuntu-latest diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 02c18c847..cd5e49efa 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -15,7 +15,7 @@ jobs: - name: Prepare ONNX run: npm run create-onnx -t - name: Test - run: npm run test:lib --bail + run: npm run test:lib -- --bail 1 publish: runs-on: ubuntu-latest needs: test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 476fd0150..04879395e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,12 +13,12 @@ jobs: - name: Prepare ONNX run: npm run create-onnx -t - name: Test lib - run: npm run test:lib --bail + run: npm run test:lib -- --bail 1 - name: Coveralls uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} - file: coverage/clover.xml + files: coverage/clover.xml continue-on-error: true test-js: runs-on: ubuntu-latest diff --git a/tests/lib/model/kernelized_perceptron.test.js b/tests/lib/model/kernelized_perceptron.test.js index ec0dcb75b..26d57a092 100644 --- a/tests/lib/model/kernelized_perceptron.test.js +++ b/tests/lib/model/kernelized_perceptron.test.js @@ -6,7 +6,7 @@ import { accuracy } from '../../../lib/evaluate/classification.js' describe('classification', () => { test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }, 'polynomial', { name: 'polynomial', d: 3 }])( 'kernel %s', - { retry: 10 }, + { retry: 20 }, kernel => { const model = new KernelizedPerceptron(1, kernel) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() diff --git a/tests/lib/model/lmclus.test.js b/tests/lib/model/lmclus.test.js index 69ee4ce4f..9179557c8 100644 --- a/tests/lib/model/lmclus.test.js +++ b/tests/lib/model/lmclus.test.js @@ -3,7 +3,7 @@ import LMCLUS from '../../../lib/model/lmclus.js' import { randIndex } from '../../../lib/evaluate/clustering.js' -test('clustering', { retry: 5 }, () => { +test('clustering', { retry: 10 }, () => { const model = new LMCLUS(5, 1.5, 0.4) const n = 50 const x = Matrix.concat( diff --git a/tests/lib/model/nns/layer/graph_sage.test.js b/tests/lib/model/nns/layer/graph_sage.test.js index ee00a0f0c..f8ad968c2 100644 --- a/tests/lib/model/nns/layer/graph_sage.test.js +++ b/tests/lib/model/nns/layer/graph_sage.test.js @@ -255,7 +255,7 @@ describe('nn', () => { } }) - test('grad decay', () => { + test('grad decay', { timeout: 10000 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'graph_sage', out_size: 3, l2_decay: 0.001 }, { type: 'readout' }], 'mse', diff --git a/tests/lib/model/nns/optimizer/rmsprop.test.js b/tests/lib/model/nns/optimizer/rmsprop.test.js index 8f4beebaf..0519ee277 100644 --- a/tests/lib/model/nns/optimizer/rmsprop.test.js +++ b/tests/lib/model/nns/optimizer/rmsprop.test.js @@ -69,7 +69,7 @@ describe('rmsprop', () => { }) }) -test('nn', { retry: 3 }, () => { +test('nn', { retry: 5 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input', name: 'in' }, diff --git a/tests/lib/model/polynomial_histogram.test.js b/tests/lib/model/polynomial_histogram.test.js index 24670533a..8ecdee672 100644 --- a/tests/lib/model/polynomial_histogram.test.js +++ b/tests/lib/model/polynomial_histogram.test.js @@ -33,7 +33,7 @@ describe('density estimation', () => { expect(corr).toBeGreaterThan(0.1) }) - test.each([0, 2, undefined])('%j', p => { + test.each([0, 2, undefined])('%j', { retry: 3 }, p => { const model = new PolynomialHistogram(p, 2) const n = 500 const x = Matrix.concat(Matrix.randn(n, 2, 0, 0.1), Matrix.randn(n, 2, 5, 0.1)).toArray() From 4d298471998b824227d49bd869cf80fc68e0ab29 Mon Sep 17 00:00:00 2001 From: ishii-norimi Date: Sun, 16 Nov 2025 20:05:00 +0900 Subject: [PATCH 4/9] Update Coveralls action version and fix file parameter in workflows --- .github/workflows/gh-pages.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index e0586344f..9a06a9dea 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -30,10 +30,10 @@ jobs: - name: Test lib run: npm run test:lib -- --bail 1 - name: Coveralls - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@2 with: github-token: ${{ secrets.GITHUB_TOKEN }} - files: coverage/clover.xml + file: coverage/clover.xml continue-on-error: true test-js: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 04879395e..1016153bf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,10 +15,10 @@ jobs: - name: Test lib run: npm run test:lib -- --bail 1 - name: Coveralls - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@2 with: github-token: ${{ secrets.GITHUB_TOKEN }} - files: coverage/clover.xml + file: coverage/clover.xml continue-on-error: true test-js: runs-on: ubuntu-latest From af8f1049dceae43cb96d117d0d46138574a3aa96 Mon Sep 17 00:00:00 2001 From: ishii-norimi Date: Sun, 16 Nov 2025 20:06:43 +0900 Subject: [PATCH 5/9] Update Coveralls action version to v2 in GitHub workflows --- .github/workflows/gh-pages.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 9a06a9dea..d17760d7f 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -30,7 +30,7 @@ jobs: - name: Test lib run: npm run test:lib -- --bail 1 - name: Coveralls - uses: coverallsapp/github-action@2 + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} file: coverage/clover.xml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1016153bf..439136a6a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - name: Test lib run: npm run test:lib -- --bail 1 - name: Coveralls - uses: coverallsapp/github-action@2 + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} file: coverage/clover.xml From 9bae9ca11bf2e609c447f8302df62f10807c2bab Mon Sep 17 00:00:00 2001 From: ishii-norimi Date: Sun, 16 Nov 2025 23:51:19 +0900 Subject: [PATCH 6/9] Increase timeout for 'update' test in lppool test suite --- tests/lib/model/nns/layer/lppool.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/model/nns/layer/lppool.test.js b/tests/lib/model/nns/layer/lppool.test.js index f31a1e5c7..be180ebc7 100644 --- a/tests/lib/model/nns/layer/lppool.test.js +++ b/tests/lib/model/nns/layer/lppool.test.js @@ -311,7 +311,7 @@ describe('layer', () => { }) describe('nn', () => { - test('update', { retry: 3 }, () => { + test('update', { retry: 3, timeout: 10000 }, () => { const net = NeuralNetwork.fromObject( [ { type: 'input' }, From 16a809f3e80bbc7508b44137acebc617fa794f06 Mon Sep 17 00:00:00 2001 From: ishii-norimi Date: Wed, 19 Nov 2025 22:50:20 +0900 Subject: [PATCH 7/9] Enhance test reliability by adding retry options to various model tests --- tests/lib/model/knearestneighbor.test.js | 2 +- tests/lib/model/lvq.test.js | 2 +- tests/lib/model/nns/layer/graph_sage.test.js | 2 +- tests/lib/model/nof.test.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/lib/model/knearestneighbor.test.js b/tests/lib/model/knearestneighbor.test.js index 45444d6fe..1418ad4aa 100644 --- a/tests/lib/model/knearestneighbor.test.js +++ b/tests/lib/model/knearestneighbor.test.js @@ -116,7 +116,7 @@ describe.each([ 'chebyshev', 'minkowski', (a, b) => a.reduce((s, v, i) => s + Math.exp((v - b[i]) ** 2) - 1, 0), -])('anomaly detection %s', metric => { +])('anomaly detection %s', { retry: 5 }, metric => { test.each([undefined, 5])('k %j', k => { const model = new KNNAnomaly(k, metric) const x = Matrix.randn(100, 2, 0, 0.2).toArray() diff --git a/tests/lib/model/lvq.test.js b/tests/lib/model/lvq.test.js index 9cfbab335..60d5e75a7 100644 --- a/tests/lib/model/lvq.test.js +++ b/tests/lib/model/lvq.test.js @@ -35,7 +35,7 @@ describe('clustering', () => { }) describe.each([1, 2, 3])('classification type %i', type => { - test('default', () => { + test('default', { retry: 5 }, () => { const model = new LVQClassifier(type) const x = Matrix.concat(Matrix.randn(50, 2, 0, 0.2), Matrix.randn(50, 2, 5, 0.2)).toArray() x[50] = [0.1, 0.1] diff --git a/tests/lib/model/nns/layer/graph_sage.test.js b/tests/lib/model/nns/layer/graph_sage.test.js index f8ad968c2..edea5f7b7 100644 --- a/tests/lib/model/nns/layer/graph_sage.test.js +++ b/tests/lib/model/nns/layer/graph_sage.test.js @@ -255,7 +255,7 @@ describe('nn', () => { } }) - test('grad decay', { timeout: 10000 }, () => { + test('grad decay', { retry: 3, timeout: 30000 }, () => { const net = NeuralNetwork.fromObject( [{ type: 'input' }, { type: 'graph_sage', out_size: 3, l2_decay: 0.001 }, { type: 'readout' }], 'mse', diff --git a/tests/lib/model/nof.test.js b/tests/lib/model/nof.test.js index 672ca820f..ce5bff52c 100644 --- a/tests/lib/model/nof.test.js +++ b/tests/lib/model/nof.test.js @@ -14,7 +14,7 @@ describe('anomaly detection', () => { expect(y[y.length - 1]).toBe(true) }) - test('no parameters', () => { + test('no parameters', { retry: 3 }, () => { const model = new NOF() const x = Matrix.randn(100, 2, 0, 0.2).toArray() x.push([10, 10]) From ba8148aaca6daa0ab722aa525a568bfbcf5eac3b Mon Sep 17 00:00:00 2001 From: ishii-norimi Date: Wed, 19 Nov 2025 23:13:34 +0900 Subject: [PATCH 8/9] Increase retry count for default MacQueenKMeans test to improve test stability --- tests/lib/model/macqueen_kmeans.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/model/macqueen_kmeans.test.js b/tests/lib/model/macqueen_kmeans.test.js index 93613a765..d154fa35e 100644 --- a/tests/lib/model/macqueen_kmeans.test.js +++ b/tests/lib/model/macqueen_kmeans.test.js @@ -4,7 +4,7 @@ import MacQueenKMeans from '../../../lib/model/macqueen_kmeans.js' import { randIndex } from '../../../lib/evaluate/clustering.js' describe('clustering', () => { - test('default', { retry: 10 }, () => { + test('default', { retry: 20 }, () => { const model = new MacQueenKMeans(3) const n = 20 const x = Matrix.concat( From 534f2d4581f009f206311c9aede596d37d737baf Mon Sep 17 00:00:00 2001 From: ishii-norimi Date: Wed, 19 Nov 2025 23:41:47 +0900 Subject: [PATCH 9/9] Increase retry count for kernel tests in Forgetron model to enhance test stability --- tests/lib/model/forgetron.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/model/forgetron.test.js b/tests/lib/model/forgetron.test.js index 387e25dc2..ae5f8d6b3 100644 --- a/tests/lib/model/forgetron.test.js +++ b/tests/lib/model/forgetron.test.js @@ -4,7 +4,7 @@ import Forgetron from '../../../lib/model/forgetron.js' import { accuracy } from '../../../lib/evaluate/classification.js' describe('classification', () => { - test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', { retry: 10 }, kernel => { + test.each([undefined, 'gaussian', { name: 'gaussian', s: 0.8 }])('kernel %s', { retry: 20 }, kernel => { const model = new Forgetron(10, kernel) const s = 2 const x = []