Skip to content
Snippets Groups Projects
Commit 5ca387d4 authored by David Hendriks's avatar David Hendriks
Browse files

updated function to be able to merge astropy arrays

parent 0939ff02
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,8 @@ from collections import ( ...@@ -29,6 +29,8 @@ from collections import (
import h5py import h5py
import numpy as np import numpy as np
import astropy.units as u
from binarycpython import _binary_c_bindings from binarycpython import _binary_c_bindings
import binarycpython.utils.moe_di_stefano_2017_data as moe_di_stefano_2017_data import binarycpython.utils.moe_di_stefano_2017_data as moe_di_stefano_2017_data
...@@ -1635,6 +1637,10 @@ def merge_dicts(dict_1: dict, dict_2: dict) -> dict: ...@@ -1635,6 +1637,10 @@ def merge_dicts(dict_1: dict, dict_2: dict) -> dict:
elif isinstance(dict_1[key], list) and isinstance(dict_2[key], list): elif isinstance(dict_1[key], list) and isinstance(dict_2[key], list):
new_dict[key] = dict_1[key] + dict_2[key] new_dict[key] = dict_1[key] + dict_2[key]
# Astropy quantities (using a dummy type representing the numpy array)
elif isinstance(dict_1[key], type(np.array([1])*u.m)) and isinstance(dict_2[key], type(np.array([1])*u.m)):
new_dict[key] = dict_1[key] + dict_2[key]
# dicts # dicts
elif isinstance(dict_1[key], dict) and isinstance(dict_2[key], dict): elif isinstance(dict_1[key], dict) and isinstance(dict_2[key], dict):
new_dict[key] = merge_dicts(dict_1[key], dict_2[key]) new_dict[key] = merge_dicts(dict_1[key], dict_2[key])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment