Skip to content

Commit f7d87dc

Browse files
committed
MAINT custom minor refactoring
1 parent 7d8f546 commit f7d87dc

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ $ pip install pandas_ta
112112

113113
Latest Version
114114
--------------
115-
Best choice! Version: *0.3.13b*
115+
Best choice! Version: *0.3.14b*
116116
* Includes all fixes and updates between **pypi** and what is covered in this README.
117117
```sh
118118
$ pip install -U git+https://github.com/twopirllc/pandas-ta

pandas_ta/custom.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
import importlib
33
import os
44
import sys
5+
import types
6+
57
from os.path import abspath, join, exists, basename, splitext
68
from glob import glob
7-
import types
9+
810
import pandas_ta
9-
import pandas as pd
1011
from pandas_ta import AnalysisIndicators
1112

1213

@@ -86,7 +87,7 @@ def import_dir(path, verbose=True):
8687
return
8788

8889
# list the contents of the directory
89-
dirs = glob(abspath(join(path, '*')))
90+
dirs = glob(abspath(join(path, "*")))
9091

9192
# traverse full directory, importing all modules found there
9293
for d in dirs:
@@ -99,7 +100,7 @@ def import_dir(path, verbose=True):
99100
continue
100101

101102
# for each module found in that category (directory)...
102-
for module in glob(abspath(join(path, dirname, '*.py'))):
103+
for module in glob(abspath(join(path, dirname, "*.py"))):
103104
module_name = splitext(basename(module))[0]
104105

105106
# ensure that the supplied path is included in our python path
@@ -111,13 +112,13 @@ def import_dir(path, verbose=True):
111112

112113
# figure out which of the modules functions to bind to pandas_ta
113114
fcn_callable = module_functions.get(module_name, None)
114-
fcn_method_callable = module_functions.get(module_name + "_method", None)
115+
fcn_method_callable = module_functions.get(f"{module_name}_method", None)
115116

116117
if fcn_callable == None:
117118
print(f"[X] Unable to find a function named '{module_name}' in the module '{module_name}.py'.")
118119
continue
119120
if fcn_method_callable == None:
120-
missing_method = module_name + "_method"
121+
missing_method = f"{module_name}_method"
121122
print(f"[X] Unable to find a method function named '{missing_method}' in the module '{module_name}.py'.")
122123
continue
123124

@@ -145,7 +146,7 @@ def import_dir(path, verbose=True):
145146
146147
If you at some late point would like to push them into the pandas_ta library
147148
you can do so very easily by following the step by step instruction here
148-
https://github.com/twopirllc/pandas-ta/issues/264.
149+
https://github.com/twopirllc/pandas-ta/issues/355.
149150
150151
A brief example of usage:
151152
@@ -160,8 +161,8 @@ def import_dir(path, verbose=True):
160161
>>> import os
161162
>>> from os.path import abspath, join, expanduser
162163
>>> from pandas_ta.custom import create_dir, import_dir
163-
>>> my_dir = abspath(join(expanduser("~"), "my_indicators"))
164-
>>> create_dir(my_dir)
164+
>>> ta_dir = abspath(join(expanduser("~"), "my_indicators"))
165+
>>> create_dir(ta_dir)
165166
166167
3. You can now create your own custom indicator e.g. by copying existing
167168
ones from pandas_ta core module and modifying them.
@@ -194,14 +195,14 @@ def import_dir(path, verbose=True):
194195
4. We can now dynamically load all our custom indicators located in our
195196
designated indicators directory like this:
196197
197-
>>> import_dir(my_dir)
198+
>>> import_dir(ta_dir)
198199
199200
If your custom indicator(s) loaded succesfully then it should behave exactly
200201
like all other native indicators in pandas_ta, including help functions.
201202
"""
202203

203204

204-
def load_indicator_module(module_name):
205+
def load_indicator_module(name):
205206
"""
206207
Helper function to (re)load an indicator module.
207208
@@ -215,9 +216,9 @@ def load_indicator_module(module_name):
215216
"""
216217
# load module
217218
try:
218-
module = importlib.import_module(module_name)
219+
module = importlib.import_module(name)
219220
except Exception as ex:
220-
print(f"[X] An error occurred when attempting to load module {module_name}: {ex}")
221+
print(f"[X] An error occurred when attempting to load module {name}: {ex}")
221222
sys.exit(1)
222223

223224
# reload to refresh previously loaded module

pandas_ta/utils/_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
from numpy import argmax, argmin
77
from pandas import DataFrame, Series
8-
from pandas_ta import Imports
98
from pandas.api.types import is_datetime64_any_dtype
9+
from pandas_ta import Imports
1010

1111

1212
def _camelCase2Title(x: str):

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"pandas_ta.volatility",
2020
"pandas_ta.volume"
2121
],
22-
version=".".join(("0", "3", "13b")),
22+
version=".".join(("0", "3", "14b")),
2323
description=long_description,
2424
long_description=long_description,
2525
author="Kevin Johnson",

0 commit comments

Comments
 (0)