Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to pyproject.toml files #707

Merged
merged 9 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .ci/code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@
code_gen.connect(2, False)
else:
code_gen.connect(2, True)
print(
f"Generating optional {lib} operators for server {core.SERVER.version}..."
)
print(f"Generating optional {lib} operators for server {core.SERVER.version}...")
code_gen.run()
time.sleep(0.1)
except Exception as e:
Expand Down
4 changes: 1 addition & 3 deletions .ci/run_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
print(os.path.join(actual_path, os.path.pardir, "examples"))


for root, subdirectories, files in os.walk(
os.path.join(actual_path, os.path.pardir, "examples")
):
for root, subdirectories, files in os.walk(os.path.join(actual_path, os.path.pardir, "examples")):
for subdirectory in subdirectories:
subdir = os.path.join(root, subdirectory)
for file in glob.iglob(os.path.join(subdir, "*.py")):
Expand Down
4 changes: 1 addition & 3 deletions .ci/run_non_regression_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
os.path.join(actual_path, os.path.pardir, "examples", "00-basic"),
os.path.join(actual_path, os.path.pardir, "examples", "01-transient_analyses"),
os.path.join(actual_path, os.path.pardir, "examples", "02-modal-harmonic"),
os.path.join(
actual_path, os.path.pardir, "examples", "05-plotting", "00-basic_plotting.py"
),
os.path.join(actual_path, os.path.pardir, "examples", "05-plotting", "00-basic_plotting.py"),
os.path.join(
actual_path,
os.path.pardir,
Expand Down
38 changes: 8 additions & 30 deletions examples/00-basic/03-create_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def search_sequence_numpy(arr, seq):
indexes = np.where(np.isclose(arr, seq[0]))
for index in np.nditer(indexes[0]):
if index % 3 == 0:
if np.allclose(arr[index + 1], seq[1]) and np.allclose(
arr[index + 2], seq[2]
):
if np.allclose(arr[index + 1], seq[1]) and np.allclose(arr[index + 2], seq[2]):
return index
return -1

Expand All @@ -45,22 +43,13 @@ def search_sequence_numpy(arr, seq):
# Add nodes:
n_id = 1
for i, x in enumerate(
[
float(i) * length / float(num_nodes_in_length)
for i in range(0, num_nodes_in_length)
]
[float(i) * length / float(num_nodes_in_length) for i in range(0, num_nodes_in_length)]
):
for j, y in enumerate(
[
float(i) * width / float(num_nodes_in_width)
for i in range(0, num_nodes_in_width)
]
[float(i) * width / float(num_nodes_in_width) for i in range(0, num_nodes_in_width)]
):
for k, z in enumerate(
[
float(i) * depth / float(num_nodes_in_depth)
for i in range(0, num_nodes_in_depth)
]
[float(i) * depth / float(num_nodes_in_depth) for i in range(0, num_nodes_in_depth)]
):
mesh.nodes.add_node(n_id, [x, y, z])
n_id += 1
Expand All @@ -81,31 +70,20 @@ def search_sequence_numpy(arr, seq):
# Add solid elements (linear hexa with eight nodes):
e_id = 1
for i, x in enumerate(
[
float(i) * length / float(num_nodes_in_length)
for i in range(num_nodes_in_length - 1)
]
[float(i) * length / float(num_nodes_in_length) for i in range(num_nodes_in_length - 1)]
):
for j, y in enumerate(
[
float(i) * width / float(num_nodes_in_width)
for i in range(num_nodes_in_width - 1)
]
[float(i) * width / float(num_nodes_in_width) for i in range(num_nodes_in_width - 1)]
):
for k, z in enumerate(
[
float(i) * depth / float(num_nodes_in_depth)
for i in range(num_nodes_in_depth - 1)
]
[float(i) * depth / float(num_nodes_in_depth) for i in range(num_nodes_in_depth - 1)]
):
coord1 = np.array([x, y, z])
connectivity = []
for xx in [x, x + length / float(num_nodes_in_length)]:
for yy in [y, y + width / float(num_nodes_in_width)]:
for zz in [z, z + depth / float(num_nodes_in_depth)]:
data_index = search_sequence_numpy(
flat_coordinates_data, [xx, yy, zz]
)
data_index = search_sequence_numpy(flat_coordinates_data, [xx, yy, zz])
scoping_index = int(data_index / 3) # 3components
connectivity.append(scoping_index)
# rearrange connectivity
Expand Down
4 changes: 1 addition & 3 deletions examples/01-transient_analyses/00-basic_transient.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@
ind, mask = nodes.map_scoping(field.scoping)

# Show that the order of the remapped node scoping matches the field scoping.
print(
"Scoping matches:", np.allclose(np.array(nodes.scoping.ids)[ind], field.scoping.ids)
)
print("Scoping matches:", np.allclose(np.array(nodes.scoping.ids)[ind], field.scoping.ids))

# Now plot the von Mises stress relative to the Z coordinates.
z_coord = nodes.coordinates_field.data[ind, 2]
Expand Down
11 changes: 3 additions & 8 deletions examples/03-advanced/02-volume_averaged_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@
elements_indexes = []
# get elements attached to nodes
for current_node_index in current_node_indexes:
elements_indexes.extend(
nodal_connectivity.get_entity_data(i).flatten()
)
elements_indexes.extend(nodal_connectivity.get_entity_data(i).flatten())

current_node_indexes = []
for index in elements_indexes:
Expand Down Expand Up @@ -123,8 +121,7 @@
ssum = 0.0
for id in node_index_to_el_ids[key]:
ssum += (
values_to_sum.get_entity_data_by_id(id)[0]
* vol.get_entity_data_by_id(id)[0]
values_to_sum.get_entity_data_by_id(id)[0] * vol.get_entity_data_by_id(id)[0]
)
dataseqvsum.append(ssum)
datavolsum.append(node_index_to_found_volume[key])
Expand All @@ -150,9 +147,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~
# An operator with the same algorithm has been implemented
s_fc = s.outputs.fields_container()
single_field_vol_fc = dpf.fields_container_factory.over_time_freq_fields_container(
[vol_field]
)
single_field_vol_fc = dpf.fields_container_factory.over_time_freq_fields_container([vol_field])

single_field_fc = dpf.fields_container_factory.over_time_freq_fields_container(
[values_to_sum_field]
Expand Down
8 changes: 2 additions & 6 deletions examples/03-advanced/03-exchange_data_between_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@
#
# The ``as_global`` attributes allows you to choose whether a server is stored
# by the module and used by default. This example sets the first server as the default.
server1 = dpf.start_local_server(
as_global=True, config=dpf.AvailableServerConfigs.GrpcServer
)
server2 = dpf.start_local_server(
as_global=False, config=dpf.AvailableServerConfigs.GrpcServer
)
server1 = dpf.start_local_server(as_global=True, config=dpf.AvailableServerConfigs.GrpcServer)
server2 = dpf.start_local_server(as_global=False, config=dpf.AvailableServerConfigs.GrpcServer)

# Check that the two servers are listening on different ports.
print(
Expand Down
4 changes: 1 addition & 3 deletions examples/03-advanced/06-stress_gradient_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@
###############################################################################
# Create coordinates using 3D line equation.
#
coordinates = [
[fx(t * delta), fy(t * delta), fz(t * delta)] for t in range(int(depth / delta))
]
coordinates = [[fx(t * delta), fy(t * delta), fz(t * delta)] for t in range(int(depth / delta))]
flat_coordinates = [entry for data in coordinates for entry in data]
###############################################################################
# Create field for coordinates of the path.
Expand Down
4 changes: 1 addition & 3 deletions examples/03-advanced/10-asme_secviii_divtwo.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@
###############################################################################
# Strain limit condition (less than 1 pass the criteria)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
strainratio = dpf.operators.math.component_wise_divide(
fieldA=eppleqvave, fieldB=strainlimit
)
strainratio = dpf.operators.math.component_wise_divide(fieldA=eppleqvave, fieldB=strainlimit)
strainratio = strainratio.outputs.field()

###############################################################################
Expand Down
8 changes: 2 additions & 6 deletions examples/05-plotting/00-basic_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
stress.inputs.requested_location.connect("Nodal")
fc = stress.outputs.fields_container()
field = fc[0]
field.plot(
notebook=False, shell_layers=None, show_axes=True, title="Field", text="Field plot"
)
field.plot(notebook=False, shell_layers=None, show_axes=True, title="Field", text="Field plot")
# # Additional PyVista kwargs are supported, such as:
field.plot(
off_screen=True,
Expand Down Expand Up @@ -70,9 +68,7 @@
title="Mesh with fields container",
text="Mesh fc plot",
)
mesh.plot(
field_or_fields_container=field, title="Mesh with field", text="Mesh field plot"
)
mesh.plot(field_or_fields_container=field, title="Mesh with field", text="Mesh field plot")


# ##############################################################################################
Expand Down
4 changes: 1 addition & 3 deletions examples/05-plotting/02-solution_combination.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@

###############################################################################
# Add load cases.
stress_tensor_combi = dpf.operators.math.add(
fieldA=field_lc1, fieldB=stress_tensor_lc2_sc
)
stress_tensor_combi = dpf.operators.math.add(fieldA=field_lc1, fieldB=stress_tensor_lc2_sc)

###############################################################################
# Principal stresses are the Eigenvalues of the stress tensor.
Expand Down
4 changes: 1 addition & 3 deletions examples/05-plotting/04-plot_on_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@
###############################################################################
# Plot the solution along the specified line. Note that since the line is only
# moving along the y-axis, the stresses are plotted with respect to the y coordinate.
y_coords = [
mesh_m.nodes.coordinates_field.data[i][1] for i in range(mesh_m.nodes.n_nodes)
]
y_coords = [mesh_m.nodes.coordinates_field.data[i][1] for i in range(mesh_m.nodes.n_nodes)]
plt.plot(y_coords, field_m.data, "r")
plt.xlabel(f"y-coordinate [{mesh.unit}]")
plt.ylabel(f"Stress [{field_m.unit}]")
Expand Down
4 changes: 1 addition & 3 deletions examples/05-plotting/06-animate_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

# Use Scoping instances to adjust the region and the steps involved.
# Create a scoping on all nodes
mesh_scoping = dpf.mesh_scoping_factory.nodal_scoping(
model.metadata.meshed_region.nodes.scoping
)
mesh_scoping = dpf.mesh_scoping_factory.nodal_scoping(model.metadata.meshed_region.nodes.scoping)
# Create a scoping on all time steps
time_scoping = dpf.time_freq_scoping_factory.scoping_on_all_time_freqs(model)

Expand Down
8 changes: 2 additions & 6 deletions examples/06-distributed-post/00-distributed_total_disp.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,8 @@
)

remote_servers = [
dpf.start_local_server(
as_global=False, config=dpf.AvailableServerConfigs.GrpcServer
),
dpf.start_local_server(
as_global=False, config=dpf.AvailableServerConfigs.GrpcServer
),
dpf.start_local_server(as_global=False, config=dpf.AvailableServerConfigs.GrpcServer),
dpf.start_local_server(as_global=False, config=dpf.AvailableServerConfigs.GrpcServer),
]
ips = [remote_server.ip for remote_server in remote_servers]
ports = [remote_server.port for remote_server in remote_servers]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@
)

remote_servers = [
dpf.start_local_server(
as_global=False, config=dpf.AvailableServerConfigs.GrpcServer
),
dpf.start_local_server(
as_global=False, config=dpf.AvailableServerConfigs.GrpcServer
),
dpf.start_local_server(as_global=False, config=dpf.AvailableServerConfigs.GrpcServer),
dpf.start_local_server(as_global=False, config=dpf.AvailableServerConfigs.GrpcServer),
]

###############################################################################
Expand Down
12 changes: 3 additions & 9 deletions examples/06-distributed-post/02-distributed-msup_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,8 @@
)

