Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copying BaseCatalogTable objects is unreliable #268

Open
taldcroft opened this issue Feb 13, 2019 · 0 comments
Open

Copying BaseCatalogTable objects is unreliable #268

taldcroft opened this issue Feb 13, 2019 · 0 comments

Comments

@taldcroft
Copy link
Member

These tests fail, so beware that even deepcopy is not doing what you think. Workaround is pickle.loads(pickle.dumps(aca)). I'm surprised that deepcopy() doesn't work since I thought that actually used the pickle __setstate__ and __getstate__ methods.

    aca = get_aca_catalog(**KWARGS_48464)

    aca2 = aca.__class__(aca)  # default is copy=True
    assert aca2.acqs is not aca.acqs
    for probs in aca2.acqs.cand_acqs['probs']:
        assert probs.acqs() is aca2.acqs

    aca3 = deepcopy(aca)
    for probs in aca3.acqs.cand_acqs['probs']:
        assert probs.acqs() is aca3.acqs

I'd like to fix this but initial attempts fell short. The issue revolves around the weakref in the AcqProb objects in the cand_acqs table. This is all a bit fragile and should be reworked, but not for 4.4 since it would be a big change.

However, this does work:

    acar = ACAReviewTable(aca)

    assert aca.guides is not acar.guides
    assert aca.acqs is not acar.acqs

    del aca
    gc.collect()

    # Make sure object is self-consistent and self-contained.
    for probs in acar.acqs.cand_acqs['probs']:
        assert probs.acqs() is acar.acqs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant