Skip to content

Commit

Permalink
Merge branch 'main' into intersphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Webel authored Mar 11, 2024
2 parents 470dd24 + 1c546f4 commit 95ebd1a
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 12 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/colab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test that tutorial runs on latest colab image

on:
push:
schedule:
- cron: '0 2 * * 3'

jobs:
test:
name: Test
runs-on: ubuntu-latest-4core # increase disk space
# https://console.cloud.google.com/artifacts/docker/colab-images/europe/public/runtime
container:
image: europe-docker.pkg.dev/colab-images/public/runtime:latest
steps:
- uses: actions/checkout@v4
- name: Test tutorials
run: |
python3 -m pip install papermill ipykernel njab
cd docs/tutorial
papermill explorative_analysis.ipynb --help-notebook
papermill log_reg.ipynb --help-notebook
papermill explorative_analysis.ipynb explorative_analysis_tested.ipynb
pip install njab heatmapz openpyxl "matplotlib<3.7" plotly
papermill log_reg.ipynb log_reg_tested.ipynb
80 changes: 74 additions & 6 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4.0.0
- uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand All @@ -26,9 +26,9 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4.0.0
- uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand All @@ -52,9 +52,9 @@ jobs:
- version: "3.8"
toxenv: "py38"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4.0.0
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python.version }}

Expand All @@ -72,3 +72,71 @@ jobs:
papermill log_reg.ipynb --help-notebook
papermill explorative_analysis.ipynb explorative_analysis_tested.ipynb
papermill log_reg.ipynb log_reg_tested.ipynb
build_source_dist:
name: Build source distribution
if: startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install build
run: python -m pip install build

- name: Run build
run: python -m build --sdist

- uses: actions/upload-artifact@v4
with:
path: ./dist/*.tar.gz

# build_wheels:
# name: Build wheels on ${{ matrix.os }}
# if: startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/tags')
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-20.04, windows-2019, macOS-10.15]

# steps:
# - uses: actions/checkout@v4

# - uses: actions/setup-python@v5
# with:
# python-version: "3.10"

# - name: Install cibuildwheel
# run: python -m pip install cibuildwheel==2.3.1

# - name: Build wheels
# run: python -m cibuildwheel --output-dir wheels

# - uses: actions/upload-artifact@v4
# with:
# path: ./wheels/*.whl

publish:
name: Publish package
if: startsWith(github.ref, 'refs/tags')
needs:
- format
- lint
- test
- build_source_dist
# - build_wheels
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: ./dist

- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Version 0.0.4

- [x] Add `pandas` styling compability with pandas v2.2 (PR #4)
- [x] moved `get_lr_multiplicative_decomposition` function to package [78b0c2](https://github.com/RasmussenLab/njab/commit/78b0c27c3ab11489fb81ca320e03485cdc0b1344)

## Version 0.0.3

- [x] Add pandas styling
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ functionality used two papers.
.. include:: ../README.md
:parser: myst_parser.sphinx_
:start-line: 1
:end-line: 54
:end-line: 69



Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = njab
version = 0.0.3
version = 0.0.4
description = not Just Another Biomarker
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -40,7 +40,7 @@ docs =
sphinx-book-theme
myst-nb
ipywidgets
sphinx-new-tab-link
sphinx-new-tab-link!=0.2.2

[options.packages.find]
where = src
Expand Down Expand Up @@ -88,7 +88,7 @@ source =
#########################

[tox:tox]
envlist = py38
envlist = py38,py39,py310,py311
isolated_build = True

[testenv]
Expand Down
17 changes: 15 additions & 2 deletions src/njab/pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,28 @@ def set_pandas_options() -> None:
pd.options.display.max_rows = 30
pd.options.display.min_rows = 20
pd.options.display.float_format = '{:,.3f}'.format
# https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.describe_option.html#pandas.describe_option
pd.options.styler.format.thousands = ','
# # https://github.com/pandas-dev/pandas/blob/main/pandas/io/formats/format.py#L1475
# Originally found: https://stackoverflow.com/a/29663750/9684872

class IntArrayFormatter(pf.GenericArrayFormatter):
try:
base_class = pf.GenericArrayFormatter
except AttributeError:
base_class = pf._GenericArrayFormatter

class IntArrayFormatter(base_class):

def _format_strings(self):
formatter = self.formatter or '{:,d}'.format
fmt_values = [formatter(x) for x in self.values]
return fmt_values

pf.IntArrayFormatter = IntArrayFormatter
try:
pf.IntArrayFormatter
pf.IntArrayFormatter = IntArrayFormatter
except AttributeError:
pf._IntArrayFormatter = IntArrayFormatter


def replace_with(string_key: str,
Expand Down
8 changes: 8 additions & 0 deletions test/test_pandas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pandas as pd
import njab


def test_thousands_display():
njab.pandas.set_pandas_options()
s = pd.Series([1_000_000])
assert str(s)[4:13] == '1,000,000'

0 comments on commit 95ebd1a

Please sign in to comment.