remote_servers = [
dpf.start_local_server(
as_global=False, config=dpf.AvailableServerConfigs.GrpcServer
),
dpf.start_local_server(
as_global=False, config=dpf.AvailableServerConfigs.GrpcServer
),
dpf.start_local_server(as_global=False, config=dpf.AvailableServerConfigs.GrpcServer),
dpf.start_local_server(as_global=False, config=dpf.AvailableServerConfigs.GrpcServer),
]
ips = [remote_server.ip for remote_server in remote_servers]
ports = [remote_server.port for remote_server in remote_servers]
Expand Down Expand Up @@ -155,9 +151,7 @@
response = ops.result.displacement(data_sources=ds)
response.inputs.mesh(merge_mesh.outputs.merges_mesh)

expansion = ops.math.modal_superposition(
solution_in_modal_space=response, modal_basis=merge_fields
)
expansion = ops.math.modal_superposition(solution_in_modal_space=response, modal_basis=merge_fields)
component = ops.logic.component_selector_fc(expansion, 1)

###############################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,8 @@
)

remote_servers = [
dpf.start_local_server(
as_global=False, config=dpf.AvailableServerConfigs.GrpcServer
),
dpf.start_local_server(
as_global=False, config=dpf.AvailableServerConfigs.GrpcServer
),
dpf.start_local_server(as_global=False, config=dpf.AvailableServerConfigs.GrpcServer),
dpf.start_local_server(as_global=False, config=dpf.AvailableServerConfigs.GrpcServer),
]

