Skip to content

Commit

Permalink
Fix linting and formatting and switch to lsst.utils.tests.TestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
eigerx committed Jan 10, 2025
1 parent 7d6d3a1 commit 283c1cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
3 changes: 2 additions & 1 deletion python/lsst/analysis/tools/tasks/gatherResourceUsage.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ class GatherResourceUsageTask(PipelineTask):
- ``init_time``: the time spent in task construction;
- ``run_time``: the time spent executing the task's runQuantum
method.
- ``wall_time`` : the total elapsed real time time spent executing the task.
- ``wall_time`` : the total elapsed real time time spent executing the
task.
- ``{method}``: the time spent in a particular task or subtask
method decorated with `lsst.utils.timer.timeMethod`.
Expand Down
17 changes: 8 additions & 9 deletions tests/test_gatherResourceUsage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
from __future__ import annotations

import os
from unittest import TestCase, main
from unittest import main

import lsst.utils.tests

from lsst.analysis.tools.tasks import GatherResourceUsageConfig, GatherResourceUsageTask
from lsst.daf.butler import Butler, DatasetType, DeferredDatasetHandle
from lsst.pipe.base import TaskMetadata
from lsst.daf.butler.tests.utils import makeTestTempDir, removeTestTempDir
from lsst.analysis.tools.tasks import GatherResourceUsageConfig, GatherResourceUsageTask
from lsst.pipe.base import TaskMetadata

TESTDIR = os.path.abspath(os.path.dirname(__file__))

Expand All @@ -45,7 +44,7 @@
"""


class TestGatherResourceUsage(TestCase):
class TestGatherResourceUsage(lsst.utils.tests.TestCase):
"""Tests for the gatherResourceUsage class and methods."""

def setUp(self):
Expand All @@ -72,10 +71,10 @@ def test_gatherResourceUsage(self):
universe=self.butler.dimensions, input_metadata=input_metadata
).getDict()["output_table"]
print(type(ru_output["init_time"].values))
self.assertEqual(ru_output["memory"].values[0], 1.23456789e+09)
self.assertEqual(ru_output["init_time"].values[0], 2.0)
self.assertEqual(ru_output["run_time"].values[0], 25.0)
self.assertAlmostEqual(ru_output["wall_time"].values[0], 45.0)
self.assertFloatsAlmostEqual(ru_output["memory"].values[0], 1.23456789e09, atol=1e-3, rtol=1e-4)
self.assertFloatsAlmostEqual(ru_output["init_time"].values[0], 2.0, atol=1e-3, rtol=1e-4)
self.assertFloatsAlmostEqual(ru_output["run_time"].values[0], 25.0, atol=1e-3, rtol=1e-4)
self.assertFloatsAlmostEqual(ru_output["wall_time"].values[0], 45.0, atol=1e-3, rtol=1e-4)


if __name__ == "__main__":
Expand Down

0 comments on commit 283c1cf

Please sign in to comment.