Exemplo n.º 1
0
# See "LICENSE" for further details.
'''
Low-level **mapping merger** (i.e., :class:`set`-style union and intersection
operations on dictionary-like types or instances) functionality.
'''

# ....................{ IMPORTS                           }....................
from betse.util.type.enums import make_enum
from betse.util.type.types import type_check, MappingType, IterableTypes
from copy import deepcopy

# ....................{ ENUMERATIONS                      }....................
MergeCollisionPolicy = make_enum(
    class_name='MergeCollisionPolicy',
    member_names=(
        'RAISE_EXCEPTION',
        'PREFER_FIRST',
        'PREFER_LAST',
    ),
)
'''
Enumeration of all supported types of **key collision merger policies** (i.e.,
strategies for merging keys shared between two or more mappings).

Key collisions occur when two or more mappings to be merged contain key-value
pairs containing the same keys but differing values -- or, equivalently, when a
key of a key-value pair of one mapping is also a key of a key-value pair of
another mapping such that the two values of these two pairs differ.

Attributes
----------
RAISE_EXCEPTION : enum
Exemplo n.º 2
0
**Simulation configuration enumerations** (i.e., :class:`enum.Enum` subclasses
required to validate typed data in simulation configuration files).
'''

# ....................{ IMPORTS                           }....................
from betse.util.type import enums

# ....................{ ENUMS ~ cell                      }....................
CellLatticeType = enums.make_enum(class_name='CellLatticeType',
                                  member_names=(
                                      'HEX',
                                      'SQUARE',
                                  ),
                                  doc='''
Enumeration of all supported types of **base cell lattices** (i.e., uniform
grid to which cells are situated *before* random lattice disorder is applied).

Attributes
----------
HEX : enum
    Hexagonal base cell lattice, situating cells along a hexagonal grid.
SQUARE : enum
    Rectilinear base cell lattice, situating cells along a square grid.
''')

# ....................{ ENUMS ~ cells                     }....................
CellsPickerType = enums.make_enum(class_name='CellsPickerType',
                                  member_names=(
                                      'ALL',
                                      'COLOR',
                                      'IMAGE',
                                      'INDICES',
Exemplo n.º 3
0
from betse.util.type.types import (
    type_check,
    CallableTypes,
    GeneratorType,
    IterableOrNoneTypes,
    NumericSimpleTypes,
    SequenceTypes,
)
from distutils import dir_util
from os import path as os_path

# ....................{ ENUMERATIONS                      }....................
DirOverwritePolicy = make_enum(
    class_name='DirOverwritePolicy',
    member_names=(
        'HALT_WITH_EXCEPTION',
        'SKIP_WITH_WARNING',
        'OVERWRITE',
    ),
)
'''
Enumeration of all supported types of **directory overwrite policies** (i.e.,
strategies for handling existing paths visited by recursive directory
operations).

Attributes
----------
HALT_WITH_EXCEPTION : enum
    Policy raising a fatal exception if any target path already exists. This
    constitutes the strictest and thus safest such policy.
SKIP_WITH_WARNING : enum
    Policy ignoring (i.e., skipping) each existing target path with a non-fatal
Exemplo n.º 4
0
# ....................{ IMPORTS                           }....................
from betse.util.app.meta import appmetaone
from betse.cli.repl import replenv
from betse.lib import libs
from betse.util.io.log import logs
from betse.util.path import files
from betse.util.os.command import cmdexit
from betse.util.type.enums import make_enum
from betse.util.type.types import type_check

# ....................{ ENUMS                             }....................
# One-liners are happy liners.
ReplType = make_enum(
    class_name='ReplType',
    member_names=(
        'first_available',
        'ptpython',
        'code',
    ),
)
'''
Enumeration of all possible REPLs currently supported by this submodule.
'''


# ....................{ FUNCTIONS                         }....................
@type_check
def start_repl(repl_type: ReplType = ReplType.first_available) -> None:
    '''
    Start a REPL of the passed type.

    Parameters
Exemplo n.º 5
0
from betse.util.type.enums import make_enum

# ....................{ ENUMS                             }....................
SimExportType = make_enum(
    class_name='SimExportType',
    member_names=(
        'ANIM',
        'CSV',
        'PLOT',
    ),
    doc='''
    Enumeration of all supported types of **post-simulation exports** (e.g.,
    plots, animations, comma-separated value (CSV) files).

    Attributes
    ----------
    ANIM : enum
        Post-simulation animations, visualizing the cell cluster across one or
        more sampled time steps of an initialization or simulation phase as the
        same number of frames of an animated video.
    CSV : enum
        Post-simulation comma-separated value (CSV) files, aggregating raw data
        for the cell cluster across one or more sampled time steps of an
        initialization or simulation phase.
    PLOT : enum
        Post-simulation plots, visualizing the cell cluster across one or more
        sampled time steps of an initialization or simulation phase as a single
        non-animated image.
    ''',
)
Exemplo n.º 6
0
# ....................{ ENUMS                             }....................
IonType = enums.make_enum(
    class_name='IonType',
    member_names=('Na', 'K', 'Ca', 'Cl', 'M', 'P',),
    is_ordered=True,
    doc='''
Ordered enumeration of all supported types of **ions** (i.e., atoms or
molecules having lost or gained electrons and hence net electric charge).

For brevity, the names of these types are intentionally condensed to their
standard abbreviations rather than elongated to their human-readable nouns
(e.g., ``Na`` rather than ``SODIUM``). Doing so also improves interoperability
with the remainder of the codebase, which first invented this nomenclature.

Attributes
----------
Na : enum
    Sodium cation Na+.
K : enum
    Potassium cation K+.
Ca : enum
    Calcium cation Ca2+.
Cl : enum
    Chloride anion Cl-.
M : enum
    Unidentified anion M-, synthetically manufactured to enforce
    charge-balancing across the environmental matrix for both simulation
    stability and correctness.
P : enum
    Anionic protein P-.
''')
Exemplo n.º 7
0
#!/usr/bin/env python3
# --------------------( LICENSE                            )--------------------
# Copyright 2014-2019 by Alexis Pietak & Cecil Curry.
# See "LICENSE" for further details.
'''
**Enumeration types** (i.e., :class:`enum.Enum` subclasses) required to express
typed data in simulation configuration files.
'''

# ....................{ IMPORTS                            }....................
from betse.util.type.enums import make_enum

# ....................{ ENUMS ~ cell                       }....................
CellLatticeType = make_enum(class_name='CellLatticeType',
                            member_names=(
                                'HEX',
                                'SQUARE',
                            ))
'''
Enumeration of all supported types of **base cell lattices** (i.e., uniform grid
to which cells are situated *before* random lattice disorder is applied).

Attributes
----------
HEX : enum
    Hexagonal base cell lattice, situating cells along a hexagonal grid.
SQUARE : enum
    Rectilinear base cell lattice, situating cells along a square grid.
'''

# ....................{ ENUMS ~ cells                      }....................