Repository: BlueBrain/NeuroM

Issue:
One test failing with 4.0.0: `Arrays are not almost equal to 5 decimals`
While updating the package to 4.0.0 in Fedora rawhide (the dev branch), we see one test failing:


```
>       assert_almost_equal(s.volume, 3160.274957542371, decimal=5)
tests/core/test_soma.py:263: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
args = (3160.2749000561025, 3160.274957542371), kwds = {'decimal': 5}
    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Arrays are not almost equal to 5 decimals
E            ACTUAL: 3160.2749000561025
E            DESIRED: 3160.274957542371
/usr/lib64/python3.12/contextlib.py:81: AssertionError
```

The values are close, but not as close as they should be. How should we handle this please? Complete log is here:

[fedora-rawhide-neuroml-build-log.txt](https://github.com/BlueBrain/NeuroM/files/15483281/fedora-rawhide-neuroml-build-log.txt)


Discussion:
codecov-commenter: ## [Codecov](https://app.codecov.io/gh/BlueBrain/NeuroM/pull/1128?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 100.00%. Comparing base [(`548e054`)](https://app.codecov.io/gh/BlueBrain/NeuroM/commit/548e054a9d7e1509a301f84cbe6bbd03b446565f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain) to head [(`2182759`)](https://app.codecov.io/gh/BlueBrain/NeuroM/commit/2182759fcd52eb7d405384f291f104fad350e39a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain).

> :exclamation: **Current head 2182759 differs from pull request most recent head b21324a**
> 
> Please [upload](https://docs.codecov.com/docs/codecov-uploader) reports for the commit b21324a to get more accurate results.

<details><summary>Additional details and impacted files</summary>



```diff
@@            Coverage Diff            @@
##            master     #1128   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           35        34    -1     
  Lines         2706      2671   -35     
=========================================
- Hits          2706      2671   -35     
```

</details>

Patch:
diff --git a/neurom/core/morphology.py b/neurom/core/morphology.py
index 1431eda..6852aee 100644
--- a/neurom/core/morphology.py
+++ b/neurom/core/morphology.py
@@ -454,8 +454,10 @@ class Neurite:
         subtree_types = [next(it).to_morphio().type]
 
         for section in it:
-            if section.type != section.parent.type:
-                subtree_types.append(NeuriteType(section.to_morphio().type))
+            # A subtree can start from a single branch or as a fork of the same type from a parent
+            # with different type.
+            if section.type not in (section.parent.type, subtree_types[-1]):
+                subtree_types.append(section.to_morphio().type)
 
         return subtree_types
 


Test patch:
diff --git a/tests/core/test_soma.py b/tests/core/test_soma.py
index cef38c1..c6cc305 100644
--- a/tests/core/test_soma.py
+++ b/tests/core/test_soma.py
@@ -223,7 +223,7 @@ def test_Soma_Cylinders():
     # area of a cylinder (excluding end caps) is:
     # 2*pi*r*h == 4*pi*r^2 == area of a sphere of radius 20
     assert s.radius == 20.0
-    assert_almost_equal(s.area, 5026.548245743669)
+    assert_almost_equal(s.area, 5026.548245743669, decimal=5)
     assert_array_equal(s.center, [0, 0, -10])
     assert 'SomaCylinders' in str(s)
 
@@ -241,7 +241,7 @@ def test_Soma_Cylinders():
 
     assert 'SomaNeuromorphoThreePointCylinders' in str(s)
     assert list(s.center) == [0.0, 0.0, 0.0]
-    assert_almost_equal(s.area, 1256.6370614)
+    assert_almost_equal(s.area, 1256.6370614, decimal=5)
 
     # some neuromorpho files don't follow the convention
     # but have (ys + rs) as point 2, and have xs different in each line
@@ -260,7 +260,7 @@ def test_Soma_Cylinders():
     assert 'SomaNeuromorphoThreePointCylinders' in str(s)
     assert list(s.center) == [0.0, 0.0, 0.0]
     assert_almost_equal(s.area, 794.76706126368811, decimal=5)
-    assert_almost_equal(s.volume, 3160.274957542371, decimal=5)
+    assert_almost_equal(s.volume, 3160.274957542371, decimal=3)
 
     s = load_morphology(
         StringIO(
@@ -276,7 +276,7 @@ def test_Soma_Cylinders():
     ).soma
 
     assert list(s.center) == [0.0, 0.0, 0.0]
-    assert_almost_equal(s.area, 444.288293851)  # cone area, not including bottom
+    assert_almost_equal(s.area, 444.288293851, decimal=5)  # cone area, not including bottom
 
 
 def test_soma_overlaps():
diff --git a/tests/test_mixed.py b/tests/test_mixed.py
index b3bed77..d06177e 100644
--- a/tests/test_mixed.py
+++ b/tests/test_mixed.py
@@ -1140,3 +1140,26 @@ def test_sholl_frequency_pop(mixed_morph):
         2,
         0,
     ]
+
+
+def test_axon_fork_as_axon_carrying_dendrite():
+    """Test that a axon subtree starting as a fork is considered an AcD."""
+    m = neurom.load_morphology(
+        """
+        1  1   0  0  0   0.5 -1
+        2  3   0  1  0   0.1  1
+        3  3   1  2  0   0.1  2
+        4  2   1  4  0   0.1  3
+        5  2   1  4  1   0.1  4
+        6  2   1  4 -1   0.1  4
+        7  2   2  3  0   0.1  3
+        8  2   2  4  0   0.1  7
+        9  2   3  3  0   0.1  7
+        10 2   3  3  1   0.1  9
+        11 2   3  3 -1   0.1  9
+        """,
+        reader="swc",
+        process_subtrees=True,
+    )
+    neurite = m.neurites[0]
+    assert neurite.type is NeuriteType.axon_carrying_dendrite