CrossMapping

class PlasmaCalcs.quantities.collisions.cross_section_tools.CrossMapping(mapping={}, *, smart=True)

Bases: SymmetricPairMapping

SymmetricPairMapping where values are CrossTable objects.

smart: True, False, ‘files’, or ‘defaults’

if smart, values can also be strings.
‘files’ –> strings are interepreted as filenames.
‘defaults’ –> strings are interpreted as one of the keys for CrossTable.from_defaults.
True –> use ‘files’ mode if the file exists, else ‘defaults’ mode, for strings.
False –> strings are not allowed; all entries must be CrossTable objects.
string values are converted into CrossTable objects immediately, during self[key] = value;

Methods

__iter__()

iterate over self.items (not self.keys).

__setitem__(key, value)

set self.mapping[key] = value.

assert_symmetric_mapping(ss)

check that ss is a symmetric mapping; crash with InputError otherwise.

clear()

remove all known items from self.

copy()

return a shallow copy of self.

from_symmetric_dict(ss)

return SymmetricPairMapping from symmetric dict ss,

items()

keys()

pop(key, default)

remove self[key], and return its value.

update(other)

update self with other.

values()

_sanitize_key(key)

return sanitized key (obj1, obj2) such that obj1 <= obj2.

__iter__()

iterate over self.items (not self.keys).

__setitem__(key, value)

set self.mapping[key] = value.

key: tuple of (obj1, obj2). If obj2 < obj1, will use (obj2, obj1) instead.
value: CrossTable object
_sanitize_key(key)

return sanitized key (obj1, obj2) such that obj1 <= obj2.

static assert_symmetric_mapping(ss)

check that ss is a symmetric mapping; crash with InputError otherwise.

I.e., ensure for all keys key12=(obj1, obj2) in ss, key21=(obj2, obj1) is also in ss,
and ss[key12] == ss[key21].
clear()

remove all known items from self.

copy()

return a shallow copy of self.

cross_table_cls

alias of CrossTable

classmethod from_symmetric_dict(ss)

return SymmetricPairMapping from symmetric dict ss,

which contains both ((obj1, obj2): val12) and ((obj2, obj1): val21) for each pair of objs,
with val12 == val21 confirmed here first (crash with InputError if ss not symmetric).
pop(key, default)

remove self[key], and return its value. if key not in self, return default.

update(other)

update self with other.

other: dict of {(obj1, obj2): value}