We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
BUG: spurious log warning when saving a plot to png format
### Bug report

**Bug summary**

**Code for reproduction**

```python
import yt

yt.funcs.mylog.setLevel("warning")

ds = yt.load_sample("IsolatedGalaxy")
p = yt.SlicePlot(ds, "z", "density")
p.save("/tmp/test.png")
```


**Actual outcome**

```
yt : [WARNING  ] 2021-10-20 11:50:44,393 Received two valid image formats '.png' (from `filename`) and 'png' (from `suffix`). The former is ignored.
```

**Expected outcome**

No log warning

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `yt/visualization/_commons.py`
Content:
```
1 import os
2 import sys
3 from typing import Optional, Type
4 
5 import matplotlib
6 from packaging.version import Version
7 
8 from yt.utilities.logger import ytLogger as mylog
9 
10 from ._mpl_imports import (
11     FigureCanvasAgg,
12     FigureCanvasBase,
13     FigureCanvasPdf,
14     FigureCanvasPS,
15     FigureCanvasSVG,
16 )
17 
18 MPL_VERSION = Version(matplotlib.__version__)
19 
20 DEFAULT_FONT_PROPERTIES = {
21     "family": "stixgeneral",
22     "size": 18,
23 }
24 
25 if MPL_VERSION >= Version("3.4"):
26     DEFAULT_FONT_PROPERTIES["math_fontfamily"] = "cm"
27 
28 SUPPORTED_FORMATS = frozenset(FigureCanvasBase.get_supported_filetypes().keys())
29 SUPPORTED_CANVAS_CLASSES = frozenset(
30     (FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS, FigureCanvasSVG)
31 )
32 
33 
34 def get_canvas_class(suffix: str) -> Type[FigureCanvasBase]:
35     s = normalize_extension_string(suffix)
36     if s not in SUPPORTED_FORMATS:
37         raise ValueError(f"Unsupported file format '{suffix}'.")
38     for cls in SUPPORTED_CANVAS_CLASSES:
39         if s in cls.get_supported_filetypes():
40             return cls
41     raise RuntimeError(
42         "Something went terribly wrong. "
43         f"File extension '{suffix}' is supposed to be supported "
44         "but no compatible backend was found."
45     )
46 
47 
48 def normalize_extension_string(s: str) -> str:
49     if sys.version_info < (3, 9):
50         if s.startswith("."):
51             return s[1:]
52         return s
53     else:
54         return s.removeprefix(".")
55 
56 
57 def validate_image_name(filename, suffix: Optional[str] = None) -> str:
58     """
59     Build a valid image filename with a specified extension (default to png).
60     The suffix parameter is ignored if the input filename has a valid extension already.
61     Otherwise, suffix is appended to the filename, replacing any existing extension.
62     """
63     name, psuffix = os.path.splitext(filename)
64     if normalize_extension_string(psuffix) in SUPPORTED_FORMATS:
65         if suffix is not None:
66             suffix = normalize_extension_string(suffix)
67         if suffix in SUPPORTED_FORMATS and suffix != psuffix:
68             mylog.warning(
69                 "Received two valid image formats '%s' (from `filename`) "
70                 "and '%s' (from `suffix`). The former is ignored.",
71                 psuffix,
72                 suffix,
73             )
74             return f"{name}.{suffix}"
75         return str(filename)
76 
77     if suffix is None:
78         suffix = ".png"
79 
80     suffix = normalize_extension_string(suffix)
81 
82     if suffix not in SUPPORTED_FORMATS:
83         raise ValueError(f"Unsupported file format '{suffix}'.")
84 
85     return f"{filename}.{suffix}"
86 
87 
88 def get_canvas(figure, filename):
89 
90     name, suffix = os.path.splitext(filename)
91 
92     if not suffix:
93         raise ValueError(
94             f"Can not determine canvas class from filename '{filename}' "
95             f"without an extension."
96         )
97     return get_canvas_class(suffix)(figure)
98
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/yt/visualization/_commons.py b/yt/visualization/_commons.py
--- a/yt/visualization/_commons.py
+++ b/yt/visualization/_commons.py
@@ -61,9 +61,12 @@
     Otherwise, suffix is appended to the filename, replacing any existing extension.
     """
     name, psuffix = os.path.splitext(filename)
-    if normalize_extension_string(psuffix) in SUPPORTED_FORMATS:
-        if suffix is not None:
-            suffix = normalize_extension_string(suffix)
+    psuffix = normalize_extension_string(psuffix)
+
+    if suffix is not None:
+        suffix = normalize_extension_string(suffix)
+
+    if psuffix in SUPPORTED_FORMATS:
         if suffix in SUPPORTED_FORMATS and suffix != psuffix:
             mylog.warning(
                 "Received two valid image formats '%s' (from `filename`) "
@@ -75,9 +78,7 @@
         return str(filename)
 
     if suffix is None:
-        suffix = ".png"
-
-    suffix = normalize_extension_string(suffix)
+        suffix = "png"
 
     if suffix not in SUPPORTED_FORMATS:
         raise ValueError(f"Unsupported file format '{suffix}'.")

{"golden_diff": "diff --git a/yt/visualization/_commons.py b/yt/visualization/_commons.py\n--- a/yt/visualization/_commons.py\n+++ b/yt/visualization/_commons.py\n@@ -61,9 +61,12 @@\n     Otherwise, suffix is appended to the filename, replacing any existing extension.\n     \"\"\"\n     name, psuffix = os.path.splitext(filename)\n-    if normalize_extension_string(psuffix) in SUPPORTED_FORMATS:\n-        if suffix is not None:\n-            suffix = normalize_extension_string(suffix)\n+    psuffix = normalize_extension_string(psuffix)\n+\n+    if suffix is not None:\n+        suffix = normalize_extension_string(suffix)\n+\n+    if psuffix in SUPPORTED_FORMATS:\n         if suffix in SUPPORTED_FORMATS and suffix != psuffix:\n             mylog.warning(\n                 \"Received two valid image formats '%s' (from `filename`) \"\n@@ -75,9 +78,7 @@\n         return str(filename)\n \n     if suffix is None:\n-        suffix = \".png\"\n-\n-    suffix = normalize_extension_string(suffix)\n+        suffix = \"png\"\n \n     if suffix not in SUPPORTED_FORMATS:\n         raise ValueError(f\"Unsupported file format '{suffix}'.\")\n", "issue": "BUG: spurious log warning when saving a plot to png format\n### Bug report\r\n\r\n**Bug summary**\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nimport yt\r\n\r\nyt.funcs.mylog.setLevel(\"warning\")\r\n\r\nds = yt.load_sample(\"IsolatedGalaxy\")\r\np = yt.SlicePlot(ds, \"z\", \"density\")\r\np.save(\"/tmp/test.png\")\r\n```\r\n\r\n\r\n**Actual outcome**\r\n\r\n```\r\nyt : [WARNING  ] 2021-10-20 11:50:44,393 Received two valid image formats '.png' (from `filename`) and 'png' (from `suffix`). The former is ignored.\r\n```\r\n\r\n**Expected outcome**\r\n\r\nNo log warning\n", "before_files": [{"content": "import os\nimport sys\nfrom typing import Optional, Type\n\nimport matplotlib\nfrom packaging.version import Version\n\nfrom yt.utilities.logger import ytLogger as mylog\n\nfrom ._mpl_imports import (\n    FigureCanvasAgg,\n    FigureCanvasBase,\n    FigureCanvasPdf,\n    FigureCanvasPS,\n    FigureCanvasSVG,\n)\n\nMPL_VERSION = Version(matplotlib.__version__)\n\nDEFAULT_FONT_PROPERTIES = {\n    \"family\": \"stixgeneral\",\n    \"size\": 18,\n}\n\nif MPL_VERSION >= Version(\"3.4\"):\n    DEFAULT_FONT_PROPERTIES[\"math_fontfamily\"] = \"cm\"\n\nSUPPORTED_FORMATS = frozenset(FigureCanvasBase.get_supported_filetypes().keys())\nSUPPORTED_CANVAS_CLASSES = frozenset(\n    (FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS, FigureCanvasSVG)\n)\n\n\ndef get_canvas_class(suffix: str) -> Type[FigureCanvasBase]:\n    s = normalize_extension_string(suffix)\n    if s not in SUPPORTED_FORMATS:\n        raise ValueError(f\"Unsupported file format '{suffix}'.\")\n    for cls in SUPPORTED_CANVAS_CLASSES:\n        if s in cls.get_supported_filetypes():\n            return cls\n    raise RuntimeError(\n        \"Something went terribly wrong. \"\n        f\"File extension '{suffix}' is supposed to be supported \"\n        \"but no compatible backend was found.\"\n    )\n\n\ndef normalize_extension_string(s: str) -> str:\n    if sys.version_info < (3, 9):\n        if s.startswith(\".\"):\n            return s[1:]\n        return s\n    else:\n        return s.removeprefix(\".\")\n\n\ndef validate_image_name(filename, suffix: Optional[str] = None) -> str:\n    \"\"\"\n    Build a valid image filename with a specified extension (default to png).\n    The suffix parameter is ignored if the input filename has a valid extension already.\n    Otherwise, suffix is appended to the filename, replacing any existing extension.\n    \"\"\"\n    name, psuffix = os.path.splitext(filename)\n    if normalize_extension_string(psuffix) in SUPPORTED_FORMATS:\n        if suffix is not None:\n            suffix = normalize_extension_string(suffix)\n        if suffix in SUPPORTED_FORMATS and suffix != psuffix:\n            mylog.warning(\n                \"Received two valid image formats '%s' (from `filename`) \"\n                \"and '%s' (from `suffix`). The former is ignored.\",\n                psuffix,\n                suffix,\n            )\n            return f\"{name}.{suffix}\"\n        return str(filename)\n\n    if suffix is None:\n        suffix = \".png\"\n\n    suffix = normalize_extension_string(suffix)\n\n    if suffix not in SUPPORTED_FORMATS:\n        raise ValueError(f\"Unsupported file format '{suffix}'.\")\n\n    return f\"{filename}.{suffix}\"\n\n\ndef get_canvas(figure, filename):\n\n    name, suffix = os.path.splitext(filename)\n\n    if not suffix:\n        raise ValueError(\n            f\"Can not determine canvas class from filename '{filename}' \"\n            f\"without an extension.\"\n        )\n    return get_canvas_class(suffix)(figure)\n", "path": "yt/visualization/_commons.py"}], "after_files": [{"content": "import os\nimport sys\nfrom typing import Optional, Type\n\nimport matplotlib\nfrom packaging.version import Version\n\nfrom yt.utilities.logger import ytLogger as mylog\n\nfrom ._mpl_imports import (\n    FigureCanvasAgg,\n    FigureCanvasBase,\n    FigureCanvasPdf,\n    FigureCanvasPS,\n    FigureCanvasSVG,\n)\n\nMPL_VERSION = Version(matplotlib.__version__)\n\nDEFAULT_FONT_PROPERTIES = {\n    \"family\": \"stixgeneral\",\n    \"size\": 18,\n}\n\nif MPL_VERSION >= Version(\"3.4\"):\n    DEFAULT_FONT_PROPERTIES[\"math_fontfamily\"] = \"cm\"\n\nSUPPORTED_FORMATS = frozenset(FigureCanvasBase.get_supported_filetypes().keys())\nSUPPORTED_CANVAS_CLASSES = frozenset(\n    (FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS, FigureCanvasSVG)\n)\n\n\ndef get_canvas_class(suffix: str) -> Type[FigureCanvasBase]:\n    s = normalize_extension_string(suffix)\n    if s not in SUPPORTED_FORMATS:\n        raise ValueError(f\"Unsupported file format '{suffix}'.\")\n    for cls in SUPPORTED_CANVAS_CLASSES:\n        if s in cls.get_supported_filetypes():\n            return cls\n    raise RuntimeError(\n        \"Something went terribly wrong. \"\n        f\"File extension '{suffix}' is supposed to be supported \"\n        \"but no compatible backend was found.\"\n    )\n\n\ndef normalize_extension_string(s: str) -> str:\n    if sys.version_info < (3, 9):\n        if s.startswith(\".\"):\n            return s[1:]\n        return s\n    else:\n        return s.removeprefix(\".\")\n\n\ndef validate_image_name(filename, suffix: Optional[str] = None) -> str:\n    \"\"\"\n    Build a valid image filename with a specified extension (default to png).\n    The suffix parameter is ignored if the input filename has a valid extension already.\n    Otherwise, suffix is appended to the filename, replacing any existing extension.\n    \"\"\"\n    name, psuffix = os.path.splitext(filename)\n    psuffix = normalize_extension_string(psuffix)\n\n    if suffix is not None:\n        suffix = normalize_extension_string(suffix)\n\n    if psuffix in SUPPORTED_FORMATS:\n        if suffix in SUPPORTED_FORMATS and suffix != psuffix:\n            mylog.warning(\n                \"Received two valid image formats '%s' (from `filename`) \"\n                \"and '%s' (from `suffix`). The former is ignored.\",\n                psuffix,\n                suffix,\n            )\n            return f\"{name}.{suffix}\"\n        return str(filename)\n\n    if suffix is None:\n        suffix = \"png\"\n\n    if suffix not in SUPPORTED_FORMATS:\n        raise ValueError(f\"Unsupported file format '{suffix}'.\")\n\n    return f\"{filename}.{suffix}\"\n\n\ndef get_canvas(figure, filename):\n\n    name, suffix = os.path.splitext(filename)\n\n    if not suffix:\n        raise ValueError(\n            f\"Can not determine canvas class from filename '{filename}' \"\n            f\"without an extension.\"\n        )\n    return get_canvas_class(suffix)(figure)\n", "path": "yt/visualization/_commons.py"}]}