Skip to content
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

numpy.float128 not available on Windows #46

Open
realitychemist opened this issue Oct 21, 2024 · 1 comment
Open

numpy.float128 not available on Windows #46

realitychemist opened this issue Oct 21, 2024 · 1 comment

Comments

@realitychemist
Copy link

realitychemist commented Oct 21, 2024

Attempting to run the latest version of sqsgenerator on Windows 10 (64-bit) gives the following error upon the completion of a simulation: AttributeError: module 'numpy' has no attribute 'float128'. Did you mean: 'float16'? Here's the full traceback (paths trimmed to site-packages):

  File "...\sqsgen\Scripts\sqsgen-script.py", line 10, in <module>
    sys.exit(cli())
             ^^^^^
  File "...\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "...\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\sqsgenerator\commands\common.py", line 88, in _inner 
    result = f(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^
  File "...\sqsgenerator\commands\common.py", line 132, in _dummy
    return f(settings, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\sqsgenerator\commands\run.py", line 44, in iteration 
    to_dict(final_document), output_format=dump_format
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "...\sqsgenerator\io.py", line 288, in to_dict
    np.float128: float,
    ^^^^^^^^^^^
  File "...\numpy\__init__.py", line 414, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float128'. Did you mean: 'float16'?

Just searching around a little bit online, it looks like numpy.float128 is unavailable on Windows and Mac (at least M1, maybe also M2). I re-ran the script on the same machine but under WSL (Debian) and it completed without errors. I got a well-formatted *.result.yaml file that I was able to export as a .cif. So this appears to be an issue on non-linux operating systems only.

The simple fix would seem to be just exporting with float-64 precision instead: this discussion suggests that even where the name numpy.float128 is available it is probably not actually giving 128 bits of precision, so just changing the output to float64 seems like it might be fine. Otherwise you could test for float128 support before exporting, and export with float64 only if it's not available.

@dgehringer
Copy link
Owner

Hi @realitychemist !

Thanks a lot for digging that deep!
Indeed it is true that wide integer types are missing on Windows!
Actually we also need those types to generate random numbers. Therefore, there's already a Windows specific workaround

But that should be easy to fix!

Thanks again for reporting and for helping so much

Best
@dgehringer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants