shancx 1.9.33.228__py3-none-any.whl → 1.9.33.229__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
shancx/npz.py CHANGED
@@ -1,14 +1,28 @@
1
1
  import numpy as np
2
2
  from pathlib import Path
3
+ import os
4
+ import uuid
5
+ import traceback
3
6
  def npzSave(output, data):
4
- output = output.replace('.npy', '.npz')
5
- output_path = Path(output).with_suffix('.npz')
6
- output_path.parent.mkdir(parents=True, exist_ok=True)
7
- np.savez_compressed(output_path, data=data)
8
- print(f"{output_path} done")
7
+ try:
8
+ output_path = Path(output)
9
+ if output_path.suffix in ['.npy', '.nc', '.h5', '.hdf5']:
10
+ output_path = output_path.with_suffix('.npz')
11
+ output_path.parent.mkdir(parents=True, exist_ok=True)
12
+ temp_filename = output_path.with_suffix(f'.tmp.{uuid.uuid4()}.npz')
13
+ np.savez_compressed(temp_filename, data=data)
14
+ os.replace(temp_filename, output_path)
15
+ print(f"{output_path} done")
16
+ except Exception as e:
17
+ print(traceback.format_exc())
18
+ if temp_filename and temp_filename.exists():
19
+ try:
20
+ os.remove(temp_filename)
21
+ print(f"⚠ Temporary files have been cleared: {temp_filename}")
22
+ except:
23
+ pass
9
24
  def npzLoad(output_path):
10
25
  return np.load(Path(output_path).with_suffix('.npz'))['data']
11
-
12
26
  """
13
27
  npzSave(output, data)
14
28
  npzLoad(output_path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shancx
3
- Version: 1.9.33.228
3
+ Version: 1.9.33.229
4
4
  Summary: A simple timer decorator
5
5
  Home-page: https://gitee.com/shancx
6
6
  Author: shancx
@@ -17,7 +17,7 @@ shancx/geosProj.py,sha256=JMmtj3kV8rtFkKbmwvTKuDWlC8AkgLG8JvCPzkn8Dfs,2685
17
17
  shancx/getResponse.py,sha256=QmJfa4czGCOiKb8RuCLXKE7AAKVADAptNiwn7v1tfbM,1055
18
18
  shancx/info.py,sha256=0rk_L8Z5uj9RliaZrzT-CArH9ZObmdmcp-1RxAItL08,1122
19
19
  shancx/netdfJU.py,sha256=96KR9NMLr2Kcs_OOMpX7QPujdWUj0GCEUIZ7_4_pBxw,7741
20
- shancx/npz.py,sha256=ZydULlx1ZhgwxrdIrVDm9lGa8KY4q1MJ9dZo_wQriso,462
20
+ shancx/npz.py,sha256=AOE-_f9OItnJLTgH_6kQj5Fn4dOHtLJ6yWRRKk853gM,1045
21
21
  shancx/sendM.py,sha256=dcqGNPPy1n0NxrRgOrHZEpaGtLy15FS_lCYe6_TkvSs,3510
22
22
  shancx/wait.py,sha256=OgT9JmEgMH7d3ir3TEksx0_Kyl_S4bkOKl50jvVpdFA,8575
23
23
  shancx/3D/__init__.py,sha256=pDFvW1OOEW-ueXH50NJIYdWlySHZU6sr5htzHUSeROo,1000
@@ -87,7 +87,7 @@ shancx/Train/multiGpu.py,sha256=D_oZeiSc7VWktpnVDwrFOC1CYZSt9rxOKY5lngE5vFg,820
87
87
  shancx/Train/prepare.py,sha256=vL_8UOA66oZCBIwCICtihsGibivtNgaVJGulJxfNdn8,6793
88
88
  shancx/Train/renet50.py,sha256=wEhYk1X96WE5zuqHqVxWLJa-A5jDNkz4z6edORNufnA,6428
89
89
  shancx/tensBoard/__init__.py,sha256=ga2C5YyJITvvQA1ocpxna_KNFnNRJVwkTjLoIglLZUQ,993
90
- shancx-1.9.33.228.dist-info/METADATA,sha256=r6Ia88MeKIEh1e5RlSm2UzxuC7QwY_dJInPIr5iE8gU,850
91
- shancx-1.9.33.228.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
92
- shancx-1.9.33.228.dist-info/top_level.txt,sha256=akfCS1vKWz3pNmEN_yN9ZiGp-60IQY5ET38mRx_i_-4,7
93
- shancx-1.9.33.228.dist-info/RECORD,,
90
+ shancx-1.9.33.229.dist-info/METADATA,sha256=bnZn5H1P1YztHINGA-DS0ObKNoJG9NCfKkmmP7iO2JA,850
91
+ shancx-1.9.33.229.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
92
+ shancx-1.9.33.229.dist-info/top_level.txt,sha256=akfCS1vKWz3pNmEN_yN9ZiGp-60IQY5ET38mRx_i_-4,7
93
+ shancx-1.9.33.229.dist-info/RECORD,,