Skip to content

Allow squeeze to search over non-monotonic polynomials #256

@Sparks29032

Description

@Sparks29032

I think we should just allow squeeze to be non-monotonic. Like my previous suggestion, sort the grid (and in parallel the function values). Since we have discrete data, overlap is unlikely. In the case of overlap, take the average value of the overlaps. We would no longer have this error. I suggest warning the user if the final (only the final) squeeze parameters results in non-monotonicity and allowing them to disable it with another setting:

Warning: The squeeze morph has interpolated your morphed function from a non-monotonically increasing grid. This can result in strange behavior in the regions {list_of_regions}. To disable this setting, please enable --check-increasing.

If the final result is still on a monotonic increasing grid, good! That means only the intermediates were non-monotonic. This change only benefits us since if we do not implement this, the user will see an error on all cases where the grid is non-monotonic, and they recover the same behavior using check-increasing (or perhaps a better name for this option).

Use something like this to find non-unique values efficiently.

Use np.diff and check for negatives to quickly find the region where the interpolation has resulted in non-monotonicity. Specifically, for each set of continuous negative values in np.diff(a) for some array a, your non-monotonic region is a[idx2+1] to a[idx1] where idx1 is the index of where the negative region in np.diff(a) starts and and idx2 is the index where it ends. For example, if np.diff(a) is negative on the range 10-20, your non-monotonic region is a[21] to a[10]. You will not have index out of bounds errors from this since np.diff returns an array one smaller than the original.

Note that the grid size can change, but we implemented ways to handle that in morphrgrid.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions