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

get_scalar_fields_range -> get_scalar_field_range #291

Merged
merged 3 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def _display_vector(self, obj, plotter: Union[BackgroundPlotter, pv.Plotter]):
else:
auto_range_on = obj.range.auto_range_on
if auto_range_on.global_range():
range = field_info.get_scalar_fields_range(obj.field(), False)
range = field_info.get_scalar_field_range(obj.field(), False)
else:
range = [np.min(scalar_field), np.max(scalar_field)]

Expand Down Expand Up @@ -360,7 +360,7 @@ def _display_contour(self, obj, plotter: Union[BackgroundPlotter, pv.Plotter]):
field_info = obj._api_helper.field_info()
plotter.add_mesh(
mesh,
clim=field_info.get_scalar_fields_range(obj.field(), False),
clim=field_info.get_scalar_field_range(obj.field(), False),
scalars=field,
show_edges=obj.show_edges(),
scalar_bar_args=scalar_bar_args,
Expand Down
14 changes: 7 additions & 7 deletions tests/test_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class MockFieldInfo:
def __init__(self, solver_data):
self._session_data = solver_data

def get_scalar_fields_range(
def get_scalar_field_range(
self, field: str, node_value: bool = False, surface_ids: List[int] = []
) -> List[float]:
if not surface_ids:
Expand Down Expand Up @@ -328,23 +328,23 @@ def test_contour_object():
if k in contour1.surfaces_list()
]

range = field_info.get_scalar_fields_range(
range = field_info.get_scalar_field_range(
contour1.field(), contour1.node_values(), surfaces_id
)
assert range[0] == pytest.approx(contour1.range.auto_range_off.minimum())
assert range[1] == pytest.approx(contour1.range.auto_range_off.maximum())

# Range should adjust to min/max of cell field values.
contour1.node_values = False
range = field_info.get_scalar_fields_range(
range = field_info.get_scalar_field_range(
contour1.field(), contour1.node_values(), surfaces_id
)
assert range[0] == pytest.approx(contour1.range.auto_range_off.minimum())
assert range[1] == pytest.approx(contour1.range.auto_range_off.maximum())

# Range should adjust to min/max of node field values
contour1.field = "pressure"
range = field_info.get_scalar_fields_range(
range = field_info.get_scalar_field_range(
contour1.field(), contour1.node_values(), surfaces_id
)
assert range[0] == pytest.approx(contour1.range.auto_range_off.minimum())
Expand Down Expand Up @@ -381,7 +381,7 @@ def test_vector_object():
if k in vector1.surfaces_list()
]

range = field_info.get_scalar_fields_range("velocity-magnitude", False)
range = field_info.get_scalar_field_range("velocity-magnitude", False)
assert range == pytest.approx(
[
vector1.range.auto_range_off.minimum(),
Expand Down Expand Up @@ -419,7 +419,7 @@ def test_surface_object():

# Iso surface value should automatically update upon change in field.
iso_surf.field = "temperature"
range = field_info.get_scalar_fields_range(iso_surf.field(), True)
range = field_info.get_scalar_field_range(iso_surf.field(), True)
assert (range[0] + range[1]) / 2.0 == pytest.approx(iso_surf.iso_value())

# Setting out of range should throw exception
Expand All @@ -431,7 +431,7 @@ def test_surface_object():

# Iso surface value should automatically update upon change in field.
iso_surf.field = "pressure"
range = field_info.get_scalar_fields_range(iso_surf.field(), True)
range = field_info.get_scalar_field_range(iso_surf.field(), True)
assert (range[0] + range[1]) / 2.0 == pytest.approx(iso_surf.iso_value())

# New surface should be in allowed values for graphics.
Expand Down