Raw File
Tip revision: 47e788a2d0f5af76a53ca8ee831a0607bae4704f authored by Artem Artemev on 31 March 2020, 13:19:27 UTC
Release 2.0.0 (#1396)
Tip revision: 47e788a
# Copyright 2017-2019 GPflow
# 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
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: skip-file

import os

def is_continuous_integration():
    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):
    return test_n if is_continuous_integration() else n

def ci_range(n: int, test_n: int = 2):
    return range(ci_niter(n, test_n))

def ci_list(lst: list, test_n=2):
    return lst[:test_n] if is_continuous_integration() else lst

def subclasses(cls):
    Generator that returns all (not just direct) subclasses of `cls`
    for subclass in cls.__subclasses__():
        yield from subclasses(subclass)
        yield subclass
back to top