Skip to content

CHORE: Add numpy as default requirement #6289

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

Merged
merged 3 commits into from
Jun 20, 2025
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
1 change: 1 addition & 0 deletions doc/changelog.d/6289.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add numpy as default requirement
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies = [
"rpyc>=6.0.0,<6.1",
"pyyaml",
"defusedxml>=0.7,<8.0",
"numpy>=1.20.0,<2.3",
]

[project.optional-dependencies]
Expand All @@ -55,7 +56,6 @@ unit-tests = [
]
integration-tests = [
"matplotlib>=3.5.0,<3.11",
"numpy>=1.20.0,<2.3",
"pandas>=1.1.0,<2.3",
"pyaedt[unit-tests]",
]
Expand Down Expand Up @@ -105,7 +105,6 @@ jupyter = [
]
all = [
"matplotlib>=3.5.0,<3.11",
"numpy>=1.20.0,<2.3",
"openpyxl>=3.1.0,<3.3",
"osmnx>=1.1.0,<2.1",
"pandas>=1.1.0,<2.3",
Expand All @@ -120,7 +119,6 @@ all = [
examples = [
"imageio>=2.34.0,<2.38",
"matplotlib>=3.5.0,<3.11",
"numpy>=1.20.0,<2.3",
"openpyxl>=3.1.0,<3.3",
"osmnx>=1.1.0,<2.1",
"pandas>=1.1.0,<2.3",
Expand Down
12 changes: 2 additions & 10 deletions src/ansys/aedt/core/generic/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,11 +670,7 @@ def parse_excitation_file(
tuple or bool
Frequency, magnitude and phase.
"""
try:
import numpy as np
except ImportError: # pragma: no cover
pyaedt_logger.error("NumPy is not available. Install it.")
return False
import numpy as np

try:
import pandas
Expand Down Expand Up @@ -880,11 +876,7 @@ def compute_fft(time_values, data_values, window=None) -> Union[tuple, bool]: #
tuple or bool
Frequency and values.
"""
try:
import numpy as np
except ImportError:
pyaedt_logger.error("NumPy is not available. Install it.")
return False
import numpy as np

deltaT = time_values[-1] - time_values[0]
num_points = len(time_values)
Expand Down
6 changes: 1 addition & 5 deletions src/ansys/aedt/core/generic/general_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,11 +794,7 @@ def conversion_function(data, function=None): # pragma: no cover
>>> conversion_function(values, "ang_deg")
array([ 0., 0., 0., 0.])
"""
try:
import numpy as np
except ImportError:
logging.error("NumPy is not available. Install it.")
return False
import numpy as np

function = function or "dB10"
available_functions = {
Expand Down
11 changes: 2 additions & 9 deletions src/ansys/aedt/core/generic/python_optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,8 @@

import sys
import threading
import warnings

try:
import numpy as np
except ImportError: # pragma: no cover
warnings.warn(
"The NumPy module is required to run some functionalities of PostProcess.\n"
"Install with \n\npip install numpy\n\nRequires CPython."
)

import numpy as np


class ThreadTrace(threading.Thread):
Expand Down
8 changes: 2 additions & 6 deletions src/ansys/aedt/core/modeler/advanced_cad/oms.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,16 @@
import os
import warnings

import numpy as np

from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
from ansys.aedt.core.generic.general_methods import settings
from ansys.aedt.core.internal.checks import graphics_required

logger = settings.logger

try:
import numpy as np
except ImportError: # pragma: no cover
warnings.warn("The NumPy module is required to use the OpenStreetMap Reader.\nInstall with \n\npip install numpy")

try:
import osmnx as ox

except ImportError: # pragma: no cover
warnings.warn("OpenStreetMap Reader requires osmnx extra package.\nInstall with \n\npip install osmnx")

Expand Down
6 changes: 1 addition & 5 deletions src/ansys/aedt/core/q3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2044,11 +2044,7 @@ def set_material_thresholds(

self.oboundary.SetMaterialThresholds(insulator_threshold, perfect_conductor_threshold, magnetic_threshold)
return True
except ImportError: # pragma: no cover
warnings.warn(
"The NumPy module is required to use functionalities provided by the module ansys.edt.core.q3d.\n"
"Install with \n\npip install numpy"
)

except Exception:
return False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import os
import shutil
import sys
import warnings

import defusedxml
from defusedxml.ElementTree import ParseError
import numpy as np

from ansys.aedt.core.aedt_logger import pyaedt_logger as logger
from ansys.aedt.core.generic.constants import AEDT_UNITS
Expand All @@ -47,16 +47,6 @@
from ansys.aedt.core.visualization.plot.pyvista import ModelPlotter
from ansys.aedt.core.visualization.plot.pyvista import get_structured_mesh

try:
import numpy as np
except ImportError: # pragma: no cover
warnings.warn(
"The NumPy module is required to run some functionalities of FfdSolutionData.\n"
"Install with \n\npip install numpy"
)
np = None


defusedxml.defuse_stdlib()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import csv
from pathlib import Path
import sys
import warnings

import numpy as np

from ansys.aedt.core.aedt_logger import pyaedt_logger as logger
from ansys.aedt.core.generic.constants import SpeedOfLight
Expand All @@ -38,14 +39,6 @@
if current_python_version < (3, 10): # pragma: no cover
raise Exception("Python 3.10 or higher is required for Monostatic RCS post-processing.")

try:
import numpy as np
except ImportError: # pragma: no cover
warnings.warn(
"The NumPy module is required to use module rcs_visualization.py.\nInstall with \n\npip install numpy"
)
np = None


class FRTMData(object):
"""Provides FRTM data.
Expand Down
9 changes: 2 additions & 7 deletions src/ansys/aedt/core/visualization/advanced/hdm_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,14 @@
import os
import warnings

import numpy as np

Check warning on line 30 in src/ansys/aedt/core/visualization/advanced/hdm_plot.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/visualization/advanced/hdm_plot.py#L30

Added line #L30 was not covered by tests

from ansys.aedt.core.generic.constants import AEDT_UNITS
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
from ansys.aedt.core.internal.checks import graphics_required
from ansys.aedt.core.visualization.plot.pyvista import CommonPlotter
from ansys.aedt.core.visualization.plot.pyvista import ObjClass

try:
import numpy as np
except ImportError:
warnings.warn(
"The NumPy module is required to run some functionalities of PostProcess.\nInstall with \n\npip install numpy"
)


class HDMPlotter(CommonPlotter):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import sys
import warnings

import numpy as np
from scipy.interpolate import RegularGridInterpolator

from ansys.aedt.core.aedt_logger import pyaedt_logger as logger
Expand All @@ -45,13 +46,6 @@
if current_python_version < (3, 10): # pragma: no cover
raise Exception("Python 3.10 or higher is required for Monostatic RCS post-processing.")

try:
import numpy as np
except ImportError: # pragma: no cover
warnings.warn(
"The NumPy module is required to use module rcs_visualization.py.\nInstall with \n\npip install numpy"
)
np = None

# Check that graphics are available
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,14 @@

import ast
import struct
import warnings

import numpy as np

try:
from enum import Enum
except ImportError:
pass

try:
import numpy as np
except ImportError:
warnings.warn(
"The NumPy module is required to run some functionalities of PostProcess.\nInstall with \n\npip install numpy"
)

from ansys.aedt.core.aedt_logger import pyaedt_logger


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,15 @@
import tempfile
import warnings

import numpy as np

from ansys.aedt.core import Edb
from ansys.aedt.core.aedt_logger import pyaedt_logger as logger
from ansys.aedt.core.generic.file_utils import open_file
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
from ansys.aedt.core.internal.aedt_versions import aedt_versions
from ansys.aedt.core.internal.checks import graphics_required

try:
import numpy as np
except ImportError: # pragma: no cover
warnings.warn(
"The NumPy module is required to run some functionalities of TouchstoneData.\n"
"Install with \n\npip install numpy"
)
np = None

try:
import skrf as rf
except ImportError: # pragma: no cover
Expand Down
9 changes: 2 additions & 7 deletions src/ansys/aedt/core/visualization/plot/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,13 @@
import os
import warnings

import numpy as np

from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
from ansys.aedt.core.generic.settings import settings
from ansys.aedt.core.internal.checks import ERROR_GRAPHICS_REQUIRED
from ansys.aedt.core.internal.checks import check_graphics_available

try:
import numpy as np
except ImportError:
warnings.warn(
"The NumPy module is required to run some functionalities of PostProcess.\nInstall with \n\npip install numpy"
)

# Check that graphics are available
try:
check_graphics_available()
Expand Down
9 changes: 2 additions & 7 deletions src/ansys/aedt/core/visualization/plot/pyvista.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import time
import warnings

import numpy as np

from ansys.aedt.core.aedt_logger import pyaedt_logger
from ansys.aedt.core.generic.constants import AEDT_UNITS
from ansys.aedt.core.generic.constants import CSS4_COLORS
Expand All @@ -39,13 +41,6 @@
from ansys.aedt.core.internal.checks import ERROR_GRAPHICS_REQUIRED
from ansys.aedt.core.internal.checks import check_graphics_available

try:
import numpy as np
except ImportError:
warnings.warn(
"The NumPy module is required to run some functionalities of PostProcess.\nInstall with \n\npip install numpy"
)

# Check that graphics are available
try:
check_graphics_available()
Expand Down
13 changes: 3 additions & 10 deletions src/ansys/aedt/core/visualization/post/post_common_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
from typing import Tuple
import warnings

import numpy as np

from ansys.aedt.core.generic.constants import unit_converter
from ansys.aedt.core.generic.file_utils import check_and_download_file
from ansys.aedt.core.generic.file_utils import generate_unique_name
Expand All @@ -47,17 +49,8 @@
from ansys.aedt.core.generic.settings import settings
from ansys.aedt.core.modeler.cad.elements_3d import FacePrimitive
from ansys.aedt.core.visualization.post.common import PostProcessorCommon
from ansys.aedt.core.visualization.post.fields_calculator import FieldsCalculator

try:
import numpy as np
except ImportError:
np = None
warnings.warn(
"The NumPy module is required to run some functionalities of PostProcess.\nInstall with \n\npip install numpy"
)

from ansys.aedt.core.visualization.post.field_data import FieldPlot
from ansys.aedt.core.visualization.post.fields_calculator import FieldsCalculator
from ansys.aedt.core.visualization.report.constants import ORIENTATION_TO_VIEW


Expand Down
12 changes: 2 additions & 10 deletions src/ansys/aedt/core/visualization/post/solution_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import os
import warnings

import numpy as np

from ansys.aedt.core import Quantity
from ansys.aedt.core.generic.constants import AEDT_UNITS
from ansys.aedt.core.generic.constants import db10
Expand All @@ -36,16 +38,6 @@
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
from ansys.aedt.core.generic.settings import settings

np = None
pd = None

try:
import numpy as np
except ImportError:
np = None
warnings.warn(
"The NumPy module is required to run some functionalities of PostProcess.\nInstall with \n\npip install numpy"
)
try:
import pandas as pd
except ImportError:
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/aedt/core/visualization/post/spisim.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ class DataSet(object):
Normally the user doesn't have to be aware of this class. It is only used internally to encapsulate the different
implementations of the wave population.
Data can be retrieved directly by using the [] operator.
If numpy is available, the numpy vector can be retrieved by using the get_wave() method.
The parameter whattype defines what is the trace representing in the simulation, Voltage, Current a Time or
The numpy vector can be retrieved by using the get_wave() method.
The parameter whattype defines what the trace is representing in the simulation, Voltage, Current a Time or
Frequency.
"""

Expand Down Expand Up @@ -490,7 +490,7 @@ class Trace(DataSet):
"""This class is used to represent a trace.

This class is constructed by the get_trace() command.
If numpy is available the get_wave() method will return a numpy array.
The get_wave() method will return a numpy array.
"""

def __init__(
Expand Down