Skip to content

Commit

Permalink
Address run-through feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoules committed Sep 25, 2024
1 parent 9c68d2b commit e724bf9
Show file tree
Hide file tree
Showing 16 changed files with 226 additions and 120 deletions.
Binary file modified 34_PyPackaging/assets/sample-layout-shorter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 34_PyPackaging/assets/sample-layout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions 34_PyPackaging/example_project_root/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "SciwarePackage"
name = "sciware_package"
version = "0.0.1"
description = "Example package for Sciware 34"
authors = [
Expand All @@ -19,9 +19,8 @@ dependencies = [
file = "LICENSE"

[build-system]
requires = ["setuptools>=61.0"]
requires = ["setuptools"]
build-backend="setuptools.build_meta"

[tool.setuptools]
package-dir = {"" = "src"}
packages = ["SciwarePackage"]
[tool.setuptools.packages.find]
where = ["src"]

This file was deleted.

24 changes: 0 additions & 24 deletions 34_PyPackaging/example_project_root/src/SciwarePackage/api.py

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from sciware_package.api import *
51 changes: 51 additions & 0 deletions 34_PyPackaging/example_project_root/src/sciware_package/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

from sciware_package.util import canonicalize_string
from sciware_package.util.enums import Mode


def multiply(a: int | float, b: int | float):
"""Multiply two numbers.
Args:
a (int | float): First number
b (int | float): Second number
Returns:
int | float: The product of the input numbers.
"""
return float(a * b)


def describe_operation(desc: str, left_operand: int | float, right_operand: int | float):
"""A trivial function that calls a few functions defined in a few modules.
Multiplies two numbers, as well as a string describing the operation performed.
Args:
desc (str): Description of the operation.
left_operand (int | float): The first number.
right_operand (int | float): The second number.
"""
canonical_string = canonicalize_string(desc)
product = multiply(left_operand, right_operand)
print(f"{canonical_string}\n\t{product}")


def main(mode: Mode, l: int | float, r: int | float):
"""Entry point function. Multiplies two numbers, and describes them either
succinctly or verbosely, based on the mode.
Args:
mode (Mode): If SIMPLE, will use a succinct description. If ADVANCED,
will use a verbose description.
l (int | float): First number to multiply.
r (int | float): Second number to multiply.
"""
if mode == Mode.SIMPLE:
describe_operation("times", l, r)
else:
describe_operation("multiplication of two numbers", l, r)


if __name__ == "__main__":
main(Mode.ADVANCED, 3, 5)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .enums import Mode as Mode
from .enums import Precision as Precision
from .formatting import canonicalize_string
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from enum import Enum

class Mode(Enum):
"""Enum defining functionality modes.
"""
SIMPLE = 'simple'
ADVANCED = 'advanced'
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from enum import Enum

class Precision(Enum):
"""Enum defining low and high precision.
"""
LOW = 1
HIGH = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def canonicalize_string(base_string: str) -> str:
"""Convert a base string into a canonical representation for our application.
Args:
base_string (str): The input string to canonicalize.
Returns:
str: An explicit "empty string" representation, if an empty
string was originally passed; otherwise, the input string,
with the first character capitalized and the rest in lower case.
"""
if (base_string == ''):
return "[empty string]"
return base_string.capitalize()
Empty file.
Loading

0 comments on commit e724bf9

Please sign in to comment.