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

name 'UnifiedDiff' is not defined #2

Open
zeydabadi opened this issue Dec 9, 2018 · 2 comments
Open

name 'UnifiedDiff' is not defined #2

zeydabadi opened this issue Dec 9, 2018 · 2 comments

Comments

@zeydabadi
Copy link

Hi,
I ran the following code in my jupyter-notebook. data[0] contains a string which is the path to a .py file.
import pycode_similar pycode_similar.detect([data[0], data[0]],diff_method=UnifiedDiff)
but I receive this error:
`--------------------------------------------------------------------------
NameError Traceback (most recent call last)
in
1 import pycode_similar
----> 2 pycode_similar.detect([data[0], data[0]],diff_method=UnifiedDiff)

NameError: name 'UnifiedDiff' is not defined
I ran the code like below:import pycode_similar
pycode_similar.detect([data[0], data[0]],diff_method='UnifiedDiff')`

and I got this error:
`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
1 import pycode_similar
----> 2 pycode_similar.detect([data[0], data[0]],diff_method='UnifiedDiff')

~/deid2/lib/python3.6/site-packages/pycode_similar.py in detect(pycode_string_list, diff_method)
446 min_diff_func_info = None
447 for fi2 in func_info_candidate:
--> 448 dv = diff_method.diff(fi1, fi2)
449 if dv < min_diff_value:
450 min_diff_value = dv

AttributeError: 'str' object has no attribute 'diff'`

Can you please help me understand what I am doing wrong?

Thank you!

@fyrestone
Copy link
Owner

Sorry for the incorrect document. The usage should be:

import pycode_similar
pycode_similar.detect([data[0], data[0]],diff_method=pycode_similar.UnifiedDiff)

@zeydabadi
Copy link
Author

Thanks for your response.
running the above code I receive this output:
[(1,
[<pycode_similar.FuncDiffInfo at 0x7f8cd62bb828>,
<pycode_similar.FuncDiffInfo at 0x7f8cd617a828>])]

I'm not sure what is wrong.

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