-
Notifications
You must be signed in to change notification settings - Fork 8
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
Low and mid-level functions #3
Comments
Nice Mike. I'll focus on a higher level class that uses the functionality... |
Sure, sounds good. I'll patch in the remaining Fortran functions and see what we can do with them. |
Ok, all 12 Fortran functions are now prototyped and exposed in |
@mwtoews were you planning to also add the model input functions as well? These listed in https://github.com/pypest/pypestutils/blob/develop/org_from_john_7aug2023/new_function_documentation.docx starting on page 28. Just curious... |
Yes, the plan is to go forward on those dozen other functions too. These will need some Fortran modifications to enable the bindings, then they can be prototyped and "Pythonized" along with the other functions. I'm only modifying in |
gotcha. I'm hoping we are done with |
I've made a bit of progress, but it might be a few more days until they are all in. I'll push a few commits of the progress so far. It's still mostly running smoothly, but there is potential trouble with (e.g.) pypestutils/src/sgsim_code.f90 Line 147 in 55e9bb4
Since this is an external module, we'll probably need to check some of these inputs before passing. Otherwise the "stop" will kill the Python process, and I'm not sure if there is any elegant Fortran way to capture these signals. |
I've added some enums too, which optionally allow their from pypestutils import core, enum
lib = core.PestUtilsLib(logger_level=10)
# These all do the same thing
lib.build_covar_matrix_2d([1.1, 2.2], [2.2, 5.4], 1, "spher", 1, 2, 3, 4, 5, 3)
lib.build_covar_matrix_2d([1.1, 2.2], [2.2, 5.4], 1, enum.VarioType.spher, 1, 2, 3, 4, 5, 3)
lib.build_covar_matrix_2d([1.1, 2.2], [2.2, 5.4], 1, 1, 1, 2, 3, 4, 5, 3) As for the 1D array inputs, many of them can be array_like (e.g. a list), and others I'm relaxing to be scalars, e.g. zone 1 which gets filled-out to an array of 1 the expected length. |
And if you want to see gslib unexpectedly exit Python, here you go: lib.calc_kriging_factors_3d([1.1], [2], [2], 2, [3.3], [3.4], [3.5], 2, 2, "simple", "pow", 2.2, 3.3, 4.4, 5.5, 6.6, 1.1, 2.2, 3.3, 10, 11, 3, "out.fac", "text")
STOP INVALID power variogram technically it's not a crash, but it is mishandled. It might be worth discussing with John, since he has already modified the gslib source for this project. |
hmm. How many |
All of the remaining functions are in! Have a go, and gather your feedback. Note that while "Pythonizing" the Fortran functions, the "in" (and "inout") parameters should match the Python signature, with a few exceptions:
Furthermore, with the Python return value, if there is more than one "out" (or "inout"), then it is returned in a dict. But if there is only one output object, then that item is returned. Other notes:
I'll write some pytests for these functions later, when we think we are happy with the current situation. |
Nice one @mwtoews ! I'm pretty sure you can move ahead with pytests if you want - the higher level UI should be g2g with the way you've structured the underlying lib calls... |
Hi @jtwhite79 I have some parallel development going on:
It's parallel development, as you have similar interfaces in utils.py. We'll sort out how to harmonise the approaches at some point, but I don't want to step on your commits for now.
Here are some examples:
it's going pretty smoothly, no crashes!
The text was updated successfully, but these errors were encountered: