Skip to content

Commit 1c44659

Browse files
Merge pull request #152 from PythonPredictions/151-include-turorial-while-importing
#151 add tutorial while importing
2 parents 2447c86 + 97fe18f commit 1c44659

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

cobra/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
from .version import __version__
1+
from .version import __version__
2+
from cobra.utils import log_tutorial
3+
import logging
4+
5+
logging.basicConfig(level=logging.INFO, format="%(message)s")
6+
7+
log_tutorial()

cobra/preprocessing/preprocessor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def from_pipeline(cls, pipeline: dict):
223223
target_encoder,
224224
is_fitted=pipeline["_is_fitted"],
225225
)
226-
226+
227227
def get_continuous_and_discrete_columns(
228228
self, df: pd.DataFrame, id_col_name: str, target_column_name: str
229229
) -> tuple:

cobra/utils.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
import logging
2+
3+
# logger = logging.getLogger(__name__)
4+
# logger.setLevel(logging.INFO)
5+
# logger.addHandler(logging.Handler())
6+
7+
18
def clean_predictor_name(predictor_name: str) -> str:
29
"""Strip the redundant suffix (e.g. "_enc" or "_bin") off from the end
310
of the predictor name to return a clean version of the predictor
411
"""
5-
return (predictor_name.replace("_enc", "")
6-
.replace("_bin", "")
7-
.replace("_processed", ""))
12+
return (
13+
predictor_name.replace("_enc", "").replace("_bin", "").replace("_processed", "")
14+
)
15+
16+
17+
def log_tutorial() -> None:
18+
logging.info(
19+
"""
20+
Hi, welcome to Cobra!
21+
You can find some tutorials that explain the functioning of cobra on the PythonPredictions GitHub:
22+
https://github.com/PythonPredictions/cobra/tree/master/tutorials
23+
"""
24+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import logging
2+
3+
4+
def test_log_tutorial(caplog):
5+
from cobra.utils import log_tutorial
6+
7+
with caplog.at_level(logging.DEBUG):
8+
log_tutorial()
9+
assert (
10+
"https://github.com/PythonPredictions/cobra/tree/master/tutorials"
11+
in caplog.text
12+
)

0 commit comments

Comments
 (0)