Repository: magpylib/magpylib

Issue:
`current.Line` accepts discontinuous lines, but fails silently on `getB`
### Magpylib version

4.x (Latest)

### What happened?

The `current.Line` source currently accepts discontinuous lines, but fails on `getB` without warning.


```python
import magpylib as magpy

line12 = magpy.current.Line(
    current=1,
    vertices=[
        [0, 0, 0],
        [0, 0, 1],
        [None, None, None],
        [1, 0, 0],
        [1, 0, 1],
    ],
)

line12.getB((0, 0, 0)) # returns array([nan, nan, nan])
```

I see 3 options here:
- [ ] option 1: We raise a `ValueError`, if the line is discontinuous
- [x] option 2: We allow discontinuous outputs and treat is as multiple lines.
- [ ] option 3 (2b): We have a boolean `allow_discontinuous` argument in the `__init__` method

In option 2 or 3 it should be equivalent to:

```python
import magpylib as magpy

line1 = magpy.current.Line(current=1, vertices=[[0, 0, 0], [0, 0, 1]])
line2 = magpy.current.Line(current=1, vertices=[[1, 0, 0], [1, 0, 1]])
line_coll = magpy.Collection(line1, line2)

line_coll.getB((0, 0, 0)) # returns array([ 0.        , -0.07071068,  0.        ])
```

Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/magpylib/magpylib/pull/642?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib) Report
> Merging [#642](https://app.codecov.io/gh/magpylib/magpylib/pull/642?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib) (d62a55f) into [main](https://app.codecov.io/gh/magpylib/magpylib/commit/e4f4d950f13b8ca6de6966968af6539e2f73b726?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib) (e4f4d95) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

```diff
@@           Coverage Diff           @@
##             main     #642   +/-   ##
=======================================
  Coverage   98.97%   98.97%           
=======================================
  Files          55       55           
  Lines        6957     6960    +3     
=======================================
+ Hits         6886     6889    +3     
  Misses         71       71           
```


| [Files Changed](https://app.codecov.io/gh/magpylib/magpylib/pull/642?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib) | Coverage Δ | |
|---|---|---|
| [magpylib/\_src/fields/field\_BH\_line.py](https://app.codecov.io/gh/magpylib/magpylib/pull/642?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib#diff-bWFncHlsaWIvX3NyYy9maWVsZHMvZmllbGRfQkhfbGluZS5weQ==) | `100.00% <100.00%> (ø)` | |



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bb3a9a72..43925140 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,8 +3,9 @@ All notable changes to magpylib are documented here.
 
 # Releases
 
-## [4.3.x] 
+## [4.4.0] 
 - include self-intersection check in `TriangularMesh` ([#589](https://github.com/magpylib/magpylib/issues/589)).
+- disconnected line
 
 ## [4.3.0] - 2023-06-25
 - New `TriangularMesh` magnet class added to conveniently work with triangular surface meshes instead of large collections of individual `Triangle` objects. The `TriangularMesh` class performs important checks (closed, connected, oriented) and can directly import pyvista objects and for convex hull bodies. ([#569](https://github.com/magpylib/magpylib/issues/569), [#598](https://github.com/magpylib/magpylib/pull/598)).
diff --git a/magpylib/_src/fields/field_BH_line.py b/magpylib/_src/fields/field_BH_line.py
index 10add772..b7bb126c 100644
--- a/magpylib/_src/fields/field_BH_line.py
+++ b/magpylib/_src/fields/field_BH_line.py
@@ -122,8 +122,12 @@ def current_line_field(
     ntot = len(current)
     field_all = np.zeros((ntot, 3))
 
-    # Check for zero-length segments
-    mask0 = np.all(segment_start == segment_end, axis=1)
+    # Check for zero-length segments (or discontinuous)
+    mask_nan_start = np.isnan(segment_start).all(axis=1)
+    mask_nan_end = np.isnan(segment_end).all(axis=1)
+    mask_equal = np.all(segment_start == segment_end, axis=1)
+    mask0 = mask_equal | mask_nan_start | mask_nan_end
+
     if np.all(mask0):
         return field_all
 


Test patch:
diff --git a/tests/test_obj_Line.py b/tests/test_obj_Line.py
index d07387d4..ee046125 100644
--- a/tests/test_obj_Line.py
+++ b/tests/test_obj_Line.py
@@ -83,3 +83,36 @@ def test_line_position_bug():
     B2 = col.getB(poso)
 
     assert np.allclose(B1, B2)
+
+
+def test_discontinous_line():
+    """test discontinuous line"""
+    line_1 = magpy.current.Line(
+        current=1,
+        vertices=[
+            [0, 0, 0],
+            [0, 0, 1],
+        ],
+    )
+    line_2 = magpy.current.Line(
+        current=1,
+        vertices=[
+            [1, 0, 0],
+            [1, 0, 1],
+        ],
+    )
+    line_12 = magpy.current.Line(
+        current=1,
+        vertices=[
+            [None, None, None],
+            *line_1.vertices.tolist(),
+            [None, None, None],
+            [None, None, None],
+            *line_2.vertices.tolist(),
+            [None, None, None],
+        ],
+    )
+
+    B1 = magpy.getB((line_1, line_2), (0, 0, 0), sumup=True)
+    B2 = line_12.getB((0, 0, 0))
+    np.testing.assert_allclose(B1, B2)