-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
226 additions
and
120 deletions.
There are no files selected for viewing
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
34_PyPackaging/example_project_root/src/SciwarePackage/__init__.py
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
34_PyPackaging/example_project_root/src/SciwarePackage/api.py
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
34_PyPackaging/example_project_root/src/SciwarePackage/util/formatting.py
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
34_PyPackaging/example_project_root/src/sciware_package/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from sciware_package.api import * |
51 changes: 51 additions & 0 deletions
51
34_PyPackaging/example_project_root/src/sciware_package/api.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
3 changes: 3 additions & 0 deletions
3
34_PyPackaging/example_project_root/src/sciware_package/util/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
...oot/src/SciwarePackage/util/enums/mode.py → ...ot/src/sciware_package/util/enums/mode.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
2 changes: 2 additions & 0 deletions
2
...rc/SciwarePackage/util/enums/precision.py → ...c/sciware_package/util/enums/precision.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
14 changes: 14 additions & 0 deletions
14
34_PyPackaging/example_project_root/src/sciware_package/util/formatting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.