-
Notifications
You must be signed in to change notification settings - Fork 46
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
Runtime Type check bug in utils.py #367
Comments
Thanks for brining up this problem, giving a clear example and analyzing the issue! The canonical way to open your file with IOData, would be as follows: from iodata import load_one
data = load_one("h4_2_0.0_STO-6G.fcidump", fmt="fcidump") Can you try if that works? The fact that your example used to work, is somewhat a coincidence. The argument of the file-format specific Things to be done:
|
Hi, thank you for addressing this issue so promptly. I tried the option you mentioned, but it is not working. I got the error "TypeError: load_one() got an unexpected keyword argument 'fmt'" |
Is there a chance that the https://github.com/theochem/iodata/blob/main/iodata/api.py#L158 It is made available as https://github.com/theochem/iodata/blob/main/iodata/__init__.py#L28 |
Oh I see, yeah, that works fine! Thank you for your help |
@DanielCalero1 Thanks for verifying. The fixed type checking just got merged. This means your example should work with the latest revision, even if it is not the documented way of using it. |
Hi, I've been using iodata lately to extract the electron integrals from a fcidump file and just today the code that I've been using for some time failed.
The line of code that is failing is
with the error "Types of file and lineno are not supported: <_io.TextIOWrapper name='h4_2_0.0_STO-6G.fcidump' mode='r' encoding='UTF-8'>, None"
I spent some time looking through the module code and I think I found the source of the error.
When a loadWarning is raised inside the function "fcidump.load_one" the function "_interpret_file_lineno" of utils.py is called. Within the following lines I found the problem:
The problem is, as far as I know, that the class TextIO can not be used for checking data types at run time. Instead, it can be changed for
io.TextIOBase is the base class for all text file objects in Python, and it can surely be used for Runtime type checks
The text was updated successfully, but these errors were encountered: