Skip to content

Commit

Permalink
Merge pull request #408 from eric-wieser/debug-no-jit-ci-failure
Browse files Browse the repository at this point in the history
Re-enable the no-JIT CI test
  • Loading branch information
eric-wieser committed Jul 20, 2021
2 parents 3413e84 + 28fdc11 commit a5b1c3f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ jobs:
matrix:
include:
# fastest jobs first
# This job currently fails
# - python-version: 3.8
# name: without JIT
# disable_jit: 1
- python-version: 3.8
name: without JIT
disable_jit: 1
- python-version: 3.8
name: doctests
mode: doctests
Expand All @@ -70,7 +69,7 @@ jobs:
name: "build | ${{ matrix.name }} | Python ${{matrix.python-version}}"
steps:
- uses: actions/checkout@v2

# python / pip
- name: Set up Python ${{ matrix.python-version }}
if: "!matrix.conda"
Expand All @@ -84,7 +83,7 @@ jobs:
pip install . --prefer-binary;
# test dependencies
pip install --upgrade pytest pytest-cov pytest-benchmark IPython
# conda
- name: Set up Python ${{ matrix.python-version }} (conda)
if: matrix.conda
Expand Down
16 changes: 16 additions & 0 deletions clifford/_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,3 +881,19 @@ def MultiVector(self, *args, **kwargs) -> MultiVector:
convenience func to ``MultiVector(layout)``
'''
return MultiVector(self, *args, **kwargs)

if _numba_utils.DISABLE_JIT:
def __reduce__(self):
data = super().__reduce__()
state = data[2]

# Workaround for gh-404 - remove all cached properties that look
# like jittable functions, as these crash when pickling.
# For now, we only do this if jitting is disabled, as it may still
# be useful to use pickling in lieu of a proper cache. To this end,
# we also leave around the non-function caches like multiplication tables.
for k, v in list(state.items()):
if isinstance(getattr(type(self), k, None), _cached_property) and callable(v):
del state[k]

return data
6 changes: 5 additions & 1 deletion clifford/_numba_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class pickleable_function:
Numba jitted functions are pickleable, so we should be too.
Here we just reach into the internals of numba to pull out their
serialization helpers
serialization helpers.
.. warning::
This seems to no longer work in most versions of numba, see
gh-404.
"""
def __new__(cls, func):
if isinstance(func, pickleable_function):
Expand Down
10 changes: 5 additions & 5 deletions clifford/test/test_tools_classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class _TestBase:
def radius(self, request):
return request.param

def _test_roundrip(self, cls, g, **kwargs):
def _test_roundtrip(self, cls, g, **kwargs):
b = cls[g](**kwargs)
b_rt = classify(b.mv)
assert isinstance(b_rt, cls)
Expand All @@ -45,28 +45,28 @@ def _test_roundrip(self, cls, g, **kwargs):

def test_roundtrip_direction(self, direction):
g = _grade(direction)
self._test_roundrip(
self._test_roundtrip(
Direction, g + 1,
direction=direction,
)

def test_roundtrip_round(self, direction, location, radius):
g = _grade(direction)
self._test_roundrip(
self._test_roundtrip(
Round, g + 1,
direction=direction, location=location, radius=radius,
)

def test_roundtrip_flat(self, direction, location):
g = _grade(direction)
self._test_roundrip(
self._test_roundtrip(
Flat, g + 2,
direction=direction, location=location,
)

def test_roundtrip_dual_flat(self, direction, location):
g = _grade(direction)
self._test_roundrip(
self._test_roundtrip(
DualFlat, self.layout.dims - (g + 2),
flat=Flat(direction=direction, location=location),
)
Expand Down

0 comments on commit a5b1c3f

Please sign in to comment.