diff --git a/validphys2/src/validphys/commondatawriter.py b/validphys2/src/validphys/commondatawriter.py deleted file mode 100644 index 650df84cb..000000000 --- a/validphys2/src/validphys/commondatawriter.py +++ /dev/null @@ -1,84 +0,0 @@ -""" -This module contains functions to write commondata and systypes -tables to files -""" - - -def write_commondata_data(commondata, buffer): - """ - write commondata table to buffer, this can be a memory map, - compressed archive or strings (using for instance StringIO) - - - Parameters - ---------- - - commondata : validphys.coredata.CommonData - - buffer : memory map, compressed archive or strings - example: StringIO object - - - Example - ------- - >>> from validphys.loader import Loader - >>> from io import StringIO - - >>> l = Loader() - >>> cd = l.check_commondata("NMC").load_commondata_instance() - >>> sio = StringIO() - >>> write_commondata_data(cd,sio) - >>> print(sio.getvalue()) - - """ - header = f"{commondata.setname} {commondata.nsys} {commondata.ndata}\n" - buffer.write(header) - commondata.commondata_table.to_csv(buffer, sep="\t", header=None) - - -def write_commondata_to_file(commondata, path): - """ - write commondata table to file - """ - with open(path, "w") as file: - write_commondata_data(commondata, file) - - -def write_systype_data(commondata, buffer): - """ - write systype table to buffer, this can be a memory map, - compressed archive or strings (using for instance StringIO) - - - Parameters - ---------- - - commondata : validphys.coredata.CommonData - - buffer : memory map, compressed archive or strings - example: StringIO object - - - Example - ------- - >>> from validphys.loader import Loader - >>> from io import StringIO - - >>> l = Loader() - >>> cd = l.check_commondata("NMC").load_commondata_instance() - >>> sio = StringIO() - >>> write_systype_data(cd,sio) - >>> print(sio.getvalue()) - - """ - header = f"{commondata.nsys}\n" - buffer.write(header) - commondata.systype_table.to_csv(buffer, sep="\t", header=None) - - -def write_systype_to_file(commondata, path): - """ - write systype table to file - """ - with open(path, "w") as file: - write_systype_data(commondata, file) diff --git a/validphys2/src/validphys/coredata.py b/validphys2/src/validphys/coredata.py index 2f95bc3af..edd6023e8 100644 --- a/validphys2/src/validphys/coredata.py +++ b/validphys2/src/validphys/coredata.py @@ -7,8 +7,6 @@ import dataclasses from typing import Dict -from validphys.commondatawriter import write_commondata_to_file, write_systype_to_file - import numpy as np import pandas as pd @@ -223,6 +221,7 @@ def with_cuts(self, cuts): self, ndata=newndata, commondata_table=new_commondata_table ) + @property def central_values(self): return self.commondata_table["data"] @@ -303,18 +302,3 @@ def with_central_value(self, cv): tb = self.commondata_table.copy() tb["data"] = cv return dataclasses.replace(self, commondata_table=tb) - - def export(self, path): - """Export the data, and error types - Use the same format as libNNPDF: - - - A DATA_.dat file with the dataframe of accepted points - - A systypes/STYPES_.dat file with the error types - """ - - dat_path = path / f"DATA_{self.setname}.dat" - sys_path = path / "systypes" / f"SYSTYPE_{self.setname}_DEFAULT.dat" - sys_path.parent.mkdir(exist_ok=True) - - write_systype_to_file(self, sys_path) - write_commondata_to_file(self, dat_path) \ No newline at end of file