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 deprecation of numpy.float and numpy.int #734

Merged
merged 41 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
630d437
Try new numpy package
anslpa Jan 2, 2023
903200a
Revert "Try new numpy package"
anslpa Jan 2, 2023
d0ef559
Remove requirement on numpy in setup.py
anslpa Jan 2, 2023
0b8130a
Bump numpy version in requirements/requirements_install.txt
anslpa Jan 2, 2023
ea89f51
Update np.int with np.int32
anslpa Jan 2, 2023
fbef575
Update np.float references of dpf-core source code
anslpa Jan 2, 2023
5f63f82
Update np.float references in tests
anslpa Jan 2, 2023
f80351d
Add --find-links to docs, examples, gate, post CI templates that it c…
anslpa Jan 2, 2023
c0ad9b6
Add gate in .github folder to test it
anslpa Jan 2, 2023
e8d8405
Remove gate from .github
anslpa Jan 2, 2023
a928074
Update unit test in test_geometry
anslpa Jan 2, 2023
12cd7aa
Update docker tests run with extra-pip-args
anslpa Jan 2, 2023
c58eb0b
Add dpf_wheels_directory to CI (tests, for retro)
anslpa Jan 2, 2023
ed62c7e
Add ansys-dpf-gate wheel
anslpa Jan 2, 2023
88993a7
update dtype in docstring
anslpa Jan 3, 2023
761a746
to revert: test
anslpa Jan 3, 2023
e5128ee
Update test
anslpa Jan 3, 2023
0a93d19
Add check
anslpa Jan 3, 2023
02eae39
add test
anslpa Jan 3, 2023
2404683
Add test
anslpa Jan 3, 2023
a82704b
Move check step
anslpa Jan 3, 2023
c2f2fcf
Update dpf_wheels_directory
anslpa Jan 3, 2023
f77eef6
add check
anslpa Jan 3, 2023
47493bd
update ci
anslpa Jan 3, 2023
3bdd3c1
Move check
anslpa Jan 3, 2023
f82112b
Update docker step
anslpa Jan 3, 2023
31554fe
test adding ROOT_SPACE
anslpa Jan 3, 2023
2d7b7cb
Update CI
anslpa Jan 3, 2023
9847426
Try source dir
anslpa Jan 3, 2023
38c8fce
remove failing check
anslpa Jan 3, 2023
3d2c625
Removing failing on docstring (different on windows and on linux)
anslpa Jan 3, 2023
5077d19
Docker step updated
anslpa Jan 3, 2023
fb956ec
Merge branch 'master' of https://github.com/pyansys/pydpf-core into d…
anslpa Jan 3, 2023
4d6a3f0
Merge with master
PProfizi Jan 26, 2023
adb0970
Redo Docker_test
PProfizi Jan 26, 2023
532e69b
Update test_geometry.py
PProfizi Jan 26, 2023
df6325e
Fix expected raised error type in test_geometry.py
PProfizi Jan 26, 2023
e3c15d1
Remove numpy pin in pyproject.toml
PProfizi Jan 26, 2023
1cfbc8b
Fix expected raised error type in test_geometry.py
PProfizi Jan 26, 2023
f319b34
Merge branch 'master' into deprecation/numpy_1_24
PProfizi Feb 21, 2023
860486c
Remove test gate package since it has been released
PProfizi Feb 23, 2023
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ jobs:
ANSYS_VERSION: "231"
python_versions: '["3.8"]'
DOCSTRING: false
custom-wheels: './.github'
secrets: inherit

retro_222:
Expand All @@ -123,6 +124,7 @@ jobs:
ANSYS_VERSION: "222"
python_versions: '["3.8"]'
DOCSTRING: false
custom-wheels: './.github'
secrets: inherit

retro_221:
Expand All @@ -133,6 +135,7 @@ jobs:
ANSYS_VERSION: "221"
python_versions: '["3.8"]'
DOCSTRING: false
custom-wheels: './.github'
secrets: inherit

pydpf-post:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ on:
env:
PACKAGE_NAME: ansys-dpf-core
MODULE: core
extra: "--find-links .github/"

jobs:
setup:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ on:
env:
PACKAGE_NAME: ansys-dpf-core
MODULE: core
extra: "--find-links .github/"

