<commit_before>import sys
import os
import copy
import pickle
from numbers import Integral
from collections import OrderedDict

import openmc
import openmc.mgxs
import openmc.checkvalue as cv


if sys.version_info[0] >= 3:
    basestring = str


class Library(object):
    """A multi-group cross section library for some energy group structure.

    This class can be used for both OpenMC input generation and tally data
    post-processing to compute spatially-homogenized and energy-integrated
    multi-group cross sections for deterministic neutronics calculations.

    This class helps automate the generation of MGXS objects for some energy
    group structure and domain type. The Library serves as a collection for
    MGXS objects with routines to automate the initialization of tallies for
    input files, the loading of tally data from statepoint files, data storage,
    energy group condensation and more.

    Parameters
    ----------
    openmc_geometry : openmc.Geometry
        An geometry which has been initialized with a root universe
    by_nuclide : bool
        If true, computes cross sections for each nuclide in each domain
    mgxs_types : Iterable of str
        The types of cross sections in the library (e.g., ['total', 'scatter'])
    name : str, optional
        Name of the multi-group cross section. library Used as a label to
        identify tallies in OpenMC 'tallies.xml' file.

    Attributes
    ----------
    openmc_geometry : openmc.Geometry
        An geometry which has been initialized with a root universe
    opencg_geometry : opencg.Geometry
        An OpenCG geometry object equivalent to the OpenMC geometry
        encapsulated by the summary file. Use of this attribute requires
        installation of the OpenCG Python module.
    by_nuclide : bool
        If true, computes cross sections for each nuclide in each domain
    mgxs_types : Iterable of str
        The types of cross sections in the library (e.g., ['total', 'scatter'])
    domain_type : {'material', 'cell', 'distribcell', 'universe'}
        Domain type for spatial homogenization
    correction : 'P0' or None
        Apply the P0 correction to scattering matrices if set to 'P0'
    energy_groups : EnergyGroups
        Energy group structure for energy condensation
    tally_trigger : Trigger
        An (optional) tally precision trigger given to each tally used to
        compute the cross section
    all_mgxs : OrderedDict
        MGXS objects keyed by domain ID and cross section type
    statepoint : openmc.StatePoint
        The statepoint with tally data used to the compute cross sections
    name : str, optional
        Name of the multi-group cross section library. Used as a label to
        identify tallies in OpenMC 'tallies.xml' file.

    """

    def __init__(self, openmc_geometry, by_nuclide=False,
                 mgxs_types=None, name=''):

        self._name = ''
        self._openmc_geometry = None
        self._opencg_geometry = None
        self._by_nuclide = None
        self._mgxs_types = []
        self._domain_type = None
        self._correction = 'P0'
        self._energy_groups = None
        self._tally_trigger = None
        self._all_mgxs = OrderedDict()
        self._sp_filename = None

        self.name = name
        self.openmc_geometry = openmc_geometry
        self.by_nuclide = by_nuclide

        if mgxs_types is not None:
            self.mgxs_types = mgxs_types

    def __deepcopy__(self, memo):
        existing = memo.get(id(self))

        # If this is the first time we have tried to copy this object, copy it
        if existing is None:
            clone = type(self).__new__(type(self))
            clone._name = self.name
            clone._openmc_geometry = self.openmc_geometry
            clone._opencg_geometry = self.opencg_geometry
            clone._by_nuclide = self.by_nuclide
            clone._mgxs_types = self.mgxs_types
            clone._domain_type = self.domain_type
            clone._correction = self.correction
            clone._energy_groups = copy.deepcopy(self.energy_groups, memo)
            clone._tally_trigger = copy.deepcopy(self.tally_trigger, memo)
            clone._all_mgxs = self.all_mgxs
            clone._sp_filename = self._sp_filename<commit_msg>Removed OpenCG geometry reference in openmc.mgxs.Library.__deepcopy__ routine<commit_after>import sys
import os
import copy
import pickle
from numbers import Integral
from collections import OrderedDict

