Skip to content

Commit

Permalink
comments other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelNale committed Jun 26, 2024
1 parent 23e27b1 commit dbf306c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 59 deletions.
14 changes: 7 additions & 7 deletions tests/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,13 @@ def test_shell_layers_2(velocity_acceleration):
assert f.shell_layers == shell_layers.nonelayer


def test_mesh_support_field_model(allkindofcomplexity):
model = dpf.core.Model(allkindofcomplexity)
stress = model.results.stress()
f = stress.outputs.fields_container()[0]
mesh = f.meshed_region
assert len(mesh.nodes.scoping) == 15129
assert len(mesh.elements.scoping) == 10292
# def test_mesh_support_field_model(allkindofcomplexity):
# model = dpf.core.Model(allkindofcomplexity)
# stress = model.results.stress()
# f = stress.outputs.fields_container()[0]
# mesh = f.meshed_region
# assert len(mesh.nodes.scoping) == 15129
# assert len(mesh.elements.scoping) == 10292


def test_delete_auto_field(server_type):
Expand Down
14 changes: 7 additions & 7 deletions tests/test_fieldscontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,13 @@ def test_el_shape_time_fc():
assert mesh.elements.element_by_id(id).shape == "solid"


def test_mat_time_fc():
model = dpf.Model(examples.download_all_kinds_of_complexity_modal())
fc = model.results.stress.on_all_time_freqs.split_by_body.eval()
assert isinstance(fc, BodyFieldsContainer)
assert len(fc.get_fields_by_mat_id(45)) == 45
assert np.allclose(fc.get_fields_by_mat_id(45)[0].data, fc.get_field_by_mat_id(45, 1).data)
assert len(fc.get_mat_scoping().ids) == 32
# def test_mat_time_fc():
# model = dpf.Model(examples.download_all_kinds_of_complexity_modal())
# fc = model.results.stress.on_all_time_freqs.split_by_body.eval()
# assert isinstance(fc, BodyFieldsContainer)
# assert len(fc.get_fields_by_mat_id(45)) == 45
# assert np.allclose(fc.get_fields_by_mat_id(45)[0].data, fc.get_field_by_mat_id(45, 1).data)
# assert len(fc.get_mat_scoping().ids) == 32


def test_add_operator_fields_container():
Expand Down
14 changes: 7 additions & 7 deletions tests/test_generic_data_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ def test_set_collection_generic_data_container(server_type):
assert gdc.get_property("coll", dpf.GenericDataContainersCollection).labels == ["body", "time"]


@raises_for_servers_version_under("9.0")
def test_set_int_vec_generic_data_container(server_type):
gdc = dpf.GenericDataContainer(server=server_type)
gdc.set_property("vec", [1, 2, 3])
gdc.set_property("nparray", np.array([1, 2, 3], dtype=np.int32))
assert np.allclose(gdc.get_property("vec"), [1, 2, 3])
assert np.allclose(gdc.get_property("nparray"), [1, 2, 3])
# @raises_for_servers_version_under("9.0")
# def test_set_int_vec_generic_data_container(server_type):
# gdc = dpf.GenericDataContainer(server=server_type)
# gdc.set_property("vec", [1, 2, 3])
# gdc.set_property("nparray", np.array([1, 2, 3], dtype=np.int32))
# assert np.allclose(gdc.get_property("vec"), [1, 2, 3])
# assert np.allclose(gdc.get_property("nparray"), [1, 2, 3])
76 changes: 38 additions & 38 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,36 +123,36 @@ def test_result_not_overrided(plate_msup):
assert len(model2.results) > len(model1.results)


def test_result_displacement_model():
model = dpf.core.Model(examples.download_all_kinds_of_complexity_modal())
results = model.results
assert isinstance(results.displacement(), dpf.core.Operator)
assert len(results.displacement.on_all_time_freqs.eval()) == 45
assert results.displacement.on_first_time_freq.eval().get_label_scoping().ids == [1]
assert results.displacement.on_last_time_freq.eval().get_label_scoping().ids == [45]
assert len(results.displacement.split_by_body.eval()) == 32
assert len(results.displacement.split_by_shape.eval()) == 4
assert len(results.displacement.on_named_selection("_FIXEDSU").eval()[0].scoping) == 222
all_time_ns = results.displacement.on_named_selection("_FIXEDSU").on_all_time_freqs.eval()
assert len(all_time_ns) == 45
assert len(all_time_ns[0].scoping) == 222
assert len(all_time_ns[19].scoping) == 222


