# Path: dbcollection/utils/string_ascii.py
# def convert_ascii_to_str(input_array):
#     """Convert a numpy array to a string (or a list of strings)
# 
#     Parameters
#     ----------
#     input_array : np.ndarray
#         Array of strings encoded in ASCII format.
# 
#     Returns
#     -------
#     str/list
#         String or list of strings.
# 
#     Examples
#     --------
#     Convert a numpy array to a string.
# 
#     >>> from dbcollection.utils.string_ascii import convert_ascii_to_str
#     >>> import numpy as np
#     >>> # ascii format of 'string1'
#     >>> tensor = np.array([[115, 116, 114, 105, 110, 103, 49, 0]], dtype=np.uint8)
#     >>> convert_ascii_to_str(tensor)
#     ['string1']
# 
#     """
#     assert isinstance(input_array, np.ndarray), "Must input a valid numpy array."
#     list_str = input_array.tolist()
#     if input_array.ndim > 1:
#         return [ascii_to_str(list(filter(lambda x: x > 0, str_))) for str_ in list_str]
#     else:
#         return ascii_to_str(list(filter(lambda x: x > 0, list_str)))


import h5py
from dbcollection.utils.string_ascii import convert_ascii_to_str
    fields : tuple
        List of all field names of the set.
    object_fields : tuple
        List of all field names of the set contained by the 'object_ids' list.
    nelems : int
        Number of rows in 'object_ids'.

    """

    def __init__(self, hdf5_group):
        """Initialize class."""
        assert hdf5_group, 'Must input a valid hdf5 group'

        self.hdf5_group = hdf5_group
        self.set = self._get_set_name()
        self.object_fields = self._get_object_fields()
        self.nelems = self._get_num_elements()
        self._fields = self._get_field_names()
        self.fields = self._load_hdf5_fields()  # add all hdf5 datasets as data fields

        self._fields_info = []
        self._lists_info = []

    def _get_set_name(self):
        hdf5_object_str = self.hdf5_group.name
        str_split = hdf5_object_str.split('/')
        return str_split[-1]

    def _get_object_fields(self):
        object_fields_data = self.hdf5_group['object_fields'].value

# Path: dbcollection/utils/string_ascii.py
# def convert_ascii_to_str(input_array):
#     """Convert a numpy array to a string (or a list of strings)
# 
#     Parameters
#     ----------
#     input_array : np.ndarray
#         Array of strings encoded in ASCII format.
# 
#     Returns
#     -------
#     str/list
#         String or list of strings.
# 
#     Examples
#     --------
#     Convert a numpy array to a string.
# 
#     >>> from dbcollection.utils.string_ascii import convert_ascii_to_str
#     >>> import numpy as np
#     >>> # ascii format of 'string1'
#     >>> tensor = np.array([[115, 116, 114, 105, 110, 103, 49, 0]], dtype=np.uint8)
#     >>> convert_ascii_to_str(tensor)
#     ['string1']
# 
#     """
#     assert isinstance(input_array, np.ndarray), "Must input a valid numpy array."
#     list_str = input_array.tolist()
#     if input_array.ndim > 1:
#         return [ascii_to_str(list(filter(lambda x: x > 0, str_))) for str_ in list_str]
#     else:
#         return ascii_to_str(list(filter(lambda x: x > 0, list_str)))


# Path: dbcollection/core/loader.py
import h5py
from dbcollection.utils.string_ascii import convert_ascii_to_str

    fields : tuple
        List of all field names of the set.
    object_fields : tuple
        List of all field names of the set contained by the 'object_ids' list.
    nelems : int
        Number of rows in 'object_ids'.

    """

    def __init__(self, hdf5_group):
        """Initialize class."""
        assert hdf5_group, 'Must input a valid hdf5 group'

        self.hdf5_group = hdf5_group
        self.set = self._get_set_name()
        self.object_fields = self._get_object_fields()
        self.nelems = self._get_num_elements()
        self._fields = self._get_field_names()
        self.fields = self._load_hdf5_fields()  # add all hdf5 datasets as data fields

        self._fields_info = []
        self._lists_info = []

    def _get_set_name(self):
        hdf5_object_str = self.hdf5_group.name
        str_split = hdf5_object_str.split('/')
        return str_split[-1]

    def _get_object_fields(self):
        object_fields_data = self.hdf5_group['object_fields'].value

        output = convert_ascii_to_str(object_fields_data)