Skip to content

Commit

Permalink
FIX: Allow scale_min and max to be set if not log scale (#5131)
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Morais <[email protected]>
  • Loading branch information
gmalinve and SMoraisAnsys authored Sep 8, 2024
1 parent f9465db commit bf6c25c
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 1 deletion.
89 changes: 89 additions & 0 deletions _unittest/test_12_1_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,95 @@ def test_14B_Field_Ploton_Vector(self):
image_format="jpg",
)
assert os.path.exists(plot_obj.image_file)
assert plot_obj.range_min is None
assert plot_obj.range_max is None
plot_obj_1 = self.aedtapp.post.plot_field(
"Vector_E",
cutlist,
"CutPlane",
setup=setup_name,
intrinsics=intrinsic,
mesh_on_fields=False,
view="isometric",
show=False,
export_path=self.local_scratch.path,
image_format="jpg",
log_scale=False,
)
assert os.path.exists(plot_obj_1.image_file)
assert plot_obj_1.range_min is None
assert plot_obj_1.range_max is None
plot_obj_2 = self.aedtapp.post.plot_field(
"Vector_E",
cutlist,
"CutPlane",
setup=setup_name,
intrinsics=intrinsic,
mesh_on_fields=False,
view="isometric",
show=False,
export_path=self.local_scratch.path,
image_format="jpg",
log_scale=False,
scale_min=0,
scale_max=10e6,
)
assert os.path.exists(plot_obj_2.image_file)
assert plot_obj_2.range_min == 0
assert plot_obj_2.range_max == 10e6
plot_obj_3 = self.aedtapp.post.plot_field(
"Vector_E",
cutlist,
"CutPlane",
setup=setup_name,
intrinsics=intrinsic,
mesh_on_fields=False,
view="isometric",
show=False,
export_path=self.local_scratch.path,
image_format="jpg",
log_scale=True,
scale_min=0,
scale_max=10e6,
)
assert os.path.exists(plot_obj_3.image_file)
assert plot_obj_3.range_min is None
assert plot_obj_3.range_max is None
plot_obj_4 = self.aedtapp.post.plot_field(
"Vector_E",
cutlist,
"CutPlane",
setup=setup_name,
intrinsics=intrinsic,
mesh_on_fields=False,
view="isometric",
show=False,
export_path=self.local_scratch.path,
image_format="jpg",
log_scale=True,
scale_min=10e6,
scale_max=0,
)
assert os.path.exists(plot_obj_4.image_file)
assert plot_obj_4.range_min is None
assert plot_obj_4.range_max is None
plot_obj_5 = self.aedtapp.post.plot_field(
"Vector_E",
cutlist,
"CutPlane",
setup=setup_name,
intrinsics=intrinsic,
mesh_on_fields=False,
view="isometric",
show=False,
export_path=self.local_scratch.path,
image_format="jpg",
log_scale=False,
scale_min=0,
)
assert os.path.exists(plot_obj_5.image_file)
assert plot_obj_5.range_min is None
assert plot_obj_5.range_max is None

@pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in ironpython")
def test_15_export_plot(self):
Expand Down
8 changes: 7 additions & 1 deletion src/ansys/aedt/core/modules/advanced_post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,13 @@ def plot_field_from_fieldplot(
if is_pcb:
model.z_scale = 5

if scale_min and scale_max:
if scale_min is not None and scale_max is None or scale_min is None and scale_max is not None:
self.logger.warning("Invalid scale values: both values must be None or different from None.")
elif scale_min is not None and scale_max is not None and not 0 <= scale_min < scale_max:
self.logger.warning("Invalid scale values: scale_min must be greater than zero and less than scale_max.")
elif log_scale and scale_min == 0:
self.logger.warning("Invalid scale minimum value for logarithm scale.")
else:
model.range_min = scale_min
model.range_max = scale_max
if project_path:
Expand Down

0 comments on commit bf6c25c

Please sign in to comment.