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

Scan and imageset slicing inconsistent #213

Closed
rjgildea opened this issue Aug 26, 2020 · 2 comments
Closed

Scan and imageset slicing inconsistent #213

rjgildea opened this issue Aug 26, 2020 · 2 comments

Comments

@rjgildea
Copy link

def test_scan_imageset_slice_consistency(dials_data):
    files = dials_data("centroid_test_data").listdir("*.cbf", sort=True)[1:]
    expt = ExperimentListFactory.from_filenames(f.strpath for f in files)[0]
    assert expt.scan[0:8] == expt.scan
    # The following doesn't work, and expects expt.imageset[1:9]
    assert expt.imageset[0:8] == expt.imageset

gives the following error:

self = <dxtbx_imageset_ext.ImageSequence object at 0x114481810>, item = slice(0, 8, None)

    def __getitem__(self, item):
        """Get an item from the sequence stream.
    
        If the item is an index, read and return the image at the given index.
        Otherwise, if the item is a slice, then create a new Sequence object
        with the given number of array indices from the slice.
    
        Params:
            item The index or slice
    
        Returns:
            An image or new Sequence object
    
        """
        if isinstance(item, slice):
            offset = self.get_scan().get_batch_offset()
            if item.step is not None:
                raise IndexError("Sequences must be sequential")
    
            # nasty workaround for https://github.com/dials/dials/issues/1153
            # slices with -1 in them are meaningful :-/ so grab the original
            # constructor arguments of the slice object.
            # item.start and item.stop may have been compromised at this point.
            if offset < 0:
                start, stop, step = item.__reduce__()[1]
                if start is None:
                    start = 0
                else:
                    start -= offset
                if stop is None:
                    stop = len(self)
                else:
                    stop -= offset
                return self.partial_set(start, stop)
            else:
                start = item.start or 0
                stop = item.stop or (len(self) + offset)
>               return self.partial_set(start - offset, stop - offset)
E               OverflowError: can't convert negative value to unsigned int

imageset.py:264: OverflowError

This issue is the root cause of dials/dials#1382

rjgildea added a commit to dials/dials that referenced this issue Aug 26, 2020
Gorilla of temporary workarounds for inconsistent scan and imageset slicing
(cctbx/dxtbx#213).

Fixes #1382
rjgildea added a commit to dials/dials that referenced this issue Aug 27, 2020
Gorilla of temporary workarounds for inconsistent scan and imageset slicing
(cctbx/dxtbx#213).

Fixes #1382
ndevenish pushed a commit to dials/dials that referenced this issue Sep 1, 2020
Gorilla of temporary workarounds for inconsistent scan and imageset slicing
(cctbx/dxtbx#213).

Also: Add slice_experiments test for #1382

Fixes #1382
@dagewa
Copy link
Member

dagewa commented Jul 28, 2023

Following #634 the inconsistency has been dealt with. Scans and imagesets now slice in the same way (see also dials/dials#2472 (review))

@dagewa dagewa closed this as completed Jul 28, 2023
@ndevenish
Copy link
Collaborator

So, it is probably safe to remove this XPASS now? 3fad1e5

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

3 participants