@@ -57,7 +57,9 @@ def _(ax: axis.Regular | axis.Integer, /) -> dict[str, Any]:
5757 if isinstance (ax , axis .Integer ):
5858 data ["writer_info" ] = {"boost-histogram" : {"orig_type" : "Integer" }}
5959
60- data ["metadata" ] = serialize_metadata (ax .__dict__ )
60+ metadata = serialize_metadata (ax .__dict__ )
61+ if metadata :
62+ data ["metadata" ] = metadata
6163
6264 return data
6365
@@ -72,7 +74,10 @@ def _(ax: axis.Variable, /) -> dict[str, Any]:
7274 "overflow" : ax .traits .overflow ,
7375 "circular" : ax .traits .circular ,
7476 }
75- data ["metadata" ] = serialize_metadata (ax .__dict__ )
77+
78+ metadata = serialize_metadata (ax .__dict__ )
79+ if metadata :
80+ data ["metadata" ] = metadata
7681
7782 return data
7883
@@ -85,7 +90,10 @@ def _(ax: axis.IntCategory, /) -> dict[str, Any]:
8590 "categories" : list (ax ),
8691 "flow" : ax .traits .overflow ,
8792 }
88- data ["metadata" ] = serialize_metadata (ax .__dict__ )
93+
94+ metadata = serialize_metadata (ax .__dict__ )
95+ if metadata :
96+ data ["metadata" ] = metadata
8997
9098 return data
9199
@@ -98,7 +106,10 @@ def _(ax: axis.StrCategory, /) -> dict[str, Any]:
98106 "categories" : list (ax ),
99107 "flow" : ax .traits .overflow ,
100108 }
101- data ["metadata" ] = serialize_metadata (ax .__dict__ )
109+
110+ metadata = serialize_metadata (ax .__dict__ )
111+ if metadata :
112+ data ["metadata" ] = metadata
102113
103114 return data
104115
@@ -109,7 +120,10 @@ def _(ax: axis.Boolean, /) -> dict[str, Any]:
109120 data : dict [str , Any ] = {
110121 "type" : "boolean" ,
111122 }
112- data ["metadata" ] = serialize_metadata (ax .__dict__ )
123+
124+ metadata = serialize_metadata (ax .__dict__ )
125+ if metadata :
126+ data ["metadata" ] = metadata
113127
114128 return data
115129
0 commit comments