Skip to content

Commit

Permalink
fix the typing of conditionally importing xgboost and pai4sk
Browse files Browse the repository at this point in the history
  • Loading branch information
shinnar committed Dec 3, 2020
1 parent ff1a1fb commit bd37c07
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lale/lib/pai4sk/decision_tree_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

try:
import pai4sk
import pai4sk # type: ignore

pai4sk_installed = True
except ImportError:
pai4sk_installed = False
if TYPE_CHECKING:
import pai4sk # type: ignore

import lale.datasets.data_schemas
import lale.docstrings
import lale.operators
Expand Down
7 changes: 6 additions & 1 deletion lale/lib/pai4sk/random_forest_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING

try:
import pai4sk
import pai4sk # type: ignore

pai4sk_installed = True
except ImportError:
pai4sk_installed = False
if TYPE_CHECKING:
import pai4sk # type: ignore

import lale.datasets.data_schemas
import lale.docstrings
import lale.operators
Expand Down
8 changes: 7 additions & 1 deletion lale/lib/pai4sk/random_forest_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING

try:
import pai4sk
import pai4sk # type: ignore

pai4sk_installed = True
except ImportError:
pai4sk_installed = False
if TYPE_CHECKING:
import pai4sk # type: ignore


import lale.datasets.data_schemas
import lale.docstrings
import lale.operators
Expand Down
6 changes: 5 additions & 1 deletion lale/lib/xgboost/xgb_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING

import pandas as pd
from sklearn.base import BaseEstimator

import lale.docstrings
import lale.operators

try:
import xgboost
import xgboost # type: ignore

xgboost_installed = True
except ImportError:
xgboost_installed = False
if TYPE_CHECKING:
import xgboost # type: ignore


def _rename_one_feature(name):
Expand Down
6 changes: 5 additions & 1 deletion lale/lib/xgboost/xgb_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING

import pandas as pd
from sklearn.base import BaseEstimator

import lale.docstrings
import lale.operators

try:
import xgboost
import xgboost # type: ignore

xgboost_installed = True
except ImportError:
xgboost_installed = False
if TYPE_CHECKING:
import xgboost # type: ignore


def _rename_one_feature(name):
Expand Down

0 comments on commit bd37c07

Please sign in to comment.