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

We should [not] use assert to control program flow? #566

Open
graeme-winter opened this issue Oct 24, 2022 · 2 comments
Open

We should [not] use assert to control program flow? #566

graeme-winter opened this issue Oct 24, 2022 · 2 comments

Comments

@graeme-winter
Copy link
Collaborator

Discussion topic / vote - derived from investigation of dials/dials#2253

We should use assert to control program flow e.g.

def datablocks_from_imagesets(imagesets):
    """Load a list of datablocks from imagesets."""

    datablocks = []
    if not isinstance(imagesets, list):
        imagesets = [imagesets]
    for imageset in imagesets:
        try:
            datablocks[-1].append(imageset)
        except (IndexError, AssertionError):
            datablocks.append(DataBlock([imageset]))
    return datablocks

it is appropriate to use raising of AssertionError to indcate that we should have a new DataBlock not a continuation of an existing one. Vote 👍 if you agree or 👎 if you do not, or comment below.

@graeme-winter graeme-winter changed the title We should not use assert to control program flow? We should [not] use assert to control program flow? Oct 24, 2022
@graeme-winter
Copy link
Collaborator Author

Commentary: some motivation behind the DXTBX_ASSERT etc. available at

https://web.archive.org/web/20050226022241/http://www.cuj.com/documents/s=8464/cujcexp0308alexandr/

@graeme-winter
Copy link
Collaborator Author

See your AssertionError and raise RuntimeError as 100% should not be used

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