Canonical way of generating matrices #65
Replies: 1 comment 5 replies
-
Hi! No worries, even simple questions can have surprisingly complex answers :) I hope this isn't overwhelming; there's quite a bit of depth to be explored here! So, in principle generating any 2D array is simple: just generate any vector,
For testing purposes, most matrices that are of a similar shape are likely to behave mostly the same. It's the edge cases that are most interesting here, so it would be nicer to bias the generation process a bit to make those edge cases more likely, and in the limit perhaps even guarantee to hit the largest & smallest edge cases. At the same time, precisely because testing with large matrices necessarily takes longer, you also end up wanting to bias the generation towards smaller matrices, since it's generally unlikely that a given bug will only show up with huge matrices. Fulfilling all of those criteria is a bit nontrivial to do - I do have an experiment on an old branch set up, which generates 2D matrices that look like so: Apologies for the lack of labels, this is a graph I made for debugging purposes. The heatmap shows the sizes of various generated matrices that show up while a property is tested, while the bargraph shows how often that particular number of elements showed up in total (which is also important! 5x3 is the same as 3x5 in the amount of data, so making sure that this doesn't disadvantage the diagonal matters). The matrices here go from (30,20) to (90,80). This graph looks quite ok, but there are some bugs still left that I'd love to work out first, and unfortunately I've not been able to spend a bunch of time on this yet :/ |
Beta Was this translation helpful? Give feedback.
-
Hi there,
I'm new to PBT and Supposition.jl, so apologies if this is a bit of a simple question. Is there a canonical way of generating matrices for testing? I have found the
Data.Vectors
generator, but can't see anything analogous for generating aMatrix
, and can't really see a simple way of generating a random (non-square) matrix through@composed
.I found this previous short discussion about Array generators, but I'm not looking to generate arrays with an arbitrary number of dimensions, just a 2D array where the two dimensions have arbitrary size.
Beta Was this translation helpful? Give feedback.
All reactions