kmayerb / tcrdist3

flexible CDR based distance metrics
MIT License
53 stars 17 forks source link

Tiny issue: hcluster_tally function uses np.int, throws up error #102

Open JoshYeeXJ opened 4 months ago

JoshYeeXJ commented 4 months ago

Hi there,

I was following along with the CDR3 Motifs tutorial. I ran into a problem at this block of code. Specifically the hcluster_diff function, which uses the hcluster_tally function, which uses np.int:

from tcrdist.rep_diff import hcluster_diff
tr.hcluster_df, tr.Z =\
    hcluster_diff(clone_df = tr.clone_df, 
                  pwmat    = tr.pw_beta + tr.pw_alpha,
                  x_cols = ['epitope'], 
                  count_col = 'count')

Using np.int, throws up this error that tells you to use int instead of np.int :

AttributeError: module 'numpy' has no attribute 'int'. np.int was a deprecated alias for the builtin int. To avoid this error in existing code, use int by itself. Doing this will not modify any behavior and is safe. When replacing np.int, you may wish to use e.g. np.int64 or np.int32 to specify the precision. If you wish to review your current use, check the release note link for additional information. 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

The problem code is here:

File ~/.local/lib/python3.10/site-packages/hierdiff/tally.py:475, in hcluster_tally(df, pwmat, x_cols, Z, count_col, subset_ind, method, optimal_ordering) 473 for cid, m in members.items(): 474 not_m = [i for i in range(n) if not i in m] --> 475 y_float = np.zeros(n, dtype=np.int) 476 y_float[m] = 1 478 y_lu = {1:'MEM+', 0:'MEM-'}

I think that's the issue. Or maybe I should be using an older version of python or numpy. I look forward to hearing from you!

Thanks, Josh