harmslab / topiary

Python framework for doing ancestral sequence reconstruction
MIT License
31 stars 7 forks source link

numpy 1.24 doesn't like np.float() #28

Closed jkaczmarski closed 1 year ago

jkaczmarski commented 1 year ago

Hey again Mike,

Just letting you know I ran into this issue as well (when running your example dataset). Issue is that I had numpy 1.24.1 in my topiary env, and np.float() now not supported (https://levelup.gitconnected.com/fix-attributeerror-module-numpy-has-no-attribute-float-d7d68c5a4971). Changing line 213 in ancestor.py to mean_pp = float(anc_dict[a]["anc_pp"]) runs fine when using numpy 1.24.1.

Not sure if best solution is just to tell people to use numpy ver < 1.24 or alter code.

Otherwise, everything else running to completion now! :)

Cheers,

Joe

Generating report in ali_to_anc/results/gene-tree/
Traceback (most recent call last):
  File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/_private/interface.py", line 32, in wrapper
    value = func(*args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/pipeline/alignment_to_ancestors.py", line 412, in alignment_to_ancestors
    pipeline_report(pipeline_directory=out_dir,
  File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/reports/reports.py", line 410, in pipeline_report
    tree_report(tree_directory=gene_dirs["tree"],
  File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/reports/reports.py", line 321, in tree_report
    anc_card = create_ancestor_card(anc_dict,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/reporttopiary/lib/python3.11/site-packages/topiary/reports/cards/ancestor.pys/cards/ancestor.py", line 213, in create_ancestor_card
    mean_pp = np.float(anc_dict[a]["anc_pp"])
              ^^^^^^^^
  File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float'. Did you mean: 'cfloat'?

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/_private/wrap.py", line 185, in wrap_function
    ret = fcn(**fcn_args.__dict__)
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/_private/interface.py", line 38, in wrapper
    raise WrappedFunctionException(err) from e
topiary._private.interface.WrappedFunctionException: 

Caught exception in function 'alignment_to_ancestors'. Returning to starting
directory and cleaning up. Check error stack for cause of
this error.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/joek/.conda/envs/topiary/bin/topiary-alignment-to-ancestors", line 26, in <module>
    main()
  File "/home/joek/.conda/envs/topiary/bin/topiary-alignment-to-ancestors", line 21, in main
    wrap_function(alignment_to_ancestors,
  File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/_private/wrap.py", line 189, in wrap_function
    raise RuntimeError(err) from e
RuntimeError: 

Function alignment_to_ancestors raised an error.

To see command line help, run topiary-alignment-to-ancestors --help
harmsm commented 1 year ago

Best solution is definitely to update code. Definitely don’t want to pin on an old version of numpy. just checked: that is the only place where we called np.float. If you want to do PR on this, you’ll get credit :). Otherwise, I can patch soon. Thanks for the report.

Mike

On Jan 12, 2023, at 3:51 PM, Joe Kaczmarski @.***> wrote:

Hey again Mike,

Just letting you know I ran into this issue as well (when running your example dataset). Issue is that I had numpy 1.24.1 in my topiary env, and np.float() now not supported (https://levelup.gitconnected.com/fix-attributeerror-module-numpy-has-no-attribute-float-d7d68c5a4971). Changing line 213 in ancestor.py to mean_pp = float(anc_dict[a]["anc_pp"]) runs fine when using numpy 1.24.1.

Not sure if best solution is just to tell people to use numpy ver < 1.24 or alter code.

Otherwise, everything else running to completion now! :)

Cheers,

Joe

Generating report in ali_to_anc/results/gene-tree/ Traceback (most recent call last): File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/_private/interface.py", line 32, in wrapper value = func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/pipeline/alignment_to_ancestors.py", line 412, in alignment_to_ancestors pipeline_report(pipeline_directory=out_dir, File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/reports/reports.py", line 410, in pipeline_report tree_report(tree_directory=gene_dirs["tree"], File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/reports/reports.py", line 321, in tree_report anc_card = create_ancestor_card(anc_dict, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/reporttopiary/lib/python3.11/site-packages/topiary/reports/cards/ancestor.pys/cards/ancestor.py", line 213, in create_ancestor_card mean_pp = np.float(anc_dict[a]["anc_pp"]) ^^^^^^^^ File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/numpy/init.py", line 284, in getattr raise AttributeError("module {!r} has no attribute " AttributeError: module 'numpy' has no attribute 'float'. Did you mean: 'cfloat'?

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/_private/wrap.py", line 185, in wrap_function ret = fcn(**fcn_args.dict) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/_private/interface.py", line 38, in wrapper raise WrappedFunctionException(err) from e topiary._private.interface.WrappedFunctionException:

Caught exception in function 'alignment_to_ancestors'. Returning to starting directory and cleaning up. Check error stack for cause of this error.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/joek/.conda/envs/topiary/bin/topiary-alignment-to-ancestors", line 26, in main() File "/home/joek/.conda/envs/topiary/bin/topiary-alignment-to-ancestors", line 21, in main wrap_function(alignment_to_ancestors, File "/home/joek/.conda/envs/topiary/lib/python3.11/site-packages/topiary/_private/wrap.py", line 189, in wrap_function raise RuntimeError(err) from e RuntimeError:

Function alignment_to_ancestors raised an error.

To see command line help, run topiary-alignment-to-ancestors --help — Reply to this email directly, view it on GitHub https://github.com/harmslab/topiary/issues/28, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFZA6R66YBS65XMFE3TURTWSCKHFANCNFSM6AAAAAATZZ7Y2Q. You are receiving this because you are subscribed to this thread.

harmsm commented 1 year ago

Fixed in latest PR.