Skip to content

Commit 224a8ee

Browse files
committed
fix merge and styling
1 parent c554151 commit 224a8ee

File tree

68 files changed

+395
-451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+395
-451
lines changed

ansys/dpf/core/common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from ansys.grpc.dpf import base_pb2, field_definition_pb2
1010

1111

12-
1312
def _camel_to_snake_case(name):
1413
return re.sub(r"(?<!^)(?=[A-Z])", "_", name).lower()
1514

ansys/dpf/core/core.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
else:
2727
CONFIGURATION = "release"
2828

29+
2930
def load_library(filename, name="", symbol="LoadOperators", server=None):
3031
"""Dynamically load an operators library for dpf.core.
3132
Code containing this library's operators is generated in
@@ -95,7 +96,7 @@ def upload_file_in_tmp_folder(file_path, new_file_name=None, server=None):
9596

9697

9798
def upload_files_in_folder(
98-
to_server_folder_path, client_folder_path, specific_extension=None, server=None
99+
to_server_folder_path, client_folder_path, specific_extension=None, server=None
99100
):
100101
"""Upload all the files from a folder of the client
101102
to the target server folder path.
@@ -160,7 +161,7 @@ def download_file(server_file_path, to_client_file_path, server=None):
160161

161162

162163
def download_files_in_folder(
163-
server_folder_path, to_client_folder_path, specific_extension=None, server=None
164+
server_folder_path, to_client_folder_path, specific_extension=None, server=None
164165
):
165166
"""Download all the files from a folder of the server
166167
to the target client folder path
@@ -376,7 +377,7 @@ def load_library(self, filename, name="", symbol="LoadOperators"):
376377
# TODO: fix code generation upload posix
377378
import os
378379

379-
if self._server().os != 'posix' or (not self._server().os and os.name!= 'posix'):
380+
if self._server().os != 'posix' or (not self._server().os and os.name != 'posix'):
380381
local_dir = os.path.dirname(os.path.abspath(__file__))
381382
LOCAL_PATH = os.path.join(local_dir, "operators")
382383

@@ -419,8 +420,8 @@ def _get_server_info(self):
419420
"server_port": response.port,
420421
"server_process_id": response.processId,
421422
"server_version": str(response.majorVersion)
422-
+ "."
423-
+ str(response.minorVersion),
423+
+ "."
424+
+ str(response.minorVersion),
424425
}
425426
if hasattr(response, "properties"):
426427
for key in response.properties:
@@ -487,28 +488,28 @@ def download_file(self, server_file_path, to_client_file_path):
487488
bar = None
488489
tot_size = sys.float_info.max
489490
for i in range(0, len(chunks.initial_metadata())):
490-
if chunks.initial_metadata()[i].key == u"size_tot" :
491-
tot_size = int(chunks.initial_metadata()[i].value)*1E-3
491+
if chunks.initial_metadata()[i].key == u"size_tot":
492+
tot_size = int(chunks.initial_metadata()[i].value) * 1E-3
492493
bar = _common_progress_bar("Downloading...",
493494
unit="KB",
494495
tot_size=tot_size)
495496
if not bar:
496-
bar = _common_progress_bar("Downloading...", unit="KB")
497-
bar.start()
497+
bar = _common_progress_bar("Downloading...", unit="KB")
498+
bar.start()
498499
i = 0
499500
with open(to_client_file_path, "wb") as f:
500501
for chunk in chunks:
501502
f.write(chunk.data.data)
502503
i += len(chunk.data.data) * 1e-3
503504
try:
504-
bar.update(min(i,tot_size))
505-
except :
505+
bar.update(min(i, tot_size))
506+
except:
506507
pass
507508
bar.finish()
508509

509510
@protect_grpc
510511
def download_files_in_folder(
511-
self, server_folder_path, to_client_folder_path, specific_extension=None
512+
self, server_folder_path, to_client_folder_path, specific_extension=None
512513
):
513514
"""Download all the files from a folder of the server
514515
to the target client folder path
@@ -555,8 +556,8 @@ def download_files_in_folder(
555556
if chunk.data.server_file_path != server_path:
556557
server_path = chunk.data.server_file_path
557558
if (
558-
specific_extension == None
559-
or pathlib.Path(server_path).suffix == "." + specific_extension
559+
specific_extension == None
560+
or pathlib.Path(server_path).suffix == "." + specific_extension
560561
):
561562
separator = self._get_separator(server_path)
562563
server_subpath = server_path.replace(
@@ -598,7 +599,7 @@ def download_files_in_folder(
598599

599600
@protect_grpc
600601
def upload_files_in_folder(
601-
self, to_server_folder_path, client_folder_path, specific_extension=None
602+
self, to_server_folder_path, client_folder_path, specific_extension=None
602603
):
603604
"""Upload all the files from a folder of the client
604605
to the target server folder path.
@@ -643,24 +644,24 @@ def upload_files_in_folder(
643644
return server_paths
644645

645646
def _upload_and_get_server_path(
646-
self,
647-
specific_extension,
648-
f,
649-
filename,
650-
server_paths,
651-
to_server_folder_path,
652-
subdirectory=None,
647+
self,
648+
specific_extension,
649+
f,
650+
filename,
651+
server_paths,
652+
to_server_folder_path,
653+
subdirectory=None,
653654
):
654655
separator = self._get_separator(to_server_folder_path)
655656

656657
if subdirectory is not None:
657658
to_server_file_path = (
658-
to_server_folder_path + separator + subdirectory + separator + filename
659+
to_server_folder_path + separator + subdirectory + separator + filename
659660
)
660661
else:
661662
to_server_file_path = to_server_folder_path + separator + filename
662663
if ((specific_extension is not None) and (f.endswith(specific_extension))) or (
663-
specific_extension is None
664+
specific_extension is None
664665
):
665666
server_path = self._stub.UploadFile(
666667
self.__file_chunk_yielder(

ansys/dpf/core/dpf_operator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ def available_operator_names(server=None):
610610
arr.extend(re.split(r'[\x00-\x08]', chunk.array.decode('utf-8')))
611611
return arr
612612

613+
613614
def _write_output_type_to_proto_style(output_type, request):
614615
subtype = ""
615616
stype = ""
@@ -715,7 +716,7 @@ def _convertOutputMessageToPythonInstance(out, output_type, server):
715716
return workflow.Workflow(server=server, workflow=toconvert)
716717

717718

718-
def _fillConnectionRequestMessage(request, inpt, pin_out=0):
719+
def _fillConnectionRequestMessage(request, inpt, server, pin_out=0):
719720
from ansys.dpf.core import (
720721
collection,
721722
cyclic_support,
@@ -727,7 +728,6 @@ def _fillConnectionRequestMessage(request, inpt, pin_out=0):
727728
workflow,
728729
)
729730

730-
731731
if isinstance(inpt, str):
732732
request.str = inpt
733733
elif isinstance(inpt, bool):

ansys/dpf/core/field_base.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ class _FieldBase:
1212
"""Contains base APIs for all implementations that follow DPF's field concept."""
1313

1414
def __init__(
15-
self,
16-
nentities=0,
17-
nature=natures.vector,
18-
location=locations.nodal,
19-
is_property_field=False,
20-
field=None,
21-
server=None,
15+
self,
16+
nentities=0,
17+
nature=natures.vector,
18+
location=locations.nodal,
19+
is_property_field=False,
20+
field=None,
21+
server=None,
2222
):
2323
"""Initialize the field either with an optional field message or by connecting to a stub."""
2424
if server is None:
@@ -490,10 +490,10 @@ def _set_data(self, data):
490490
else:
491491
if isinstance(data, (np.ndarray, np.generic)):
492492
if (
493-
0 != self.size
494-
and self.component_count > 1
495-
and data.size // self.component_count
496-
!= data.size / self.component_count
493+
0 != self.size
494+
and self.component_count > 1
495+
and data.size // self.component_count
496+
!= data.size / self.component_count
497497
):
498498
raise ValueError(
499499
f"An array of shape {self.shape} is expected and "
@@ -609,10 +609,10 @@ def get_entity_data(self, index):
609609
last_index = self._ncomp * (index + 1) - 1
610610
if self._is_property_field:
611611
array = np.array(
612-
self._data_copy[first_index : last_index + 1], dtype=np.int32
612+
self._data_copy[first_index: last_index + 1], dtype=np.int32
613613
)
614614
else:
615-
array = np.array(self._data_copy[first_index : last_index + 1])
615+
array = np.array(self._data_copy[first_index: last_index + 1])
616616

617617
if self._ncomp > 1:
618618
return array.reshape((array.size // self._ncomp, self._ncomp))
@@ -690,7 +690,7 @@ def append(self, data, scopingid):
690690
if not isinstance(data[0], int) and not isinstance(data[0], np.int32):
691691
raise errors.InvalidTypeError("data", "list of int")
692692
if (len(data) > 0 and isinstance(data, list)) or isinstance(
693-
data, (np.ndarray, np.generic)
693+
data, (np.ndarray, np.generic)
694694
):
695695
data = np.array(data).flatten().tolist()
696696

@@ -876,7 +876,6 @@ def scoping(self):
876876
"""
877877
return self._scoping_copy
878878

879-
880879
@scoping.setter
881880
@_setter
882881
def scoping(self, data):

ansys/dpf/core/model.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,10 @@ def results(self):
125125
126126
Examples
127127
--------
128-
Create a stress result from the model and choose its time and mesh scopings.
129-
130128
>>> from ansys.dpf import core as dpf
131129
>>> from ansys.dpf.core import examples
132130
>>> model = dpf.Model(examples.electric_therm)
133131
>>> v = model.results.electric_potential
134-
>>> rf = model.results.reaction_force
135132
>>> dissip = model.results.thermal_dissipation_energy
136133
137134
Examples
@@ -246,11 +243,11 @@ def mesh_by_default(self, value):
246243

247244
class Metadata:
248245
"""Contains the metadata of a data source.
249-
246+
250247
Parameters
251248
----------
252-
data_sources :
253-
249+
data_sources : DataSources
250+
254251
server : server.DPFServer
255252
Server with the channel connected to the remote or local instance.
256253

ansys/dpf/core/nodes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ def nodal_connectivity_field(self):
245245
"""
246246
return self._mesh.field_of_properties(nodal_properties.nodal_connectivity)
247247

248-
249248
@protect_grpc
250249
def _get_coordinates_field(self):
251250
"""Retrieve the coordinates field."""

ansys/dpf/core/time_freq_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def _get_frequencies(self, cplx=False):
364364
attributes_list = self._get_attributes_list()
365365
if cplx and "freq_complex" in attributes_list:
366366
return attributes_list["freq_complex"]
367-
elif cplx!=True and "freq_real" in attributes_list:
367+
elif cplx != True and "freq_real" in attributes_list:
368368
return attributes_list["freq_real"]
369369

370370
def _get_rpms(self):

ansys/dpf/core/workflow.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ def __init__(self, workflow=None, server=None):
6868
self.__create_from_stream(workflow)
6969
elif workflow is None or remote_copy_needed:
7070
self.__send_init_request(workflow)
71-
72-
71+
7372
@protect_grpc
7473
def connect(self, pin_name, inpt, pin_out=0):
7574
"""Connect an input on the workflow using a pin name.
@@ -144,7 +143,11 @@ def get_output(self, pin_name, output_type):
144143
out = out_future.result()
145144
else:
146145
out = self._stub.Get(request)
147-
return dpf_operator._convertOutputMessageToPythonInstance(out, output_type, self._server)
146+
return dpf_operator._convertOutputMessageToPythonInstance(
147+
out,
148+
output_type,
149+
self._server
150+
)
148151
else:
149152
raise ValueError(
150153
"please specify an output type to get the workflow's output"

examples/00-basic/00-basic_example.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
model = dpf.Model(examples.simple_bar)
4141
print(model)
4242

43-
4443
###############################################################################
4544
# Model Metadata
4645
# ~~~~~~~~~~~~~~
@@ -51,19 +50,16 @@
5150
metadata = model.metadata
5251
print(metadata.result_info)
5352

54-
5553
###############################################################################
5654
# To print the mesh region:
5755

5856
print(metadata.meshed_region)
5957

60-
6158
###############################################################################
6259
# To print the time or frequency of the results:
6360

6461
print(metadata.time_freq_support)
6562

66-
6763
###############################################################################
6864
# Extracting Displacement Results
6965
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

examples/00-basic/01-basic_operators.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
print(disp_op.inputs)
3939
print(disp_op.outputs)
4040

41-
4241
###############################################################################
4342
# Compute the Maximum Normalized Displacement
4443
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -73,7 +72,6 @@
7372
# it is much easier to reference available operators by first running:
7473
print(model.results)
7574

76-
7775
###############################################################################
7876
# Create the displacement operator directly from the ``results`` property:
7977
disp_op = model.results.displacement()

0 commit comments

Comments
 (0)