Skip to content

Commit 61faf51

Browse files
authoredMar 4, 2024··
Merge pull request #50 from open-lasso-python/bugfix/fix-ls-pre-post-crashing-on-read-2024-03-04
Fix wrong writing of material pointers and string encoding
2 parents db1e5a5 + 75f591e commit 61faf51

File tree

9 files changed

+1014
-1417
lines changed

9 files changed

+1014
-1417
lines changed
 

‎.github/workflows/ci-cd.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ jobs:
1212
runs-on: ubuntu-latest
1313

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

2424
steps:
2525
- uses: actions/checkout@v3
@@ -79,10 +79,10 @@ jobs:
7979
echo "version=${VERSION}" >> $GITHUB_OUTPUT
8080
8181
# For publishing any version will do
82-
- name: Set up Python 3.10
82+
- name: Set up Python 3.11
8383
uses: actions/setup-python@v4
8484
with:
85-
python-version: "3.10"
85+
python-version: "3.11"
8686

8787
- name: Install Task
8888
run: |
@@ -127,10 +127,10 @@ jobs:
127127

128128
steps:
129129
# Install python (be aware NO checkout action)
130-
- name: Set up Python 3.10
130+
- name: Set up Python 3.11
131131
uses: actions/setup-python@v4
132132
with:
133-
python-version: "3.10"
133+
python-version: "3.11"
134134

135135
# Check if it installs without errors
136136
- name: Install package
@@ -158,10 +158,10 @@ jobs:
158158
with:
159159
fetch-depth: 0
160160

161-
- name: Set up Python 3.10
161+
- name: Set up Python 3.11
162162
uses: actions/setup-python@v4
163163
with:
164-
python-version: "3.10"
164+
python-version: "3.11"
165165

166166
- name: Install Task
167167
run: |

‎README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
|test-main| |test-dev|
66

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

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

1313
This python library is designed for general purpose usage in the field of

‎lasso/dimred/hashing_sphere.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _create_sphere_mesh(diameter: np.ndarray) -> typing.Tuple[np.ndarray, np.nda
3232
beta bin boundaries
3333
"""
3434

35-
assert diameter.dtype == np.float
35+
assert diameter.dtype == np.float32
3636

3737
# partition latitude
3838
n_alpha = 145
@@ -143,7 +143,7 @@ def sphere_hashing(
143143
assert len(bin_numbers[0] == len(field))
144144
# check data types
145145
assert bin_numbers.dtype == np.int
146-
assert bin_counts.dtype == np.float
146+
assert bin_counts.dtype == np.float32
147147

148148
n_rows = bin_counts.shape[0]
149149
n_cols = bin_counts.shape[1]

‎lasso/dyna/d3plot.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -6620,7 +6620,7 @@ def _write_geom_particle_flags(self, fp: typing.IO[Any], settings: D3plotWriterS
66206620
# only the first byte to the ascii char code
66216621
fmt_string = "{0:" + str(settings.wordsize) + "}"
66226622
for name, _ in nlist_names_typecodes:
6623-
name_formatted = fmt_string.format(name).encode("ascii")
6623+
name_formatted = fmt_string.format(name).encode("utf-8")
66246624
for ch in name_formatted:
66256625
barray = bytearray(settings.wordsize)
66266626
barray[0] = ch
@@ -6836,16 +6836,17 @@ def _write_geom_user_ids(self, fp: typing.IO[Any], settings: D3plotWriterSetting
68366836
n_bytes_written += fp.write(settings.pack(nsrtd))
68376837

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

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

6847-
# some lsdyna material pointer
6848-
nsrmp = info.ptr_material_ids_crossref
6848+
n_bytes_written += fp.write(settings.pack(nsrma))
6849+
n_bytes_written += fp.write(settings.pack(nsrmu))
68496850
n_bytes_written += fp.write(settings.pack(nsrmp))
68506851

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

73827383
formatted_title = fmt_name.format(title[:max_len])

‎lasso/dyna/test_mapper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def test_others(self):
387387
strain1 = np.random.randn(1, 2)
388388
strain2 = np.random.randn(1, 2)
389389

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

392392
history_vars1 = np.random.randn(3, 2)
393393
history_vars2 = np.random.randn(3, 2)

0 commit comments

Comments
 (0)
Please sign in to comment.