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

Closes #20. Added some dependencies #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 22 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ dynamic = ["version"]
requires-python = ">=3.10"
license = "MIT"
keywords = []
authors = [
{ name = "Leah Wasser", email = "[email protected]" },
]
authors = [{ name = "Leah Wasser", email = "[email protected]" }]
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/"
Expand All @@ -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 ******* #
Expand All @@ -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
22 changes: 0 additions & 22 deletions src/pyospackage/add_numbers.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey there @gpcureton thank you for this PR! the one challenge here that we need to think through is we can't delete this add_numbers.py module. this is because we use it in our trainings as an example module that people make. And in our tutorials as well. it's a core simple module that people can quickly make without thinking much about the code within the function there.

So we want user to be able to access this add_numbers.py module.

I'd prefer to keep the add_numbers module as is. BUT we can then rename your simple_arithmetic module to be something more specific that includes numpy or another package.

Let me know what you think.

This file was deleted.

21 changes: 21 additions & 0 deletions src/pyospackage/plot_pyramid.py
Original file line number Diff line number Diff line change
@@ -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")
96 changes: 96 additions & 0 deletions src/pyospackage/simple_arithmetic.py
Original file line number Diff line number Diff line change
@@ -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