Skip to content

Commit 24ee38c

Browse files
authored
Merge pull request #1110 from ToFuProject/devel
Prepare 1.8.16
2 parents 506004a + fb49ad2 commit 24ee38c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+12996
-5871
lines changed

.github/workflows/test-complete-matrix.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
os: windows-latest
2121

2222
steps:
23-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v4
2424
- name: Set up Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v2
25+
uses: actions/setup-python@v5
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828
- name: Install dependencies

.github/workflows/test-single-linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
strategy:
1818
max-parallel: 5
1919
steps:
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
2121
- name: Set up Python 3.9
22-
uses: actions/setup-python@v2
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: 3.9
2525
- name: Install dependencies

requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ scipy
33
numpy
44
# scikit-sparse # does not work on windows, and requires "apt/brew install libsuitesparse-dev/suite-sparse" on linux / MacOs
55
# scikit-umfpack # similar issue
6-
setuptools>=40.8.0, <64
7-
matplotlib
6+
# >=40.8.0, <64
7+
setuptools
8+
matplotlib>3.0.3
89
contourpy
910
requests
1011
svg.path
1112
Polygon3
1213

1314
######## Requirements with Version Specifier ########
1415
datastock>=0.0.54
15-
bsplines2d>=0.0.25
16+
bsplines2d>=0.0.27
1617
spectrally>=0.0.9
1718
Cython>=0.26

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,20 @@ def get_version_tofu(path=_HERE):
312312
# requirements files see:
313313
# https://packaging.python.org/en/latest/requirements.html
314314
install_requires=[
315-
"setuptools>=40.8.0, <64",
315+
# ">=40.8.0, <64",
316+
"setuptools",
316317
"numpy",
317318
"scipy",
318319
# "scikit-sparse",
319320
# "scikit-umfpack",
320-
"matplotlib",
321+
"matplotlib>3.0.3",
321322
"contourpy",
322323
"requests",
323324
"svg.path",
324325
"Polygon3",
325326
"cython>=0.26",
326327
"datastock>=0.0.54",
327-
"bsplines2d>=0.0.25",
328+
"bsplines2d>=0.0.27",
328329
"spectrally>=0.0.9",
329330
],
330331
python_requires=">=3.6",

tofu/data/_class00_poly2d_check.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"""
55

66

7+
import warnings
8+
9+
710
import numpy as np
811
import datastock as ds
912

@@ -21,6 +24,7 @@ def check(
2124
# options
2225
closed=None,
2326
clockwise=None,
27+
strict=None,
2428
):
2529
""" High-level routine to format a 2d polygon
2630
@@ -55,10 +59,11 @@ def check(
5559
# check inputs
5660
# -------------
5761

58-
key, close, clockwise = _check(
62+
key, close, clockwise, strict = _check(
5963
key=key,
6064
closed=closed,
6165
clockwise=clockwise,
66+
strict=strict,
6267
)
6368

6469
# -------------
@@ -98,15 +103,29 @@ def check(
98103
# no duplicates
99104
# -------------
100105

101-
uni = np.unique([x0_closed[:-1], x1_closed[:-1]], axis=1)
106+
uni, ind_uni = np.unique(
107+
[x0_closed[:-1], x1_closed[:-1]],
108+
axis=1,
109+
return_index=True,
110+
)
102111
if uni.shape[1] < (x0_closed.size - 1):
103-
ndup = x0.size - 1 - uni.shape[1]
112+
ind_dup = np.array([
113+
ii for ii in range(x0_closed.size-1)
114+
if ii not in ind_uni
115+
])
116+
ndup = x0_closed.size - 1 - uni.shape[1]
104117
msg = (
105118
f"Polygon 2d '{key}' seems to have {ndup} duplicate points!\n"
106-
"\t- x0 = {x0_closed[:-1]}\n"
107-
"\t- x1 = {x1_closed[:-1]}\n"
119+
f"\t- total nb of pts (with duplicates) = {x0_closed.size - 1}\n"
120+
f"\t- total nb of pts (no duplicates) = {uni.shape[1]}\n"
121+
f"\t- duplicates: {ndup}\n"
122+
f"\t\t- x0 = {x0_closed[ind_dup]}\n"
123+
f"\t\t- x1 = {x1_closed[ind_dup]}\n"
108124
)
109-
raise Exception(msg)
125+
if strict is True:
126+
raise Exception(msg)
127+
else:
128+
warnings.warn(msg)
110129

111130
# -------------
112131
# clockwise
@@ -143,6 +162,7 @@ def _check(
143162
key=None,
144163
closed=None,
145164
clockwise=None,
165+
strict=None,
146166
):
147167

148168
# ---------------
@@ -175,7 +195,17 @@ def _check(
175195
default=True,
176196
)
177197

178-
return key, closed, clockwise
198+
# ---------------
199+
# strict
200+
# ---------------
201+
202+
strict = ds._generic_check._check_var(
203+
strict, 'strict',
204+
types=bool,
205+
default=True,
206+
)
207+
208+
return key, closed, clockwise, strict
179209

180210

181211
# ###########################################################
@@ -186,4 +216,4 @@ def _check(
186216

187217
def is_clockwise(x0, x1):
188218
area_signed = np.sum((x0[1:] - x0[:-1]) * (x1[1:] + x1[:-1]))
189-
return area_signed > 0
219+
return area_signed > 0

tofu/data/_class02_Rays.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ def save_rays_to_stp(
721721
# saving
722722
pfe_save=None,
723723
overwrite=None,
724+
verb=None,
724725
):
725726
""" Save a set of 'rays' to a stp file (CAD-readable)
726727
@@ -761,4 +762,5 @@ def save_rays_to_stp(
761762
# saving
762763
pfe_save=pfe_save,
763764
overwrite=overwrite,
765+
verb=verb,
764766
)

tofu/data/_class02_sample.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ def main(
197197
iok = np.isfinite(pts_x)
198198

199199
# get shape of arrays based on max nb of points ()
200-
nn = np.ceil(length_rad / res).astype(int)
200+
nn = np.ceil(length_rad / res)
201201
nmax = np.nansum(nn, axis=0) + 1
202-
shape = tuple(np.r_[np.nanmax(nmax), length_rad.shape[1:]])
202+
shape = tuple(np.r_[int(np.nanmax(nmax)), length_rad.shape[1:]])
203203

204204
# initialize arrays
205205
itot = np.full(shape, np.nan)
@@ -230,13 +230,14 @@ def main(
230230
i0i = i0[ioki]
231231
else:
232232
i0i = i0[sli2]
233-
nni = nn[tuple([iokin] + list(ind))]
233+
nni = nn[tuple([iokin] + list(ind))].astype(int)
234234

235235
# itoti
236236
itoti = []
237237
anyok = False
238238
for jj in range(i0i.size - 1):
239239
if np.all(np.isfinite(i0i[jj:jj+2])):
240+
240241
itoti.append(
241242
np.linspace(
242243
i0i[jj],
@@ -417,7 +418,6 @@ def main(
417418
# plt.plot(lengthtot)
418419
# plt.subplot(1,4,4)
419420
# plt.plot(kk*length + lengthtot)
420-
# import pdb; pdb.set_trace() # DB
421421

422422
lout.append(kk*length + lengthtot)
423423

@@ -625,4 +625,4 @@ def remove_consecutive_nans(arr):
625625
ind = np.nonzero(np.isnan(arr))[0]
626626
cons = np.r_[False, np.diff(ind) == 1]
627627

628-
return np.delete(arr, ind[cons])
628+
return np.delete(arr, ind[cons])

0 commit comments

Comments
 (0)