Skip to content

Commit

Permalink
black reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
djm21 committed Oct 15, 2024
1 parent ee23c18 commit a7fdbfa
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/sasctl/pzmm/write_score_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def score(var1, var2, var3, var4):

if preprocess_function:
self._add_preprocess_code(preprocess_function)

# SAS Viya 3.5 model
if model_id:
mas_code, cas_code = self._viya35_score_code_import(
Expand Down Expand Up @@ -2260,13 +2260,10 @@ def _viya35_score_code_import(
mr.update_model(model)
return mas_code, cas_code

def _add_preprocess_code(
self,
preprocess_function: Callable[DataFrame, DataFrame]
):
def _add_preprocess_code(self, preprocess_function: Callable[DataFrame, DataFrame]):
"""
Places the given preprocess function, which must both take a DataFrame as an argument
and return a DataFrame, into the score code. If the preprocess function does not
and return a DataFrame, into the score code. If the preprocess function does not
return anything, an error is thrown.
Parameters
Expand All @@ -2275,14 +2272,15 @@ def _add_preprocess_code(
The preprocess function to be added to the score code.
"""
import inspect

preprocess_code = inspect.getsource(preprocess_function)
if not "return" in preprocess_code:
raise ValueError(
"The given score code does not return a value. " +
"To allow for the score code to work correctly, please ensure the preprocessed " +
"data is returned."
"The given score code does not return a value. "
+ "To allow for the score code to work correctly, please ensure the preprocessed "
+ "data is returned."
)
if self.score_code[-1] == '\n':
if self.score_code[-1] == "\n":
self.score_code += preprocess_code
else:
self.score_code += '\n' + preprocess_code
self.score_code += "\n" + preprocess_code

0 comments on commit a7fdbfa

Please sign in to comment.