Skip to content

Commit

Permalink
add pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
loco-philippe committed May 21, 2024
1 parent ce63555 commit 9890f1c
Show file tree
Hide file tree
Showing 23 changed files with 1,691 additions and 1,230 deletions.
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/-use--custom-issue-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ labels: ''
assignees: ''

---


12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install
run: |
python -m pip install --upgrade pip
pip install -r ./ci/requirements.txt
- name: Lint
run: |
# stop if Python syntax errors or undefined names
# stop if Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# treats all errors as warnings
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test
run: |
python -m unittest discover -s ./tests -p 'tests_*.py'
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
exclude: '\\*.htm*'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # the release, git tag, or commit you want to use
hooks:
- id: check-toml
- id: check-yaml
- id: check-json
- id: check-docstring-first
- id: check-ast
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.4
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format

#- repo: https://github.com/numpy/numpydoc
# rev: v1.6.0
# hooks:
# - id: numpydoc-validation
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ In [1]: example = {
'var1.variance': [[[2, 2], [0.1, 0.2, 0.3, 0.4]]],
'var1.mask1': [[[True, False]], ['x']],
'var1.mask2': [[[2, 2], [True, False, False, True]]],
'var2': [['var2.ntv'], ['x', 'y']],

'var2': [['var2.ntv'], ['x', 'y']],

'x': [['string', ['23F0AE', '578B98']], {'test': 21}],
'y': [['date', ['2021-01-01', '2022-02-02']]],

'ranking': [['month', [2, 2], [1, 2, 3, 4]], ['var1']],
'z': [['float', [10, 20]], ['x']],
'z.uncertainty': [[[0.1, 0.2]]],

'z_bis': [[['z1_bis', 'z2_bis']]],

'info': {'path': 'https://github.com/loco-philippe/ntv-numpy/tree/main/example/',
'location': [['string', ['paris']]]}
}
Expand Down Expand Up @@ -136,20 +136,20 @@ Out[5]: True
In [6]: x_dataframe = x_example.to_dataframe()
print(x_example.to_dataframe(json_name=False))
print(x_xarray)
Out[6]:
Out[6]:
ranking z z.uncertainty var1 var1.mask1 var1.mask2 \
x y
23F0AE 2021-01-01 1 10.0 0.1 10.1 True True
2022-02-02 2 10.0 0.1 0.4 True False
578B98 2021-01-01 3 20.0 0.2 3.4 False False
2022-02-02 4 20.0 0.2 8.2 False True

var1.variance location
x y
23F0AE 2021-01-01 0.1 paris
2022-02-02 0.2 paris
578B98 2021-01-01 0.3 paris
2022-02-02 0.4 paris
x y
23F0AE 2021-01-01 1 10.0 0.1 10.1 True True
2022-02-02 2 10.0 0.1 0.4 True False
578B98 2021-01-01 3 20.0 0.2 3.4 False False
2022-02-02 4 20.0 0.2 8.2 False True

