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

NameError: name 'METHOD_NCUBED' is not defined #14

Open
saulable opened this issue Aug 24, 2020 · 6 comments
Open

NameError: name 'METHOD_NCUBED' is not defined #14

saulable opened this issue Aug 24, 2020 · 6 comments

Comments

@saulable
Copy link

Hello,

I'm not that great with Python, more of a JS dev, so I don't know if this is correct?

When trying to pass in the parameters method, extmethod without quotes results in error. I suggest a fix.

trendln.plot_support_resistance(
            hist[-1000:].Close, method="METHOD_PROBHOUGH")

Then on lines 950 - 960 of init.py


    if method == "METHOD_NCUBED":
        trendmethod = get_trend
    elif method == "METHOD_NSQUREDLOGN":
        trendmethod = get_trend_opt
    elif method == "METHOD_HOUGHPOINTS":
        trendmethod = houghpt
    # pip install scikit-image
    elif method == "METHOD_HOUGHLINES":
        trendmethod = hough
    elif method == "METHOD_PROBHOUGH":
        trendmethod = prob_hough

@saulable
Copy link
Author

Otherwise I get error of NameError: name 'METHOD_PROBHOUGH' is not defined when doing like so

trendln.plot_support_resistance(
hist[-1000:].Close, method=METHOD_PROBHOUGH)

@just-a-normal-human
Copy link

I have the same problem but also when passing with quotes i get error:

ValueError: method must be one of METHOD_NCUBED, METHOD_NSQUREDLOGN, METHOD_HOUGHPOINTS, METHOD_HOUGHLINES, METHOD_PROBHOUGH

And without quotes:

NameError: name 'METHOD_NSQUREDLOGN' is not defined

@GregoryMorse @saulable

@pete011
Copy link

pete011 commented Sep 14, 2020

has this been resolved? thanks

@tsferro2
Copy link

I am having the same issue

@coditori
Copy link

@saulable It's an enum not a string, try this one:

trendln.plot_support_resistance(
            hist[-1000:].Close, method=trendln.METHOD_NCUBED)

@GregoryMorse
Copy link
Owner

The correct solution is to either import everything e.g. import trendln and to as suggested use trendln.CONSTANT_NAME syntax or use from trendln import CONSTANT_NAME. It is not necessary for these to be strings. However I will update the examples or look for scenarios where this confusion can come up so it will be corrected in the next version. These are just numeric constants with names provided for convenience. Strings might be okay as performance is not particularly an issue on these parameters but nonetheless, constants seem cleaner.

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

6 participants