-
-
Notifications
You must be signed in to change notification settings - Fork 363
libpython: add to/from numpy functions #423
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
base: main
Are you sure you want to change the base?
Conversation
See also: |
In this PR you are using the python interface to SQLite3 and PG. Have you tested the alternative using db.execute? The reason I am asking is that the GRASS db drivers have a lot of error handling that might be missing from the python interfaces to the respective DB drivers. Using the python interfaces could case cryptic errors if something goes wrong that might be better explained by the GRASS db drivers. |
Any general Python testing instructions should be applicable like this or this. You should probably focus just on SQLite, because PostgreSQL is more difficult to set up for the tests (although it is possible). If working within NC SPM location won't work for you tests, you can try to write plain Python unittest test and use e.g. --exec to run GRASS (the testing framework is from the times before --exec, so it does not integrate with it well, but I already had to use this approach here). |
I have not tested. The python interfaces offer some additional functionality and direct translation between Python objects and database data types. DB handling in pygrass (where these functions are supposed to end up) also uses Python DB adapters. But It is a good point to double check that potential errors are caught properly! |
lib/python/pygrass/utils.py
Outdated
""" | ||
sql_to_dtype = { | ||
"sqlite": { | ||
"INTEGER": [0, 2, 3, 4, 5, 6, 7, 8, 9, 10], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does these really need to be numbers and not things like numpy.int32
?
lib/python/pygrass/utils.py
Outdated
insert_sql = "INSERT INTO {}({}) VALUES %s;".format( | ||
table, | ||
", ".join(structured_array.dtype.names), | ||
",".join(["?"] * len(structured_array.dtype.names)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use named placeholders such as {table}
and table=
when there is more than one item to avoid confusion. Here seems to be some with %s
and the third argument.
@ninsbl: would you mind to rebase this PR? |
Fix dead store warning in d.linegraph module Co-authored-by: Shubham Vasudeo Desai <[email protected]>
nix: improve nix development environment * inherit build dependencies from grass package * add `dev-help` function
* CI(pre-commit): Enable markdownlint fixes * CI: Add fix: true in .markdownlint.yml for tools using that config key * Update .markdownlint.yml * Update v.surf.rst.html to remove trailing whitespaces
* CI: add nix package and dev environment test * nix: exclude more files from package source --------- Co-authored-by: Edouard Choinière <[email protected]>
This PR would add two New functions:
I would very much appreciate thorough review of the two functions, esp. the one writing to DB.
Also hints on how to properly add examples for doctest (or other unit-tests) would be very welcome...