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

any as bytes #1390

Merged
merged 25 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
538676d
any as bytes
cbellot000 Jan 31, 2024
66c74e5
update generated code
rlagha Jan 31, 2024
a735a9a
Merge branch 'maint/update_code_for_242_test_on_master' of https://gi…
cbellot000 Jan 31, 2024
fde64d3
retro
cbellot000 Jan 31, 2024
6783719
Merge branch 'master' of https://github.com/pyansys/pydpf-core into f…
cbellot000 Feb 1, 2024
bd6df90
skip
cbellot000 Feb 1, 2024
478d29f
try binary
cbellot000 Feb 2, 2024
55c8c44
update generated code
rlagha Feb 2, 2024
a17d0c3
Merge branch 'maint/update_code_for_242_test_on_master' of https://gi…
cbellot000 Feb 2, 2024
93fcd49
update generated code
rlagha Feb 3, 2024
be1c9f0
Merge branch 'maint/update_code_for_242_test_on_master' of https://gi…
cbellot000 Feb 5, 2024
5b62b92
Merge branch 'master' of https://github.com/pyansys/pydpf-core into f…
cbellot000 Feb 5, 2024
d57fc43
Merge branch 'master' of https://github.com/pyansys/pydpf-core into m…
cbellot000 Feb 5, 2024
9dacd50
Merge branch 'maint/update_code_for_242_test_on_master' of https://gi…
cbellot000 Feb 5, 2024
88353e4
update generated code
rlagha Feb 5, 2024
d6d96bd
Merge branch 'master' of https://github.com/pyansys/pydpf-core into f…
cbellot000 Feb 5, 2024
2be403b
Merge branch 'master' into maint/update_code_for_242_test_on_master
cbellot000 Feb 5, 2024
4b2ef5a
Merge branch 'maint/update_code_for_242_test_on_master' of https://gi…
cbellot000 Feb 5, 2024
f7b5b39
Merge branch 'maint/update_code_for_242_test_on_master' of https://gi…
cbellot000 Feb 5, 2024
120798e
remove test
cbellot000 Feb 5, 2024
d54741a
Merge branch 'maint/update_code_for_242_test_on_master' of https://gi…
cbellot000 Feb 5, 2024
3f401b2
fix test
cbellot000 Feb 5, 2024
eab7d0f
skip test
cbellot000 Feb 5, 2024
7456eb2
fxies
cbellot000 Feb 5, 2024
5b1d2c1
Merge branch 'master' into feat/any_as_string
cbellot000 Feb 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions doc/source/_static/dpf_operators.html

Large diffs are not rendered by default.

105 changes: 74 additions & 31 deletions src/ansys/dpf/core/any.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
import ansys.dpf.core.server_types
from ansys.dpf.core import server as server_module
from ansys.dpf.core import errors
from ansys.dpf.core.check_version import server_meet_version
from ansys.dpf.core.common import type_to_internal_object_keyword
from ansys.dpf.gate import any_abstract_api
from ansys.dpf.gate import any_abstract_api, integral_types


class Any:
Expand Down Expand Up @@ -48,8 +49,42 @@
self._internal_type = None
self._get_as_method = None

def _new_from_string(self, str):
return self._new_from_string_as_bytes(str.encode('utf-8'))

@staticmethod
def _get_as_string(self):
out = Any._get_as_string_as_bytes(self)
if out is not None and not isinstance(out, str):
return out.decode('utf-8')

Check warning on line 59 in src/ansys/dpf/core/any.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/any.py#L59

Added line #L59 was not covered by tests
return out

@staticmethod
def _type_to_new_from_get_as_method(any_dpf):
def _get_as_string_as_bytes(self):
if server_meet_version("8.0", self._server):
size = integral_types.MutableUInt64(0)
return self._api.any_get_as_string_with_size(self, size)

Check warning on line 66 in src/ansys/dpf/core/any.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/any.py#L65-L66

Added lines #L65 - L66 were not covered by tests
else:
return self._api.any_get_as_string(self)

def _new_from_string_on_client(self, client, str):
return self._new_from_string_as_bytes_on_client(client, str.encode('utf-8'))

def _new_from_string_as_bytes(self, str):
if server_meet_version("8.0", self._server):
size = integral_types.MutableUInt64(len(str))
return self._api.any_new_from_string_with_size(str, size)

Check warning on line 76 in src/ansys/dpf/core/any.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/any.py#L75-L76

Added lines #L75 - L76 were not covered by tests
else:
return self._api.any_new_from_string(str)

def _new_from_string_as_bytes_on_client(self, client, str):
if server_meet_version("8.0", self._server):
size = integral_types.MutableUInt64(len(str))
return self._api.any_new_from_string_with_size_on_client(client, str, size)

