Edit: The problem was that I did not update the scene after scaling the object.
I am trying to move the origin of the object to the center of its bounding box.
I tried this solution Get center of geometry of an object
o = bpy.context.object
vcos = [ o.matrix_world @ v.co for v in o.data.vertices ]
findCenter = lambda l: ( max(l) + min(l) ) / 2
x,y,z = [ [ v[i] for v in vcos ] for i in range(3) ]
center = [ findCenter(axis) for axis in [x,y,z] ]
bpy.context.scene.cursor.location = center
bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
This is how it always ends up:

Clearly, the origin doesn't sit at the center of the bounding box. Any help would be greatly appreciated!
global_bbox_center– batFINGER Jul 31 '20 at 16:23