Skip to content

Commit abba033

Browse files
hirzelMartin Hirzel
and
Martin Hirzel
authored
guard import of mystic (#1334)
* guard import of mystic Signed-off-by: Martin Hirzel <[email protected]> * bounding tensorflow version under the hypothesis that the newest version takes too much space due to tensorboard_data_server-0.6.1-py3-none-manylinux2010_x86_64.whl (4.9 MB) Signed-off-by: Martin Hirzel <[email protected]> --------- Signed-off-by: Martin Hirzel <[email protected]> Co-authored-by: Martin Hirzel <[email protected]>
1 parent d65dd20 commit abba033

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

lale/lib/aif360/_mystic_util.py

+37-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
1+
# Copyright 2023 IBM Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
from typing import Dict, Set
216

317
import numpy as np
4-
from mystic.coupler import and_
5-
from mystic.penalty import quadratic_equality
6-
from mystic.solvers import diffev2
18+
19+
try:
20+
from mystic.coupler import and_
21+
from mystic.penalty import quadratic_equality
22+
from mystic.solvers import diffev2
23+
24+
mystic_installed = True
25+
except ModuleNotFoundError:
26+
mystic_installed = False
27+
28+
29+
def _assert_mystic_installed():
30+
assert mystic_installed, """Your Python environment does not have mystic installed. You can install it with
31+
pip install mystic
32+
or with
33+
pip install 'lale[fairness]'"""
734

835

936
def parse_solver_soln(n_flat, group_mapping):
@@ -122,6 +149,8 @@ def obtain_solver_info(
122149

123150

124151
def construct_ci_penalty(A, C, n_ci, i):
152+
_assert_mystic_installed()
153+
125154
def condition(x):
126155
reshape_list = []
127156
for _ in range(A):
@@ -153,6 +182,8 @@ def create_ci_penalties(n_ci, n_di):
153182

154183

155184
def construct_di_penalty(A, C, n_di, F, i):
185+
_assert_mystic_installed()
186+
156187
def condition(x):
157188
reshape_list = []
158189
for _ in range(A):
@@ -201,6 +232,7 @@ def create_di_penalties(n_ci, n_di, F):
201232

202233

203234
def calc_oversample_soln(o_flat, F, n_ci, n_di):
235+
_assert_mystic_installed()
204236
# integer constraint
205237
ints = np.round
206238

@@ -235,6 +267,7 @@ def cost(x):
235267

236268

237269
def calc_undersample_soln(o_flat, F, n_ci, n_di):
270+
_assert_mystic_installed()
238271
# integer constraint
239272
ints = np.round
240273

@@ -269,6 +302,7 @@ def cost(x):
269302

270303

271304
def calc_mixedsample_soln(o_flat, F, n_ci, n_di):
305+
_assert_mystic_installed()
272306
# integer constraint
273307
ints = np.round
274308

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"lightgbm<4.0.0",
7272
"snapml>=1.7.0rc3,<1.12.0",
7373
"liac-arff>=2.4.0",
74-
"tensorflow>=2.4.0",
74+
"tensorflow>=2.4.0,<=2.13.0",
7575
"smac<=0.10.0",
7676
"numba",
7777
"aif360>=0.4.0",

0 commit comments

Comments
 (0)