import openmc
import openmc.mgxs
import openmc.checkvalue as cv


if sys.version_info[0] >= 3:
    basestring = str


class Library(object):
    """A multi-group cross section library for some energy group structure.

    This class can be used for both OpenMC input generation and tally data
    post-processing to compute spatially-homogenized and energy-integrated
    multi-group cross sections for deterministic neutronics calculations.

    This class helps automate the generation of MGXS objects for some energy
    group structure and domain type. The Library serves as a collection for
    MGXS objects with routines to automate the initialization of tallies for
    input files, the loading of tally data from statepoint files, data storage,
    energy group condensation and more.

    Parameters
    ----------
    openmc_geometry : openmc.Geometry
        An geometry which has been initialized with a root universe
    by_nuclide : bool
        If true, computes cross sections for each nuclide in each domain
    mgxs_types : Iterable of str
        The types of cross sections in the library (e.g., ['total', 'scatter'])
    name : str, optional
        Name of the multi-group cross section. library Used as a label to
        identify tallies in OpenMC 'tallies.xml' file.

    Attributes
    ----------
    openmc_geometry : openmc.Geometry
        An geometry which has been initialized with a root universe
    opencg_geometry : opencg.Geometry
        An OpenCG geometry object equivalent to the OpenMC geometry
        encapsulated by the summary file. Use of this attribute requires
        installation of the OpenCG Python module.
    by_nuclide : bool
        If true, computes cross sections for each nuclide in each domain
    mgxs_types : Iterable of str
        The types of cross sections in the library (e.g., ['total', 'scatter'])
    domain_type : {'material', 'cell', 'distribcell', 'universe'}
        Domain type for spatial homogenization
    correction : 'P0' or None
        Apply the P0 correction to scattering matrices if set to 'P0'
    energy_groups : EnergyGroups
        Energy group structure for energy condensation
    tally_trigger : Trigger
        An (optional) tally precision trigger given to each tally used to
        compute the cross section
    all_mgxs : OrderedDict
        MGXS objects keyed by domain ID and cross section type
    statepoint : openmc.StatePoint
        The statepoint with tally data used to the compute cross sections
    name : str, optional
        Name of the multi-group cross section library. Used as a label to
        identify tallies in OpenMC 'tallies.xml' file.

    """

    def __init__(self, openmc_geometry, by_nuclide=False,
                 mgxs_types=None, name=''):

        self._name = ''
        self._openmc_geometry = None
        self._opencg_geometry = None
        self._by_nuclide = None
        self._mgxs_types = []
        self._domain_type = None
        self._correction = 'P0'
        self._energy_groups = None
        self._tally_trigger = None
        self._all_mgxs = OrderedDict()
        self._sp_filename = None

        self.name = name
        self.openmc_geometry = openmc_geometry
        self.by_nuclide = by_nuclide

        if mgxs_types is not None:
            self.mgxs_types = mgxs_types

    def __deepcopy__(self, memo):
        existing = memo.get(id(self))

        # If this is the first time we have tried to copy this object, copy it
        if existing is None:
            clone = type(self).__new__(type(self))
            clone._name = self.name
            clone._openmc_geometry = self.openmc_geometry
            clone._opencg_geometry = None
            clone._by_nuclide = self.by_nuclide
            clone._mgxs_types = self.mgxs_types
            clone._domain_type = self.domain_type
            clone._correction = self.correction
            clone._energy_groups = copy.deepcopy(self.energy_groups, memo)
            clone._tally_trigger = copy.deepcopy(self.tally_trigger, memo)
            clone._all_mgxs = self.all_mgxs
            clone._sp_filename = self._sp_filename
{'fraction_non_alphanumeric': 0.057308584686774945, 'fraction_numerical': 0.0013921113689095127, 'mean_word_length': 2.5905872553102873, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2845504', 'n_tokens_mistral': 2313, 'n_tokens_neox': 2240, 'n_words': 873}