Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • f4e6509
  • /
  • gpflow
  • /
  • ci_utils.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:28b964d2f3ff2257d54219f7ba468c3504a320f4
directory badge
swh:1:dir:ede1ea43899a0554304b6f369f67a61937c0525b

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
ci_utils.py
# Copyright 2017-2020 The GPflow Contributors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: skip-file

import os
from typing import Any, Iterable, List, Sequence, Type, TypeVar


def is_continuous_integration() -> bool:
    """
    Determines whether we are running on the Continuous Integration system for
    notebook integration tests. This is used to speed up notebook integration
    tests (built on every pull request commit) by capping all expensive loops
    at a small number, rather than running until convergence. When building the
    docs (indicated by the presence of the `DOCS` environment variable), we
    need to run notebooks to completion, and this function returns `False`.
    Whether we are running on CI is determined by the presence of the `CI`
    environment variable.
    """
    if "DOCS" in os.environ:
        return False

    return "CI" in os.environ


def ci_niter(n: int, test_n: int = 2) -> int:
    return test_n if is_continuous_integration() else n


def ci_range(n: int, test_n: int = 2) -> Sequence[int]:
    return range(ci_niter(n, test_n))


T = TypeVar("T")


def ci_list(lst: List[T], test_n: int = 2) -> List[T]:
    return lst[:test_n] if is_continuous_integration() else lst


def subclasses(cls: Type[Any]) -> Iterable[Type[Any]]:
    """
    Generator that returns all (not just direct) subclasses of `cls`
    """
    for subclass in cls.__subclasses__():
        yield from subclasses(subclass)
        yield subclass

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API