def _add_depr_generator_functions(): from pytools import MovedFunctionDeprecationWrapper import hedge.mesh for name in globals(): if name.startswith("make_") or name.startswith("finish"): setattr(hedge.mesh, name, MovedFunctionDeprecationWrapper(globals()[name]))
def setify_field(f): from hedge.tools import is_obj_array if is_obj_array(f): return set(f) else: return set([f]) def obj_array_to_hashable(f): if is_obj_array(f): return tuple(f) else: return f hashable_field = MovedFunctionDeprecationWrapper(obj_array_to_hashable) def obj_array_equal(a, b): a_is_oa = is_obj_array(a) assert a_is_oa == is_obj_array(b) if a_is_oa: return np.array_equal(a, b) else: return a == b field_equal = MovedFunctionDeprecationWrapper(obj_array_equal)
ary = achng.get() from loopy.kernel.array import parse_array_dim_tags new_dim_tags = parse_array_dim_tags(dim_tags, n_axes=ary.num_user_axes(), use_increasing_target_axes=ary.max_target_axes > 1, dim_names=ary.dim_names) ary = ary.copy(dim_tags=tuple(new_dim_tags)) knl = achng.with_changed_array(ary) return knl tag_data_axes = MovedFunctionDeprecationWrapper(tag_array_axes) # }}} # {{{ set_array_axis_names def set_array_axis_names(kernel, ary_names, dim_names): """ .. versionchanged:: 2016.2 This function was called :func:`set_array_dim_names` before version 2016.2. """ from loopy.kernel.tools import ArrayChanger if isinstance(ary_names, str): ary_names = ary_names.split(",")
kernel = rule_mapping_context.finish_kernel(aash.map_kernel(kernel)) if auto_split_inames: from loopy import split_iname for iname, (outer_iname, inner_iname) in split_vars.items(): kernel = split_iname(kernel, iname, count, outer_iname=outer_iname, inner_iname=inner_iname, **split_kwargs) return kernel split_arg_axis = (MovedFunctionDeprecationWrapper(split_array_dim)) # }}} # {{{ split_array_axis def _split_array_axis_inner(kernel, array_name, axis_nr, count, order="C"): if count == 1: return kernel # {{{ adjust arrays from loopy.kernel.tools import ArrayChanger achng = ArrayChanger(kernel, array_name)
from modepy.quadrature.grundmann_moeller import GrundmannMoellerSimplexQuadrature from modepy.version import VERSION_TEXT as __version__ # noqa: N811 __all__ = [ "__version__", "jacobi", "grad_jacobi", "simplex_onb", "grad_simplex_onb", "simplex_monomial_basis", "grad_simplex_monomial_basis", "simplex_best_available_basis", "grad_simplex_best_available_basis", "tensor_product_basis", "equidistant_nodes", "warp_and_blend_nodes", "vandermonde", "resampling_matrix", "differentiation_matrices", "inverse_mass_matrix", "mass_matrix", "modal_face_mass_matrix", "nodal_face_mass_matrix", "Quadrature", "QuadratureRuleUnavailable", "JacobiGaussQuadrature", "LegendreGaussQuadrature", "XiaoGimbutasSimplexQuadrature", "GrundmannMoellerSimplexQuadrature", "VioreanuRokhlinSimplexQuadrature", ] from pytools import MovedFunctionDeprecationWrapper get_simplex_onb = MovedFunctionDeprecationWrapper(simplex_onb) get_grad_simplex_onb = MovedFunctionDeprecationWrapper(grad_simplex_onb) get_warp_and_blend_nodes = MovedFunctionDeprecationWrapper(warp_and_blend_nodes)
def link_extension(toolchain, objects, mod_name, cache_dir=None, debug=False, wait_on_error=True): import os.path if cache_dir is not None: destination = os.path.join(cache_dir, mod_name + toolchain.so_ext) else: # put the linked object in the same directory as the first object destination_base, first_object = os.path.split(objects[0]) destination = os.path.join(destination_base, mod_name + toolchain.so_ext) try: toolchain.link_extension(destination, objects, debug=debug) except CompileError: if wait_on_error: raw_input("Link error, examine %s, then press [Enter]" % objects) raise # try loading it from imp import load_dynamic return load_dynamic(mod_name, destination) from pytools import MovedFunctionDeprecationWrapper from codepy.toolchain import guess_toolchain as _gtc guess_toolchain = MovedFunctionDeprecationWrapper(_gtc)
def __init__(self, boundary_tag, axis, quadrature_tag=None): self.boundary_tag = boundary_tag self.axis = axis self.quadrature_tag = quadrature_tag def __getinitargs__(self): return (self.boundary_tag, self.axis, self.quadrature_tag) mapper_method = intern("map_normal_component") def normal(tag, dimensions): return numpy.array([BoundaryNormalComponent(tag, i) for i in range(dimensions)], dtype=object) make_normal = MovedFunctionDeprecationWrapper(normal) class GeometricFactorBase(LeafBase): def __init__(self, quadrature_tag): """ :param quadrature_tag: quadrature tag for the grid on which this geometric factor is needed, or None for nodal representation. """ self.quadrature_tag = quadrature_tag def __getinitargs__(self): return (self.quadrature_tag,)
def warn_with_kernel(kernel, id, text, type=LoopyWarning): from fnmatch import fnmatchcase for sw in kernel.silenced_warnings: if fnmatchcase(id, sw): return text += (" (add '%s' to silenced_warnings kernel attribute to disable)" % id) from warnings import warn warn(f"in kernel {kernel.name}: {text}", type, stacklevel=2) warn = MovedFunctionDeprecationWrapper(warn_with_kernel) # {{{ errors class LoopyError(RuntimeError): pass class CannotBranchDomainTree(LoopyError): pass class TypeInferenceFailure(LoopyError): pass
for iel_grp in range(grp.nelements): el_vertices = mesh.vertices[:, grp.vertex_indices[iel_grp]] el_bbox_min = np.min(el_vertices, axis=-1) - eps el_bbox_max = np.max(el_vertices, axis=-1) + eps tree.insert((igrp, iel_grp), (el_bbox_min, el_bbox_max)) return tree # }}} # {{{ nd_quad_submesh nd_quad_submesh = MovedFunctionDeprecationWrapper(hypercube_submesh) # }}} # {{{ random rotation matrix def rand_rotation_matrix(ambient_dim, deflection=1.0, randnums=None): """Creates a random rotation matrix. :arg deflection: the magnitude of the rotation. For 0, no rotation; for 1, competely random rotation. Small deflection => small perturbation. :arg randnums: 3 random numbers in the range [0, 1]. If `None`, they will be auto-generated. """ # from https://www.realtimerendering.com/resources/GraphicsGems/gemsiii/rand_rotation.c # noqa: E501
try_add_tet((0, 0, 0), (1, 0, 0), (0, 1, 0), (0, 0, 1)) try_add_tet((1, 0, 1), (1, 0, 0), (0, 0, 1), (0, 1, 0)) try_add_tet((1, 0, 1), (0, 1, 1), (0, 1, 0), (0, 0, 1)) try_add_tet((1, 0, 0), (0, 1, 0), (1, 0, 1), (1, 1, 0)) try_add_tet((0, 1, 1), (0, 1, 0), (1, 1, 0), (1, 0, 1)) try_add_tet((0, 1, 1), (1, 1, 1), (1, 0, 1), (1, 1, 0)) return result # }}} else: raise NotImplementedError("%d-dimensional sub-meshes" % dims) submesh = MovedFunctionDeprecationWrapper(simplex_submesh) @accept_scalar_or_vector(2, 2) def plot_element_values(n, nodes, values, resample_n=None, node_tuples=None, show_nodes=False): dims = len(nodes) orig_nodes = nodes orig_values = values if resample_n is not None: import modepy as mp basis = mp.simplex_onb(dims, n) fine_nodes = mp.equidistant_nodes(dims, resample_n)
if existing_pickle_actx is not None: raise RuntimeError("array_context_for_pickling should not be called " "inside the context of its own invocation.") _ARRAY_CONTEXT_FOR_PICKLING_TLS.actx = actx try: yield None finally: _ARRAY_CONTEXT_FOR_PICKLING_TLS.actx = None # }}} # {{{ deprecated obj_or_dof_array_vectorize = MovedFunctionDeprecationWrapper( rec_map_array_container, deadline="2022") obj_or_dof_array_vectorized = MovedFunctionDeprecationWrapper( mapped_over_array_containers, deadline="2022") obj_or_dof_array_vectorize_n_args = MovedFunctionDeprecationWrapper( rec_multimap_array_container, deadline="2022") obj_or_dof_array_vectorized_n_args = MovedFunctionDeprecationWrapper( multimapped_over_array_containers, deadline="2022") def thaw(actx, ary): from warnings import warn warn( "meshmode.dof_array.thaw is deprecated. Use arraycontext.thaw instead. " "WARNING: The argument order is reversed between these two functions. " "meshmode.dof_array.thaw will continue to work until 2022.", DeprecationWarning,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import numpy as np import pymbolic.primitives # noqa from pytools import MovedFunctionDeprecationWrapper from decorator import decorator # {{{ convenience functions for optemplate creation make_vector_field = \ MovedFunctionDeprecationWrapper(pymbolic.primitives.make_sym_vector) def get_flux_operator(flux): """Return a flux operator that can be multiplied with a volume field to obtain the interior fluxes or with a :class:`BoundaryPair` to obtain the lifted boundary flux. """ from hedge.tools import is_obj_array from hedge.optemplate import VectorFluxOperator, FluxOperator if is_obj_array(flux): return VectorFluxOperator(flux) else: return FluxOperator(flux)