src.pydasa.dimensional.vaschy#

Module for Schema to manage Fundamental Dimensional Units (FDUs) for Dimensional Analysis in PyDASA.

This module provides the Schema class which manages dimensional frameworks, FDU precedence, and regex patterns for dimensional expression validation.

Classes:

Schema: Manages dimensional frameworks and FDUs, providing methods for validation,

IMPORTANT: Based on the theory from:

# H.Gorter, Dimensionalanalyse: Eine Theoririe der physikalischen Dimensionen mit Anwendungen

Classes#

Schema

Schema Manages dimensional frameworks and FDUs for PyDASA.

Module Contents#

class src.pydasa.dimensional.vaschy.Schema#

Bases: pydasa.core.basic.Foundation

Schema Manages dimensional frameworks and FDUs for PyDASA.

Maintains a collection of Dimensions with their precedence, provides regex patterns for dimensional expressions, and manages the dimensional framework context.

Parameters:

Foundation – Foundation class for validation of symbols and frameworks.

_fdu_lt#

List of Fundamental Dimensional Units in precedence order.

Type:

List[Dimension]

_fdu_map#

Dictionary mapping FDU symbols to Dimension objects.

Type:

Dict[str, Dimension]

_fdu_regex#

Regex pattern for matching dimensional expressions (e.g., ‘M/L*T^-2’ to ‘M^1*L^-1*T^-2’).

Type:

str

_fdu_pow_regex#

Regex pattern for matching dimensions with exponents. (e.g., ‘M*L^-1*T^-2’ to ‘M^(1)*L^(-1)*T^(-2)’).

Type:

str

_fdu_no_pow_regex#

Regex pattern for matching dimensions without exponents. (e.g., ‘M*L*T’ to ‘M^(1)*L^(1)*T^(1)’).

Type:

str

_fdu_sym_regex#

Regex pattern for matching FDUs in symbolic expressions. (e.g., ‘M^(1)*L^(-1)*T^(-2)’ to ‘L**(-1)*M**(1)*T**(-2)’).

Type:

str

_fdu_lt: List[pydasa.dimensional.fundamental.Dimension] = []#

Internal storage for fundamental dimension objects. Always a List[Dimension] after __post_init__.

_fdu_map: Dict[str, pydasa.dimensional.fundamental.Dimension]#

Dictionary mapping FDU symbols to Dimension objects in PyDASA. procesess (e.g., Mass [M], Length [L], Time [T]).

Purpose:
  • Defines the default dimensional framework used in PyDASA.

  • Used to initialize entities without a specified framework.

  • Basis for dimensional analysis precedence list in PyDASA.

  • Validates parameter and variable dimensions in PyDASA.

  • Default is the Physical FDUs framework.

  • Can be customized for specific applications or domains.

_fdu_symbols: List[str] = []#

List of FDU symbols in the framework for the dimensional matrix (e.g., ‘M*L^-1*T^-2’).

Purpose:
  • Defines the row order in the dimensional matrix.

  • Validates parameter and variable dimensions in PyDASA.

_fdu_regex: str = ''#

Regex pattern for matching dimensional expressions.

Default/Working regex pattern to match FDUs in PyDASA (e.g., ‘M*L^-1*T^-2’ to ‘M^(1)*L^(-1)*T^(-2)’).

_fdu_pow_regex: str = '\\-?\\d+'#

Regex pattern for matching FDUs with exponents (e.g., ‘M*L^-1*T^-2’ to ‘M^(1)*L^(-1)*T^(-2)’)

_fdu_no_pow_regex: str = ''#

Regex pattern for matching dimensions without exponents.

Default/Working regex to match FDUs without exponents (e.g., ‘T*D’ instead of ‘T^2*D^-1’).

_fdu_sym_regex: str = ''#

Regex pattern for matching FDUs in symbolic expressions.

Default/Working regex to match FDU symbols in PyDASA (e.g., ‘T^(1)*D^(-1)’ to ‘D**(-1)*T**(2)’).

_setup_fdus()#

_setup_fdus() Initializes FDUs based on the selected framework.

Creates and adds standard FDUs for the selected framework (PHYSICAL, COMPUTATION, SOFTWARE) or validates custom FDUs.