var1.variance location
x y
23F0AE 2021-01-01 0.1 paris
2022-02-02 0.2 paris
578B98 2021-01-01 0.3 paris
2022-02-02 0.4 paris
```

Reversibility:
Expand Down Expand Up @@ -203,9 +203,9 @@ In [1]: example = {
'LATPOLE': -72.05457184279, 'WCSNAME': 'IDC_qbu1641sj', 'MJDREF': 0.0, 'RADESYS': 'ICRS'},
'psf': [['float[erg/s]', [1,2,3,4]]]
}
}
}
n_example = Xdataset.read_json(example)
n_example.info
n_example.info
Out[1]: {'name': 'example',
'xtype': 'group',
'data_arrays': ['data', 'psf'],
Expand Down Expand Up @@ -240,18 +240,18 @@ In [1]: example = {
'var1.variance': [[[2, 2], 'var1_variance.ntv']],
'var1.mask1': [['var1_mask1.ntv'], ['x']],
'var1.mask2': [[[2, 2], 'var1_mask2.ntv']],
'var2': [['var2.ntv'], ['x', 'y']],

'var2': [['var2.ntv'], ['x', 'y']],

'x': [['x.ntv'], {'test': 21}],
'y': [['date', 'y.ntv']],

'ranking': [['month', [2, 2], 'ranking.ntv'], ['var1']],
'z': [['float', 'z.ntv'], ['x']],
'z.uncertainty': [['z_uncertainty.ntv']],

'z_bis': [['z_bis.ntv']],

'info': {'path': 'https://github.com/loco-philippe/ntv-numpy/tree/main/example/'}
}
}
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
@author: philippe@loco-labs.io
"""

name = 'ntv_numpy'
name = "ntv_numpy"
6 changes: 3 additions & 3 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Version x.y.z
- add NTVtype extension (Ndtype class)
- add 'uniques' xndarray
- interface:
- pandas.DataFrame
- pandas.DataFrame

0.1.2 alpha 1 (2024-04-10)
---------------------------
- First version
- exchanging via JSON format
- lightweight format (structure: json, arrays: URI)
- lightweight format (structure: json, arrays: URI)
- numpy.dtype supported: all except 'complex' and 'timedelta'
- NTVtype supported:
- datetime, date, time, dat
Expand All @@ -33,4 +33,4 @@ Version x.y.z
- astropy.NDData
- scipp.Dataset
- Xarray.Dataset, Xarray.Dataarray
- JSON
- JSON
2 changes: 1 addition & 1 deletion example/ex_ndarray.ntv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{":ndarray": ["int64[kg]", [2, 2], [[1, 2, 3, 4], [0, 1, 2, 3]]]}
{":ndarray": ["int64[kg]", [2, 2], [[1, 2, 3, 4], [0, 1, 2, 3]]]}
2 changes: 1 addition & 1 deletion example/interop.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ flowchart LR
D[Scipp] <--lossless--> B
C[NDData] <--lossless--> B
B <--lossless--> E[JSON]
B <--lossless--> F[DataFrame]
B <--lossless--> F[DataFrame]
2 changes: 1 addition & 1 deletion example/struc.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ flowchart LR
classDef xnda fill:#99d,stroke:#009,stroke-width:2px,color:#808
classDef nda fill:#77b,stroke:#00e,stroke-width:2px,color:#808
classDef da fill:#55b,stroke:#00e,stroke-width:2px,color:#fff
classDef dataset stroke:#007,fill:#bbf,color:#808
classDef dataset stroke:#007,fill:#bbf,color:#808
28 changes: 16 additions & 12 deletions ntv_numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,22 @@
- `ntv-numpy.ntv_numpy.ndtype.Ndtype`
"""
# from pathlib import Path
# , read_json, to_json
from ntv_numpy.numpy_ntv_connector import XndarrayConnec, NdarrayConnec
from ntv_numpy.data_array import Dfull, Dcomplete, Darray, Dutil
from ntv_numpy.ndarray import Ndarray, Nutil
from ntv_numpy.xndarray import Xndarray
from ntv_numpy.xdataset import Xdataset
import ntv_numpy.xarray_accessors
# import ntv_pandas.pandas_ntv_connector
- `ntv-numpy.ntv_numpy.xarray_accessors` :
# path = Path(ntv_numpy.numpy_ntv_connector.__file__).parent
- `ntv-numpy.ntv_numpy.xarray_accessors.NxrDatasetAccessor`
"""

# print('package :', __package__)
# from pathlib import Path
# , read_json, to_json
from ntv_numpy.numpy_ntv_connector import XndarrayConnec as XndarrayConnec
from ntv_numpy.numpy_ntv_connector import NdarrayConnec as NdarrayConnec
from ntv_numpy.data_array import Dfull as Dfull
from ntv_numpy.data_array import Dcomplete as Dcomplete
from ntv_numpy.data_array import Darray as Darray
from ntv_numpy.data_array import Dutil as Dutil
from ntv_numpy.ndarray import Nutil as Nutil
from ntv_numpy.ndarray import Ndarray as Ndarray
from ntv_numpy.xndarray import Xndarray as Xndarray
from ntv_numpy.xdataset import Xdataset as Xdataset
from ntv_numpy.xarray_accessors import NxrDatasetAccessor as NxrDatasetAccessor
Loading

0 comments on commit 9890f1c

Please sign in to comment.