<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> def realign_dtype ( dtype , offsets ) : <EOL> """<STR_LIT>""" <EOL> cls , args , state = dtype . __reduce__ ( ) <EOL> names , fields = state [ <NUM_LIT:3> : <NUM_LIT:5> ] <EOL> fields = fields . copy ( ) <EOL> max_offset = <NUM_LIT:0> <EOL> itemsize = state [ <NUM_LIT:5> ] <EOL> if fields is None or len ( offsets ) != len ( names ) : <EOL> raise ValueError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> for name , offset in zip ( names , offsets ) : <EOL> field = fields [ name ] <EOL> if offset == field [ <NUM_LIT:1> ] : <EOL> continue <EOL> fields [ name ] = ( field [ <NUM_LIT:0> ] , offset ) <EOL> if offset > max_offset : <EOL> itemsize = offset + field [ <NUM_LIT:0> ] . itemsize <EOL> max_offset = offset <EOL> new_typespec = '<STR_LIT>' . format ( itemsize ) <EOL> new_state = state [ : <NUM_LIT:4> ] + ( fields , itemsize ) + state [ <NUM_LIT:6> : ] <EOL> new_dtype = cls ( new_typespec , * args [ <NUM_LIT:1> : ] ) <EOL> new_dtype . __setstate__ ( new_state ) <EOL> return new_dtype </s>
