diff --git a/pyproject.toml b/pyproject.toml index ad520db..27e0afb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,18 +11,16 @@ dynamic = ["version"] requires-python = ">=3.10" license = "MIT" keywords = [] -authors = [ - { name = "Leah Wasser", email = "leah@pyopensci.org" }, -] +authors = [{ name = "Leah Wasser", email = "leah@pyopensci.org" }] classifiers = [ - "Development Status :: 4 - Beta", - "Programming Language :: Python", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] -dependencies = [] +dependencies = ["numpy", "pandas", "altair", "vl-convert-python"] [project.urls] Homepage = "https://pypi.org/project/pyospackage/" @@ -32,18 +30,18 @@ Source = "https://github.com/pyopensci/pyospackage" [project.optional-dependencies] docs = [ - "sphinx", - "sphinx-autobuild", - "sphinx-inline-tabs", - # Note that the tool you install has dashes- between the name, vs _underscores - # when you call the theme in sphinx's conf.py - "pydata-sphinx-theme", - "sphinx-design", - "sphinx-copybutton", - "myst-nb", - "myst-parser", - # Create beautiful api docs automatically - "sphinx-autoapi", + "sphinx", + "sphinx-autobuild", + "sphinx-inline-tabs", + # Note that the tool you install has dashes- between the name, vs _underscores + # when you call the theme in sphinx's conf.py + "pydata-sphinx-theme", + "sphinx-design", + "sphinx-copybutton", + "myst-nb", + "myst-parser", + # Create beautiful api docs automatically + "sphinx-autoapi", ] # ******* Hatch configuration here ******* # @@ -69,16 +67,13 @@ docs-live = "sphinx-autobuild docs/ docs/_build" [tool.hatch.envs.test] -dependencies = [ - "pytest", - "pytest-cov" -] +dependencies = ["pytest", "pytest-cov"] [tool.ruff] lint.select = [ - "F", # pyflakes - "I", # isort + "F", # pyflakes + "I", # isort ] lint.ignore = ["F841"] line-length = 79 diff --git a/src/pyospackage/add_numbers.py b/src/pyospackage/add_numbers.py deleted file mode 100644 index 38f7791..0000000 --- a/src/pyospackage/add_numbers.py +++ /dev/null @@ -1,22 +0,0 @@ -"""A module that performs basic math operations.""" - - -def add_num( - a: int, - b: int, -) -> int: - """A function that adds two numbers together - - Parameters - ---------- - a : int - The first integer to be added. - b : int - The second integer to be added. - - Returns - ------- - int - The sum of the two provided integers. - """ - return a + b diff --git a/src/pyospackage/plot_pyramid.py b/src/pyospackage/plot_pyramid.py new file mode 100644 index 0000000..0ac62ba --- /dev/null +++ b/src/pyospackage/plot_pyramid.py @@ -0,0 +1,21 @@ +"""A module that performs basic math operations.""" + +import altair as alt +import pandas as pd + +alt.renderers.enable("png", scale_factor=2, ppi=144) + + +def plot_pyramid(): + category = ["Sky", "Shady side of a pyramid", "Sunny side of a pyramid"] + color = ["#416D9D", "#674028", "#DEAC58"] + df = pd.DataFrame({"category": category, "value": [75, 10, 15]}) + + alt.Chart(df, width=150, height=150).mark_arc(outerRadius=80).encode( + alt.Theta("value:Q").scale(range=[2.356, 8.639]), + alt.Color("category:N") + .title(None) + .scale(domain=category, range=color) + .legend(orient="none", legendX=160, legendY=50), + order="value:Q", + ).configure_view(strokeOpacity=0).save("pyramid.png") diff --git a/src/pyospackage/simple_arithmetic.py b/src/pyospackage/simple_arithmetic.py new file mode 100644 index 0000000..f5ff086 --- /dev/null +++ b/src/pyospackage/simple_arithmetic.py @@ -0,0 +1,96 @@ +"""A module that performs basic math operations.""" + +import numpy as np +import numpy.typing as npt + + +def add_integers( + a: int, + b: int, +) -> int: + """A function that adds two integers together + + Parameters + ---------- + a : int + The first integer to be added. + b : int + The second integer to be added. + + Returns + ------- + int + The sum of the two provided integers. + """ + + if not np.isscalar(a): + raise TypeError(f"Expected a scalar, got {a}") + if not isinstance(a, int): + raise TypeError(f"Expected a integer, got {a}") + if not np.isscalar(b): + raise TypeError(f"Expected a scalar, got {b}") + if not isinstance(b, int): + raise TypeError(f"Expected a integer, got {b}") + + return a + b + + +def multiply_integers( + a: int, + b: int, +) -> int: + """A function that multiplies two integers together + + Parameters + ---------- + a : int + The first integer to be multiplied. + b : int + The second integer to be multiplied. + + Returns + ------- + int + The product of the two provided integers. + """ + if not np.isscalar(a): + raise TypeError(f"Expected a scalar, got {a}") + if not isinstance(a, int): + raise TypeError(f"Expected an integer, got {a}") + if not np.isscalar(b): + raise TypeError(f"Expected a scalar, got {b}") + if not isinstance(b, int): + raise TypeError(f"Expected an integer, got {b}") + + return a * b + + +def create_int_vector( + a: int, + b: int, +) -> npt.NDArray[np.int32]: + """Create a numpy 1-D array + + Parameters + ---------- + a : int + The length of the 1-D array. + b : int + The integer with which to populate the array. + + Returns + ------- + ndarray[int] + The sum of the two provided integers. + """ + + if not np.isscalar(a): + raise TypeError(f"Expected a scalar, got {a}") + if not isinstance(a, int): + raise TypeError(f"Expected an integer, got {a}") + if not np.isscalar(b): + raise TypeError(f"Expected a scalar, got {b}") + if not isinstance(b, int): + raise TypeError(f"Expected an integer, got {b}") + + return np.ones(a, dtype=int) * b