<commit_before>"""
This file is part of the PhaseRetrieval project.
Copyright 2015 <NAME> (SCDA) (NYU) (MPIA).
"""

class pharetModel:

    def __init__(self, data):
        self.data = data
        self.shape = data.shape

    def realfunction():
<commit_msg>phase retrieval model class<commit_after>"""
This file is part of the PhaseRetrieval project.
Copyright 2015 <NAME> (SCDA) (NYU) (MPIA).
"""

from numpy.fft import rfftn, irfftn

class pharetModel:

    def __init__(self, data, imageshape):
        """
        Must initialize the data, and the shape of the reconstructed image.
        """
        self.datashape = None
        self.imageshape = imageshape
        self.set_data(data)

    def set_data(self, data):
        if self.datashape is None:
            self.datashape = data.shape
        assert self.datashape == data.shape
        self.data = data

    def set_real_image(self, image):
        assert self.imageshape == image.shape
        self.image = image
        self.ft = None

    def set_ft_image(self, ft):
        assert self.datashape == ft.shape
        self.ft = ft
        self.image = None

    def self.get_data(self):
        return self.data

    def get_real_image(self):
        if self.image is None:
            self.image = irfftn(self.ft, self.imageshape)
        return self.image

    def get_ft_image(self):
        if self.ft is None:
            self.ft = rfftn(self.image, self.imageshape)
        return self.ft

    def get_squared_norm_ft_image(self):
        ft = self.get_ft_image()
        return (ft * ft.conj()).real

    def get_score(self):
        return (self.get_squared_norm_ft_image() - self.get_data()) ** 2

    def __call__(self, image):
        self.set_image(image)
        return self.get_score()

{'fraction_non_alphanumeric': 0.10282485875706214, 'fraction_numerical': 0.005084745762711864, 'mean_word_length': 2.310280373831776, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '175910', 'n_tokens_mistral': 585, 'n_tokens_neox': 558, 'n_words': 150}