n3fit.io package

Submodules

n3fit.io.writer module

Module containing functions dedicated to the write down of the output of n3fit

The goal is to generate the same folder/file structure as the old nnfit code so previously active scripts can still work.

class n3fit.io.writer.SuperEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: FrozendictJsonEncoderInternal

Custom json encoder to get around the fact that np.float32 =/= float

default(o)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class n3fit.io.writer.WriterWrapper(replica_numbers, pdf_objects, stopping_object, all_chi2s, theory, timings)[source]

Bases: object

write_data(save_path, fitname, weights_name)[source]

Save all the data of a fit, for all replicas.

Parameters
  • save_path – path for the fit results, ex: ${PWD}/runcard_name/nnfit

  • fitname – name of the fit, ex: Basic_runcard

  • weights_name – name of the file to save weights to, if not empty

n3fit.io.writer.evln2lha(evln, nf=6)[source]
n3fit.io.writer.jsonfit(best_epoch, positivity_status, preprocessing, arc_lengths, integrability_numbers, tr_chi2, vl_chi2, true_chi2, stop_epoch, timing)[source]

Generates a dictionary containing all relevant metadata for the fit

Parameters
  • best_epoch (int) – epoch at which the best fit was found

  • positivity_status (str) – string describing the positivity status of the fit

  • preprocessing (dict) – dictionary of the preprocessing factors

  • arc_lengths (list) – list of the arc lengths of the different PDFs

  • integrability_numbers (list) – list of the integrability numbers of the different PDFs

  • tr_chi2 (float) – chi2 for the training

  • vl_chi2 (float) – chi2 for the validation

  • true_chi2 (float) – chi2 for the exp (unreplica’d data)

  • epoch_stop (int) – epoch at which the stopping stopped (not the one for the best fit!)

  • timing (dict) – dictionary of the timing of the different events that happened

n3fit.io.writer.storefit(pdf_object, replica, out_path, theory)[source]

One-trick function which generates all output in the NNPDF format so that all other scripts can still be used.

Parameters
  • pdf_object – N3PDF object constructed from the pdf_model that receives as input a point in x and returns an array of 14 flavours

  • replica – the replica index

  • out_path – the path where to store the output

  • theory – theory information of the fit

n3fit.io.writer.version()[source]

Generates a dictionary with misc version info for this run

Module contents