Closed adrien-berchet closed 7 months ago
Trying it with the full hierarchy:
from voxcell import RegionMap
r = RegionMap.load_json("mba_hierarchy.json")
df = r.as_dataframe()
r2 = RegionMap.from_dataframe(df)
should_be_None = r2.get(997, attr="parent_structure_id")
type(should_be_None)
>> float
Returns a float NaN which does not pass checks like X is None and is not consistent with the initial region map's None value.
Trying it with the full hierarchy:
from voxcell import RegionMap r = RegionMap.load_json("mba_hierarchy.json") df = r.as_dataframe() r2 = RegionMap.from_dataframe(df) should_be_None = r2.get(997, attr="parent_structure_id") type(should_be_None) >> float
Returns a float NaN which does not pass checks like X is None and is not consistent with the initial region map's None value.
Indeed. Is the conversion from nan
to None
specific to the parent_structure_id
attr or should all the nan
from any column be converted to None
? Since the conversion to DF casts None
to nan
, I'm afraid it's hard to know when we should convert nan
back to None
, except if we know the list of columns for which the cast should be performed.
I'm afraid it's hard to know when we should convert
nan
back toNone
, except if we know the list of columns for which the cast should be performed.
Of maybe we can consider that we should convert nan
to None
for all columns with dtype=float
?
All modified and coverable lines are covered by tests :white_check_mark:
:exclamation: No coverage uploaded for pull request base (
main@42c4987
). Click here to learn what that means.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
LGTM. Maybe @mgeplf would also like to take a look.
I need to create custom hierarchies and the nested dict structure is very boring to update so I would prefer updating the DataFrame representation and then be able to create a RegionMap object from it.
I just need a clarification: in the tests the root node ID is
-1
, which means that in the DataFrame representation it is its own parent since the root parent ID is always-1
. I feel it weird so I changed the test to ensure that no node have a-1
ID. But I can change if you think that this situation actually makes sense, and I could consider that the first node withparent_id == -1
is the root node for example.