solrat.engine.generators.merge_frame module

solrat.engine.generators.merge_frame.merge(df1, df2, on=None)[source]

Merge helper function with overwritten default behavior.

class solrat.engine.generators.merge_frame.SumLimits[source]

Bases: object

Sum limits base class.

The inheriting classes control the limits for the summation indexes such as \(L, J, K, Q,\) etc. We start from the ‘base_frame’ which has some indexes and quantities already pre-merged, like \(L_l, L_u, S\), Einstein coefficients. Then we can determine the boundaries of the summation indexes that follow.

Triangular means from \(|a-b|\) to \(a + b\) (both ends included)

FromTo means from \(a\) to \(b\) (both ends included)

Intersection means including only shared values of 2 or more sets of values.

For further information inspect each Looper individually.

classmethod get_indexes()[source]
class solrat.engine.generators.merge_frame.FrameFactor(name: str, factor: Callable | None = None, dependencies: List[str] | None = None, merged: bool = False, elementwise: bool = False)[source]

Bases: object

Single multiplicand in the frame

copy()[source]
class solrat.engine.generators.merge_frame.Frame(base_frame: DataFrame | None = None, **kwargs: Looper)[source]

Bases: Generic[SumLimitsT]

Frame engine for performing multiplication and summation.

Loopers are merged immediately to the base frame. Factors are stored and evaluated+merged when needed.

static from_sum_limits(base_frame: DataFrame, sum_limits: SumLimitsT) Frame[source]
copy()[source]
construct_sub_frame(columns: List[str]) DataFrame[source]

This is used to reduce the evaluations of loopers/factors to minimum: we get all unique dependencies, evaluate on them, then merge back to the frame.

register_multiplication(*args: Callable, elementwise: bool = False, **kwargs)[source]

This just registers the factors. They will be evaluated/merged later on demand.

get_dependent_factors(column: str) List[str][source]
merge_factor(factor_name: str)[source]

Construct factor frame, evaluate, and merge it to the main frame

combine_all_merged_factors() str[source]

Multiply all merged factors so that the frame has a single combined merged factor.

remove_dependency(column: str)[source]
get_other_frame_columns(exclude: str) List[str][source]

Get looper columns other than the specified one

reduce_single_index(column: str | Looper)[source]

Reduction is Looper-wise (this way it clearly follows the logic of ‘summation’ operation)

reduce(*args: Looper | str) ndarray | float | complex | Self[source]

usage: frame.reduce() to reduce all, frame.reduce(col1, col2, …, col5, col6) to specify first and last columns to reduce

to_coefficient() Self[source]

Merge all registered factors into a single ‘coefficient’ column without reducing any loop columns. Use this when you want the coefficient but still need all loop columns for index lookup.

reduce_partially(*args: Looper | str) Self[source]

Reduce the given loop columns (groupby-sum) then merge all factors to ‘coefficient’.

debug_reduce_legacy()[source]