The introduction of ModelLibrary (JP-3690) introduced a bug where the drizzled array weights are ignored entirely when the in_memory parameter is set to True. This can be seen by modifying this unit test as follows, such that it's meaningful with respect to the weights array and weight threshold:
def test_create_median(three_sci_as_asn, tmp_cwd):
"""Test creation of median on disk vs in memory"""
lib_on_disk = ModelLibrary(three_sci_as_asn, on_disk=True)
lib_in_memory = ModelLibrary(three_sci_as_asn, on_disk=False)
# make this test meaningful w.r.t. handling of weights
with (lib_on_disk, lib_in_memory):
for lib in [lib_on_disk, lib_in_memory]:
for model in lib:
model.wht = np.ones_like(model.data)
model.wht[4,9] = 0.5
lib.shelve(model, modify=True)
median_on_disk = create_median(lib_on_disk, 0.7, on_disk=True)
median_in_memory = create_median(lib_in_memory, 0.7, on_disk=False)
assert np.isnan(median_in_memory[4,9])
# Make sure the median library is the same for on-disk and in-memory
assert np.allclose(median_on_disk, median_in_memory, equal_nan=True) ```
Issue JP-3743 was created on JIRA by Ned Molter:
The introduction of ModelLibrary (JP-3690) introduced a bug where the drizzled array weights are ignored entirely when the
in_memory
parameter is set to True. This can be seen by modifying this unit test as follows, such that it's meaningful with respect to the weights array and weight threshold: