Coverage for src/bob/bio/vein/database/__init__.py: 90%
10 statements
« prev ^ index » next coverage.py v7.6.0, created at 2024-07-12 23:27 +0200
« prev ^ index » next coverage.py v7.6.0, created at 2024-07-12 23:27 +0200
1#!/usr/bin/env python
2# vim: set fileencoding=utf-8 :
3# isort: skip_file
5"""Database definitions for Vein Recognition"""
8import numpy
11class AnnotatedArray(numpy.ndarray):
12 """Defines a numpy array subclass that can carry its own metadata
14 Copied from: https://docs.scipy.org/doc/numpy-1.12.0/user/basics.subclassing.html#slightly-more-realistic-example-attribute-added-to-existing-array
15 """
17 def __new__(cls, input_array, metadata=None):
18 obj = numpy.asarray(input_array).view(cls)
19 obj.metadata = metadata if metadata is not None else dict()
20 return obj
22 def __array_finalize__(self, obj):
23 if obj is None:
24 return
25 self.metadata = getattr(obj, "metadata", dict())