<commit_before>"""Module otsun.materials for treating materials

The module relies on a basic class `Material` with two subclasses
`VolumeMaterial` and `SurfaceMaterial`, and several subclasses of them
for specific materials.
"""


import json
import zipfile
from FreeCAD import Base
from .optics import Phenomenon, OpticalState, reflexion, refraction, matrix_reflectance,\
    calculate_reflectance, simple_polarization_reflexion, simple_polarization_refraction, \
    simple_reflexion, shure_refraction
from .math import arccos, parallel_orthogonal_components, rad_to_deg, myrandom, normalize,\
    constant_function, correct_normal, tabulated_function
from numpy import sqrt
import numpy as np
from autologging import traced
from logging_unit import logger


class NumpyEncoder(json.JSONEncoder):
    """Wrapper to dump numpy arrays as json"""
    def default(self, obj):
        if isinstance(obj, np.ndarray):
            return obj.tolist()
        return json.JSONEncoder.default(self, obj)


@traced(logger)
class Material(object):
    """
    Class used to represent materials and their physical properties

    The `properties` dictionary holds the physical properties of the material.
    Its contents are specific to the kind of material.<commit_msg>import lambertian_reflexion<commit_after>"""Module otsun.materials for treating materials

The module relies on a basic class `Material` with two subclasses
`VolumeMaterial` and `SurfaceMaterial`, and several subclasses of them
for specific materials.
"""


import json
import zipfile
from FreeCAD import Base
from .optics import Phenomenon, OpticalState, reflexion, refraction, matrix_reflectance,\
    calculate_reflectance, simple_polarization_reflexion, simple_polarization_refraction, \
    simple_reflexion, shure_refraction, lambertian_reflexion
from .math import arccos, parallel_orthogonal_components, rad_to_deg, myrandom, normalize,\
    constant_function, correct_normal, tabulated_function
from numpy import sqrt
import numpy as np
from autologging import traced
from logging_unit import logger


class NumpyEncoder(json.JSONEncoder):
    """Wrapper to dump numpy arrays as json"""
    def default(self, obj):
        if isinstance(obj, np.ndarray):
            return obj.tolist()
        return json.JSONEncoder.default(self, obj)


@traced(logger)
class Material(object):
    """
    Class used to represent materials and their physical properties

    The `properties` dictionary holds the physical properties of the material.
    Its contents are specific to the kind of material.
{'fraction_non_alphanumeric': 0.062109375, 'fraction_numerical': 0.0, 'mean_word_length': 4.941995359628771, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6156441', 'n_tokens_mistral': 687, 'n_tokens_neox': 654, 'n_words': 253}