Skip to content

ENH: Fix warning and improve Exception formatting #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions codacore/model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import numpy as np
import warnings
from time import time
import statsmodels.api as sm
from sklearn.metrics import log_loss
Expand Down Expand Up @@ -51,7 +52,7 @@ def set_type(self, type):
elif type in ['amalgamations', 'amalgam', 'A', 'SLR']:
return 'A'
else:
raise ValueError("Invalid 'type' argument given", type)
raise ValueError("Invalid 'type' argument given: '%s'" % type)

def set_cv_params(self, cv_params):
"""Overrides the defaults with any user-specified params"""
Expand Down Expand Up @@ -288,7 +289,8 @@ def gradient_descent(lr, epochs):
def set_threshold_cv(self, x, y, current_estimate):

if np.any(np.abs(self.soft_assignment) > 0.999999):
Warning("Large weights encountered in gradient descent; vanishing gradients likely.")
warnings.warn("Large weights encountered in gradient descent; "
"vanishing gradients likely.", Warning)

candidate_thresholds = -np.sort(-np.abs(self.soft_assignment))
num_thresholds = self.cv_params['num_thresholds']
Expand Down Expand Up @@ -357,7 +359,7 @@ def get_logratio(self, x):
epsilon = self.opt_params['epsilon_a']
logratio = np.log(positive_part + epsilon) - np.log(negative_part + epsilon)
else:
raise ValueError("Unknown type given:", self.type)
raise ValueError("Unknown type given: '%s'" % self.type)

return logratio

Expand Down