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

FIX: replaced argument output_dir with output_file for method export_field_file #4898

Merged
merged 1 commit into from
Jul 10, 2024
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
2 changes: 1 addition & 1 deletion _unittest/test_27_Maxwell2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,6 @@ def test_37_boundaries_by_type(self):
def test_38_export_fields_calc(self):
output_file = os.path.join(self.local_scratch.path, "e_tang_field.fld")
assert self.m2d_field_export.post.export_field_file(
quantity="E_Line", output_dir=output_file, assignment="Poly1", objects_type="Line"
quantity="E_Line", output_file=output_file, assignment="Poly1", objects_type="Line"
)
assert os.path.exists(output_file)
18 changes: 9 additions & 9 deletions _unittest_solvers/test_00_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ def test_02_hfss_export_results(self, hfss_app):
assert len(exported_files) > 0

fld_file1 = os.path.join(self.local_scratch.path, "test_fld_hfss1.fld")
assert hfss_app.post.export_field_file(quantity="Mag_E", output_dir=fld_file1, assignment="Box1",
assert hfss_app.post.export_field_file(quantity="Mag_E", output_file=fld_file1, assignment="Box1",
intrinsics="1GHz", phase="5deg")
assert os.path.exists(fld_file1)
fld_file2 = os.path.join(self.local_scratch.path, "test_fld_hfss2.fld")
assert hfss_app.post.export_field_file(quantity="Mag_E", output_dir=fld_file2, assignment="Box1",
assert hfss_app.post.export_field_file(quantity="Mag_E", output_file=fld_file2, assignment="Box1",
intrinsics="1GHz")
assert os.path.exists(fld_file2)

Expand Down Expand Up @@ -298,26 +298,26 @@ def test_03d_icepak_eval_tempc(self):
def test_03e_icepak_ExportFLDFil(self):
fld_file = os.path.join(self.local_scratch.path, "test_fld.fld")
self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep, variations={},
output_dir=fld_file, assignment="box")
output_file=fld_file, assignment="box")
assert os.path.exists(fld_file)
fld_file_1 = os.path.join(self.local_scratch.path, "test_fld_1.fld")
sample_points_file = os.path.join(local_path, "example_models", test_subfolder, "temp_points.pts")
self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep,
variations=self.icepak_app.available_variations.nominal_w_values_dict,
output_dir=fld_file_1, assignment="box",
output_file=fld_file_1, assignment="box",
sample_points_file=sample_points_file)
assert os.path.exists(fld_file_1)
fld_file_2 = os.path.join(self.local_scratch.path, "test_fld_2.fld")
self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep,
variations=self.icepak_app.available_variations.nominal_w_values_dict,
output_dir=fld_file_2, assignment="box",
output_file=fld_file_2, assignment="box",
sample_points=[[0, 0, 0], [3, 6, 8], [4, 7, 9]])
assert os.path.exists(fld_file_2)
cs = self.icepak_app.modeler.create_coordinate_system()
fld_file_3 = os.path.join(self.local_scratch.path, "test_fld_3.fld")
self.icepak_app.post.export_field_file(quantity="Temp", solution=self.icepak_app.nominal_sweep,
variations=self.icepak_app.available_variations.nominal_w_values_dict,
output_dir=fld_file_3, assignment="box",
output_file=fld_file_3, assignment="box",
sample_points=[[0, 0, 0], [3, 6, 8], [4, 7, 9]],
reference_coordinate_system=cs.name, export_in_si_system=False,
export_field_in_reference=False)
Expand Down Expand Up @@ -422,17 +422,17 @@ def test_07_export_maxwell_fields(self, m3dtransient):
m3dtransient.analyze(m3dtransient.active_setup, cores=4, use_auto_settings=False)
fld_file_3 = os.path.join(self.local_scratch.path, "test_fld_3.fld")
assert m3dtransient.post.export_field_file(quantity="Mag_B", solution=m3dtransient.nominal_sweep, variations={},
output_dir=fld_file_3, assignment="Coil_A2", objects_type="Surf",
output_file=fld_file_3, assignment="Coil_A2", objects_type="Surf",
intrinsics="10ms")
assert os.path.exists(fld_file_3)
fld_file_4 = os.path.join(self.local_scratch.path, "test_fld_4.fld")
assert not m3dtransient.post.export_field_file(quantity="Mag_B", solution=m3dtransient.nominal_sweep,
variations=m3dtransient.available_variations.nominal_w_values_dict,
output_dir=fld_file_4, assignment="Coil_A2",
output_file=fld_file_4, assignment="Coil_A2",
objects_type="invalid")
setup = m3dtransient.setups[0]
m3dtransient.setups[0].delete()
assert not m3dtransient.post.export_field_file(quantity="Mag_B", variations={}, output_dir=fld_file_4,
assert not m3dtransient.post.export_field_file(quantity="Mag_B", variations={}, output_file=fld_file_4,
assignment="Coil_A2")

new_setup = m3dtransient.create_setup(name=setup.name, setup_type=setup.setuptype)
Expand Down
24 changes: 12 additions & 12 deletions pyaedt/modules/PostProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2907,7 +2907,7 @@
@pyaedt_function_handler(
quantity_name="quantity",
variation_dict="variations",
filename="output_dir",
filename="output_file",
obj_list="assignment",
obj_type="objects_type",
sample_points_lists="sample_points",
Expand All @@ -2917,7 +2917,7 @@
quantity,
solution=None,
variations=None,
output_dir=None,
output_file=None,
assignment="AllObjects",
objects_type="Vol",
intrinsics=None,
Expand All @@ -2941,9 +2941,9 @@
variations : dict, optional
Dictionary of all variation variables with their values.
The default is ``None``.
output_dir : str, optional
output_file : str, optional
Full path and name to save the file to.
The default is ``None`` which export file in working_directory.
The default is ``None`` which export a file named ``"<setup_name>.fld"`` in working_directory.
assignment : str, optional
List of objects to export. The default is ``"AllObjects"``.
objects_type : str, optional
Expand Down Expand Up @@ -2994,12 +2994,12 @@
self.logger.error("There are no existing sweeps.")
return False
solution = self._app.existing_analysis_sweeps[0]
if not output_dir:
if not output_file:
appendix = ""
ext = ".fld"
output_dir = os.path.join(self._app.working_directory, solution.replace(" : ", "_") + appendix + ext)
output_file = os.path.join(self._app.working_directory, solution.replace(" : ", "_") + appendix + ext)

Check warning on line 3000 in pyaedt/modules/PostProcessor.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modules/PostProcessor.py#L3000

Added line #L3000 was not covered by tests
else:
output_dir = output_dir.replace("//", "/").replace("\\", "/")
output_file = output_file.replace("//", "/").replace("\\", "/")
self.ofieldsreporter.CalcStack("clear")
try:
self.ofieldsreporter.EnterQty(quantity)
Expand Down Expand Up @@ -3042,7 +3042,7 @@
args = ["Solution:=", solution, "Geometry:=", assignment, "GeometryType:=", objects_type]
else:
args = ["Solution:=", solution]
self.ofieldsreporter.CalculatorWrite(output_dir, args, variation)
self.ofieldsreporter.CalculatorWrite(output_file, args, variation)
elif sample_points_file:
export_options = [
"NAME:ExportOption",
Expand All @@ -3056,7 +3056,7 @@
export_field_in_reference,
]
self.ofieldsreporter.ExportToFile(
output_dir,
output_file,
sample_points_file,
solution,
variation,
Expand All @@ -3080,15 +3080,15 @@
export_field_in_reference,
]
self.ofieldsreporter.ExportToFile(
output_dir,
output_file,
sample_points_file,
solution,
variation,
export_options,
)

if os.path.exists(output_dir):
return output_dir
if os.path.exists(output_file):
return output_file
return False # pragma: no cover

@pyaedt_function_handler(plotname="plot_name", filepath="output_dir", filename="file_name")
Expand Down
Loading