Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 23 additions & 37 deletions .github/workflows/build-ultraplot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,41 +35,27 @@ jobs:
micromamba activate ultraplot-dev
pytest

compare-baseline:
needs: build-ultraplot
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v2.0.4
with:
environment-file: ./environment.yml
init-shell: bash
create-args: >-
--verbose
python=${{ inputs.python-version }}
cache-environment: true
cache-downloads: false

- name: Generate baseline from main
shell: bash -el {0}
run: |
mkdir -p baseline
micromamba activate ultraplot-dev
git fetch origin ${{ github.event.pull_request.base.sha }}
git checkout ${{ github.event.pull_request.base.sha }}
pytest --mpl-generate-path=baseline_images
git checkout ${{ github.sha }} # Return to PR branch
# Skip pytest-mpl for now as it removes the RC file
# Future should include it though! See https://github.com/matplotlib/pytest-mpl/issues/236
# - name: Generate baseline from main
# shell: bash -el {0}
# run: |
# mkdir -p baseline
# micromamba activate ultraplot-dev
# git fetch origin ${{ github.event.pull_request.base.sha }}
# git checkout ${{ github.event.pull_request.base.sha }}
# pytest --mpl-generate-path=baseline_images
# git checkout ${{ github.sha }} # Return to PR branch
# - name: Image Comparison Ultraplot
# shell: bash -el {0}
# run: |
# micromamba activate ultraplot-dev
# pytest --mpl --mpl-baseline-path=baseline_images

- name: Image Comparison Ultraplot
shell: bash -el {0}
run: |
micromamba activate ultraplot-dev
pytest --mpl-generate-path=baseline_images --mpl-default-style $(python -c "import ultraplot as plt; print(plt.config.Configurator())")

# return the images that failed
- name: Upload comparison failures
if: failure()
uses: actions/upload-artifact@v4
with:
name: failed-comparisons
path: result_images
# # return the images that failed
# - name: Upload comparison failures
# if: failure()
# uses: actions/upload-artifact@v4
# with:
# name: failed-comparisons
# path: result_images
12 changes: 3 additions & 9 deletions ultraplot/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,9 @@ def tick_values(self, vmin, vmax): # noqa: U100
step = step // i
break
diff = np.abs(np.diff(locs[: step + 1 : step]))

if diff.size:
matches = np.where(np.isclose(locs % diff, 0.0))[0]
offset = matches[0] if len(matches) else np.argmin(np.abs(locs))
else:
offset = np.argmin(np.abs(locs))
return locs[
int(offset) % step :: step
] # even multiples from zero or zero-close
(offset,) = np.where(np.isclose(locs % diff if diff.size else 0.0, 0.0))
offset = offset[0] if offset.size else np.argmin(np.abs(locs))
return locs[offset % step :: step] # even multiples from zero or zero-close


class DegreeLocator(mticker.MaxNLocator):
Expand Down