You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately I've found a problem with a type error being raised from within Numba stemming from initalising the csr.Skeleton() class in skan-0.12.0.
Traceback
The traceback is...
tests/tracing/test_disordered_tracing.py:1265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
topostats/tracing/disordered_tracing.py:660: in disordered_trace_grain
"branch_types": get_skan_image(
topostats/tracing/disordered_tracing.py:697: in get_skan_image
skan_skeleton = skan.Skeleton(skeleton_image, spacing=1e-9, value_is_height=True)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/skan/csr.py:532: in __init__
self.nbgraph = csr_to_nbgraph(graph, self.pixel_values)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/skan/csr.py:205: in csr_to_nbgraph
return NBGraph(
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/experimental/jitclass/base.py:124: in __call__
return cls._ctor(*bind.args[1:], **bind.kwargs)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/dispatcher.py:442: in _compile_for_args
raise e
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/dispatcher.py:375: in _compile_for_args
return_val = self.compile(tuple(argtypes))
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/dispatcher.py:905: in compile
cres = self._compiler.compile(args, return_type)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/dispatcher.py:80: in compile
status, retval = self._compile_cached(args, return_type)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/dispatcher.py:94: in _compile_cached
retval = self._compile_core(args, return_type)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/dispatcher.py:107: in _compile_core
cres = compiler.compile_extra(self.targetdescr.typing_context,
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler.py:744: in compile_extra
return pipeline.compile_extra(func)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler.py:438: in compile_extra
return self._compile_bytecode()
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler.py:506: in _compile_bytecode
return self._compile_core()
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler.py:481: in _compile_core
raise e
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler.py:472: in _compile_core
pm.run(self.state)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler_machinery.py:364: in run
raise e
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler_machinery.py:356: in run
self._runPass(idx, pass_inst, state)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler_lock.py:35: in _acquire_compile_lock
return func(*args, **kwargs)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler_machinery.py:311: in _runPass
mutated |= check(pss.run_pass, internal_state)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler_machinery.py:273: in check
mangled = func(compiler_state)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typed_passes.py:112: in run_pass
typemap, return_type, calltypes, errs = type_inference_stage(
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typed_passes.py:93: in type_inference_stage
errs = infer.propagate(raise_errors=raise_errors)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typeinfer.py:1083: in propagate
errors = self.constraints.propagate(self)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typeinfer.py:182: in propagate
raise e
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typeinfer.py:160: in propagate
constraint(typeinfer)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typeinfer.py:583: in __call__
self.resolve(typeinfer, typevars, fnty)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typeinfer.py:606: in resolve
sig = typeinfer.resolve_call(fnty, pos_args, kw_args)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typeinfer.py:1577: in resolve_call
return self.context.resolve_function_type(fnty, pos_args, kw_args)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typing/context.py:196: in resolve_function_type
res = self._resolve_user_function_type(func, args, kws)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typing/context.py:248: in _resolve_user_function_type
return func.get_call_type(self, args, kws)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/types/misc.py:441: in get_call_type
return self.ctor_template(context).apply(args, kws)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typing/templates.py:350: in apply
sig = generic(args, kws)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/experimental/jitclass/base.py:269: in generic
sig = disp_type.get_call_type(self.context, boundargs, kws)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/types/functions.py:541: in get_call_type
self.dispatcher.get_call_template(args, kws)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/dispatcher.py:318: in get_call_template
self.compile(tuple(args))
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/dispatcher.py:905: in compile
cres = self._compiler.compile(args, return_type)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/dispatcher.py:80: in compile
status, retval = self._compile_cached(args, return_type)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/dispatcher.py:94: in _compile_cached
retval = self._compile_core(args, return_type)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/dispatcher.py:107: in _compile_core
cres = compiler.compile_extra(self.targetdescr.typing_context,
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler.py:744: in compile_extra
return pipeline.compile_extra(func)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler.py:438: in compile_extra
return self._compile_bytecode()
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler.py:506: in _compile_bytecode
return self._compile_core()
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler.py:481: in _compile_core
raise e
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler.py:472: in _compile_core
pm.run(self.state)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler_machinery.py:364: in run
raise e
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler_machinery.py:356: in run
self._runPass(idx, pass_inst, state)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler_lock.py:35: in _acquire_compile_lock
return func(*args, **kwargs)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler_machinery.py:311: in _runPass
mutated |= check(pss.run_pass, internal_state)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/compiler_machinery.py:273: in check
mangled = func(compiler_state)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/typed_passes.py:468: in run_pass
lower.lower()
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/lowering.py:187: in lower
self.lower_normal_function(self.fndesc)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/lowering.py:226: in lower_normal_function
entry_block_tail = self.lower_function_body()
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/lowering.py:256: in lower_function_body
self.lower_block(block)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/lowering.py:270: in lower_block
self.lower_inst(inst)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/lowering.py:564: in lower_inst
return impl(self.builder, (target, value))
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/base.py:627: in wrapped
return impl(self, builder, sig, args, attr)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/imputils.py:166: in res
return real_impl(context, builder, sig, args, attr)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/experimental/jitclass/base.py:505: in set_attr_impl
setattr(data, _mangle_attr(attr), val)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/cgutils.py:164: in __setattr__
self[self._datamodel.get_field_position(field)] = value
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/cgutils.py:178: in __setitem__
value = self._cast_member_from_value(index, value)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/cgutils.py:251: in _cast_member_from_value
return model.as_data(self._builder, val)
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/numba/core/datamodel/models.py:586: in as_data
struct = builder.insert_value(struct, el, [i])
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/llvmlite/ir/builder.py:983: in insert_value
instr = instructions.InsertValue(self.block, agg, value, idx, name=name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'InsertValue' object has no attribute '_name'") raised in repr()] InsertValue object at 0x7ccfbd4f6b90>, parent = <ir.Block 'B0' of type 'label'>
agg = <ir.InsertValue '.258' of type '{i8*, i8*, i64, i64, double*, [1 x i64], [1 x i64]}', opname 'insertvalue', operands [...value=<llvmlite.ir.values._Undefined object at 0x7cd0142cda50>>, <ir.Argument 'arg.node_props.6.0' of type i64>]>]>]>]>
elem = <ir.ExtractValue 'extracted.data.22' of type 'float*', opname 'extractvalue', operands [<ir.InsertValue 'inserted.stri...' value=<llvmlite.ir.values._Undefined object at 0x7cd0142cda50>>, <ir.Argument 'arg.node_props.6.0' of type i64>]>]>]>
indices = [4], name = ''
def __init__(self, parent, agg, elem, indices, name=''):
typ = agg.type
try:
for i in indices:
typ = typ.elements[i]
except (AttributeError, IndexError):
raise TypeError("Can't index at %r in %s"
% (list(indices), agg.type))
if elem.type != typ:
> raise TypeError("Can only insert %s at %r in %s: got %s"
% (typ, list(indices), agg.type, elem.type))
E TypeError: Can only insert double* at [4] in {i8*, i8*, i64, i64, double*, [1 x i64], [1 x i64]}: got float*
/home/neil/.virtualenvs/topostats-311b/lib/python3.11/site-packages/llvmlite/ir/instructions.py:702: TypeError
__________________________________________________________________________________________ tests/test_run_topostats.py ___________________________________________________________________________________________
git bisect
I don't see this error with skan-0.11.1 and so to investigate I undertook git bisect between v0.12.0 and v0.11.1. To check each bisection I ran the test that is failing from the TopoStatsmain branch.
git clone [email protected]:AFM-SPM/TopoStats.git
cd TopoStats
pip install -e .[tests,dev]
pytest tests/tracing/test_disordered_tracing.py::test_disordered_trace_grain # Test run on each bisect
git bisect start v0.12.0 v0.11.1
Bisecting: 6 revisions left to test after this (roughly 3 steps)
[1aee19416bf9674ece696e29d7c350f720dc39cb] Convert '-' to '_'in summary dataframe (#215)
git bisect bad
Bisecting: 3 revisions left to test after this (roughly 2 steps)
[91d4e7c57b3136138321bb191b56ee6df508f791] Improved error reporting and tests forprune_paths() methods (#212)
git bisect good
Bisecting: 1 revision left to test after this (roughly 1 step)
[20ab48dd7c033c01aca0eac7a046ff4f86309632] Update formatting on pyproject.toml to match skimage (#218)
git bisect good
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[e248c5105c5bf60e82f752cbc02a43ab47f9ab75] Allow mean pixel value inference from int arrays, not just float (#220)
git bisect bad
e248c5105c5bf60e82f752cbc02a43ab47f9ab75 is the first bad commit
commit e248c5105c5bf60e82f752cbc02a43ab47f9ab75 (HEAD)
Author: Tim Monko <[email protected]>
Date: 2023-10-30 02:23:40 -0500
Allow mean pixel value inference from int arrays, not just float (#220)
1. Now only passes None to self.pixel_values i ncsr.py if subdtype is
np.bool_ rather than only collecting pixel_values when subdtype is
np.float_ allowing for pixel_values to be obtained from int and uint
images.
2. add skeletonlabel to _testdata.py to have an example int array
3. add test_skeletonlabel to test_csr.py to confirm int array behaves as
expected with csr.summarize
---------
Co-authored-by: Juan Nunez-Iglesias <[email protected]>
pyproject.toml | 4 ++--
src/skan/_testdata.py | 7 +++++++
src/skan/csr.py | 4 +++-
src/skan/test/test_csr.py | 7 ++++++-
4 files changed, 18 insertions(+), 4 deletions(-)
The error is different from that reported by v0.12.0 though...
...and sure enough if I checkout csr_to_nbgraph() the only parameters it has are csr and node_props and ooking at this commit the only change to src/skan/csr.py is...
I thought perhaps the numba.float64 types were the problem but looking at the numba documentation on types shows that float64 and double are equivalent. Regardless I tried switching numba.float64 > numba.double but still get the TypeError: Can only insert double* at [4] in {i8*, i8*, i64, i64, double*, [1 x i64], [1 x i64]}: got float*.
I'm on a bit of a conference tour for the next 4 weeks so I'm not 100% if I'll be able to fix quickly, but I'd be happy to quickly merge a fix and push a 0.12.1 tag. Looking at the error my guess is that on some systems skeleton_image.astype(float) is interpreted float32. So the first thing I would try is skeleton_image.astype(np.float64), which would exactly match the NBGraph type annotations.
Gave the skeleton_image.astype(np.float64) a whirl but no dice.
Spent a bit more time looking through and understanding the workflow though and think I've found the problem which was that node_props in csr_to_nbgraph() was float32. Explicitly setting the type to .astype(np.float64) seems to have solved it and PR is out (see #235).
Thanks for the pointer and enjoy the conference season. 👍
Thanks for the new release @jni 😄
Unfortunately I've found a problem with a type error being raised from within Numba stemming from initalising the
csr.Skeleton()
class inskan-0.12.0
.Traceback
The traceback is...
git bisect
I don't see this error with
skan-0.11.1
and so to investigate I undertookgit bisect
betweenv0.12.0
andv0.11.1
. To check each bisection I ran the test that is failing from the TopoStatsmain
branch.The error is different from that reported by
v0.12.0
though......and sure enough if I checkout
csr_to_nbgraph()
the only parameters it has arecsr
andnode_props
and ooking at this commit the only change tosrc/skan/csr.py
is...NBGraph()
csr.csr_to_nbgraph()
returnsNBGraph
which is anumba.experimental.jitclass()
withcsr_spec_float
...I thought perhaps the
numba.float64
types were the problem but looking at the numba documentation on types shows thatfloat64
anddouble
are equivalent. Regardless I tried switchingnumba.float64
>numba.double
but still get theTypeError: Can only insert double* at [4] in {i8*, i8*, i64, i64, double*, [1 x i64], [1 x i64]}: got float*
.Current installed packages...
A cleaner environment can be found in a failed GitHub workflow of the tests which failed.
I looked at the versions of
skan
/numba
/llvmlite
/scipy
/numpy
and checked whether they were passing...Not sure how to continue investigating this but please let me know if there is any more information I can provide or try/do.
The text was updated successfully, but these errors were encountered: