Commit abe32cef authored by AUTOMATIC1111's avatar AUTOMATIC1111 Committed by GitHub

Merge pull request #10285 from akx/ruff-spacing

Indentation + ruff whitespace fixes
parents b4aaa339 49a55b41
...@@ -25,6 +25,7 @@ def crop_image(im, settings): ...@@ -25,6 +25,7 @@ def crop_image(im, settings):
elif is_portrait(settings.crop_width, settings.crop_height): elif is_portrait(settings.crop_width, settings.crop_height):
scale_by = settings.crop_height / im.height scale_by = settings.crop_height / im.height
im = im.resize((int(im.width * scale_by), int(im.height * scale_by))) im = im.resize((int(im.width * scale_by), int(im.height * scale_by)))
im_debug = im.copy() im_debug = im.copy()
...@@ -260,10 +261,11 @@ def image_entropy(im): ...@@ -260,10 +261,11 @@ def image_entropy(im):
hist = hist[hist > 0] hist = hist[hist > 0]
return -np.log2(hist / hist.sum()).sum() return -np.log2(hist / hist.sum()).sum()
def centroid(pois): def centroid(pois):
x = [poi.x for poi in pois] x = [poi.x for poi in pois]
y = [poi.y for poi in pois] y = [poi.y for poi in pois]
return PointOfInterest(sum(x)/len(pois), sum(y)/len(pois)) return PointOfInterest(sum(x) / len(pois), sum(y) / len(pois))
def poi_average(pois, settings): def poi_average(pois, settings):
...@@ -320,10 +322,10 @@ class PointOfInterest: ...@@ -320,10 +322,10 @@ class PointOfInterest:
def bounding(self, size): def bounding(self, size):
return [ return [
self.x - size//2, self.x - size // 2,
self.y - size//2, self.y - size // 2,
self.x + size//2, self.x + size // 2,
self.y + size//2 self.y + size // 2
] ]
......
...@@ -1841,15 +1841,15 @@ def versions_html(): ...@@ -1841,15 +1841,15 @@ def versions_html():
return f""" return f"""
version: <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/{commit}">{tag}</a> version: <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/{commit}">{tag}</a>
 •   •
python: <span title="{sys.version}">{python_version}</span> python: <span title="{sys.version}">{python_version}</span>
 •   •
torch: {getattr(torch, '__long_version__',torch.__version__)} torch: {getattr(torch, '__long_version__',torch.__version__)}
 •   •
xformers: {xformers_version} xformers: {xformers_version}
 •   •
gradio: {gr.__version__} gradio: {gr.__version__}
 •   •
checkpoint: <a id="sd_checkpoint_hash">N/A</a> checkpoint: <a id="sd_checkpoint_hash">N/A</a>
""" """
......
...@@ -6,6 +6,7 @@ extend-select = [ ...@@ -6,6 +6,7 @@ extend-select = [
"B", "B",
"C", "C",
"I", "I",
"W",
] ]
exclude = [ exclude = [
...@@ -20,7 +21,7 @@ ignore = [ ...@@ -20,7 +21,7 @@ ignore = [
"I001", # Import block is un-sorted or un-formatted "I001", # Import block is un-sorted or un-formatted
"C901", # Function is too complex "C901", # Function is too complex
"C408", # Rewrite as a literal "C408", # Rewrite as a literal
"W605", # invalid escape sequence, messes with some docstrings
] ]
[tool.ruff.per-file-ignores] [tool.ruff.per-file-ignores]
......
import unittest import unittest
import requests import requests
class UtilsTests(unittest.TestCase): class UtilsTests(unittest.TestCase):
def setUp(self): def setUp(self):
self.url_options = "http://localhost:7860/sdapi/v1/options" self.url_options = "http://localhost:7860/sdapi/v1/options"
...@@ -23,7 +24,7 @@ class UtilsTests(unittest.TestCase): ...@@ -23,7 +24,7 @@ class UtilsTests(unittest.TestCase):
pre_value = response.json()["send_seed"] pre_value = response.json()["send_seed"]
self.assertEqual(requests.post(self.url_options, json={"send_seed":not pre_value}).status_code, 200) self.assertEqual(requests.post(self.url_options, json={"send_seed": not pre_value}).status_code, 200)
response = requests.get(self.url_options) response = requests.get(self.url_options)
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
...@@ -58,5 +59,6 @@ class UtilsTests(unittest.TestCase): ...@@ -58,5 +59,6 @@ class UtilsTests(unittest.TestCase):
def test_embeddings(self): def test_embeddings(self):
self.assertEqual(requests.get(self.url_embeddings).status_code, 200) self.assertEqual(requests.get(self.url_embeddings).status_code, 200)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment