LCOV - code coverage report
Current view: top level - variable - sort.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 6 7 85.7 %
Date: 2024-11-24 01:48:31 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: BSD-3-Clause
       2             : // Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
       3             : /// @file
       4             : /// @author Thibault Chatel
       5             : #include "scipp/core/element/sort.h"
       6             : #include "scipp/variable/sort.h"
       7             : #include "scipp/variable/subspan_view.h"
       8             : #include "scipp/variable/transform.h"
       9             : 
      10             : using namespace scipp::core;
      11             : 
      12             : namespace scipp::variable {
      13             : 
      14           6 : Variable sort(const Variable &var, const Dim dim, const SortOrder order) {
      15           6 :   auto out = copy(var);
      16           6 :   if (order == SortOrder::Ascending)
      17           3 :     transform_in_place(subspan_view(out, dim),
      18             :                        core::element::sort_nondescending, "sort");
      19             :   else
      20           3 :     transform_in_place(subspan_view(out, dim), core::element::sort_nonascending,
      21             :                        "sort");
      22           6 :   return out;
      23           0 : }
      24             : 
      25             : } // namespace scipp::variable

Generated by: LCOV version 1.14