pyhighlights 0.7.2__tar.gz → 0.7.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/PKG-INFO +1 -1
  2. pyhighlights-0.7.3/pyhighlights/__init__.py +1 -0
  3. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/callbacks.py +12 -1
  4. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights.egg-info/PKG-INFO +1 -1
  5. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_callbacks.py +31 -0
  6. pyhighlights-0.7.2/pyhighlights/__init__.py +0 -1
  7. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/LICENSE +0 -0
  8. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/README.md +0 -0
  9. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/__init__.py +0 -0
  10. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/analyzers.py +0 -0
  11. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/benchmarks.py +0 -0
  12. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/data.py +0 -0
  13. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/faithfulness.py +0 -0
  14. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/leakage.py +0 -0
  15. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/loaders.py +0 -0
  16. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/__init__.py +0 -0
  17. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/base.py +0 -0
  18. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/data.py +0 -0
  19. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/__init__.py +0 -0
  20. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/base.py +0 -0
  21. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/dar.py +0 -0
  22. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/data.py +0 -0
  23. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/dr.py +0 -0
  24. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/fr.py +0 -0
  25. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/genspp.py +0 -0
  26. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/grat.py +0 -0
  27. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/implementations.py +0 -0
  28. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/mcd.py +0 -0
  29. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/mgr.py +0 -0
  30. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/models/spp/mrd.py +0 -0
  31. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/preprocessors.py +0 -0
  32. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/components/tasks.py +0 -0
  33. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/__init__.py +0 -0
  34. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/backbones.py +0 -0
  35. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/base.py +0 -0
  36. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/benchmarks.py +0 -0
  37. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/callbacks.py +0 -0
  38. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/dar.py +0 -0
  39. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/datasets.py +0 -0
  40. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/dr.py +0 -0
  41. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/fr.py +0 -0
  42. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/genspp.py +0 -0
  43. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/grat.py +0 -0
  44. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/keys.py +0 -0
  45. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/losses.py +0 -0
  46. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/mcd.py +0 -0
  47. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/metrics.py +0 -0
  48. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/mgr.py +0 -0
  49. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/mrd.py +0 -0
  50. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/optimizers.py +0 -0
  51. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/preprocessors.py +0 -0
  52. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/configurations/tasks.py +0 -0
  53. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/utility/__init__.py +0 -0
  54. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/utility/embeddings.py +0 -0
  55. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/utility/io.py +0 -0
  56. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/utility/losses.py +0 -0
  57. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/utility/manifest.py +0 -0
  58. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/utility/metrics.py +0 -0
  59. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights/utility/statistics.py +0 -0
  60. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights.egg-info/SOURCES.txt +0 -0
  61. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights.egg-info/dependency_links.txt +0 -0
  62. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights.egg-info/requires.txt +0 -0
  63. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights.egg-info/top_level.txt +0 -0
  64. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights_benchmarks/__init__.py +0 -0
  65. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights_benchmarks/genspp2025/__init__.py +0 -0
  66. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights_benchmarks/genspp2025/configurations/__init__.py +0 -0
  67. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights_benchmarks/genspp2025/configurations/common.py +0 -0
  68. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights_benchmarks/genspp2025/configurations/hatexplain.py +0 -0
  69. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights_benchmarks/genspp2025/configurations/keys.py +0 -0
  70. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights_benchmarks/genspp2025/configurations/toy.py +0 -0
  71. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyhighlights_benchmarks/genspp2025/corpora.py +0 -0
  72. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/pyproject.toml +0 -0
  73. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/setup.cfg +0 -0
  74. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_benchmarks.py +0 -0
  75. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_configurations.py +0 -0
  76. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_dar.py +0 -0
  77. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_data.py +0 -0
  78. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_documentation.py +0 -0
  79. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_dr.py +0 -0
  80. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_embeddings.py +0 -0
  81. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_faithfulness.py +0 -0
  82. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_fr.py +0 -0
  83. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_genspp.py +0 -0
  84. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_genspp2025.py +0 -0
  85. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_grat.py +0 -0
  86. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_imports.py +0 -0
  87. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_io.py +0 -0
  88. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_leakage.py +0 -0
  89. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_loaders.py +0 -0
  90. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_losses.py +0 -0
  91. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_manifest.py +0 -0
  92. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_metrics.py +0 -0
  93. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_mrd.py +0 -0
  94. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_optimizers.py +0 -0
  95. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_preprocessors.py +0 -0
  96. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_statistics.py +0 -0
  97. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_tasks.py +0 -0
  98. {pyhighlights-0.7.2 → pyhighlights-0.7.3}/tests/test_transformer_configurations.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhighlights
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Summary: A simple library implementing Select-Then-Predict (SPP) models.
5
5
  Author-email: Federico Ruggeri <federico.ruggeri6@unibo.it>
