brielin / Popcorn

Software for estimating correlation of trait effect sizes across populations
40 stars 16 forks source link

np.bool deprecated in newer versions of NumPy #43

Open seantcaron opened 8 months ago

seantcaron commented 8 months ago

The following error is produced when running popcorn with NumPy >= 1.20.

Performing jackknife estimation of the standard error using 200 blocks of size 17925 . /usr/local/lib/python3.8/dist-packages/popcorn/jackknife.py:44: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar. k = np.ones((x.shape[0]),dtype=np.bool) Traceback (most recent call last): File "/usr/local/bin/popcorn", line 8, in sys.exit(main()) File "/usr/local/lib/python3.8/dist-packages/popcorn/main.py", line 218, in main res = fit.fit_pg(data.data,args,M=M) File "/usr/local/lib/python3.8/dist-packages/popcorn/fit.py", line 241, in init self.jackknife = jackknife.jackknife(close_call,data,res,args) File "/usr/local/lib/python3.8/dist-packages/popcorn/jackknife.py", line 19, in init self.psuedovalues, self.delete_values = self.jackknife(f,x,r) File "/usr/local/lib/python3.8/dist-packages/popcorn/jackknife.py", line 44, in jackknife k = np.ones((x.shape[0]),dtype=np.bool) File "/usr/local/lib/python3.8/dist-packages/numpy/init.py", line 305, in getattr raise AttributeError(__former_attrs_[attr]) AttributeError: module 'numpy' has no attribute 'bool'. np.bool was a deprecated alias for the builtin bool. To avoid this error in existing code, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool` here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Could you please update line 44 in jackknife.py to replace np.bool with np.bool_ such that this will run properly with newer NumPy without modification?

Thank you!

seantcaron commented 7 months ago

I was able to correct this in my environment by just modifying line 44 in jackknife.py to use np.bool_ instead of np.bool. This sed command should do the job:

sed -i -e 's/np.bool/np.bool_/' /usr/local/lib/python3.8/dist-packages/popcorn/jackknife.py

It looks like maybe the change didn't stick for you (see line 5 in the traceback - you still have np.bool and not np.bool_)? Perhaps you accidentally reinstalled the library from Github again over your modified version?

Best,

Sean

Sean Caron (she/they) OS Programmer Lead University of Michigan Center for Statistical Genetics Department of Biostatistics, School of Public Health *e: @. @.> p: 734-474-5962*

On Mon, Apr 22, 2024 at 9:46 AM francontiram @.***> wrote:

Hi @seantcaron https://github.com/seantcaron I am getting a very similar error message - see below. I have tried manually editing jackknife.py in my local environment, line 44 to np.bool_ as you have suggested but still getting the same error message - have you managed to fix this error? It is a while since I have used Python so grateful for any advice!

Performing jackknife estimation of the standard error using 200 blocks of size 17608 . /home/francesinez/.local/lib/python3.10/site-packages/popcorn/jackknife.py:44: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar. k = np.ones((x.shape[0]),dtype=np.bool) Traceback (most recent call last): File "/home/francesinez/Popcorn/popcorn/main.py", line 246, in main() File "/home/francesinez/Popcorn/popcorn/main.py", line 218, in main res = fit.fit_pg(data.data,args,M=M) File "/home/francesinez/.local/lib/python3.10/site-packages/popcorn/fit.py", line 241, in init self.jackknife = jackknife.jackknife(close_call,data,res,args) File "/home/francesinez/.local/lib/python3.10/site-packages/popcorn/jackknife.py", line 19, in init self.psuedovalues, self.delete_values = self.jackknife(f,x,r) File "/home/francesinez/.local/lib/python3.10/site-packages/popcorn/jackknife.py", line 44, in jackknife k = np.ones((x.shape[0]),dtype=np.bool) File "/home/francesinez/.local/lib/python3.10/site-packages/numpy/init.py", line 324, in getattr raise AttributeError(former_attrs[attr]) AttributeError: module 'numpy' has no attribute 'bool'. np.bool was a deprecated alias for the builtin bool. To avoid this error in existing code, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool'?

— Reply to this email directly, view it on GitHub https://github.com/brielin/Popcorn/issues/43#issuecomment-2069497945, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEEAXHLODLN4J26U5TWIMJTY6UIBTAVCNFSM6AAAAABFUCCXUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRZGQ4TOOJUGU . You are receiving this because you were mentioned.Message ID: @.***>

francontiram commented 7 months ago

Thank you Sean – yes I realised popcorn was loading from local libs and when I changed the jackknife file there then the single change to np.bool_ worked for me too!

I deleted my comment as your fix did the job.

Thanks again,

Fran

From: Sean Caron @.> Sent: Monday, April 22, 2024 4:27 PM To: brielin/Popcorn @.> Cc: Fran Conti-Ramsden @.>; Comment @.> Subject: Re: [brielin/Popcorn] np.bool deprecated in newer versions of NumPy (Issue #43)

You don't often get email from @.**@.>. Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification I was able to correct this in my environment by just modifying line 44 in jackknife.py to use np.bool_ instead of np.bool. This sed command should do the job:

sed -i -e 's/np.bool/np.bool_/' /usr/local/lib/python3.8/dist-packages/popcorn/jackknife.py

It looks like maybe the change didn't stick for you (see line 5 in the traceback - you still have np.bool and not np.bool_)? Perhaps you accidentally reinstalled the library from Github again over your modified version?

Best,

Sean

Sean Caron (she/they) OS Programmer Lead University of Michigan Center for Statistical Genetics Department of Biostatistics, School of Public Health *e: @.<mailto:@.> @.<mailto:@.>> p: 734-474-5962*

On Mon, Apr 22, 2024 at 9:46 AM francontiram @.<mailto:@.>> wrote:

Hi @seantcaron https://github.com/seantcaron I am getting a very similar error message - see below. I have tried manually editing jackknife.py in my local environment, line 44 to np.bool_ as you have suggested but still getting the same error message - have you managed to fix this error? It is a while since I have used Python so grateful for any advice!

Performing jackknife estimation of the standard error using 200 blocks of size 17608 . /home/francesinez/.local/lib/python3.10/site-packages/popcorn/jackknife.py:44: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar. k = np.ones((x.shape[0]),dtype=np.bool) Traceback (most recent call last): File "/home/francesinez/Popcorn/popcorn/main.py", line 246, in main() File "/home/francesinez/Popcorn/popcorn/main.py", line 218, in main res = fit.fit_pg(data.data,args,M=M) File "/home/francesinez/.local/lib/python3.10/site-packages/popcorn/fit.py", line 241, in init self.jackknife = jackknife.jackknife(close_call,data,res,args) File "/home/francesinez/.local/lib/python3.10/site-packages/popcorn/jackknife.py", line 19, in init self.psuedovalues, self.delete_values = self.jackknife(f,x,r) File "/home/francesinez/.local/lib/python3.10/site-packages/popcorn/jackknife.py", line 44, in jackknife k = np.ones((x.shape[0]),dtype=np.bool) File "/home/francesinez/.local/lib/python3.10/site-packages/numpy/init.py", line 324, in getattr raise AttributeError(former_attrs[attr]) AttributeError: module 'numpy' has no attribute 'bool'. np.bool was a deprecated alias for the builtin bool. To avoid this error in existing code, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool'?

— Reply to this email directly, view it on GitHub https://github.com/brielin/Popcorn/issues/43#issuecomment-2069497945, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEEAXHLODLN4J26U5TWIMJTY6UIBTAVCNFSM6AAAAABFUCCXUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRZGQ4TOOJUGU . You are receiving this because you were mentioned.Message ID: @.<mailto:@.>>

— Reply to this email directly, view it on GitHubhttps://github.com/brielin/Popcorn/issues/43#issuecomment-2069886134, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BIACF2UTWQPR3XF3NF52Q7TY6UT5RAVCNFSM6AAAAABFUCCXUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRZHA4DMMJTGQ. You are receiving this because you commented.Message ID: @.**@.>>

seantcaron commented 7 months ago

Wonderful! I'm so happy that my issue report was able to help others!

Best,

Sean

Sean Caron (she/they) OS Programmer Lead University of Michigan Center for Statistical Genetics Department of Biostatistics, School of Public Health *e: @. @.> p: 734-474-5962*

On Mon, Apr 22, 2024 at 11:34 AM francontiram @.***> wrote:

Thank you Sean – yes I realised popcorn was loading from local libs and when I changed the jackknife file there then the single change to np.bool_ worked for me too!

I deleted my comment as your fix did the job.

Thanks again,

Fran

From: Sean Caron @.> Sent: Monday, April 22, 2024 4:27 PM To: brielin/Popcorn @.> Cc: Fran Conti-Ramsden @.>; Comment @.> Subject: Re: [brielin/Popcorn] np.bool deprecated in newer versions of NumPy (Issue #43)

You don't often get email from @.**@.>. Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification I was able to correct this in my environment by just modifying line 44 in jackknife.py to use np.bool_ instead of np.bool. This sed command should do the job:

sed -i -e 's/np.bool/np.bool_/' /usr/local/lib/python3.8/dist-packages/popcorn/jackknife.py

It looks like maybe the change didn't stick for you (see line 5 in the traceback - you still have np.bool and not np.bool_)? Perhaps you accidentally reinstalled the library from Github again over your modified version?

Best,

Sean

Sean Caron (she/they) OS Programmer Lead University of Michigan Center for Statistical Genetics Department of Biostatistics, School of Public Health *e: @.<mailto:@.> @.<mailto:@.>> p: 734-474-5962*

On Mon, Apr 22, 2024 at 9:46 AM francontiram @.<mailto:@.>>

wrote:

Hi @seantcaron https://github.com/seantcaron I am getting a very similar error message - see below. I have tried manually editing jackknife.py in my local environment, line 44 to np.bool_ as you have suggested but still getting the same error message - have you managed to fix this error? It is a while since I have used Python so grateful for any advice!

Performing jackknife estimation of the standard error using 200 blocks of size 17608 .

/home/francesinez/.local/lib/python3.10/site-packages/popcorn/jackknife.py:44:

FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar. k = np.ones((x.shape[0]),dtype=np.bool) Traceback (most recent call last): File "/home/francesinez/Popcorn/popcorn/main.py", line 246, in main() File "/home/francesinez/Popcorn/popcorn/main.py", line 218, in main res = fit.fit_pg(data.data,args,M=M) File "/home/francesinez/.local/lib/python3.10/site-packages/popcorn/fit.py", line 241, in init self.jackknife = jackknife.jackknife(close_call,data,res,args) File

"/home/francesinez/.local/lib/python3.10/site-packages/popcorn/jackknife.py",

line 19, in init self.psuedovalues, self.delete_values = self.jackknife(f,x,r) File

"/home/francesinez/.local/lib/python3.10/site-packages/popcorn/jackknife.py",

line 44, in jackknife k = np.ones((x.shape[0]),dtype=np.bool) File "/home/francesinez/.local/lib/python3.10/site-packages/numpy/init.py", line 324, in getattr raise AttributeError(former_attrs[attr]) AttributeError: module 'numpy' has no attribute 'bool'. np.bool was a deprecated alias for the builtin bool. To avoid this error in existing code, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool'?

— Reply to this email directly, view it on GitHub https://github.com/brielin/Popcorn/issues/43#issuecomment-2069497945, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AEEAXHLODLN4J26U5TWIMJTY6UIBTAVCNFSM6AAAAABFUCCXUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRZGQ4TOOJUGU>

. You are receiving this because you were mentioned.Message ID: @.<mailto:@.>>

— Reply to this email directly, view it on GitHub< https://github.com/brielin/Popcorn/issues/43#issuecomment-2069886134>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/BIACF2UTWQPR3XF3NF52Q7TY6UT5RAVCNFSM6AAAAABFUCCXUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRZHA4DMMJTGQ>.

You are receiving this because you commented.Message ID: @.**@.>>

— Reply to this email directly, view it on GitHub https://github.com/brielin/Popcorn/issues/43#issuecomment-2069916907, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEEAXHL6UKAXNHDVCXG6WRLY6UUXLAVCNFSM6AAAAABFUCCXUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRZHEYTMOJQG4 . You are receiving this because you were mentioned.Message ID: @.***>