ips = [remote_server.ip for remote_server in remote_servers]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
files = examples.download_distributed_files()

config = dpf.ServerConfig(protocol=dpf.server.CommunicationProtocols.gRPC)
remote_servers = [
dpf.start_local_server(as_global=False, config=config) for file in files
]
remote_servers = [dpf.start_local_server(as_global=False, config=config) for file in files]
ips = [remote_server.ip for remote_server in remote_servers]
ports = [remote_server.port for remote_server in remote_servers]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
dpf.set_default_server_context(dpf.AvailableServerContexts.premium)

GITHUB_SOURCE_URL = (
"https://github.com/pyansys/pydpf-core/"
"raw/examples/first_python_plugins/python_plugins"
"https://github.com/pyansys/pydpf-core/" "raw/examples/first_python_plugins/python_plugins"
)
EXAMPLE_FILE = GITHUB_SOURCE_URL + "/easy_statistics.py"
operator_file_path = examples.downloads._retrieve_file(
Expand Down Expand Up @@ -73,9 +72,7 @@
dpf.start_local_server(config=dpf.AvailableServerConfigs.GrpcServer)

operator_server_file_path = dpf.upload_file_in_tmp_folder(operator_file_path)
dpf.load_library(
os.path.dirname(operator_server_file_path), "py_easy_statistics", "load_operators"
)
dpf.load_library(os.path.dirname(operator_server_file_path), "py_easy_statistics", "load_operators")

###############################################################################
# Instantiate the operator.
Expand Down
4 changes: 1 addition & 3 deletions examples/07-python-operators/01-package_python_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@
dpf.start_local_server(config=dpf.AvailableServerConfigs.GrpcServer)

tmp = dpf.make_tmp_dir_server()
dpf.upload_files_in_folder(
dpf.path_utilities.join(tmp, "average_filter_plugin"), plugin_folder
)
dpf.upload_files_in_folder(dpf.path_utilities.join(tmp, "average_filter_plugin"), plugin_folder)
dpf.load_library(
os.path.join(dpf.path_utilities.join(tmp, "average_filter_plugin")),
"py_average_filter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
]
plugin_path = None
GITHUB_SOURCE_URL = (
"https://github.com/pyansys/pydpf-core/raw/"
""
"examples/first_python_plugins/python_plugins"
"https://github.com/pyansys/pydpf-core/raw/" "" "examples/first_python_plugins/python_plugins"
)

for file in file_list:
Expand Down Expand Up @@ -196,12 +194,8 @@
dpf.start_local_server(config=dpf.AvailableServerConfigs.GrpcServer)

tmp = dpf.make_tmp_dir_server()
dpf.upload_files_in_folder(
dpf.path_utilities.join(tmp, "plugins", "gltf_plugin"), plugin_path
)
dpf.upload_file(
plugin_path + ".xml", dpf.path_utilities.join(tmp, "plugins", "gltf_plugin.xml")
)
dpf.upload_files_in_folder(dpf.path_utilities.join(tmp, "plugins", "gltf_plugin"), plugin_path)
dpf.upload_file(plugin_path + ".xml", dpf.path_utilities.join(tmp, "plugins", "gltf_plugin.xml"))

dpf.load_library(
dpf.path_utilities.join(tmp, "plugins", "gltf_plugin"),
Expand Down
Loading