Skip to content

Commit

Permalink
Optimized use of conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaruland committed Jan 31, 2024
1 parent 674e58e commit 94cbd5a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions databroker/mongo_normalized.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,8 @@ def structure_from_descriptor(descriptor, sub_dict, max_seq_num, unicode_columns
# dimensions (it's optional) use the same default dimension
# names that xarray would.
ndim = len(field_metadata["shape"])
if "dims" in field_metadata:
if len(field_metadata["dims"]) == ndim:
dims = ["time"] + field_metadata["dims"]
else:
dims = ["time"] + [f"dim_{next(dim_counter)}" for _ in range(ndim)]
if "dims" in field_metadata and len(field_metadata["dims"]) == ndim:
dims = ["time"] + field_metadata["dims"]
else:
dims = ["time"] + [f"dim_{next(dim_counter)}" for _ in range(ndim)]
attrs = {}
Expand Down Expand Up @@ -1009,11 +1006,8 @@ def build_config_xarray(
# dimensions (it's optional) use the same default dimension
# names that xarray would.
ndim = len(field_metadata["shape"])
if "dims" in field_metadata:
if len(field_metadata["dims"]) == ndim:
dims = ["time"] + field_metadata["dims"]
else:
dims = ["time"] + [f"dim_{next(dim_counter)}" for _ in range(ndim)]
if "dims" in field_metadata and len(field_metadata["dims"]) == ndim:
dims = ["time"] + field_metadata["dims"]
else:
dims = ["time"] + [f"dim_{next(dim_counter)}" for _ in range(ndim)]
units = field_metadata.get("units")
Expand Down

0 comments on commit 94cbd5a

Please sign in to comment.