pytomography.io.PET.prd._ndjson#

Module Contents#

Classes#

NDJsonProtocolWriter

Helper class that provides a standard way to create an ABC using

NDJsonProtocolReader

JsonConverter

Abstract base class for generic types.

BoolConverter

Abstract base class for generic types.

Int8Converter

Abstract base class for generic types.

UInt8Converter

Abstract base class for generic types.

Int16Converter

Abstract base class for generic types.

UInt16Converter

Abstract base class for generic types.

Int32Converter

Abstract base class for generic types.

UInt32Converter

Abstract base class for generic types.

Int64Converter

Abstract base class for generic types.

UInt64Converter

Abstract base class for generic types.

SizeConverter

Abstract base class for generic types.

Float32Converter

Abstract base class for generic types.

Float64Converter

Abstract base class for generic types.

Complex32Converter

Abstract base class for generic types.

Complex64Converter

Abstract base class for generic types.

StringConverter

Abstract base class for generic types.

DateConverter

Abstract base class for generic types.

TimeConverter

Abstract base class for generic types.

DateTimeConverter

Abstract base class for generic types.

EnumConverter

Abstract base class for generic types.

FlagsConverter

Abstract base class for generic types.

OptionalConverter

Abstract base class for generic types.

UnionConverter

Abstract base class for generic types.

VectorConverter

Abstract base class for generic types.

FixedVectorConverter

Abstract base class for generic types.

MapConverter

Abstract base class for generic types.

NDArrayConverterBase

Abstract base class for generic types.

FixedNDArrayConverter

Abstract base class for generic types.

DynamicNDArrayConverter

Abstract base class for generic types.

NDArrayConverter

Abstract base class for generic types.

Attributes#

CURRENT_NDJSON_FORMAT_VERSION

INT8_MIN

INT8_MAX

UINT8_MAX

INT16_MIN

INT16_MAX

UINT16_MAX

INT32_MIN

INT32_MAX

UINT32_MAX

INT64_MIN

INT64_MAX

UINT64_MAX

MISSING_SENTINEL

T

T_NP

bool_converter

int8_converter

uint8_converter

int16_converter

uint16_converter

int32_converter

uint32_converter

int64_converter

uint64_converter

size_converter

float32_converter

float64_converter

complexfloat32_converter

complexfloat64_converter

string_converter

date_converter

time_converter

datetime_converter

TEnum

TFlag

TKey

TKey_NP

TValue

TValue_NP

pytomography.io.PET.prd._ndjson.CURRENT_NDJSON_FORMAT_VERSION: int = 1[source]#
pytomography.io.PET.prd._ndjson.INT8_MIN: int[source]#
pytomography.io.PET.prd._ndjson.INT8_MAX: int[source]#
pytomography.io.PET.prd._ndjson.UINT8_MAX: int[source]#
pytomography.io.PET.prd._ndjson.INT16_MIN: int[source]#
pytomography.io.PET.prd._ndjson.INT16_MAX: int[source]#
pytomography.io.PET.prd._ndjson.UINT16_MAX: int[source]#
pytomography.io.PET.prd._ndjson.INT32_MIN: int[source]#
pytomography.io.PET.prd._ndjson.INT32_MAX: int[source]#
pytomography.io.PET.prd._ndjson.UINT32_MAX: int[source]#
pytomography.io.PET.prd._ndjson.INT64_MIN: int[source]#
pytomography.io.PET.prd._ndjson.INT64_MAX: int[source]#
pytomography.io.PET.prd._ndjson.UINT64_MAX: int[source]#
pytomography.io.PET.prd._ndjson.MISSING_SENTINEL[source]#
class pytomography.io.PET.prd._ndjson.NDJsonProtocolWriter(stream, schema)[source]#

Bases: pytomography.io.PET.prd.yardl_types.ABC

Helper class that provides a standard way to create an ABC using inheritance.

Parameters:
  • stream (pytomography.io.PET.prd.yardl_types.Union[TextIO, str]) –

  • schema (str) –

close()[source]#
Return type:

None

_end_stream()[source]#
Return type:

None

_write_json_line(value)[source]#
Parameters:

value (object) –

Return type:

None

class pytomography.io.PET.prd._ndjson.NDJsonProtocolReader(stream, schema)[source]#
Parameters:
  • stream (pytomography.io.PET.prd.yardl_types.Union[io.BufferedReader, TextIO, str]) –

  • schema (str) –

close()[source]#
Return type:

None

_read_json_line(stepName, required)[source]#
Parameters:
  • stepName (str) –

  • required (bool) –

Return type:

object

pytomography.io.PET.prd._ndjson.T[source]#
pytomography.io.PET.prd._ndjson.T_NP[source]#
class pytomography.io.PET.prd._ndjson.JsonConverter(dtype)[source]#

Bases: pytomography.io.PET.prd.yardl_types.Generic[T, T_NP], pytomography.io.PET.prd.yardl_types.ABC

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:

dtype (numpy.typing.DTypeLike) –

overall_dtype()[source]#
Return type:

pytomography.io.PET.prd.yardl_types.np.dtype[Any]

abstract to_json(value)[source]#
Parameters:

value (T) –

Return type:

object

abstract numpy_to_json(value)[source]#
Parameters:

value (T_NP) –

Return type:

object

abstract from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

T

abstract from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

T_NP

supports_none()[source]#
Return type:

bool

class pytomography.io.PET.prd._ndjson.BoolConverter[source]#

Bases: JsonConverter[bool, pytomography.io.PET.prd.yardl_types.np.bool_]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (bool) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.bool_) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

bool

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.bool_

pytomography.io.PET.prd._ndjson.bool_converter[source]#
class pytomography.io.PET.prd._ndjson.Int8Converter[source]#

Bases: JsonConverter[int, pytomography.io.PET.prd.yardl_types.np.int8]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (int) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.int8) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

int

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.int8

pytomography.io.PET.prd._ndjson.int8_converter[source]#
class pytomography.io.PET.prd._ndjson.UInt8Converter[source]#

Bases: JsonConverter[int, pytomography.io.PET.prd.yardl_types.np.uint8]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (int) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.uint8) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

int

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.uint8

pytomography.io.PET.prd._ndjson.uint8_converter[source]#
class pytomography.io.PET.prd._ndjson.Int16Converter[source]#

Bases: JsonConverter[int, pytomography.io.PET.prd.yardl_types.np.int16]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (int) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.int16) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

int

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.int16

pytomography.io.PET.prd._ndjson.int16_converter[source]#
class pytomography.io.PET.prd._ndjson.UInt16Converter[source]#

Bases: JsonConverter[int, pytomography.io.PET.prd.yardl_types.np.uint16]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (int) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.uint16) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

int

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.uint16

pytomography.io.PET.prd._ndjson.uint16_converter[source]#
class pytomography.io.PET.prd._ndjson.Int32Converter[source]#

Bases: JsonConverter[int, pytomography.io.PET.prd.yardl_types.np.int32]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (int) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.int32) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

int

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.int32

pytomography.io.PET.prd._ndjson.int32_converter[source]#
class pytomography.io.PET.prd._ndjson.UInt32Converter[source]#

Bases: JsonConverter[int, pytomography.io.PET.prd.yardl_types.np.uint32]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (int) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.uint32) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

int

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.uint32

pytomography.io.PET.prd._ndjson.uint32_converter[source]#
class pytomography.io.PET.prd._ndjson.Int64Converter[source]#

Bases: JsonConverter[int, pytomography.io.PET.prd.yardl_types.np.int64]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (int) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.int64) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

int

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.int64

pytomography.io.PET.prd._ndjson.int64_converter[source]#
class pytomography.io.PET.prd._ndjson.UInt64Converter[source]#

Bases: JsonConverter[int, pytomography.io.PET.prd.yardl_types.np.uint64]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (int) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.uint64) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

int

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.uint64

pytomography.io.PET.prd._ndjson.uint64_converter[source]#
class pytomography.io.PET.prd._ndjson.SizeConverter[source]#

Bases: JsonConverter[int, pytomography.io.PET.prd.yardl_types.np.uint64]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (int) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.uint64) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

int

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.uint64

pytomography.io.PET.prd._ndjson.size_converter[source]#
class pytomography.io.PET.prd._ndjson.Float32Converter[source]#

Bases: JsonConverter[float, pytomography.io.PET.prd.yardl_types.np.float32]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (float) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.float32) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

float

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.float32

pytomography.io.PET.prd._ndjson.float32_converter[source]#
class pytomography.io.PET.prd._ndjson.Float64Converter[source]#

Bases: JsonConverter[float, pytomography.io.PET.prd.yardl_types.np.float64]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (float) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.float64) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

float

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.float64

pytomography.io.PET.prd._ndjson.float64_converter[source]#
class pytomography.io.PET.prd._ndjson.Complex32Converter[source]#

Bases: JsonConverter[complex, pytomography.io.PET.prd.yardl_types.np.complex64]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (complex) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.complex64) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

complex

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.complex64

pytomography.io.PET.prd._ndjson.complexfloat32_converter[source]#
class pytomography.io.PET.prd._ndjson.Complex64Converter[source]#

Bases: JsonConverter[complex, pytomography.io.PET.prd.yardl_types.np.complex128]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (complex) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.complex128) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

complex

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.complex128

pytomography.io.PET.prd._ndjson.complexfloat64_converter[source]#
class pytomography.io.PET.prd._ndjson.StringConverter[source]#

Bases: JsonConverter[str, pytomography.io.PET.prd.yardl_types.np.object_]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (str) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.object_) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

str

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.object_

pytomography.io.PET.prd._ndjson.string_converter[source]#
class pytomography.io.PET.prd._ndjson.DateConverter[source]#

Bases: JsonConverter[pytomography.io.PET.prd.yardl_types.datetime.date, pytomography.io.PET.prd.yardl_types.np.datetime64]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.datetime.date) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.datetime64) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.datetime.date

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.datetime64

pytomography.io.PET.prd._ndjson.date_converter[source]#
class pytomography.io.PET.prd._ndjson.TimeConverter[source]#

Bases: JsonConverter[pytomography.io.PET.prd.yardl_types.Time, pytomography.io.PET.prd.yardl_types.np.timedelta64]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.Time) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.timedelta64) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.Time

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.timedelta64

pytomography.io.PET.prd._ndjson.time_converter[source]#
class pytomography.io.PET.prd._ndjson.DateTimeConverter[source]#

Bases: JsonConverter[pytomography.io.PET.prd.yardl_types.DateTime, pytomography.io.PET.prd.yardl_types.np.datetime64]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.DateTime) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.datetime64) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.DateTime

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.datetime64

pytomography.io.PET.prd._ndjson.datetime_converter[source]#
pytomography.io.PET.prd._ndjson.TEnum[source]#
class pytomography.io.PET.prd._ndjson.EnumConverter(enum_type, numpy_type, name_to_value, value_to_name)[source]#

Bases: pytomography.io.PET.prd.yardl_types.Generic[TEnum, T_NP], JsonConverter[TEnum, T_NP]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:
  • enum_type (type[TEnum]) –

  • numpy_type (type) –

  • name_to_value (dict[str, TEnum]) –

  • value_to_name (dict[TEnum, str]) –

to_json(value)[source]#
Parameters:

value (TEnum) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (T_NP) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

TEnum

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

T_NP

pytomography.io.PET.prd._ndjson.TFlag[source]#
class pytomography.io.PET.prd._ndjson.FlagsConverter(enum_type, numpy_type, name_to_value, value_to_name)[source]#

Bases: pytomography.io.PET.prd.yardl_types.Generic[TFlag, T_NP], JsonConverter[TFlag, T_NP]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:
  • enum_type (type[TFlag]) –

  • numpy_type (type) –

  • name_to_value (dict[str, TFlag]) –

  • value_to_name (dict[TFlag, str]) –

to_json(value)[source]#
Parameters:

value (TFlag) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (T_NP) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

TFlag

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

T_NP

class pytomography.io.PET.prd._ndjson.OptionalConverter(element_converter)[source]#

Bases: pytomography.io.PET.prd.yardl_types.Generic[T, T_NP], JsonConverter[Optional[T], pytomography.io.PET.prd.yardl_types.np.void]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:

element_converter (JsonConverter[T, T_NP]) –

to_json(value)[source]#
Parameters:

value (Optional[T]) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.void) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

Optional[T]

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.void

supports_none()[source]#
Return type:

bool

class pytomography.io.PET.prd._ndjson.UnionConverter(union_type, cases, simple)[source]#

Bases: JsonConverter[T, pytomography.io.PET.prd.yardl_types.np.object_]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:
  • union_type (type) –

  • cases (list[Optional[tuple[type, JsonConverter[Any, Any], list[type]]]]) –

  • simple (bool) –

to_json(value)[source]#
Parameters:

value (T) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.object_) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

T

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.object_

supports_none()[source]#
Return type:

bool

class pytomography.io.PET.prd._ndjson.VectorConverter(element_converter)[source]#

Bases: pytomography.io.PET.prd.yardl_types.Generic[T, T_NP], JsonConverter[list[T], pytomography.io.PET.prd.yardl_types.np.object_]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:

element_converter (JsonConverter[T, T_NP]) –

to_json(value)[source]#
Parameters:

value (list[T]) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (object) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

list[T]

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.object_

class pytomography.io.PET.prd._ndjson.FixedVectorConverter(element_converter, length)[source]#

Bases: pytomography.io.PET.prd.yardl_types.Generic[T, T_NP], JsonConverter[list[T], pytomography.io.PET.prd.yardl_types.np.object_]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:
  • element_converter (JsonConverter[T, T_NP]) –

  • length (int) –

to_json(value)[source]#
Parameters:

value (list[T]) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.object_) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

list[T]

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.object_

pytomography.io.PET.prd._ndjson.TKey[source]#
pytomography.io.PET.prd._ndjson.TKey_NP[source]#
pytomography.io.PET.prd._ndjson.TValue[source]#
pytomography.io.PET.prd._ndjson.TValue_NP[source]#
class pytomography.io.PET.prd._ndjson.MapConverter(key_converter, value_converter)[source]#

Bases: pytomography.io.PET.prd.yardl_types.Generic[TKey, TKey_NP, TValue, TValue_NP], JsonConverter[dict[TKey, TValue], pytomography.io.PET.prd.yardl_types.np.object_]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:
to_json(value)[source]#
Parameters:

value (dict[TKey, TValue]) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.object_) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

dict[TKey, TValue]

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.object_

class pytomography.io.PET.prd._ndjson.NDArrayConverterBase(overall_dtype, element_converter, dtype)[source]#

Bases: pytomography.io.PET.prd.yardl_types.Generic[T, T_NP], JsonConverter[numpy.typing.NDArray[Any], pytomography.io.PET.prd.yardl_types.np.object_]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:
  • overall_dtype (numpy.typing.DTypeLike) –

  • element_converter (JsonConverter[T, T_NP]) –

  • dtype (numpy.typing.DTypeLike) –

static _get_dtype_and_subarray_shape(dtype)[source]#
Parameters:

dtype (pytomography.io.PET.prd.yardl_types.np.dtype[Any]) –

Return type:

tuple[pytomography.io.PET.prd.yardl_types.np.dtype[Any], tuple[int, Ellipsis]]

check_dtype(input_dtype)[source]#
Parameters:

input_dtype (numpy.typing.DTypeLike) –

_read(shape, json_object)[source]#
Parameters:
  • shape (tuple[int, Ellipsis]) –

  • json_object (list[object]) –

Return type:

numpy.typing.NDArray[Any]

class pytomography.io.PET.prd._ndjson.FixedNDArrayConverter(element_converter, shape)[source]#

Bases: pytomography.io.PET.prd.yardl_types.Generic[T, T_NP], NDArrayConverterBase[T, T_NP]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:
  • element_converter (JsonConverter[T, T_NP]) –

  • shape (tuple[int, Ellipsis]) –

to_json(value)[source]#
Parameters:

value (numpy.typing.NDArray[Any]) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.object_) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

numpy.typing.NDArray[Any]

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.object_

class pytomography.io.PET.prd._ndjson.DynamicNDArrayConverter(element_serializer)[source]#

Bases: NDArrayConverterBase[T, T_NP]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:

element_serializer (JsonConverter[T, T_NP]) –

to_json(value)[source]#
Parameters:

value (numpy.typing.NDArray[Any]) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.object_) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

numpy.typing.NDArray[Any]

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.object_

class pytomography.io.PET.prd._ndjson.NDArrayConverter(element_converter, ndims)[source]#

Bases: pytomography.io.PET.prd.yardl_types.Generic[T, T_NP], NDArrayConverterBase[T, T_NP]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:
to_json(value)[source]#
Parameters:

value (numpy.typing.NDArray[Any]) –

Return type:

object

numpy_to_json(value)[source]#
Parameters:

value (pytomography.io.PET.prd.yardl_types.np.object_) –

Return type:

object

from_json(json_object)[source]#
Parameters:

json_object (object) –

Return type:

numpy.typing.NDArray[Any]

from_json_to_numpy(json_object)[source]#
Parameters:

json_object (object) –

Return type:

pytomography.io.PET.prd.yardl_types.np.object_