diff --git a/ignite/handlers/checkpoint.py b/ignite/handlers/checkpoint.py
index 43c0b992..4f806cd5 100644
--- a/ignite/handlers/checkpoint.py
+++ b/ignite/handlers/checkpoint.py
@@ -1,5 +1,6 @@
 import os
 import tempfile
+import numbers
 
 from collections import namedtuple
 import collections.abc as collections
@@ -177,21 +178,26 @@ class Checkpoint:
 
         if self._score_function is not None:
             priority = self._score_function(engine)
+            if not isinstance(priority, numbers.Number):
+                raise ValueError("Output of score_function should be a number")
         else:
             priority = engine.state.get_event_attrib_value(Events.ITERATION_COMPLETED)
 
         if self._check_lt_n_saved() or self._saved[0].priority < priority:
 
+            priority_str = "{}".format(priority) if isinstance(priority, numbers.Integral) \
+                else "{:.4f}".format(priority)
+
             if self._score_name is not None:
                 if len(suffix) > 0:
                     suffix += "_"
-                suffix = "{}{}={:.4f}".format(suffix, self._score_name, priority)
+                suffix = "{}{}={}".format(suffix, self._score_name, priority_str)
             elif self._score_function is not None:
                 if len(suffix) > 0:
                     suffix += "_"
-                suffix = "{}{:.4f}".format(suffix, priority)
+                suffix = "{}{}".format(suffix, priority_str)
             elif len(suffix) == 0:
-                suffix = "{}".format(priority)
+                suffix = "{}".format(priority_str)
 
             checkpoint = self._setup_checkpoint()
 

Improve filename produced by Checkpoint when score value is Integer
Following the comment: https://github.com/pytorch/ignite/pull/745#issuecomment-580632176

> And BTW, I found some small bugs in current checkpoint handler:
> The latest code added logic: suffix = "{}{:.4f}", which forces the "priority" to be float number.
> There is some mixed use of " " and ' ', which causes the saved filename includes a ' '.
> For example, the saved model filename for epoch 2 will be: 'checkpoint_epoch=2.0000.pth'

cc @Nic-Ma
diff --git a/tests/ignite/handlers/test_checkpoint.py b/tests/ignite/handlers/test_checkpoint.py
index b36d5fc1..208698bc 100644
--- a/tests/ignite/handlers/test_checkpoint.py
+++ b/tests/ignite/handlers/test_checkpoint.py
@@ -47,6 +47,17 @@ def test_checkpoint_wrong_input():
         Checkpoint(to_save, lambda x: x, score_function=lambda e: 123, score_name="acc", global_step_transform=123)
 
 
+def test_checkpoint_score_function_wrong_output():
+    model = DummyModel()
+    to_save = {'model': model}
+
+    checkpointer = Checkpoint(to_save, lambda x: x, score_function=lambda e: {"1": 1}, score_name="acc")
+    trainer = Engine(lambda e, b: None)
+    trainer.state = State(epoch=0, iteration=0)
+    with pytest.raises(ValueError, match=r"Output of score_function should be a number"):
+        checkpointer(trainer)
+
+
 def test_checkpoint_default():
 
     def _test(to_save, obj, name):
@@ -199,6 +210,51 @@ def test_checkpoint_with_score_name_and_function():
     _test(to_save, {'model': model.state_dict(), 'optimizer': optimizer.state_dict()}, 'checkpoint')
 
 
+def test_checkpoint_with_int_score():
+
+    def _test(to_save, obj, name, score_name=None):
+        save_handler = MagicMock()
+        save_handler.remove = MagicMock()
+
+        checkpointer = Checkpoint(to_save, save_handler=save_handler,
+                                  score_name=score_name,
+                                  score_function=lambda e: e.state.epoch)
+
+        if score_name is None:
+            score_name = ""
+        else:
+            score_name += "="
+
+        trainer = Engine(lambda e, b: None)
+        trainer.state = State(epoch=1, iteration=1)
+
+        checkpointer(trainer)
+        assert save_handler.call_count == 1
+
+        save_handler.assert_called_with(obj, "{}_{}1.pth".format(name, score_name))
+
+        trainer.state.epoch = 12
+        trainer.state.iteration = 1234
+
+        checkpointer(trainer)
+        assert save_handler.call_count == 2
+        save_handler.assert_called_with(obj, "{}_{}12.pth".format(name, score_name))
+        assert save_handler.remove.call_count == 1
+        save_handler.remove.assert_called_with("{}_{}1.pth".format(name, score_name))
+        assert checkpointer.last_checkpoint == "{}_{}12.pth".format(name, score_name)
+
+    model = DummyModel()
+    to_save = {'model': model}
+    _test(to_save, model.state_dict(), 'model')
+    _test(to_save, model.state_dict(), 'model', "epoch")
+
+    model = DummyModel()
+    optimizer = torch.optim.SGD(model.parameters(), lr=0.1)
+    to_save = {'model': model, 'optimizer': optimizer}
+    _test(to_save, {'model': model.state_dict(), 'optimizer': optimizer.state_dict()}, 'checkpoint')
+    _test(to_save, {'model': model.state_dict(), 'optimizer': optimizer.state_dict()}, 'checkpoint', "epoch")
+
+
 def test_checkpoint_with_score_function_and_trainer_epoch():
 
     def _test(to_save, obj, name):

pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc pip install torch torchvision -f https://download.pytorch.org/whl/cpu/torch_stable.html -U
3.7
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
exceptiongroup==1.2.2
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
numpy==1.21.6
packaging==24.0
Pillow==9.5.0
pluggy==1.2.0
pytest==7.4.4
-e git+https://github.com/pytorch/ignite.git@08ec3286dc9b8c24f618942f9834b8d16fe8715d#egg=pytorch_ignite
requests==2.31.0
tomli==2.0.1
torch==1.13.1+cpu
torchvision==0.14.1+cpu
typing_extensions==4.7.1
urllib3==2.0.7
zipp==3.15.0

name: ignite
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - charset-normalizer==3.4.1
      - exceptiongroup==1.2.2
      - idna==3.10
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - numpy==1.21.6
      - packaging==24.0
      - pillow==9.5.0
      - pluggy==1.2.0
      - pytest==7.4.4
      - requests==2.31.0
      - tomli==2.0.1
      - torch==1.13.1+cpu
      - torchvision==0.14.1+cpu
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - zipp==3.15.0
prefix: /opt/conda/envs/ignite

tests/ignite/handlers/test_checkpoint.py::test_checkpoint_score_function_wrong_output tests/ignite/handlers/test_checkpoint.py::test_checkpoint_with_int_score
tests/ignite/handlers/test_checkpoint.py::test_checkpoint_wrong_input tests/ignite/handlers/test_checkpoint.py::test_checkpoint_default tests/ignite/handlers/test_checkpoint.py::test_checkpoint_with_global_step_transform tests/ignite/handlers/test_checkpoint.py::test_checkpoint_with_score_function tests/ignite/handlers/test_checkpoint.py::test_checkpoint_with_score_name_and_function tests/ignite/handlers/test_checkpoint.py::test_checkpoint_with_score_function_and_trainer_epoch tests/ignite/handlers/test_checkpoint.py::test_checkpoint_with_score_name_and_function_and_trainer_epoch tests/ignite/handlers/test_checkpoint.py::test_checkpoint_last_checkpoint tests/ignite/handlers/test_checkpoint.py::test_checkpoint_last_checkpoint_on_score tests/ignite/handlers/test_checkpoint.py::test_model_checkpoint_args_validation tests/ignite/handlers/test_checkpoint.py::test_model_checkpoint_simple_recovery tests/ignite/handlers/test_checkpoint.py::test_model_checkpoint_simple_recovery_from_existing_non_empty tests/ignite/handlers/test_checkpoint.py::test_disk_saver_atomic tests/ignite/handlers/test_checkpoint.py::test_last_k tests/ignite/handlers/test_checkpoint.py::test_disabled_n_saved tests/ignite/handlers/test_checkpoint.py::test_best_k tests/ignite/handlers/test_checkpoint.py::test_best_k_with_suffix tests/ignite/handlers/test_checkpoint.py::test_with_engine tests/ignite/handlers/test_checkpoint.py::test_with_state_dict tests/ignite/handlers/test_checkpoint.py::test_valid_state_dict_save tests/ignite/handlers/test_checkpoint.py::test_save_model_optimizer_lr_scheduler_with_state_dict tests/ignite/handlers/test_checkpoint.py::test_checkpoint_load_objects tests/ignite/handlers/test_checkpoint.py::test_disksaver_wrong_input
ignite/handlers/checkpoint.py
ignite/handlers/checkpoint.py