Open c-winder opened 2 months ago
Hi, @c-winder. Thanks for reporting. Would you be willing to contribute with a PR? We can start by adding your snippet in a unit test, and your fix would make the new test pass.
Sorry for the delay @fepegar, I've raised a PR which fixes the bug and extends test_copy_subclass.
Is there an existing issue for this?
Bug summary
A subclass of Subject with keyword arguments cannot be copied with
copy.copy()
which is used in transform.py. RaisesTypeError: A subject without images cannot be created
.Code for reproduction
Actual outcome
Raises
TypeError: A subject without images cannot be created
.The subclass cannot be copied as
_subject_copy_helper
in subject.py callsnew = new_subj_cls(result_dict)
.In the above example,
result_dict = {'name:'colin', 'brain': ...}
which means thatname=result_dict
on subclass recreation. This is the only parameter the subclass can see and hence it contains no images.This can be fixed by changing
_subject_copy_helper
, to unpackresult_dict
as below, although I'm unsure if this is the best way of implementing the fix.Error messages
Expected outcome
Subclass should copy correctly.
System info