Open SylviaWhittle opened 11 months ago
On first look at this I think all of the *.pop()
can be removed.
They were pop()
because each of the classes properties was a list (perhaps dictionary, can't remember but suspect list) as the class was iterating through each of the grains, but if a ValueError
was encountered then it failed to trace and so needed removing.
I think, but would have to dig deeper and check, that these attributes (self.mol_is_circular
/ self.disordered_trace
/ self.grain
/ self.ordered_trace
) could remain as is and we just set self.splining_success = False
here. (I suspect that is too simple a solution though and its more complicated!).
Also, if removing these lines works, it would be worth writing (yet another) test to cover this try: ... except:
.
Thanks @ns-rse
Do you have thoughts about perhaps merging (once ready) #653 to enable us to delete this block of code?
Also, removing the .pop
doesn't appear to work as a new error is thrown: the variable spline_running_total
undefined.
I have just realised though that I don't think spline_running_total
is ever defined...
Possible duplicate of #366
@ns-rse These lines aren't in the code anymore so is this ok to be closed? Doesn't seem like a duplicate as this is one specific cause of #366 whereas #366 is surrounding the try/catch.
@MaxGamill-Sheffield Agreed on closer inspection this is a possible cause of #366.
The broad try:...except:
is still in place on the main
branch in topostats.processing.py
and when it fails grain statistics are returned which means users will at least get something even if tracing fails (note however that you have disabled this try: ... except:
on branch maxgamill-sheffield/800-better-processing
see line 400 and line 480 which I only know about because PyLint complained about the use of """..."""
to comment a section as it made it look like the return ...
wasn't at the end of the function, better to use #
for commenting regions).
I've not looked at this in a long time so can't say right now what to do, however, with the desire to get all of the revised tracing/pruning/detangling into the main
branch so that papers can be published and new versions released I would be inclined to stay focused on that aspect for now and come back to this once that work is completed.
Removing the broad try: ...except:
, which was thrown in because of a desire to have something working quickly if I remember correctly, could perhaps be the next Milestone for TopoStats and would encapsulate this issue.
I personally don't have much of a problem with issues being noted, they are at least then documented and can be dealt with in order of priority but I am wary of assuming things are fixed without checking and don't have masses of capacity to investigate this myself right now given the above priority and the height profile work.
The issue: It appears that there may be a little bit more work to be done on the removing loops from
dnatracing.py
. There is an error where inget_splined_traces()
, where if aValueError
is raised on line370
, thenself.mol_is_circular.pop(dna_num)
is called. This is code from when thednaTrace
class acted on the whole image (all molecules) and not a single molecule. Hence,dna_num
is undefined,self.mol_is_circular
is abool
not alist
and.pop()
is therefore not defined forself.mol_is_circular
.There are lines below it that will be affected similarly. I tried to have a go at fixing this but it seems like it will need a bit of an in-depth consideration as I'm not familiar with the control flow surrounding this, and how to represent a failure state properly without breaking the data structures.
Then again, I believe this fix might not be necessary if I tidy up and address the comments on #653 Improve Linear Splining, as that removes this block of code entirely. Thoughts would be appreciated @ns-rse 😄
I'd really like to get this fixed ASAP as this is preventing me from fixing the test
test_run_dnatracing()
intest_processing.py
which I need working to be able to add tests for #695 🙏Version: Current main branch: 2.1.3.dev2+g6354f5477.d20231012 Config file: Default Processing file: minicircle.spm Command:
pytest tests/test_processing.py::test_run_dnatracing
(Withrun_dnatracing()
inprocessing.py
set to raise errors, not ignore them) Python Version: 3.10 OS: MacOSOutput: