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

Do not expect much order in the objects of the file #140

Merged
merged 11 commits into from
Feb 8, 2019

Conversation

dneise
Copy link
Member

@dneise dneise commented Jan 31, 2019

This should show the same features as e.g. #138 but it does not expect any particular order in the objects anymore .. at least not so much order as we expected in the master.

This fixes #132, #135 and #137.

The test files needed to show this are in total 60MB! I was unable to make them smaller :-(

The tests showing that this branch fixes the upper issues are:

from collections import defaultdict


# GH: 137
def test_simtel_file_can_read_file_with_strange_structure():
    from eventio import SimTelFile
    path = 'testfile_eventio_issue_137.simtel.gz'
    for event in SimTelFile(path):
        pass
    assert event


# GH: 135
def test_file_really_had_cam_orga_v2():
    from eventio import EventIOFile
    from eventio.simtel.objects import CameraOrganization
    path = 'has_CameraOrganization_v2.simtel.gz'
    cam_orga = []
    for o in EventIOFile(path):
        if isinstance(o, CameraOrganization) and o.header.version == 2:
            cam_orga.append(o)
    assert cam_orga


# GH: 135
def test_SimTelFile_can_read_this_file():
    from eventio import SimTelFile
    path = 'has_CameraOrganization_v2.simtel.gz'
    f = SimTelFile(path)
    assert f.header


# GH: 132
def test_SimTelFile_can_read_multiple_runs_from_file():
    path = 'run1011_merged.dst0.simtel.gz'
    from eventio import SimTelFile
    events_by_run = defaultdict(int)
    f = SimTelFile(path)
    for e in f:
        events_by_run[f.header['run']] += 1

    assert events_by_run[10] == 301
    assert events_by_run[11] == 315

@dneise
Copy link
Member Author

dneise commented Jan 31, 2019

For these tests to work you need a couple of files, which I prepared for this PR.
But I have no idea where to put the files.

https://we.tl/t-19mavjGbGt

@dneise
Copy link
Member Author

dneise commented Jan 31, 2019

Showing that the tests work .. without uploading the test files to github.
https://youtu.be/IH38-ng4JCY

@dneise dneise requested a review from maxnoe February 8, 2019 10:28
@dneise dneise merged commit 6050c17 into master Feb 8, 2019
@dneise dneise deleted the no_object_order_expectation branch February 8, 2019 15:20
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

Successfully merging this pull request may close these issues.

Multiple runs per file not read
2 participants