-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from cta-observatory/zstd
Zstd support
- Loading branch information
Showing
14 changed files
with
191 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
NUMBA_NUM_THREADS: 1 | ||
MPLBACKEND: Agg | ||
PYTEST_ADDOPTS: --color=yes | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.7, 3.8, 3.9] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python --version | ||
pip install codecov pytest-cov pyflakes | ||
pip install -e .[all] | ||
pip freeze | ||
- name: Static codechecks | ||
run: | | ||
pyflakes corsikaio | ||
- name: Tests | ||
run: | | ||
pytest --cov --cov-report=xml | ||
- uses: codecov/codecov-action@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Deploy to PyPi | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python --version | ||
pip install -U build | ||
python -m build | ||
- name: Publish package | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.pypi_password }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
from .file import CorsikaFile, CorsikaCherenkovFile, CorsikaParticleFile | ||
|
||
|
||
__version__ = '0.2.5' | ||
|
||
|
||
__all__ = [ | ||
'CorsikaFile', | ||
'CorsikaCherenkovFile', | ||
'CorsikaParticleFile', | ||
'as_dict', | ||
] | ||
|
||
|
||
def as_dict(structured_array): | ||
''' | ||
Convert a structured array or row of a structure array to a python dict | ||
Useful for pretty printing run / event headers: | ||
>>> as_dict(event.header) | ||
''' | ||
return {k: structured_array[k] for k in structured_array.dtype.names} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[metadata] | ||
version = attr: corsikaio.__version__ | ||
|
||
[aliases] | ||
test=pytest | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,19 +5,26 @@ | |
long_description = f.read() | ||
|
||
|
||
extras = { | ||
'zstd': ['zstandard'], | ||
'tests': ['pytest'], | ||
} | ||
extras['all'] = list({dep for deps in extras.values() for dep in deps}) | ||
|
||
setup( | ||
name='corsikaio', | ||
version='0.2.4.post1', | ||
description='Reader for corsika binary output files using numpy', | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
url='http://github.com/fact-project/corsikaio', | ||
url='http://github.com/cta-observatory/corsikaio', | ||
author='Maximilian Nöthe', | ||
author_email='[email protected]', | ||
license='MIT', | ||
packages=find_packages(), | ||
tests_require=['pytest'], | ||
setup_requires=['pytest-runner'], | ||
extras_require=extras, | ||
python_requires='>=3.6', | ||
install_requires=[ | ||
'numpy', | ||
], | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
def test_as_dict(): | ||
from corsikaio import CorsikaCherenkovFile, as_dict | ||
|
||
with CorsikaCherenkovFile('tests/resources/corsika75700') as f: | ||
e = next(f) | ||
|
||
header = as_dict(e.header) | ||
assert isinstance(header, dict) | ||
assert header['event_number'] == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
import gzip | ||
import tempfile | ||
|
||
|
||
def test_is_gzip(): | ||
from corsikaio.file import is_gzip | ||
def test_is_not_gzip(tmp_path): | ||
from corsikaio.io import is_gzip | ||
|
||
with tempfile.NamedTemporaryFile() as tmp: | ||
with open(tmp.name, 'wb') as f: | ||
f.write(b'Hello World') | ||
path = tmp_path / "no_gzip_file" | ||
|
||
with open(tmp.name, 'rb') as f: | ||
assert not is_gzip(f) | ||
with open(path, 'wb') as f: | ||
f.write(b'Hello World') | ||
|
||
with tempfile.NamedTemporaryFile() as tmp: | ||
with gzip.open(tmp.name, 'wb') as f: | ||
f.write(b'Hello World') | ||
assert not is_gzip(path) | ||
|
||
with open(tmp.name, 'rb') as f: | ||
assert is_gzip(f) | ||
def test_is_gzip(tmp_path): | ||
from corsikaio.io import is_gzip | ||
|
||
path = tmp_path / "gzip_file" | ||
|
||
with gzip.open(path, 'wb') as f: | ||
f.write(b'Hello World') | ||
|
||
assert is_gzip(path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pytest | ||
|
||
def test_is_not_zstd(tmp_path): | ||
from corsikaio.io import is_zstd | ||
|
||
path = tmp_path / "no_a_zstd_file" | ||
|
||
with open(path, 'wb') as f: | ||
f.write(b'Hello World') | ||
|
||
assert not is_zstd(path) | ||
|
||
def test_is_zstd(tmp_path): | ||
zstd = pytest.importorskip("zstandard") | ||
|
||
from corsikaio.io import is_zstd | ||
path = tmp_path / "zstd_file" | ||
|
||
with open(path, 'wb') as f: | ||
compressor = zstd.ZstdCompressor() | ||
with compressor.stream_writer(f) as writer: | ||
writer.write(b'Hello World') | ||
|
||
assert is_zstd(path) |