How to use the barril.units.UnitDatabase.PushSingleton function in barril

To help you get started, we’ve selected a few barril examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ESSS / barril / src / barril / curve / _tests / test_curve.py View on Github external
unit_database.AddUnit("length", "centimeters", "cm", "%f * 100.0", "%f / 100.0")
    unit_database.AddUnit("length", "kilometers", "km", "%f / 1000.0", "%f * 1000.0")

    unit_database.AddUnitBase("time", "seconds", "s")
    unit_database.AddUnit("time", "minutes", "min", "%f * 60.0", " %f * 60.0")
    unit_database.AddUnit("time", "hours", "h", "%f * 3600.0", " %f * 3600.0")
    unit_database.AddUnit("time", "days", "d", "%f * 86400.0", " %f * 86400.0")

    unit_database.AddCategory(
        category="length", quantity_type="length", valid_units=["cm", "m", "km"]
    )
    unit_database.AddCategory(
        category="time", quantity_type="time", valid_units=["s", "min", "h", "d"]
    )

    UnitDatabase.PushSingleton(unit_database)
    yield unit_database

    UnitDatabase.PopSingleton()
github ESSS / barril / src / barril / fixtures.py View on Github external
def unit_database_len():
    database = units.UnitDatabase()
    units.UnitDatabase.PushSingleton(database)
    database.AddUnitBase("length", "meters", "m")
    database.AddUnit("length", "kilometers", "km", "%f / 1000.0", "%f * 1000.0")
    database.AddUnitBase("temperature", "degC", "degC")
    database.AddUnitBase("flow rate", "m3/s", "m3/s")
    database.AddCategory("length", "length")
    database.AddCategory("temperature", "temperature")
    database.AddCategory("flow rate", "flow rate", min_value=0.0)

    yield database

    units.UnitDatabase.PopSingleton()
github ESSS / barril / src / barril / fixtures.py View on Github external
def unit_database_len_time():
    database = CreateUnitDatabaseLenTime()
    units.UnitDatabase.PushSingleton(database)

    yield database

    units.UnitDatabase.PopSingleton()
github ESSS / barril / src / barril / fixtures.py View on Github external
def unit_database_posc():
    """
    Fixture to be used whenever a test needs a clean UnitDatabase. When using this fixture, it's
    safe to call UnitDatabase.GetSingleton().
    """
    unit_database = units.UnitDatabase()
    unit_database.FillUnitDatabaseWithPosc(unit_database)
    units.UnitDatabase.PushSingleton(unit_database)

    yield unit_database

    units.UnitDatabase.PopSingleton()
github ESSS / barril / src / barril / fixtures.py View on Github external
def unit_database_len_temp():
    database = CreateUnitDatabaseLenTemp()
    units.UnitDatabase.PushSingleton(database)

    yield database

    units.UnitDatabase.PopSingleton()
github ESSS / barril / src / barril / fixtures.py View on Github external
def unit_database_well_length():
    database = CreateUnitDatabaseWellLength()
    units.UnitDatabase.PushSingleton(database)

    yield database

    units.UnitDatabase.PopSingleton()
github ESSS / barril / src / barril / fixtures.py View on Github external
def unit_database_posc_len():
    database = CreateUnitDatabasePoscLen(fill_categories=True)
    units.UnitDatabase.PushSingleton(database)

    yield database

    units.UnitDatabase.PopSingleton()
github ESSS / barril / src / barril / fixtures.py View on Github external
def unit_database_custom_conversion():
    database = CreateUnitDatabaseCustomConversion()
    units.UnitDatabase.PushSingleton(database)

    yield database

    units.UnitDatabase.PopSingleton()
github ESSS / barril / src / barril / fixtures.py View on Github external
def unit_database_empty():
    database = units.UnitDatabase()
    units.UnitDatabase.PushSingleton(database)

    yield database

    units.UnitDatabase.PopSingleton()