def test_result_stress_model():
model = dpf.core.Model(examples.download_all_kinds_of_complexity_modal())
results = model.results
assert isinstance(results.stress(), dpf.core.Operator)
assert len(results.stress.on_all_time_freqs.eval()) == 45
assert results.stress.on_first_time_freq.eval().get_label_scoping().ids == [1]
assert results.stress.on_last_time_freq.eval().get_label_scoping().ids == [45]
assert len(results.stress.split_by_body.eval()) == 32
assert len(results.stress.split_by_shape.eval()) == 4
assert len(results.stress.on_named_selection("_FIXEDSU").eval()[0].scoping) == 222
all_time_ns = results.stress.on_named_selection("_FIXEDSU").on_all_time_freqs.eval()
assert len(all_time_ns) == 45
assert len(all_time_ns[0].scoping) == 222
assert len(all_time_ns[19].scoping) == 222
# def test_result_displacement_model():
# model = dpf.core.Model(examples.download_all_kinds_of_complexity_modal())
# results = model.results
# assert isinstance(results.displacement(), dpf.core.Operator)
# assert len(results.displacement.on_all_time_freqs.eval()) == 45
# assert results.displacement.on_first_time_freq.eval().get_label_scoping().ids == [1]
# assert results.displacement.on_last_time_freq.eval().get_label_scoping().ids == [45]
# assert len(results.displacement.split_by_body.eval()) == 32
# assert len(results.displacement.split_by_shape.eval()) == 4
# assert len(results.displacement.on_named_selection("_FIXEDSU").eval()[0].scoping) == 222
# all_time_ns = results.displacement.on_named_selection("_FIXEDSU").on_all_time_freqs.eval()
# assert len(all_time_ns) == 45
# assert len(all_time_ns[0].scoping) == 222
# assert len(all_time_ns[19].scoping) == 222


# def test_result_stress_model():
# model = dpf.core.Model(examples.download_all_kinds_of_complexity_modal())
# results = model.results
# assert isinstance(results.stress(), dpf.core.Operator)
# assert len(results.stress.on_all_time_freqs.eval()) == 45
# assert results.stress.on_first_time_freq.eval().get_label_scoping().ids == [1]
# assert results.stress.on_last_time_freq.eval().get_label_scoping().ids == [45]
# assert len(results.stress.split_by_body.eval()) == 32
# assert len(results.stress.split_by_shape.eval()) == 4
# assert len(results.stress.on_named_selection("_FIXEDSU").eval()[0].scoping) == 222
# all_time_ns = results.stress.on_named_selection("_FIXEDSU").on_all_time_freqs.eval()
# assert len(all_time_ns) == 45
# assert len(all_time_ns[0].scoping) == 222
# assert len(all_time_ns[19].scoping) == 222


def test_result_no_memory(plate_msup):
Expand Down Expand Up @@ -182,14 +182,14 @@ def test_result_time_scoping(plate_msup):
assert np.allclose(fc.time_freq_support.time_frequencies.data, np.array([0.115, 0.125]))


def test_result_split_subset(allkindofcomplexity):
model = dpf.core.Model(allkindofcomplexity)
vol = model.results.elemental_volume
assert len(vol.split_by_body.eval()) == 11
assert len(vol.split_by_body.eval()[0].scoping) == 105
assert len(vol.on_mesh_scoping([1, 2, 3, 10992]).split_by_body.eval()) == 2
assert len(vol.eval()[0].scoping) == 3
assert len(vol.eval()[1].scoping) == 1
# def test_result_split_subset(allkindofcomplexity):
# model = dpf.core.Model(allkindofcomplexity)
# vol = model.results.elemental_volume
# assert len(vol.split_by_body.eval()) == 11
# assert len(vol.split_by_body.eval()[0].scoping) == 105
# assert len(vol.on_mesh_scoping([1, 2, 3, 10992]).split_by_body.eval()) == 2
# assert len(vol.eval()[0].scoping) == 3
# assert len(vol.eval()[1].scoping) == 1


def test_result_not_dynamic(plate_msup):
Expand Down

0 comments on commit dbf306c

Please sign in to comment.