Skip to content

Commit

Permalink
Merge branch 'main' into chunksize-empty-arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
asmeurer authored Feb 7, 2024
2 parents 309ce5c + 80c57df commit a2ea940
Show file tree
Hide file tree
Showing 52 changed files with 2,731 additions and 1,483 deletions.
42 changes: 42 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This builds a preview of the docs which can be seen on pull requests. It
# also uses the .github/workflows/docs-preview.yml GitHub Actions workflow.

# This is separate from the GitHub Actions build that builds the docs, which
# also deploys the docs
version: 2

# Aliases to reuse
_defaults: &defaults
docker:
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: cimg/python:3.10.2
working_directory: ~/repo

jobs:
Build Docs Preview:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/
- run:
name: Install dependencies
no_output_timeout: 25m
command: |
cd docs
pip install -r requirements.txt
- run:
name: Build docs
no_output_timeout: 25m
command: |
cd docs
make html
- store_artifacts:
path: docs/_build/html

workflows:
version: 2
default:
jobs:
- Build Docs Preview
21 changes: 21 additions & 0 deletions .github/workflows/docs-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Docs Preview
on: [status]
jobs:
circleci_artifacts_redirector_job:
if: "${{ github.event.context == 'ci/circleci: Build Docs Preview' }}"
runs-on: ubuntu-latest
name: Run CircleCI artifacts redirector
steps:
- name: GitHub Action step
id: step1
uses: larsoner/circleci-artifacts-redirector-action@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
artifact-path: 0/docs/_build/html/index.html
circleci-jobs: Build Docs Preview
job-title: Click here to see a preview of the documentation.
api-token: ${{ secrets.CIRCLECI_TOKEN }}
- name: Check the URL
if: github.event.status != 'pending'
run: |
curl --fail ${{ steps.step1.outputs.url }} | grep $GITHUB_SHA
13 changes: 12 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
conda config --add channels conda-forge
conda update -q conda
conda info -a
conda create -n test-environment python=${{ matrix.python-version }} pyflakes pytest pytest-doctestplus numpy hypothesis doctr sphinx myst-parser sphinx_rtd_theme pytest-cov pytest-flakes
conda create -n test-environment python=${{ matrix.python-version }} --file docs/requirements.txt
conda init
- name: Build Docs
Expand Down Expand Up @@ -51,3 +51,14 @@ jobs:
conda activate test-environment
cd docs
make html
# Note, the gh-pages deployment requires setting up a SSH deploy key.
# See
# https://github.com/JamesIves/github-pages-deploy-action/tree/dev#using-an-ssh-deploy-key-
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.ref == 'refs/heads/main' }}
with:
folder: docs/_build/html
ssh-key: ${{ secrets.DEPLOY_KEY }}
clean-exclude: benchmarks/
43 changes: 14 additions & 29 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12-dev']
# https://numpy.org/neps/nep-0029-deprecation_policy.html
numpy-version: ['1.22', 'latest', 'dev']
exclude:
- python-version: '3.12-dev'
numpy-version: '1.22'
fail-fast: false
steps:
- uses: actions/checkout@v2
Expand All @@ -16,39 +21,19 @@ jobs:
run: |
set -x
set -e
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
conda config --set always_yes yes --set changeps1 no
conda config --add channels conda-forge
conda update -q conda
conda info -a
conda create -n test-environment python=${{ matrix.python-version }} pyflakes pytest pytest-doctestplus numpy hypothesis doctr sphinx myst-parser sphinx_rtd_theme pytest-cov pytest-flakes packaging
conda init
- name: Run Tests
run: |
# Copied from .bashrc. We can't just source .bashrc because it exits
# when the shell isn't interactive.
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/usr/share/miniconda/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
python -m pip install pyflakes pytest pytest-doctestplus hypothesis pytest-cov pytest-flakes packaging
if [[ ${{ matrix.numpy-version }} == 'latest' ]]; then
python -m pip install --pre --upgrade numpy
elif [[ ${{ matrix.numpy-version }} == 'dev' ]]; then
python -m pip install --pre --upgrade --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
else
if [ -f "/usr/share/miniconda/etc/profile.d/conda.sh" ]; then
. "/usr/share/miniconda/etc/profile.d/conda.sh"
else
export PATH="/usr/share/miniconda/bin:$PATH"
fi
python -m pip install --upgrade numpy==${{ matrix.numpy-version }}.*
fi
unset __conda_setup
# <<< conda initialize <<<
- name: Run Tests
run: |
set -x
set -e
conda activate test-environment
python -We:invalid -We::SyntaxWarning -m compileall -f -q ndindex/
# The coverage requirement check is done by the coverage report line below
PYTEST_FLAGS="$PYTEST_FLAGS -v --cov-fail-under=0";
Expand Down
61 changes: 0 additions & 61 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
include versioneer.py
include ndindex/_version.py
include LICENSE
include pytest.ini
include conftest.py
include run_doctests.py
4 changes: 4 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
if LooseVersion(numpy.__version__) < LooseVersion('1.20'):
raise RuntimeError("NumPy 1.20 (development version) or greater is required to run the ndindex tests")