jobs:
setup:
Expand Down Expand Up @@ -88,7 +87,7 @@ jobs:
install_extras: plotting
wheelhouse: false
wheel: false
extra-pip-args: ${{ env.extra }}
extra-pip-args: ${{ format('--find-links ./dpf-standalone/v{0}/dist', inputs.ANSYS_VERSION) }}
standalone_suffix: ${{ inputs.standalone_suffix }}
custom-requirements: ${{ inputs.custom-requirements }}

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies = [
"packaging",
"setuptools",
"tqdm",
"numpy<1.24",
"numpy",
"ansys-dpf-gate>=0.3.*",
]

Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements_install.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ansys-dpf-gate==0.3.0
numpy==1.23.4
numpy==1.24.1
packaging==23.0
psutil==5.9.4
tqdm==4.64.1
4 changes: 2 additions & 2 deletions src/ansys/dpf/core/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def integral_collection(inpt, server: BaseServer = None):
inpt = inpt.flatten()
if all(isinstance(x, (int, np.int32)) for x in inpt):
return IntCollection(inpt, server=server)
if all(isinstance(x, (float, np.float)) for x in inpt):
if all(isinstance(x, (float, np.float64)) for x in inpt):
return FloatCollection(inpt, server=server)
else:
raise NotImplementedError(
Expand Down Expand Up @@ -556,7 +556,7 @@ def create_subtype(self, obj_by_copy):
return float(obj_by_copy)

def _set_integral_entries(self, input):
dtype = np.float
dtype = np.float64
if isinstance(input, range):
input = np.array(list(input), dtype=dtype)
elif not isinstance(input, (np.ndarray, np.generic)):
Expand Down
4 changes: 1 addition & 3 deletions src/ansys/dpf/core/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,15 +656,13 @@ def map_scoping(self, external_scope):
>>> vol = model.results.elemental_volume()
>>> field = vol.outputs.fields_container()[0]
>>> ind, mask = elements.map_scoping(field.scoping)
>>> ind
array([0, 1, 2, 3, 4, 5, 6, 7])

"""
if external_scope.location in ["Nodal", "NodalElemental"]:
raise ValueError('Input scope location must be "Nodal"')
arr = np.array(list(map(self.mapping_id_to_index.get, external_scope.ids)))
mask = arr != None
ind = arr[mask].astype(np.int)
ind = arr[mask].astype(np.int32)
return ind, mask

@property
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def map_scoping(self, external_scope):
raise ValueError('Input scope location must be "Nodal"')
arr = np.array(list(map(self.mapping_id_to_index.get, external_scope.ids)))
mask = arr != None
ind = arr[mask].astype(np.int)
ind = arr[mask].astype(np.int32)
return ind, mask

def add_node(self, id, coordinates):
Expand Down
19 changes: 9 additions & 10 deletions tests/test_custom_type_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ def test_create_custom_type_field_push_back(server_type):

@conftest.raises_for_servers_version_under("5.0")
def test_set_get_data_pointer_custom_type_field(server_type):
field = dpf.core.CustomTypeField(np.float, nentities=20, server=server_type)
field = dpf.core.CustomTypeField(np.float64, nentities=20, server=server_type)
field_def = dpf.core.FieldDefinition(server=server_type)
field_def.dimensionality = dpf.core.Dimensionality({3}, dpf.core.natures.vector)
field.field_definition = field_def
scop = dpf.core.Scoping(ids=[1, 2, 3, 4], location="faces", server=server_type)
field.scoping = scop

data = np.empty((24,), dtype=np.float)
data = np.empty((24,), dtype=np.float64)
for i in range(0, 24):
data[i] = i
field.data = data
Expand All @@ -85,7 +85,7 @@ def test_set_get_data_pointer_custom_type_field(server_type):

@conftest.raises_for_servers_version_under("5.0")
def test_set_get_field_def_custom_type_field(server_type):
field = dpf.core.CustomTypeField(np.float, nentities=20, server=server_type)
field = dpf.core.CustomTypeField(np.float64, nentities=20, server=server_type)
field_def = dpf.core.FieldDefinition(server=server_type)
field_def.dimensionality = dpf.core.Dimensionality([3], dpf.core.natures.vector)
field_def.location = core.locations.elemental
Expand Down Expand Up @@ -116,14 +116,14 @@ def test_set_get_field_def_custom_type_field(server_type):

@conftest.raises_for_servers_version_under("5.0")
def test_mutable_data_custom_type_field(server_clayer):
field = dpf.core.CustomTypeField(np.float, nentities=20, server=server_clayer)
field = dpf.core.CustomTypeField(np.float64, nentities=20, server=server_clayer)
field_def = dpf.core.FieldDefinition(server=server_clayer)
field_def.dimensionality = dpf.core.Dimensionality({3}, dpf.core.natures.vector)
field.field_definition = field_def
scop = dpf.core.Scoping(ids=[1, 2, 3, 4], location="faces", server=server_clayer)
field.scoping = scop

data = np.empty((24,), dtype=np.float)
data = np.empty((24,), dtype=np.float64)
for i in range(0, 24):
data[i] = i
field.data = data
Expand Down Expand Up @@ -153,14 +153,14 @@ def test_mutable_data_custom_type_field(server_clayer):

@conftest.raises_for_servers_version_under("5.0")
def test_mutable_data_contiguous_custom_type_field(server_clayer):
field = dpf.core.CustomTypeField(np.float, nentities=20, server=server_clayer)
field = dpf.core.CustomTypeField(np.float64, nentities=20, server=server_clayer)
field_def = dpf.core.FieldDefinition(server=server_clayer)
field_def.dimensionality = dpf.core.Dimensionality([6], dpf.core.natures.vector)
field.field_definition = field_def
scop = dpf.core.Scoping(ids=[1, 2, 3, 4], location="faces", server=server_clayer)
field.scoping = scop

data = np.empty((24,), dtype=np.float)
data = np.empty((24,), dtype=np.float64)
for i in range(0, 24):
data[i] = i
field.data = data
Expand Down Expand Up @@ -189,15 +189,14 @@ def test_mutable_data_contiguous_custom_type_field(server_clayer):

# not using a fixture on purpose: the instance of simple field SHOULD be owned by each test
def get_float_field(server_clayer):
field = dpf.core.CustomTypeField(np.float32, nentities=20, server=server_clayer)
field = dpf.core.CustomTypeField(np.float, nentities=20, server=server_clayer)
field = dpf.core.CustomTypeField(np.float64, nentities=20, server=server_clayer)
field_def = dpf.core.FieldDefinition(server=server_clayer)
field_def.dimensionality = dpf.core.Dimensionality({3}, dpf.core.natures.vector)
field.field_definition = field_def
scop = dpf.core.Scoping(ids=[1, 2, 3, 4], location="faces", server=server_clayer)
field.scoping = scop

data = np.empty((24,), dtype=np.float)
data = np.empty((24,), dtype=np.float64)
for i in range(0, 24):
data[i] = i
field.data = data
Expand Down
6 changes: 3 additions & 3 deletions tests/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_create_field(server_type):

def test_empty_field(server_type):
field = dpf.core.Field(server=server_type)
assert np.allclose(field.data, np.empty((0,), dtype=np.float))
assert np.allclose(field.data, np.empty((0,), dtype=np.float64))
field = dpf.core.PropertyField(server=server_type)
assert np.allclose(field.data, np.empty((0,), dtype=np.int32))

Expand Down Expand Up @@ -925,7 +925,7 @@ def get_simple_field(server_clayer):
scop = dpf.core.Scoping(ids=[1, 2, 3, 4], location="faces", server=server_clayer)
field.scoping = scop

data = np.empty((24,), dtype=np.float)
data = np.empty((24,), dtype=np.float64)
for i in range(0, 24):
data[i] = i
field.data = data
Expand Down Expand Up @@ -995,7 +995,7 @@ def test_mutable_entity_data_contiguous_field(server_clayer):
scop = dpf.core.Scoping(ids=[1, 2, 3, 4], location="faces", server=server_clayer)
field.scoping = scop

data = np.empty((24,), dtype=np.float)
data = np.empty((24,), dtype=np.float64)
for i in range(0, 24):
data[i] = i
field.data = data
Expand Down
Loading