mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
Rename xy_sample to xy
This commit is contained in:
@@ -57,7 +57,7 @@ def test_xy_instance():
|
||||
instance_2 = Mock(spec=Instance)
|
||||
instance_2.training_data = ["s3"]
|
||||
instance_2.features = {}
|
||||
comp.xy_sample = _xy_sample
|
||||
comp.xy = _xy_sample
|
||||
x_expected = {
|
||||
"category_a": [
|
||||
[1, 2, 3],
|
||||
|
||||
@@ -286,7 +286,7 @@ def test_xy_sample() -> None:
|
||||
[False, True],
|
||||
],
|
||||
}
|
||||
xy = StaticLazyConstraintsComponent.xy_sample(features, sample)
|
||||
xy = StaticLazyConstraintsComponent.xy(features, sample)
|
||||
assert xy is not None
|
||||
x_actual, y_actual = xy
|
||||
assert x_actual == x_expected
|
||||
|
||||
@@ -125,7 +125,7 @@ def test_xy_sample_with_lp() -> None:
|
||||
"Lower bound": [[1.0]],
|
||||
"Upper bound": [[2.0]],
|
||||
}
|
||||
xy = ObjectiveValueComponent.xy_sample(features, sample)
|
||||
xy = ObjectiveValueComponent.xy(features, sample)
|
||||
assert xy is not None
|
||||
x_actual, y_actual = xy
|
||||
assert x_actual == x_expected
|
||||
@@ -150,7 +150,7 @@ def test_xy_sample_without_lp() -> None:
|
||||
"Lower bound": [[1.0]],
|
||||
"Upper bound": [[2.0]],
|
||||
}
|
||||
xy = ObjectiveValueComponent.xy_sample(features, sample)
|
||||
xy = ObjectiveValueComponent.xy(features, sample)
|
||||
assert xy is not None
|
||||
x_actual, y_actual = xy
|
||||
assert x_actual == x_expected
|
||||
|
||||
@@ -8,15 +8,14 @@ import numpy as np
|
||||
from numpy.testing import assert_array_equal
|
||||
from scipy.stats import randint
|
||||
|
||||
from miplearn import Classifier, LearningSolver, GurobiSolver, GurobiPyomoSolver
|
||||
from miplearn import Classifier, LearningSolver
|
||||
from miplearn.classifiers.threshold import Threshold
|
||||
from miplearn.components.primal import PrimalSolutionComponent
|
||||
from miplearn.problems.tsp import TravelingSalesmanGenerator
|
||||
from miplearn.types import TrainingSample, Features
|
||||
from tests.fixtures.knapsack import get_knapsack_instance
|
||||
|
||||
|
||||
def test_xy_sample_with_lp_solution() -> None:
|
||||
def test_xy() -> None:
|
||||
features: Features = {
|
||||
"Variables": {
|
||||
"x": {
|
||||
@@ -70,14 +69,14 @@ def test_xy_sample_with_lp_solution() -> None:
|
||||
[True, False],
|
||||
]
|
||||
}
|
||||
xy = PrimalSolutionComponent.xy_sample(features, sample)
|
||||
xy = PrimalSolutionComponent.xy(features, sample)
|
||||
assert xy is not None
|
||||
x_actual, y_actual = xy
|
||||
assert x_actual == x_expected
|
||||
assert y_actual == y_expected
|
||||
|
||||
|
||||
def test_xy_sample_without_lp_solution() -> None:
|
||||
def test_xy_without_lp_solution() -> None:
|
||||
features: Features = {
|
||||
"Variables": {
|
||||
"x": {
|
||||
@@ -123,7 +122,7 @@ def test_xy_sample_without_lp_solution() -> None:
|
||||
[True, False],
|
||||
]
|
||||
}
|
||||
xy = PrimalSolutionComponent.xy_sample(features, sample)
|
||||
xy = PrimalSolutionComponent.xy(features, sample)
|
||||
assert xy is not None
|
||||
x_actual, y_actual = xy
|
||||
assert x_actual == x_expected
|
||||
@@ -170,7 +169,7 @@ def test_predict() -> None:
|
||||
}
|
||||
}
|
||||
}
|
||||
x = PrimalSolutionComponent.x_sample(features, sample)
|
||||
x, _ = PrimalSolutionComponent.xy(features, sample)
|
||||
comp = PrimalSolutionComponent()
|
||||
comp.classifiers = {"default": clf}
|
||||
comp.thresholds = {"default": thr}
|
||||
|
||||
Reference in New Issue
Block a user