# Show the NumPy version in the pytest header
def pytest_report_header(config):
return f"project deps: numpy-{numpy.__version__}"

# Add a --hypothesis-max-examples flag to pytest. See
# https://github.com/HypothesisWorks/hypothesis/issues/2434#issuecomment-630309150

Expand Down
102 changes: 102 additions & 0 deletions docs/_pygments/styles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
"""
Pygments styles used for syntax highlighting.
These are based on the Sphinx style (see
https://github.com/sphinx-doc/sphinx/blob/master/sphinx/pygments_styles.py)
for light mode and the Friendly style for dark mode.
The styles here have been adjusted so that they are WCAG AA compatible. The
tool at https://github.com/mpchadwick/pygments-high-contrast-stylesheets was
used to identify colors that should be adjusted.
"""
from pygments.style import Style
from pygments.styles.friendly import FriendlyStyle
from pygments.styles.native import NativeStyle
from pygments.token import Comment, Generic, Literal, Name, Number, Text

class SphinxHighContrastStyle(Style):
"""
Like Sphinx (which is like friendly, but a bit darker to enhance contrast
on the green background) but with higher contrast colors.
"""

@property
def _pre_style(self):
# This is used instead of the default 125% so that multiline Unicode
# pprint output looks good
return 'line-height: 120%;'

background_color = '#eeffcc'
default_style = ''

styles = FriendlyStyle.styles
styles.update({
# These are part of the Sphinx modification to "friendly"
Generic.Output: '#333',
Number: '#208050',

# These are adjusted from "friendly" (Comment is adjusted from
# "sphinx") to have better color contrast against the background.
Comment: 'italic #3c7a88',
Comment.Hashbang: 'italic #3c7a88',
Comment.Multiline: 'italic #3c7a88',
Comment.PreprocFile: 'italic #3c7a88',
Comment.Single: 'italic #3c7a88',
Comment.Special: '#3a7784 bg:#fff0f0',
Generic.Error: '#e60000',
Generic.Inserted: '#008200',
Generic.Prompt: 'bold #b75709',
Name.Class: 'bold #0e7ba6',
Name.Constant: '#2b79a1',
Name.Entity: 'bold #c54629',
Name.Namespace: 'bold #0e7ba6',
Name.Variable: '#ab40cd',
Text.Whitespace: '#707070',
Literal.String.Interpol: 'italic #3973b7',
Literal.String.Other: '#b75709',
Name.Variable.Class: '#ab40cd',
Name.Variable.Global: '#ab40cd',
Name.Variable.Instance: '#ab40cd',
Name.Variable.Magic: '#ab40cd',
})



class NativeHighContrastStyle(NativeStyle):
"""
Like native, but with higher contrast colors.
"""
@property
def _pre_style(self):
# This is used instead of the default 125% so that multiline Unicode
# pprint output looks good
return 'line-height: 120%;'

styles = NativeStyle.styles

# These are adjusted to have better color contrast against the background
styles.update({
Comment.Preproc: 'bold #e15a5a',
Comment.Special: 'bold #f75050 bg:#520000',
Generic.Deleted: '#e75959',
Generic.Error: '#e75959',
Generic.Traceback: '#e75959',
Literal.Number: '#438dc4',
Name.Builtin: '#2594a1',
# We also remove the underline here from the original style
Name.Class: '#548bd3',
Name.Function: '#548bd3',
# We also remove the underline here from the original style
Name.Namespace: '#548bd3',
Text.Whitespace: '#878787',
Literal.Number.Bin: '#438dc4',
Literal.Number.Float: '#438dc4',
Literal.Number.Hex: '#438dc4',
Literal.Number.Integer: '#438dc4',
Literal.Number.Oct: '#438dc4',
Name.Builtin.Pseudo: '#2594a1',
Name.Function.Magic: '#548bd3',
Literal.Number.Integer.Long: '#438dc4',
})
Loading

0 comments on commit a2ea940

Please sign in to comment.