Raises:
  • ValueError – If framework is not supported.

  • ValueError – If custom framework FDUs are not provided.

  • ValueError – If custom framework FDUs are not properly formatted.

  • ValueError – If custom framework FDUs contain invalid types.

Return type:

None

_convert_fdu_lt()#

_convert_fdu_lt() Converts and validates the provided FDUs list/dict into Dimension objects.

Raises:
  • TypeError – If elements in the list are not all Dimension or dict.

  • TypeError – If values in the dict are not all dict objects.

  • TypeError – If _fdu_lt is not a list or dict.

Return type:

None

_setup_default_framework()#

_setup_default_framework() Returns the default FDU precedence list for the specified framework.

Returns:

Default FDUs precedence list based on the framework map.

Return type:

List[str]

_validate_fdu_precedence()#

_validate_fdu_precedence() Ensures FDUs have valid and unique precedence values.

Raises:

ValueError – If FDU precedence values are duplicated.

Return type:

None

_update_fdu_map()#

_update_fdu_map() Updates the FDU symbol to object mapping.

Return type:

None

_update_fdu_symbols()#

_update_fdu_symbols() Updates the list of FDU symbols in precedence order.

Return type:

None

_setup_regex()#

_setup_regex() Sets up regex patterns for dimensional validation. Generates regex patterns for: - validating dimensional expressions. - parsing exponents. - completing expressions with exponent. - handling symbolic expressions.

Return type:

None

_validate_fdu_lt(value)#

_validate_fdu_lt() Custom validator for fdu_lt property.

Parameters:

value (List[Dimension]) – List of FDUs to validate.

Raises:

ValueError – If list is empty or contains non-Dimension objects.

Return type:

None

property fdu_lt: List[pydasa.dimensional.fundamental.Dimension]#

fdu_lt Get the list of FDUs in precedence order.

Returns:

List of FDUs.

Return type:

List[Dimension]

property fdu_symbols: List[str]#

fdu_symbols Get the list of FDU symbols in precedence order.

Returns:

List of FDU symbols.

Return type:

List[str]

property size: int#

size Get the number of FDUs in the framework.

Returns:

Number of FDUs.

Return type:

int

property fdu_regex: str#

fdu_regex Get the FDU regex pattern.

Returns:

Regex pattern for validating dimensional expressions.

Return type:

str

property fdu_pow_regex: str#

fdu_pow_regex Get the FDU powered regex pattern.

Returns:

Regex pattern for matching dimensions with exponents.

Return type:

str

property fdu_no_pow_regex: str#

fdu_no_pow_regex Get the FDU no-power regex pattern.

Returns:

Regex pattern for matching dimensions without exponents.

Return type:

str

property fdu_sym_regex: str#

fdu_sym_regex Get the FDU symbol regex pattern.

Returns:

Regex pattern for matching FDUs in symbolic expressions.

Return type:

str

get_fdu(symbol)#

get_fdu() Get an FDU by its symbol.

Parameters:

symbol (str) – FDU symbol.

Returns:

FDU object if found, None otherwise.

Return type:

Optional[Dimension]

has_fdu(symbol)#

has_fdu() Check if an FDU with the given symbol exists.

Parameters:

symbol (str) – FDU symbol.

Returns:

True if the FDU exists, False otherwise.

Return type:

bool

add_fdu(fdu)#

add_fdu() Add an FDU to the framework.

Parameters:

fdu (Dimension) – FDU to add.

Raises:
  • ValueError – If an FDU with the same symbol already exists.

  • ValueError – If the FDU framework does not match the current framework.

Return type:

None

remove_fdu(sym)#

remove_fdu() Remove an FDU from the framework.

Parameters:

sym (str) – Symbol of the FDU to remove.

Returns:

removed FDU object.

Return type:

Dimension

reset()#
Return type:

None

to_dict()#

to_dict() Convert framework to dictionary representation.

Returns:

Dictionary representation of the framework.

Return type:

Dict[str, Any]

classmethod from_dict(data)#

from_dict() Create framework from dictionary representation.

Parameters:

data (Dict[str, Any]) – Dictionary representation of the framework.

Returns:

New DimScheme instance.

Return type:

DimScheme