Skip to content

bug: getBounds and getBounds2 in FitRecipe both return defaults even when bounds are set #158

@cadenmyers13

Description

@cadenmyers13

Problem

When trying to write a test for getBounds and getBounds2 they both return [-inf, inf] even when they are bounded,

def test_getBounds():
    recipe = FitRecipe("recipe")
    recipe.create_new_variable("var1", 1)
    recipe.restrain("var1", lb=-1, ub=1)
    actual_bounds = recipe.getBounds()
    expected_bounds = [(-1, 1)]
    assert actual_bounds == expected_bounds

def test_getBounds2():
    recipe = FitRecipe("recipe")
    recipe.create_new_variable("var1", 1)
    recipe.create_new_variable("var2", 2)
    recipe.restrain("var1", lb=0, ub=5)
    recipe.restrain("var2", lb=-1, ub=3)
    actual_lower_bounds, actual_upper_bounds = recipe.getBounds2()
    expected_lower_bounds = [0, -1]
    expected_upper_bounds = [5, 3]
    assert list(actual_lower_bounds) == expected_lower_bounds
    assert list(actual_upper_bounds) == expected_upper_bounds
FAILED tests/test_fitrecipe.py::test_getBounds - assert [[-inf, inf]] == [(-1, 1)]
FAILED tests/test_fitrecipe.py::test_getBounds2 - assert [np.float64(-...float64(-inf)] == [0, -1]

Proposed solution

  1. Implement the above two tests and fix the code to get it passing.
  2. These functions are going to be deprecated so make sure we are testing both the new and deprecated ones

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions