-
Notifications
You must be signed in to change notification settings - Fork 87
add setuptools files for example package mentioned in Issue 248 #659
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,3 @@ | ||
| [build-system] | ||
| requires = ["setuptools>=61"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [project] | ||
| name = "examplePy" | ||
| authors = [ | ||
|
|
@@ -10,15 +6,47 @@ authors = [ | |
| maintainers = [ | ||
| {name = "All the contributors"}, | ||
| ] | ||
| description = "An example Python package used to support Python packaging tutorials" | ||
| description = "A setuptools example Python package used to support Python packaging tutorials" | ||
| keywords = ["pyOpenSci", "python packaging"] | ||
| readme = "README.md" | ||
| license = "BSD-3-Clause" | ||
| classifiers = [ | ||
| "Programming Language :: Python :: 3", | ||
| "Operating System :: OS Independent", | ||
| "Intended Audience :: Science/Research", | ||
| ] | ||
| dependencies = [ | ||
| "dependency-package-name-1", | ||
| "dependency-package-name-2", | ||
| dependencies = [] | ||
| dynamic = [ | ||
| "version", | ||
| ] | ||
|
|
||
|
|
||
| [build-system] | ||
| requires = [ | ||
| "setuptools>=61", | ||
| "wheel", | ||
| ] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
|
|
||
| [tool.setuptools] | ||
| zip-safe = true | ||
| include-package-data = false | ||
|
Comment on lines
+33
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comments on what these do, or links to docs? |
||
|
|
||
| [tool.setuptools_scm] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this project wants to use |
||
| write_to = "src/examplePy/_version.py" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe some comment on how this is used? like e.g. this might be imported in |
||
| version_scheme = "release-branch-semver" | ||
|
|
||
|
|
||
| [project.optional-dependencies] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally like and use |
||
|
|
||
| test = [ | ||
| "pytest", | ||
| "numpy", | ||
| "pandas", | ||
| "ruff", | ||
| ] | ||
|
|
||
| contrib = [ | ||
| "pre-commit>=4.1.0", | ||
| ] | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||
| def celsius_to_fahrenheit(celsius): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| """ | ||||||
| Convert temperature from Celsius to Fahrenheit. | ||||||
|
|
||||||
| Parameters: | ||||||
| celsius (float): Temperature in Celsius. | ||||||
|
|
||||||
| Returns: | ||||||
| float: Temperature in Fahrenheit. | ||||||
| """ | ||||||
| fahrenheit = (celsius * 9 / 5) + 32 | ||||||
| return fahrenheit | ||||||
|
|
||||||
|
|
||||||
| def fahrenheit_to_celsius(fahrenheit): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| """ | ||||||
| Convert temperature from Fahrenheit to Celsius. | ||||||
|
|
||||||
| Parameters: | ||||||
| fahrenheit (float): Temperature in Fahrenheit. | ||||||
|
|
||||||
| Returns: | ||||||
| float: Temperature in Celsius. | ||||||
| """ | ||||||
| celsius = (fahrenheit - 32) * 5 / 9 | ||||||
| return celsius | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hyphen in filename, wouldn't import, looks like a duplicate of
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this for some other example code and the hyphen was intentional. In sphinx we can use Not sure if that is that is what is going on here, as I don't see any documentation references to this file.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, OK. Didn't know that, thanks for the context. I didn't diff them but they look the same? Maybe a leftover from another example or something.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to capture the purpose of examples/ in https://github.com/pyOpenSci/python-package-guide/blob/main/CONTRIBUTING.md#annex, although it looks like I failed to mention anything about diffing... |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||
| from typing import Sequence | ||||
|
|
||||
| import pandas | ||||
|
|
||||
| from examplePy.temperature import fahrenheit_to_celsius | ||||
|
|
||||
|
|
||||
| def calc_annual_mean(df: pandas.DataFrame): | ||||
| """Function to calculate the mean temperature for each year and the final mean""" | ||||
| # TODO: make this a bit more robust so we can write integration test examples?? | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
do we need this todo? |
||||
| # Calculate the mean temperature for each year | ||||
| yearly_means = df.groupby("Year").mean() | ||||
|
|
||||
| # Calculate the final mean temperature across all years | ||||
| final_mean = yearly_means.mean() | ||||
|
|
||||
| # Return a converted value | ||||
| return fahrenheit_to_celsius(yearly_means), fahrenheit_to_celsius(final_mean) | ||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||
| from typing import Sequence | ||||||
|
|
||||||
|
Comment on lines
+1
to
+2
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
appears unused? |
||||||
| import pandas | ||||||
|
|
||||||
| from examplePy.temperature import fahrenheit_to_celsius | ||||||
|
|
||||||
|
|
||||||
| def calc_annual_mean(df: pandas.DataFrame): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| """Function to calculate the mean temperature for each year and the final mean""" | ||||||
| # TODO: make this a bit more robust so we can write integration test examples?? | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
similarly, do we need this todo? |
||||||
| # Calculate the mean temperature for each year | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this is okay for an example project. But I would block this as over-commented for a deployed library. |
||||||
| yearly_means = df.groupby("Year").mean() | ||||||
|
|
||||||
| # Calculate the final mean temperature across all years | ||||||
| final_mean = yearly_means.mean() | ||||||
|
|
||||||
| # Return a converted value | ||||||
| return fahrenheit_to_celsius(yearly_means), fahrenheit_to_celsius(final_mean) | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this section get moved down?