Skip to content

Commit

Permalink
Merge pull request #154 from MC-kit/devel
Browse files Browse the repository at this point in the history
Add export to pandas and duckdb
  • Loading branch information
dvp2015 authored Apr 2, 2023
2 parents 13698da + 316a1c5 commit 8b8cf1a
Show file tree
Hide file tree
Showing 45 changed files with 11,186 additions and 457 deletions.
8 changes: 6 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,19 @@ exclude=
*.egg-info
.cache
.eggs
notebooks/dvp/*.py
.nox
.idea

per-file-ignores =
benchmarks/*:S101,DAR101
noxfile.py:ANN,DAR101
tools/clear-prev-dist-info.py:S404,S603,S607
tests/*:ANN,B950,DAR100,D100,D101,D102,D103,D104,DAR101,DAR103,S101
src/xpypact/Inventory.py:F811
src/xpypact/inventory.py:F811
src/xpypact/data_arrays.py:ANN401,PD011
src/xpypact/utils/resource.py:ANN202
src/xpypact/Fluxes.py:F811
src/xpypact/fluxes.py:F811
ignore-decorators=click,pytest
docstring-convention = google
rst-roles = class,const,func,meth,mod,ref
Expand Down
2 changes: 1 addition & 1 deletion .github/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip==23.0.1
nox==2022.11.21
poetry==1.4.0
poetry==1.4.1
virtualenv==20.16.5 # restricted by poetry on Windows, current 20.17.1
wheel-0.38.4
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.5.0

- name: Sync GitHub Issue Labels
uses: crazy-max/ghaction-github-labeler@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

steps:
- name: Check out the repository
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.5.0
with:
fetch-depth: 2 # need previous revision to define tag

Expand Down Expand Up @@ -71,14 +71,14 @@ jobs:
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/gh-action-pypi-publish@v1.6.4
uses: pypa/gh-action-pypi-publish@v1.8.3
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/gh-action-pypi-publish@v1.6.4
uses: pypa/gh-action-pypi-publish@v1.8.3
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/stale@v7
- uses: actions/stale@v8
with:
repo-token: ${{ secrets.MCKIT_GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
!contains(github.event.head_commit.message, '[skip_ci]')
steps:
- name: Check out the repository
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.5.0

- name: Set up Python 3.10 # on 3.11 pip install in unstable: "canonicalize" fails occasionally
uses: actions/[email protected]
Expand All @@ -55,7 +55,7 @@ jobs:
- name: Load poetry cache
id: cached-poetry-dependencies
uses: actions/cache@v3.2.6
uses: actions/cache@v3.3.1
with:
path: |
.cache/pypoetry
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
needs: lint
steps:
- name: Check out the repository
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.5.0
with:
fetch-depth: 1

Expand All @@ -106,7 +106,7 @@ jobs:
- name: Load poetry cache
id: cached-poetry-dependencies
uses: actions/cache@v3.2.6
uses: actions/cache@v3.3.1
with:
path: |
.cache/pypoetry
Expand Down Expand Up @@ -137,7 +137,7 @@ jobs:
steps:

- name: Checkout repository
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.5.0
with:
fetch-depth: 1

Expand All @@ -158,7 +158,7 @@ jobs:
- name: Load poetry cache
id: cached-poetry-dependencies
uses: actions/cache@v3.2.6
uses: actions/cache@v3.3.1
with:
path: |
.cache/pypoetry
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
steps:

- name: Check out the repository
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3.5.0

- name: Set up Python 3.11
uses: actions/[email protected]
Expand All @@ -201,7 +201,7 @@ jobs:
- name: Load poetry cache
id: cached-poetry-dependencies
uses: actions/cache@v3.2.6
uses: actions/cache@v3.3.1
with:
path: |
.cache/pypoetry
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,9 @@ dmypy.json

# A soundbox work and data folder
wrk/


# poetry local config
/poetry.toml


8 changes: 5 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ repos:
entry: poetry run black
language: system
types: [python]
exclude: ^notebooks
# Lint
- id: flake8
name: flake8
entry: poetry run flake8
- id: ruff
name: ruff
entry: poetry run ruff --force-exclude --fix --config pyproject.toml
language: system
types: [python]
exclude: ^notebooks
# Also code format the docs
# - id: blacken-docs
# name: blacken-docs
Expand Down
17 changes: 14 additions & 3 deletions benchmarks/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@
See https://pytest-benchmark.readthedocs.io/en/latest/index.html
"""
from __future__ import annotations

from typing import TYPE_CHECKING, cast

import bz2

from xpypact.Inventory import Inventory, from_json
from pathlib import Path

from xpypact.inventory import from_json
from xpypact.utils.resource import path_resolver

if TYPE_CHECKING:
from xpypact.inventory import Inventory

EXPECTED_TIME_STEPS = 65

data_path_resolver = path_resolver("benchmarks")

with bz2.open(data_path_resolver("data/Ag-1.json.bz2")) as fid:
with bz2.open(cast(Path, data_path_resolver("data/Ag-1.json.bz2"))) as fid:
AG_1_TEXT = fid.read().decode("utf-8")


def test_load_from_string(benchmark) -> None:
"""Loading from string."""
inventory: Inventory = benchmark(from_json, AG_1_TEXT)
assert len(inventory.inventory_data) == 65
assert len(inventory.inventory_data) == EXPECTED_TIME_STEPS
26 changes: 14 additions & 12 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
from typing import Dict, List

import sys

from pathlib import Path

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import sys

from pathlib import Path

pkg_path = Path("..", "..", "src").absolute()
assert pkg_path.exists(), f"Invalid path {pkg_path}"
sys.path.insert(0, str(pkg_path))

from typing import Dict, List
import xpypact # noqa: E402

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import mckit_nuclides

# -- Project information -----------------------------------------------------

Expand All @@ -35,9 +37,9 @@
# built documents.
#
# The short X.Y version.
version = mckit_nuclides.__version__.rsplit(".", maxsplit=1)[0]
version = xpypact.__version__.rsplit(".", maxsplit=1)[0]
# The full version, including alpha/beta/rc tags.
release = mckit_nuclides.__version__
release = xpypact.__version__


# -- General configuration ---------------------------------------------------
Expand Down
Loading

0 comments on commit 8b8cf1a

Please sign in to comment.