From 4bc3da3fdecba515e8f59fa601d9779eba74a79b Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 16 Jan 2024 11:51:16 -0600 Subject: [PATCH 1/3] ADD: Stricter unit tests for number concentration --- setup.py | 2 +- tests/test_gfit.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c51f78a..4ec2111 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ PLATFORMS = "Linux, Windows, OSX" MAJOR = 1 MINOR = 3 -MICRO = 4 +MICRO = 5 #SCRIPTS = glob.glob('scripts/*') #TEST_SUITE = 'nose.collector' diff --git a/tests/test_gfit.py b/tests/test_gfit.py index 26c1956..fd15de0 100644 --- a/tests/test_gfit.py +++ b/tests/test_gfit.py @@ -29,3 +29,8 @@ def test_psds(): my_binary['ScatDiaBC50'].values[ScatRejectKey == 0]) < 1000. my_psds = pysp2.util.process_psds(my_binary, my_hk, my_ini) np.testing.assert_almost_equal(my_psds['NumConcIncan'].max(), 0.95805343) + np.testing.assert_almost_equal(my_psds['ScatNumEnsemble'].sum(), 254.773995310) + np.testing.assert_almost_equal(my_psds['IncanNumEnsemble'].sum(), 32.22939087) + np.testing.assert_almost_equal(my_psds['ScatMassEnsemble'].sum(), 3.15026266) + np.testing.assert_almost_equal(my_psds['IncanMassEnsemble'].sum(), 0.08177226) + From 9b54c45498d40a0cf9840284d2ba1407ce03cc96 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 16 Jan 2024 13:21:17 -0600 Subject: [PATCH 2/3] FIX: Pin sphinx and .csv to .text for new version of ACT --- docs/environment_docs.yml | 1 + pysp2/io/read_dat.py | 4 ++-- pysp2/io/read_hk.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/environment_docs.yml b/docs/environment_docs.yml index 385ba2b..acff5a2 100644 --- a/docs/environment_docs.yml +++ b/docs/environment_docs.yml @@ -12,3 +12,4 @@ dependencies: - pydata-sphinx-theme<0.9.0 - sphinx_design - nbsphinx + - sphinxcontrib-applehelp<1.0.8 diff --git a/pysp2/io/read_dat.py b/pysp2/io/read_dat.py index d1c6eae..96daba3 100644 --- a/pysp2/io/read_dat.py +++ b/pysp2/io/read_dat.py @@ -38,9 +38,9 @@ def read_dat(file_name, type): for f in fname: try: if type.lower() == 'particle': - ds = act.io.csvfiles.read_csv(f, sep="\t", skiprows=2) + ds = act.io.text.read_csv(f, sep="\t", skiprows=2) else: - ds = act.io.csvfiles.read_csv(f, sep="\t") + ds = act.io.text.read_csv(f, sep="\t") ds_list.append(ds) except (pd.errors.EmptyDataError, IndexError): continue diff --git a/pysp2/io/read_hk.py b/pysp2/io/read_hk.py index c76d639..dd4f7c9 100644 --- a/pysp2/io/read_hk.py +++ b/pysp2/io/read_hk.py @@ -29,7 +29,7 @@ def read_hk_file(file_name): try: my_df = act.io.csvfiles.read_csv(file_name, sep="\t") except AttributeError: - my_df = act.io.csv.read_csv(file_name, sep="\t") + my_df = act.io.text.read_csv(file_name, sep="\t") # Parse time from filename start_time = pd.Timestamp('1904-01-01') my_df = my_df.rename({'index': 'time'}) From bc8e501b16cecedddfc0bbd411fba3a03661aef6 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 18 Jan 2024 14:58:31 -0600 Subject: [PATCH 3/3] ADD: Fixes for the docs and stricter unit tests --- .github/workflows/pypi-release.yml | 74 +++++++++++++++ docs/environment_docs.yml | 4 +- docs/source/_static/default.css | 146 ----------------------------- docs/source/_static/doc_shared.js | 2 +- docs/source/_templates/layout.html | 9 -- docs/source/conf.py | 5 +- pysp2/__init__.py | 2 +- pysp2/io/read_dat.py | 4 +- pysp2/vis/plot_wave.py | 4 +- setup.py | 4 +- 10 files changed, 85 insertions(+), 169 deletions(-) create mode 100644 .github/workflows/pypi-release.yml delete mode 100644 docs/source/_static/default.css diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml new file mode 100644 index 0000000..8de3d0d --- /dev/null +++ b/.github/workflows/pypi-release.yml @@ -0,0 +1,74 @@ +name: Build and Upload PySP2 Release to PyPI +on: + release: + types: + - published + +jobs: + build-artifacts: + runs-on: ubuntu-latest + if: github.repository == 'ARM-DOE/PySP2' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-python@v4 + name: Install Python + with: + python-version: 3.11 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install setuptools setuptools-scm wheel twine check-manifest + - name: Build tarball and wheels + run: | + git clean -xdf + git restore -SW . + python -m build --sdist --wheel . + - name: Check built artifacts + run: | + python -m twine check dist/* + pwd + if [ -f dist/pysp2-0.0.0.tar.gz ]; then + echo "❌ INVALID VERSION NUMBER" + exit 1 + else + echo "✅ Looks good" + fi + - uses: actions/upload-artifact@v3 + with: + name: releases + path: dist + + test-built-dist: + needs: build-artifacts + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v4 + name: Install Python + with: + python-version: "3.x" + - uses: actions/download-artifact@v3 + with: + name: releases + path: dist + - name: List contents of built dist + run: | + ls -ltrh + ls -ltrh dist + upload-to-pypi: + needs: test-built-dist + if: github.event_name == 'release' + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: releases + path: dist + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@v1.8.10 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + verbose: true \ No newline at end of file diff --git a/docs/environment_docs.yml b/docs/environment_docs.yml index acff5a2..e591e8d 100644 --- a/docs/environment_docs.yml +++ b/docs/environment_docs.yml @@ -5,11 +5,11 @@ channels: dependencies: - act-atmos - xarray + - sphinx + - pydata-sphinx-theme - pip: - - sphinx - sphinx_gallery - sphinx-copybutton - - pydata-sphinx-theme<0.9.0 - sphinx_design - nbsphinx - sphinxcontrib-applehelp<1.0.8 diff --git a/docs/source/_static/default.css b/docs/source/_static/default.css deleted file mode 100644 index 229041c..0000000 --- a/docs/source/_static/default.css +++ /dev/null @@ -1,146 +0,0 @@ -/* ACT style heading towards use of Poppins font */ -.header-style, h1, h2, h3, h4, h5, h6 { - font-family: Poppins, sans-serif; - } - - /* ARM header color */ - .bg-arm { - background-color: #182b55; - } - - :root { - --pst-color-navbar-link: 255, 255, 255; - --pst-color-text-base: 24, 43, 85; - --pst-color-h3: var(--pst-color-text-base); - --pst-color-h4: var(--pst-color-text-base); - --pst-color-h5: var(--pst-color-text-base); - --pst-color-h6: var(--pst-color-text-base); - --pst-color-paragraph: var(--pst-color-text-base); - } - -/* Override the default color set in the original theme for title */ -.navbar-brand>.title { - color: rgba(255, 255, 255) !important; - font-weight: 400 !important; - font-style: bold; -} - - /* Override the default color set in the original theme */ - .navbar-nav>.active>.nav-link { - color: rgba(255, 255, 255) !important; - font-weight: 400 !important; - font-style: italic; - } - - .fa-github-square:before { - color: rgba(255, 255, 255) !important; - font-weight: 400 !important; - } - - .fa-twitter-square:before { - color: rgba(255, 255, 255) !important; - font-weight: 400 !important; - } - - /* Override the default logo height */ - .navbar-brand { - height: 50px; - } - - /* Enhance the links to function docs in the gallery examples */ - div[class^="highlight"] a { - background-color: #EEEEEE; - } - - /* Control the appearance of the version alert banner */ - #banner .alert-version, .alert-news { - margin: 1em; - padding: 0.5em; - font-family: "Work Sans", sans-serif; - font-weight: 600; font-size: 16px; - } - - .intro-card { - background: #d8e5e8; - border: none; - border-radius: 0; - padding: 30px 10px 10px 10px; - margin: 10px 0px; - } - - .intro-card .card-text { - margin: 20px 0px; - } - - .card-button { - background-color: #fafafa; - border: none; - color: #484848; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 0.9rem; - border-radius: 0.5rem; - max-width: 220px; - padding: 0.5rem 0rem; - margin-top: auto; - } - - .card-button a { - color: #484848; - } - - .card-button p { - margin-top: 0; - margin-bottom: 0rem; - color: #484848; - } - - /* Tweaks to the appearance of the sidebars */ - .bd-sidebar { - flex: 0 0 20%; - border-right: none; - } - - .bd-toc .tocsection { - border-left: none; - } - - .bd-toc .section-nav { - border-left: none; - } - - /* Can remove once theme releases new version */ - /* xarray output display in bootstrap */ - .xr-wrap[hidden] { - display: block !important; - } - - .xr-var-data pre { - border: none; - box-shadow: none; - } - - - /* Styling the API Changes Table */ - .api-table tr:nth-child(3n + 1){ - background: #EEF5F5; - } - - .api-table tr:nth-child(3n + 2){ - opacity: 0.65; - } - - code.literal:not(.xref) span.pre { - color: #000; - } - - .api-table tr:nth-child(3n + 2)>td span:first-child::before{ - content: url(old.png); - zoom: 0.25; - } - - .api-table tr:nth-child(3n + 3)>td span:first-child::before{ - content: url(new.png); - zoom: 0.21; - } diff --git a/docs/source/_static/doc_shared.js b/docs/source/_static/doc_shared.js index 9d59448..8ab970f 100644 --- a/docs/source/_static/doc_shared.js +++ b/docs/source/_static/doc_shared.js @@ -1,4 +1,4 @@ -const project = "ACT"; +const project = "PySP2"; // Borrowed from Bokeh docs to look for a banner.html at the base of the docs repo and add that // to the banner if present. diff --git a/docs/source/_templates/layout.html b/docs/source/_templates/layout.html index a5e99e6..cfa4bfd 100644 --- a/docs/source/_templates/layout.html +++ b/docs/source/_templates/layout.html @@ -6,12 +6,3 @@ {{ super() }} {% endblock %} - -{% block docs_navbar %} - - -{# Added to support a banner with an alert #} - -{% endblock %} diff --git a/docs/source/conf.py b/docs/source/conf.py index b9593ab..78e68f6 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -72,9 +72,6 @@ napoleon_include_init_with_doc = False napoleon_use_param = False -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -87,7 +84,7 @@ # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] -html_css_files = ['default.css'] +html_css_files = ['act-theme.css'] html_js_files = ['doc_shared.js'] diff --git a/pysp2/__init__.py b/pysp2/__init__.py index 1070b21..12ed406 100644 --- a/pysp2/__init__.py +++ b/pysp2/__init__.py @@ -9,4 +9,4 @@ from . import vis from . import testing -__version__ = "1.3.3" +__version__ = "1.4.0" diff --git a/pysp2/io/read_dat.py b/pysp2/io/read_dat.py index 96daba3..d1c6eae 100644 --- a/pysp2/io/read_dat.py +++ b/pysp2/io/read_dat.py @@ -38,9 +38,9 @@ def read_dat(file_name, type): for f in fname: try: if type.lower() == 'particle': - ds = act.io.text.read_csv(f, sep="\t", skiprows=2) + ds = act.io.csvfiles.read_csv(f, sep="\t", skiprows=2) else: - ds = act.io.text.read_csv(f, sep="\t") + ds = act.io.csvfiles.read_csv(f, sep="\t") ds_list.append(ds) except (pd.errors.EmptyDataError, IndexError): continue diff --git a/pysp2/vis/plot_wave.py b/pysp2/vis/plot_wave.py index 8cbb5de..870e0d6 100644 --- a/pysp2/vis/plot_wave.py +++ b/pysp2/vis/plot_wave.py @@ -50,9 +50,9 @@ def plot_wave(ds, record_no, chn, plot_fit=True, if append_to_display is not False: display = append_to_display else: - display = act.plotting.HistogramDisplay(inp_data) + display = act.plotting.DistributionDisplay(inp_data) else: - display = act.plotting.HistogramDisplay(inp_data, **init_kwargs) + display = act.plotting.DistributionDisplay(inp_data, **init_kwargs) if 'subplot_index' in kwargs.keys(): ax = display.plot_size_distribution( 'Data_ch' + str(chn), bins, diff --git a/setup.py b/setup.py index 4ec2111..a81d304 100644 --- a/setup.py +++ b/setup.py @@ -40,8 +40,8 @@ LICENSE = 'BSD' PLATFORMS = "Linux, Windows, OSX" MAJOR = 1 -MINOR = 3 -MICRO = 5 +MINOR = 4 +MICRO = 0 #SCRIPTS = glob.glob('scripts/*') #TEST_SUITE = 'nose.collector'