Skip to content

Commit

Permalink
Auto-format more files
Browse files Browse the repository at this point in the history
  • Loading branch information
theodore-s-beers committed Dec 9, 2024
1 parent 8177acf commit 4ecc1e7
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
Setup file for PyKubeGrader.
Use setup.cfg to configure your project.
Setup file for PyKubeGrader.
Use setup.cfg to configure your project.
This file was generated with PyScaffold 4.6.
PyScaffold helps you to put up the scaffold of your new Python project.
Learn more under: https://pyscaffold.org/
This file was generated with PyScaffold 4.6.
PyScaffold helps you to put up the scaffold of your new Python project.
Learn more under: https://pyscaffold.org/
"""

from setuptools import setup
Expand Down
2 changes: 1 addition & 1 deletion src/pykubegrader/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
ipython.events.register("pre_run_cell", telemetry)
print("Telemetry registered with pre_run_cell event.")
else:
print("Not in a Jupyter environment or telemetry unavailable.")
print("Not in a Jupyter environment or telemetry unavailable.")
1 change: 1 addition & 0 deletions src/pykubegrader/mc_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .misc import list_of_lists
from .select_base import SelectQuestion


def MCQ(
descriptions: list[str],
options: list[str] | list[list[str]],
Expand Down
2 changes: 1 addition & 1 deletion src/pykubegrader/seed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from . import hash_seed

__all__ = ['hash_seed']
__all__ = ["hash_seed"]
17 changes: 9 additions & 8 deletions src/pykubegrader/seed/hash_seed.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import hashlib


def hash_to_seed(input_string):
"""
Hash a string into a small integer seed less than 500.
Parameters:
input_string (str): The string to hash.
Returns:
int: A seed value (0 <= seed < 500).
"""
# Ensure the input is a string
input_string = str(input_string)

# Create a SHA-256 hash of the string
hash_object = hashlib.sha256(input_string.encode())

# Convert the hash to an integer
large_number = int.from_bytes(hash_object.digest(), 'big')
large_number = int.from_bytes(hash_object.digest(), "big")

# Reduce the number to a value less than 500
small_seed = large_number % 500
return small_seed

return small_seed
5 changes: 4 additions & 1 deletion src/pykubegrader/select_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ def __init__(

self.layout = pn.Column(
f"# Question {self.question_number}: {title}",
*(pn.Column(desc_widget, pn.Row(dropdown)) for desc_widget, dropdown in widget_pairs),
*(
pn.Column(desc_widget, pn.Row(dropdown))
for desc_widget, dropdown in widget_pairs
),
self.submit_button,
)

Expand Down
12 changes: 6 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
Dummy conftest.py for pykubegrader.
Dummy conftest.py for pykubegrader.
If you don't know what this is for, just leave it empty.
Read more about conftest.py under:
- https://docs.pytest.org/en/stable/fixture.html
- https://docs.pytest.org/en/stable/writing_plugins.html
If you don't know what this is for, just leave it empty.
Read more about conftest.py under:
- https://docs.pytest.org/en/stable/fixture.html
- https://docs.pytest.org/en/stable/writing_plugins.html
"""

import pytest
import pytest # noqa: F401

0 comments on commit 4ecc1e7

Please sign in to comment.