6
6
  License-Expression: MIT
@@ -0,0 +1 @@
1
+ __version__ = "0.7.3"
@@ -153,7 +153,18 @@ class GeneralizationLossScore(MonitoredScore):
153
153
  # learning curve can be drawn from it afterwards.
154
154
  trainer.callback_metrics[self.name] = th.tensor(score)
155
155
  if trainer.logger is not None:
156
- trainer.logger.log_metrics({self.name: score}, step=trainer.current_epoch)
156
+ # `epoch` goes in the payload and not only in `step`. A
157
+ # `LightningModule` logging with `on_epoch=True` adds that column
158
+ # itself; a callback reaching the logger directly does not, and
159
+ # `CSVLogger` then writes the score on a row whose `epoch` is
160
+ # blank. Anything grouping `metrics.csv` by epoch -- which is what
161
+ # drawing a learning curve is -- drops that row, so the quantity
162
+ # the run was stopped and scored on is the one quantity missing
163
+ # from its own curves.
164
+ trainer.logger.log_metrics(
165
+ {self.name: score, "epoch": trainer.current_epoch},
166
+ step=trainer.current_epoch,
167
+ )
157
168
 
158
169
 
159
170
  class WarmupEarlyStopping(EarlyStopping):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhighlights
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Summary: A simple library implementing Select-Then-Predict (SPP) models.
5
5
  Author-email: Federico Ruggeri <federico.ruggeri6@unibo.it>
6
6
  License-Expression: MIT
@@ -41,6 +41,16 @@ class Recorder(L.LightningModule):
41
41
  self.logged[name] = float(value)
42
42
 
43
43
 
44
+ class Logger:
45
+ """Records what reached `log_metrics`, payload and step."""
46
+
47
+ def __init__(self):
48
+ self.calls = []
49
+
50
+ def log_metrics(self, metrics, step=None):
51
+ self.calls.append((dict(metrics), step))
52
+
53
+
44
54
  class Fake:
45
55
  """Enough of a trainer for a callback that only reads metrics."""
46
56
 
@@ -77,6 +87,27 @@ def test_the_score_charges_only_for_loss_above_its_own_best():
77
87
  )
78
88
 
79
89
 
90
+ def test_the_score_logs_the_epoch_it_belongs_to():
91
+ """Without it the quantity a run was scored on has no learning curve.
92
+
93
+ A `LightningModule` logging with `on_epoch=True` gets an `epoch` column
94
+ for free; a callback reaching the logger directly does not, and `CSVLogger`
95
+ then writes the score on a row whose `epoch` is blank. Grouping
96
+ `metrics.csv` by epoch -- which is what drawing a curve is -- drops exactly
97
+ that row.
98
+ """
99
+ callback = GeneralizationLossScore(coefficient=2.0)
100
+ trainer = Fake({"val_f1": 0.30, "val_loss": 0.40}, epoch=3)
101
+ trainer.logger = Logger()
102
+
103
+ callback.on_validation_end(trainer, Recorder())
104
+
105
+ (payload, step) = trainer.logger.calls[-1]
106
+ assert payload[callback.name] == pytest.approx(0.30)
107
+ assert payload["epoch"] == 3
108
+ assert step == 3
109
+
110
+
80
111
  def test_the_coefficient_spans_the_two_criteria_it_replaces():
81
112
  """0 monitors the metric alone; a large one monitors the loss alone."""
82
113
  metrics = [
@@ -1 +0,0 @@
1
- __version__ = "0.7.2"
File without changes
File without changes
File without changes