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 wrong writing of material pointers and string encoding #50

Merged
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
16 changes: 8 additions & 8 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
runs-on: ubuntu-latest

strategy:
# If either the tests for 3.8 or 3.10 fail all workflows
# If either the tests for 3.8 or 3.11 fail all workflows
# are terminated to safe computing resources.
fail-fast: true
# To safe runtime least and latest version supported are
# chosen. We go for 3.8 due to some dependencies. For more
# info see the pyproject.toml
matrix:
python-version: ["3.8", "3.10"]
python-version: ["3.8", "3.11"]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -79,10 +79,10 @@ jobs:
echo "version=${VERSION}" >> $GITHUB_OUTPUT

# For publishing any version will do
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Install Task
run: |
Expand Down Expand Up @@ -127,10 +127,10 @@ jobs:

steps:
# Install python (be aware NO checkout action)
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

# Check if it installs without errors
- name: Install package
Expand Down Expand Up @@ -158,10 +158,10 @@ jobs:
with:
fetch-depth: 0

- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Install Task
run: |
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

|test-main| |test-dev|

.. |test-main| image:: https://github.com/open-lasso-python/lasso-python/actions/workflows/test-runner.yml/badge.svg?branch=main
.. |test-main| image:: https://github.com/open-lasso-python/lasso-python/actions/workflows/ci-cd.yml/badge.svg?branch=main
:target: https://github.com/open-lasso-python/lasso-python/actions/workflows/test-runner.yml

.. |test-dev| image:: https://github.com/open-lasso-python/lasso-python/actions/workflows/test-runner.yml/badge.svg?branch=dev
.. |test-dev| image:: https://github.com/open-lasso-python/lasso-python/actions/workflows/ci-cd.yml/badge.svg?branch=dev
:target: https://github.com/open-lasso-python/lasso-python/actions/workflows/test-runner.yml

This python library is designed for general purpose usage in the field of
Expand Down
4 changes: 2 additions & 2 deletions lasso/dimred/hashing_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _create_sphere_mesh(diameter: np.ndarray) -> typing.Tuple[np.ndarray, np.nda
beta bin boundaries
"""

assert diameter.dtype == np.float
assert diameter.dtype == np.float32

# partition latitude
n_alpha = 145
Expand Down Expand Up @@ -143,7 +143,7 @@ def sphere_hashing(
assert len(bin_numbers[0] == len(field))
# check data types
assert bin_numbers.dtype == np.int
assert bin_counts.dtype == np.float
assert bin_counts.dtype == np.float32

n_rows = bin_counts.shape[0]
n_cols = bin_counts.shape[1]
Expand Down
21 changes: 11 additions & 10 deletions lasso/dyna/d3plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6620,7 +6620,7 @@ def _write_geom_particle_flags(self, fp: typing.IO[Any], settings: D3plotWriterS
# only the first byte to the ascii char code
fmt_string = "{0:" + str(settings.wordsize) + "}"
for name, _ in nlist_names_typecodes:
name_formatted = fmt_string.format(name).encode("ascii")
name_formatted = fmt_string.format(name).encode("utf-8")
for ch in name_formatted:
barray = bytearray(settings.wordsize)
barray[0] = ch
Expand Down Expand Up @@ -6836,16 +6836,17 @@ def _write_geom_user_ids(self, fp: typing.IO[Any], settings: D3plotWriterSetting
n_bytes_written += fp.write(settings.pack(nsrtd))

if ArrayType.part_ids in self.arrays:
# some lsdyna material pointer
nsrma = info.ptr_material_ids
n_bytes_written += fp.write(settings.pack(nsrma))
# some lsdyna material pointer - Used by LS-Prepost in labelling materials

# some lsdyna material pointer
nsrmu = info.ptr_material_ids_defined_order
n_bytes_written += fp.write(settings.pack(nsrmu))
# Unsorted material ID pointer
nsrmu = nsrt + settings.header["nelth"]
# Sorted material ID pointer
nsrma = nsrmu + settings.header["nmmat"]
# Mapping array between sorted and unsorted
nsrmp = nsrma + settings.header["nmmat"]

# some lsdyna material pointer
nsrmp = info.ptr_material_ids_crossref
n_bytes_written += fp.write(settings.pack(nsrma))
n_bytes_written += fp.write(settings.pack(nsrmu))
n_bytes_written += fp.write(settings.pack(nsrmp))

# "Total number of materials (parts)"
Expand Down Expand Up @@ -7376,7 +7377,7 @@ def _write_header_part_contact_interface_titles(
max_len = 18 * title_wordsize
fmt_name = "{0:" + str(max_len) + "}"
for pid, title in zip(part_titles_ids, part_titles):
title = title.decode("ascii")
title = title.decode("utf-8")
n_bytes_written += fp.write(settings.pack(pid))

formatted_title = fmt_name.format(title[:max_len])
Expand Down
2 changes: 1 addition & 1 deletion lasso/dyna/test_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def test_others(self):
strain1 = np.random.randn(1, 2)
strain2 = np.random.randn(1, 2)

history_vars = np.array([[1, 2], [0, 3], [12, 2]], dtype=np.float)
history_vars = np.array([[1, 2], [0, 3], [12, 2]], dtype=np.float32)

history_vars1 = np.random.randn(3, 2)
history_vars2 = np.random.randn(3, 2)
Expand Down
Loading
Loading