Commit 3f9a7790 authored by Frisinghelli Daniel's avatar Frisinghelli Daniel
Browse files

Implemented support for multi-label cases.

parent 04d2ca58
...@@ -16,6 +16,7 @@ License ...@@ -16,6 +16,7 @@ License
# builtins # builtins
import enum import enum
from collections.abc import Iterable
# externals # externals
import numpy as np import numpy as np
...@@ -116,7 +117,17 @@ class LabelMapping(dict): ...@@ -116,7 +117,17 @@ class LabelMapping(dict):
def to_numpy(self): def to_numpy(self):
"""Return the label mapping dictionary as :py:class:`numpy.ndarray`.""" """Return the label mapping dictionary as :py:class:`numpy.ndarray`."""
return np.array(list(self.items()))
# check for multiple labels
mapping = {}
for k, v in self.items():
if isinstance(k, Iterable):
for label in k:
mapping[label] = v
else:
mapping[k] = v
return np.array(list(mapping.items()))
class SparcsLabels(Label): class SparcsLabels(Label):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment