Small-Bodies-Node / pds4_tools

Python package to read and display NASA PDS4 data.
17 stars 13 forks source link

to_dict method | Reference_List dictionary - sub-groups collapse #91

Closed Fenreg closed 4 months ago

Fenreg commented 11 months ago

Dear @LevN0,

I found out that the to_dict method has apparently an issue when dealing with a Reference_List, and apparently collapses the duplicate sub-groups into a single one. Consider a Reference_List containing multiple Internal_Reference labels set as below: image Which when read as follows: image Provides the following results: image

My understanding is that this feature happens despite the Reference_List being structured as expected according the Information model specs (https://pds.nasa.gov/datastandards/documents/im/v1/index_1K00.html#reference_type).

Could you throw maybe some light on this ? Looking forward to your reply, All the best

LevN0 commented 11 months ago

I may be misunderstanding, but I think the result you are seeing is what I would expect.

<Reference_List>
    <Internal_Reference>
        <lid_reference>1</lid_reference>
        <reference_type>1b</reference_type>
        <comment>1c</comment>
    </Internal_Reference>
    <Internal_Reference>
        <lid_reference>2a</lid_reference>
        <reference_type>2b</reference_type>
        <comment>2c</comment>
    </Internal_Reference>
</Reference_List>

Should translate to


dict_label = {
    'Reference_List': {
        'Internal_Reference': [
            {
                  'lid_reference': '1a',
                  'reference_type': '1b',
                  'comment': '1c'
            },
            {
                  'lid_reference': '2a',
                  'reference_type': '2b',
                  'comment': '2c'
            }
        ]
    }
}

Is this not what you see, or not what you expect? If the latter, what did you expect?

LevN0 commented 7 months ago

@Fenreg

Following up on this one. If I don't hear back from you, I'll go ahead and assume this as resolved.