mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
Remove obsolete methods
This commit is contained in:
@@ -9,8 +9,8 @@ from miplearn.features import Features
|
||||
from miplearn.instance.base import Instance
|
||||
|
||||
|
||||
def test_xy_instance_old() -> None:
|
||||
def _sample_xy_old(features: Features, sample: str) -> Tuple[Dict, Dict]:
|
||||
def test_xy_instance() -> None:
|
||||
def _sample_xy(features: Features, sample: str) -> Tuple[Dict, Dict]:
|
||||
x = {
|
||||
"s1": {
|
||||
"category_a": [
|
||||
@@ -55,12 +55,10 @@ def test_xy_instance_old() -> None:
|
||||
|
||||
comp = Component()
|
||||
instance_1 = Mock(spec=Instance)
|
||||
instance_1.training_data = ["s1", "s2"]
|
||||
instance_1.features = {}
|
||||
instance_1.samples = ["s1", "s2"]
|
||||
instance_2 = Mock(spec=Instance)
|
||||
instance_2.training_data = ["s3"]
|
||||
instance_2.features = {}
|
||||
comp.sample_xy_old = _sample_xy_old # type: ignore
|
||||
instance_2.samples = ["s3"]
|
||||
comp.sample_xy = _sample_xy # type: ignore
|
||||
x_expected = {
|
||||
"category_a": [
|
||||
[1, 2, 3],
|
||||
@@ -96,6 +94,6 @@ def test_xy_instance_old() -> None:
|
||||
[11],
|
||||
],
|
||||
}
|
||||
x_actual, y_actual = comp.xy_instances_old([instance_1, instance_2])
|
||||
x_actual, y_actual = comp.xy_instances([instance_1, instance_2])
|
||||
assert x_actual == x_expected
|
||||
assert y_actual == y_expected
|
||||
|
||||
@@ -13,7 +13,6 @@ from miplearn.classifiers.threshold import MinProbabilityThreshold
|
||||
from miplearn.components import classifier_evaluation_dict
|
||||
from miplearn.components.dynamic_lazy import DynamicLazyConstraintsComponent
|
||||
from miplearn.features import (
|
||||
TrainingSample,
|
||||
Features,
|
||||
InstanceFeatures,
|
||||
Sample,
|
||||
@@ -24,60 +23,6 @@ from miplearn.solvers.tests import assert_equals
|
||||
E = 0.1
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def training_instances_old() -> List[Instance]:
|
||||
instances = [cast(Instance, Mock(spec=Instance)) for _ in range(2)]
|
||||
instances[0].features = Features(
|
||||
instance=InstanceFeatures(
|
||||
user_features=[50.0],
|
||||
),
|
||||
)
|
||||
instances[0].training_data = [
|
||||
TrainingSample(lazy_enforced={"c1", "c2"}),
|
||||
TrainingSample(lazy_enforced={"c2", "c3"}),
|
||||
]
|
||||
instances[0].get_constraint_category = Mock( # type: ignore
|
||||
side_effect=lambda cid: {
|
||||
"c1": "type-a",
|
||||
"c2": "type-a",
|
||||
"c3": "type-b",
|
||||
"c4": "type-b",
|
||||
}[cid]
|
||||
)
|
||||
instances[0].get_constraint_features = Mock( # type: ignore
|
||||
side_effect=lambda cid: {
|
||||
"c1": [1.0, 2.0, 3.0],
|
||||
"c2": [4.0, 5.0, 6.0],
|
||||
"c3": [1.0, 2.0],
|
||||
"c4": [3.0, 4.0],
|
||||
}[cid]
|
||||
)
|
||||
instances[1].features = Features(
|
||||
instance=InstanceFeatures(
|
||||
user_features=[80.0],
|
||||
),
|
||||
)
|
||||
instances[1].training_data = [
|
||||
TrainingSample(lazy_enforced={"c3", "c4"}),
|
||||
]
|
||||
instances[1].get_constraint_category = Mock( # type: ignore
|
||||
side_effect=lambda cid: {
|
||||
"c1": None,
|
||||
"c2": "type-a",
|
||||
"c3": "type-b",
|
||||
"c4": "type-b",
|
||||
}[cid]
|
||||
)
|
||||
instances[1].get_constraint_features = Mock( # type: ignore
|
||||
side_effect=lambda cid: {
|
||||
"c2": [7.0, 8.0, 9.0],
|
||||
"c3": [5.0, 6.0],
|
||||
"c4": [7.0, 8.0],
|
||||
}[cid]
|
||||
)
|
||||
return instances
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def training_instances() -> List[Instance]:
|
||||
instances = [cast(Instance, Mock(spec=Instance)) for _ in range(2)]
|
||||
|
||||
@@ -12,7 +12,7 @@ from gurobipy import GRB
|
||||
from networkx import Graph
|
||||
from overrides import overrides
|
||||
|
||||
from miplearn import InternalSolver
|
||||
from miplearn.solvers.learning import InternalSolver
|
||||
from miplearn.components.dynamic_user_cuts import UserCutsComponent
|
||||
from miplearn.instance.base import Instance
|
||||
from miplearn.solvers.gurobi import GurobiSolver
|
||||
|
||||
Reference in New Issue
Block a user