Calculating for the scale factor

Are the shapes groups or component instances ?

If yes, then see these posts for getting the scales of instances:
How to check if 2 transformation are same? - #4 by DanRathbun
… or …
Face#area weird behavior - #6 by Aerilius

If not, get the scale by using the edges.

scale = edge1_of_shape2 / edge1_of_shape1