Skip to content

Commit

Permalink
pypestutils to toml
Browse files Browse the repository at this point in the history
  • Loading branch information
briochh committed Nov 17, 2024
2 parents b8ef6bf + 6080911 commit 10fbbab
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 24 deletions.
21 changes: 14 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
examples/* linguist-vendored=true
autotest/* linguist-vendored=true
dist/* linguist-vendored=true
doc/* linguist-vendored=true
build/* linguist-vendored=true
misc/* linguist-vendored=true
verification/* linguist-vendored=true
pyemu/_version.py export-subst
*.rei linguist-vendored # ignore because recognized as Reason
*.ins linguist-vendored # ignore because recognized as LaTex
*.aux linguist-vendored # ignore because recognized as LaTex
*.tex linguist-vendored # ignore because recognized as LaTex
*.go linguist-vendored # ignore because recognized as Go
*.tpl linguist-vendored # ignore because recognized as Smarty
*.bas linguist-vendored # ignore because recognized as VBA
*.res linguist-vendored # ignore because recognized as ReScript
*.dsp linguist-vendored # ignore because recognized as Faust
*.spc linguist-vendored # ignore because recognized as PLSQL
*.bat linguist-vendored # ignore because recognized as Batchfile
*.arr linguist-vendored # ignore because recognized as Pyret
*.mps linguist-vendored # ignore because recognized as JetBrains MPS

43 changes: 27 additions & 16 deletions pyemu/utils/pst_from.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
from __future__ import print_function, division
from __future__ import division, print_function

import copy
import os
from pathlib import Path
import warnings
import platform
import string
import warnings
from inspect import getsource
from pathlib import Path
from typing import Callable, Union

import numpy as np
import pandas as pd
import pyemu
from ..pyemu_warnings import PyemuWarning
import copy
import string

import pyemu
from pyemu.utils.helpers import _try_pdcol_numeric

from ..pyemu_warnings import PyemuWarning

# the tolerable percent difference (100 * (max - min)/mean)
# used when checking that constant and zone type parameters are in fact constant (within
# a given zone)
Expand Down Expand Up @@ -1194,13 +1199,16 @@ def _next_count(self, prefix):
return self._prefix_count[prefix]

def add_py_function(
self, file_name, call_str=None, is_pre_cmd=True,
function_name=None
self,
file_name: Union[str, Callable],
call_str: Union[None, str] = None,
is_pre_cmd: Union[bool, None] = True,
function_name=None,
):
"""add a python function to the forward run script
Args:
file_name (`str`): a python source file
file_name (`str` or `callable`): a python source file or function/callable
call_str (`str`): the call string for python function in
`file_name`.
`call_str` will be added to the forward run script, as is.
Expand Down Expand Up @@ -1256,12 +1264,6 @@ def add_py_function(
self.logger.lraise(
"add_py_function(): No function call string passed in arg " "'call_str'"
)
if not os.path.exists(file_name):
self.logger.lraise(
"add_py_function(): couldnt find python source file '{0}'".format(
file_name
)
)
if "(" not in call_str or ")" not in call_str:
self.logger.lraise(
"add_py_function(): call_str '{0}' missing paretheses".format(call_str)
Expand All @@ -1277,7 +1279,16 @@ def add_py_function(
f"original will be maintained",
PyemuWarning,
)
if callable(file_name):
func_lines = getsource(file_name).splitlines(keepends=True)
self._function_lines_list.append(func_lines)
else:
if not os.path.exists(file_name):
self.logger.lraise(
"add_py_function(): couldnt find python source file '{0}'".format(
file_name
)
)
func_lines = []
search_str = "def " + function_name + "("
abet_set = set(string.printable) - {' '}
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ optional = [
"pyshp",
"scipy",
"shapely",
"jinja2" # for to_latex options
"jinja2", # for to_latex options
"pypestutils"
]
test = [
"coveralls",
Expand Down

0 comments on commit 10fbbab

Please sign in to comment.