-
Notifications
You must be signed in to change notification settings - Fork 45
Adding Mkdocs and Simplifying Github Actions #318
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
Changes from all commits
3061305
3d3795c
e47600d
5129e03
5f94cdf
e5e4a0a
df574f9
b816612
0b71b09
e942b79
cf9ab15
1ac6b22
3e43354
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # GitHub Copilot Instructions for cdflib | ||
|
|
||
| This repository contains `cdflib`, a pure Python library for reading and writing NASA Common Data Format (CDF) files. It does not rely on the NASA CDF C library. | ||
|
|
||
| ## Project Architecture & Core Components | ||
|
|
||
| - **Pure Python Implementation**: The core logic uses `numpy` and `struct` to parse binary CDF files. No C extensions are used. | ||
| - **Reading (`cdflib/cdfread.py`)**: | ||
| - The `CDF` class is the main entry point for reading. | ||
| - Supports reading from local files, URLs, and S3 buckets. | ||
| - **Key Method**: `CDF.varget(variable_name)` retrieves variable data. | ||
| - **Key Method**: `CDF.cdf_info()` returns global file information. | ||
| - **Writing (`cdflib/cdfwrite.py`)**: | ||
| - The `CDF` class in this module is used to create new CDF files. | ||
| - Requires a `cdf_spec` dictionary to define file properties (encoding, majority, etc.). | ||
| - **Xarray Integration (`cdflib/xarray/`)**: | ||
| - `cdf_to_xarray`: Converts CDF files to `xarray.Dataset` objects, mapping ISTP attributes to xarray conventions. | ||
| - `xarray_to_cdf`: Converts `xarray.Dataset` objects back to CDF files. | ||
| - **Time Handling (`cdflib/epochs.py`)**: | ||
| - `CDFepoch` class handles conversions between CDF time types (CDF_EPOCH, CDF_EPOCH16, TT2000) and Python `datetime`, `numpy.datetime64`, or Unix timestamps. | ||
|
|
||
| ## Developer Workflows | ||
|
|
||
| - **Dependency Management**: Dependencies are defined in `pyproject.toml`. | ||
| - Core: `numpy` | ||
| - Optional/Test: `xarray`, `astropy`, `hypothesis`, `pytest` | ||
| - **Testing**: | ||
| - Run tests using `tox` to test across multiple Python versions. | ||
| - Run specific tests with `pytest`: `pytest tests/test_cdfread.py`. | ||
| - Tests are located in the `tests/` directory. | ||
| - **Formatting**: | ||
| - The project uses `black` for code formatting and `isort` for import sorting. | ||
| - Configuration is in `pyproject.toml`. | ||
|
|
||
| ## Coding Conventions & Patterns | ||
|
|
||
| - **Type Hinting**: Use Python type hints extensively (e.g., `Union[str, Path]`, `npt.ArrayLike`). | ||
| - **Path Handling**: Support both `str` and `pathlib.Path` objects for file paths. Internally, paths are often resolved to strings or `Path` objects. | ||
| - **Numpy Usage**: Use `numpy` for all array operations. Avoid explicit loops over data where possible. | ||
| - **S3 Support**: When handling S3 paths (`s3://`), use the internal `cdflib.s3` module logic. | ||
|
|
||
| ## Common Code Examples | ||
|
|
||
| ### Reading a CDF File | ||
| ```python | ||
| import cdflib | ||
| cdf_file = cdflib.CDF('/path/to/file.cdf') | ||
| info = cdf_file.cdf_info() | ||
| data = cdf_file.varget("VariableName") | ||
| ``` | ||
|
|
||
| ### Converting to Xarray | ||
| ```python | ||
| from cdflib import cdf_to_xarray | ||
| ds = cdf_to_xarray('/path/to/file.cdf', to_datetime=True) | ||
| ``` | ||
|
|
||
| ### Time Conversion | ||
| ```python | ||
| from cdflib.epochs import CDFepoch | ||
| # Convert CDF epoch to datetime | ||
| dt = CDFepoch.to_datetime(cdf_epoch_value) | ||
| # Convert datetime to CDF epoch | ||
| epoch = CDFepoch.compute(dt) | ||
| ``` | ||
|
|
||
| ### Writing a CDF File | ||
| ```python | ||
| from cdflib.cdfwrite import CDF | ||
| spec = {'Majority': 'row_major', 'Encoding': 6} # 6 is IBMPC_ENCODING | ||
| with CDF('new_file.cdf', cdf_spec=spec) as cdf: | ||
| cdf.write_globalattrs(global_attrs) | ||
| cdf.write_var(var_spec, var_attrs, var_data) | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,49 @@ | ||
| name: Run tests | ||
| name: Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - 'main' | ||
| branches: [ main ] | ||
| pull_request: | ||
| # Allow manual runs through the web UI | ||
| workflow_dispatch: | ||
|
|
||
| # Only allow one run per git ref at a time | ||
| concurrency: | ||
| group: '${{ github.workflow }}-${{ github.ref }}' | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| core: | ||
| uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1 | ||
| with: | ||
| submodules: false | ||
| coverage: codecov | ||
| envs: | | ||
| - linux: py39 | ||
| #- linux: py310 | ||
| #- linux: py311 | ||
| - linux: py312 | ||
| #- windows: py39 | ||
| - windows: py310 | ||
| #- windows: py311 | ||
| #- windows: py312 | ||
| #- macos: py38 | ||
| #- macos: py39 | ||
| #- macos: py310 | ||
| - macos: py311-online | ||
| - macos: py312 | ||
| - windows: py313-devdeps | ||
| tests: | ||
| name: ${{ matrix.os }} / ${{ matrix.python-version }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest, macos-latest] | ||
| python-version: ["3.10", "3.11", "3.12", "3.13"] | ||
| include: | ||
| - os: ubuntu-latest | ||
| python-version: "3.13" | ||
| tox-env: devdeps | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| cache: 'pip' | ||
|
|
||
| - name: Install Tools | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install tox | ||
| - name: Run Tests via Tox | ||
| # If a specific tox-env is set in matrix, use it; otherwise use standard py version | ||
| run: | | ||
| if [ -z "${{ matrix.tox-env }}" ]; then | ||
| tox -e py$(echo ${{ matrix.python-version }} | tr -d .) | ||
bryan-harter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| else | ||
| tox -e ${{ matrix.tox-env }} | ||
| fi | ||
| shell: bash | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||
| name: docs | ||||||
| on: | ||||||
| push: | ||||||
| branches: | ||||||
| - main | ||||||
bryan-harter marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| permissions: | ||||||
| contents: write | ||||||
| jobs: | ||||||
| build-and-deploy-docs: | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - name: Checkout | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Set up Python | ||||||
| uses: actions/setup-python@v5 | ||||||
| with: | ||||||
| python-version: 3.x | ||||||
|
|
||||||
| - name: Install dependencies | ||||||
| run: | | ||||||
| pip install -e .[tests,dev,docs] | ||||||
|
||||||
| pip install -e .[tests,dev,docs] | |
| pip install -e .[docs] |
bryan-harter marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| name: Remote Data Tests | ||
|
|
||
| on: | ||
| # Allow manual trigger via the "Run Workflow" button in UI | ||
| workflow_dispatch: | ||
| # Run automatically every Monday at 6am UTC | ||
| schedule: | ||
| - cron: '0 6 * * 1' | ||
|
|
||
| jobs: | ||
| remote-tests: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| pip install .[tests] | ||
|
|
||
| - name: Run Remote Tests | ||
| # We explicitly tell pytest to run ONLY the remote_data tests | ||
| run: pytest -m remote_data |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.