Skip to content

Bug: MultiReducedOrderModel crashes during error estimation and save() #297

@kshitij-maths

Description

@kshitij-maths

Describe the bug
The error estimation methods inside MultiReducedOrderModel (test_error, kfold_cv_error, loo_error, optimal_mu, reduction_error, and approximation_error) are structurally broken. Because self.database and self.roms are stored as dictionaries in MROM, these methods crash when trying to apply NumPy boolean arrays to slice the dictionary (e.g., executing self.database[indeces] inside loo_error throws a TypeError).

Additionally, MROM is missing the @reduction.deleter and @approximation.deleter decorators. This causes the mrom.save() method to crash with an AttributeError when save_approx=False or save_reduction=False are passed.

To Reproduce

from ezyrb import MultiReducedOrderModel, Database, POD, RBF
import numpy as np

db = Database(np.random.rand(10, 2), np.random.rand(10, 5))
mrom = MultiReducedOrderModel({"p": db}, {"pod": POD()}, {"rbf": RBF()}).fit()

# Bug 1: Crashes due to boolean array indexing on a dictionary
mrom.loo_error()

# Bug 2: Crashes due to missing deleters
mrom.save("test.pkl", save_approx=False)

Output

Database with 5 snapshots and 2 parameters
Traceback (most recent call last):
  File "mrom_bug.py", line 9, in <module>
    mrom.loo_error()
  File "/mnt/raid/kpandey/Kshitij/ITCS/EZyRB/ezyrb/reducedordermodel.py", line 1068, in loo_error
    new_db = self.database[indeces]
TypeError: unhashable type: 'numpy.ndarray'

Expected behavior
The error methods in MultiReducedOrderModel must be rewritten to correctly handle dictionary inputs. They should iterate over self.roms and self.database, compute the mathematical errors independently for each model-database pair, and return a dictionary of results. Furthermore, the property deleters must be added so the class can be partially pickled without throwing errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions