Data Processor Module

class chipfiring.CFDataProcessor.CFDataProcessor[source]

Bases: object

A class to handle data input and output for chip-firing objects in various formats like .txt, .json, and .tex.

__init__()[source]

Initialize the CFDataProcessor.

read_json(file_path: str, object_type: str)[source]

Reads a CF object from a .json file.

Parameters:
  • file_path (str) – The path to the .json file.

  • object_type (str) – The type of CF object to read (‘graph’, ‘divisor’, ‘orientation’, ‘firingscript’).

Returns:

A CF object (e.g., CFGraph, CFDivisor) or None if reading fails.

to_json(cf_object, file_path: str)[source]

Writes a CF object to a .json file.

Parameters:
  • cf_object – The CF object to serialize (e.g., CFGraph, CFDivisor).

  • file_path (str) – The path to save the .json file.

read_txt(file_path: str, object_type: str)[source]

Reads a CF object from a .txt file.

Parameters:
  • file_path (str) – The path to the .txt file.

  • object_type (str) – The type of CF object to read.

Returns:

A CF object or None if reading fails.

to_txt(cf_object, file_path: str)[source]

Writes a CF object to a .txt file.

Parameters:
  • cf_object – The CF object to serialize.

  • file_path (str) – The path to save the .txt file.

to_tex(cf_object, file_path: str)[source]

Writes a CF object to a .tex file using basic TikZ representation.

Parameters:
  • cf_object – The CF object to serialize (CFGraph or CFDivisor).

  • file_path (str) – The path to save the .tex file.