trendln icon indicating copy to clipboard operation
trendln copied to clipboard

NameError: name 'METHOD_NCUBED' is not defined

Open saulable opened this issue 4 years ago • 6 comments

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 avatar Aug 24 '20 10:08 saulable

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)

saulable avatar Aug 24 '20 10:08 saulable

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

just-a-normal-human avatar Aug 29 '20 09:08 just-a-normal-human

has this been resolved? thanks

pete011 avatar Sep 14 '20 22:09 pete011

I am having the same issue

tsferro2 avatar Sep 17 '20 11:09 tsferro2

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

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

coditori avatar Sep 29 '20 22:09 coditori

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.

GregoryMorse avatar Sep 30 '20 10:09 GregoryMorse