diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 4e1ef42..495e3c3 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,5 +1,5 @@ # This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# For more information see https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries name: Upload Python Package diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index cc6cf9d..d66144a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -9,15 +9,26 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.x' - - name: Install dependencies + + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/dev-requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install Dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | - python -m pip install -U pip - python -m pip install -r dev-requirements.txt + pip install -r dev-requirements.txt + - name: Linter run: make lint + - name: Test run: make test diff --git a/dev-requirements.txt b/dev-requirements.txt index 259022d..0226baf 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -4,3 +4,4 @@ flake8 autopep8 sympy numpy +scipy diff --git a/mathgenerator/funcs/__init__.py b/mathgenerator/funcs/__init__.py index b76db90..be02113 100644 --- a/mathgenerator/funcs/__init__.py +++ b/mathgenerator/funcs/__init__.py @@ -94,4 +94,5 @@ from .degree_to_rad import * from .radian_to_deg import * from .differentiation import * from .definite_integral import * +from .is_prime import * from .curvedSurfaceAreaCylinderFunc import * diff --git a/mathgenerator/funcs/decimal_to_roman_numerals.py b/mathgenerator/funcs/decimal_to_roman_numerals.py index 46a1ebd..63b64f2 100644 --- a/mathgenerator/funcs/decimal_to_roman_numerals.py +++ b/mathgenerator/funcs/decimal_to_roman_numerals.py @@ -15,7 +15,7 @@ def decimalToRomanNumeralsFunc(maxDecimal=4000): if last_value <= 3: solution += (roman_dict[divisor] * last_value) elif last_value == 4: - solution += (roman_dict[divisor] * roman_dict[divisor * 5]) + solution += (roman_dict[divisor] + roman_dict[divisor * 5]) elif 5 <= last_value <= 8: solution += (roman_dict[divisor * 5] + (roman_dict[divisor] * (last_value - 5))) elif last_value == 9: diff --git a/mathgenerator/funcs/definite_integral.py b/mathgenerator/funcs/definite_integral.py index 9dc6290..6e8453f 100644 --- a/mathgenerator/funcs/definite_integral.py +++ b/mathgenerator/funcs/definite_integral.py @@ -1,4 +1,5 @@ from .__init__ import * +import scipy from scipy.integrate import quad diff --git a/mathgenerator/funcs/is_prime.py b/mathgenerator/funcs/is_prime.py new file mode 100644 index 0000000..143f4d3 --- /dev/null +++ b/mathgenerator/funcs/is_prime.py @@ -0,0 +1,22 @@ +from .__init__ import * + + +def isprime(max_a=100): + a = random.randint(2, max_a) + problem = a + if a == 2: + solution = True + return (problem, solution) + if a % 2 == 0: + solution = False + return (problem, solution) + for i in range(3, a // 2 + 1, 2): + if a % i == 0: + solution = False + return (problem, solution) + solution = True + return (problem, solution) + + +is_prime = Generator('isprime', 90, 'a any positive integer', + 'True/False', isprime) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index b724345..2a969fa 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -1,9 +1,6 @@ -import random -import math -import fractions from .funcs import * from .__init__ import getGenList -import scipy + genList = getGenList() diff --git a/setup.py b/setup.py index 4bfbcd0..7b022b4 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,16 @@ from setuptools import setup, find_packages setup(name='mathgenerator', - version='1.1.3', + version='1.1.4', description='An open source solution for generating math problems', url='https://github.com/todarith/mathgenerator', author='Luke Weiler', author_email='lukew25073@gmail.com', license='MIT', packages=find_packages(), - install_requires=[], + install_requires=[ + 'sympy', + 'numpy', + 'scipy' + ], entry_points={}) diff --git a/test.py b/test.py index 74d73ce..2fa65b7 100644 --- a/test.py +++ b/test.py @@ -10,4 +10,4 @@ for item in list: print(item[2]) # print(mathgen.getGenList()) -print(mathgen.genById(89)) +print(mathgen.genById(85))