Skip to content

Commit 086a08b

Browse files
authored
Merge pull request #10 from jbussemaker/dev
Merge dev
2 parents 9590894 + a08248c commit 086a08b

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

.github/workflows/tests_basic.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Basic Tests
55

66
on:
77
push:
8-
branches: [ "main" ]
8+
branches: [ "main", "dev" ]
99
pull_request:
10-
branches: [ "main" ]
10+
branches: [ "main", "dev" ]
1111

1212
jobs:
1313
test:

sb_arch_opt/problems/assignment.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,16 @@ def _get_n_valid_discrete(self) -> int:
7575

7676
def _is_conditionally_active(self) -> List[bool]:
7777
_, is_act_all = self.all_discrete_x
78-
if is_act_all is None:
79-
raise RuntimeError(f'_is_conditionally_active not implemented for {self.__class__.__name__}')
80-
return list(np.any(~is_act_all, axis=0))
78+
if is_act_all is not None:
79+
return list(np.any(~is_act_all, axis=0))
80+
81+
if isinstance(self._problem, MultiAssignmentProblem):
82+
dv_cond = []
83+
for assignment_manager in self._problem.assignment_managers:
84+
dv_cond += [dv.conditionally_active for dv in assignment_manager.design_vars]
85+
return dv_cond
86+
87+
return [dv.conditionally_active for dv in self._problem.assignment_manager.design_vars]
8188

8289
def _gen_all_discrete_x(self) -> Optional[Tuple[np.ndarray, np.ndarray]]:
8390
if isinstance(self._problem, AnalyticalProblemBase):

sb_arch_opt/tests/problems/test_assignment.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ def test_partitioning():
2929
Partitioning().print_stats()
3030
run_test_hierarchy(PartitioningCovering(), 1.71)
3131

32+
_ = PartitioningCovering().is_conditionally_active
33+
3234

3335
@check_dependency()
3436
def test_unordered():
3537
run_test_hierarchy(UnordNonReplComb(), 2.55)
3638
UnordNonReplCombLarge().print_stats()
3739
UnorderedComb().print_stats()
3840

41+
_ = UnorderedComb().is_conditionally_active
42+
3943

4044
@check_dependency()
4145
def test_assign_enc_gnc():
@@ -49,8 +53,4 @@ def test_assign_enc_gnc():
4953
assert problem.get_n_valid_discrete() == n_valid
5054

5155
x_all, _ = problem.all_discrete_x
52-
if x_all is not None:
53-
_ = problem.is_conditionally_active
54-
else:
55-
with pytest.raises(RuntimeError):
56-
_ = problem.is_conditionally_active
56+
_ = problem.is_conditionally_active

0 commit comments

Comments
 (0)