<jupyter_start><jupyter_text>Array MathThis example will demonstrate how to perform a mathematical operationbetween two input arrays for any given source.This filter allows the user to select two input data arrays on which to performmath operations. The input arrays are used in their order of selection for theoperations.This example demos: :class:`PVGeo.filters.ArrayMath`<jupyter_code>import numpy as np
import pyvista
import PVGeo
from PVGeo.filters import ArrayMath<jupyter_output><empty_output><jupyter_text>Create some input data. This can be any `vtkDataObject`<jupyter_code>inp = pyvista.UniformGrid((10, 10, 4))
# Populate the tables
n = 400
arr0 = np.random.random(n)
arr1 = np.random.random(n)
inp['Array 0'] = arr0
inp['Array 1'] = arr1<jupyter_output><empty_output><jupyter_text>Use the filter:<jupyter_code>f = ArrayMath(operation='add', new_name='foo')
# Now get the result
output = f.apply(inp, 'Array 0', 'Array 1')
print(output)<jupyter_output><empty_output><jupyter_text>Note that the output now has three arrays<jupyter_code>arr = output['foo']
assert np.allclose(arr, arr0 + arr1)<jupyter_output><empty_output><jupyter_text>Use a custom math operation:<jupyter_code>def power(arr0, arr1):
    return arr0 ** arr1


# Use filter generated above
f.set_operation(power)
f.set_new_array_name('powered')
f.update()

# Now get the result
output = f.get_output()
print(output)
arr = output['powered']
assert np.allclose(arr, arr0 ** arr1)
output.plot(scalars='powered')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10766182298546896, 'fraction_numerical': 0.015852047556142668, 'mean_word_length': 7.101604278074866, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '398460', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 525, 'n_tokens_neox': 507, 'n_words': 142, 'path': 'locale/examples/filters-general/array-math.ipynb', 'repo_name': 'tkoyama010/PVGeo-doc-translations', 'size': '1514'}