Check warning on line 83 in src/ansys/dpf/core/any.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/any.py#L82-L83

Added lines #L82 - L83 were not covered by tests
else:
return self._api.any_new_from_string_on_client(client, str)

def _type_to_new_from_get_as_method(self):
from ansys.dpf.core import (
field,
property_field,
Expand All @@ -62,47 +97,53 @@
return [
(
int,
any_dpf._api.any_new_from_int,
any_dpf._api.any_get_as_int,
any_dpf._api.any_new_from_int_on_client,
self._api.any_new_from_int,
self._api.any_get_as_int,
self._api.any_new_from_int_on_client,
),
(
str,
any_dpf._api.any_new_from_string,
any_dpf._api.any_get_as_string,
any_dpf._api.any_new_from_string_on_client,
self._new_from_string,
self._get_as_string,
self._new_from_string_on_client,
),
(
float,
any_dpf._api.any_new_from_double,
any_dpf._api.any_get_as_double,
any_dpf._api.any_new_from_double_on_client,
self._api.any_new_from_double,
self._api.any_get_as_double,
self._api.any_new_from_double_on_client,
),
(field.Field, any_dpf._api.any_new_from_field, any_dpf._api.any_get_as_field),
(
bytes,
self._new_from_string_as_bytes,
self._get_as_string_as_bytes,
self._new_from_string_as_bytes_on_client,
),
(field.Field, self._api.any_new_from_field, self._api.any_get_as_field),
(
property_field.PropertyField,
any_dpf._api.any_new_from_property_field,
any_dpf._api.any_get_as_property_field,
self._api.any_new_from_property_field,
self._api.any_get_as_property_field,
),
(
string_field.StringField,
any_dpf._api.any_new_from_string_field,
any_dpf._api.any_get_as_string_field,
self._api.any_new_from_string_field,
self._api.any_get_as_string_field,
),
(
generic_data_container.GenericDataContainer,
any_dpf._api.any_new_from_generic_data_container,
any_dpf._api.any_get_as_generic_data_container,
self._api.any_new_from_generic_data_container,
self._api.any_get_as_generic_data_container,
),
(
scoping.Scoping,
any_dpf._api.any_new_from_scoping,
any_dpf._api.any_get_as_scoping,
self._api.any_new_from_scoping,
self._api.any_get_as_scoping,
),
(
data_tree.DataTree,
any_dpf._api.any_new_from_data_tree,
any_dpf._api.any_get_as_data_tree,
self._api.any_new_from_data_tree,
self._api.any_get_as_data_tree,
),
]

Expand All @@ -120,22 +161,22 @@
Wrapped any type.
"""

innerServer = server if server is not None else obj._server
inner_server = server if server is not None else obj._server

if not innerServer.meet_version("7.0"):
if not inner_server.meet_version("7.0"):
raise errors.DpfVersionNotSupported("7.0")

any_dpf = Any(server=innerServer)
any_dpf = Any(server=inner_server)

for type_tuple in Any._type_to_new_from_get_as_method(any_dpf):
for type_tuple in any_dpf._type_to_new_from_get_as_method():
if isinstance(obj, type_tuple[0]):
# call respective new_from function
if isinstance(server, ansys.dpf.core.server_types.InProcessServer) or not (
isinstance(obj, int) or isinstance(obj, str) or isinstance(obj, float)
isinstance(obj, int) or isinstance(obj, str) or isinstance(obj, float) or isinstance(obj, bytes)
):
any_dpf._internal_obj = type_tuple[1](obj)
else:
any_dpf._internal_obj = type_tuple[3](innerServer.client, obj)
any_dpf._internal_obj = type_tuple[3](inner_server.client, obj)
# store get_as & type for casting back to original type
any_dpf._internal_type = type_tuple[0]
any_dpf._get_as_method = type_tuple[2]
Expand Down Expand Up @@ -190,9 +231,11 @@
# call the get_as function for the appropriate type
internal_obj = type_tuple[2](self)
if (
self._internal_type is int
or self._internal_type is str
or self._internal_type is float
self._internal_type is int
or self._internal_type is str
or self._internal_type is float
or self._internal_type is bytes

):
obj = internal_obj
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
====================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=======================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=====================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/operators/averaging/elemental_mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
==============
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
========================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
==================================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=====================================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
===========================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
============================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
===============================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
==================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=====================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
===================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
======================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/operators/averaging/gauss_to_node_fc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/operators/averaging/nodal_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
===================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=========================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
==================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=====================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/operators/averaging/to_elemental_fc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
===============
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=====================
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/operators/averaging/to_nodal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
========
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/operators/averaging/to_nodal_fc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
===========
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/operators/filter/abc_weightings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
==============
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/operators/filter/field_band_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
===============
Autogenerated DPF operator classes.
"""

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
Expand Down
Loading
Loading