cdxcore 0.1.30__tar.gz → 0.1.31__tar.gz

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.

Potentially problematic release.


This version of cdxcore might be problematic. Click here for more details.

Files changed (45) hide show
  1. {cdxcore-0.1.30 → cdxcore-0.1.31}/PKG-INFO +1 -1
  2. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/__init__.py +1 -1
  3. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/subdir.py +43 -28
  4. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore.egg-info/PKG-INFO +1 -1
  5. {cdxcore-0.1.30 → cdxcore-0.1.31}/pyproject.toml +1 -1
  6. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_subdir.py +74 -15
  7. {cdxcore-0.1.30 → cdxcore-0.1.31}/LICENSE +0 -0
  8. {cdxcore-0.1.30 → cdxcore-0.1.31}/README.md +0 -0
  9. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/config.py +0 -0
  10. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/deferred.py +0 -0
  11. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/dynalimits.py +0 -0
  12. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/dynaplot.py +0 -0
  13. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/err.py +0 -0
  14. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/filelock.py +0 -0
  15. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/jcpool.py +0 -0
  16. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/npio.py +0 -0
  17. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/npshm.py +0 -0
  18. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/pretty.py +0 -0
  19. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/uniquehash.py +0 -0
  20. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/util.py +0 -0
  21. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/verbose.py +0 -0
  22. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore/version.py +0 -0
  23. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore.egg-info/SOURCES.txt +0 -0
  24. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore.egg-info/dependency_links.txt +0 -0
  25. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore.egg-info/requires.txt +0 -0
  26. {cdxcore-0.1.30 → cdxcore-0.1.31}/cdxcore.egg-info/top_level.txt +0 -0
  27. {cdxcore-0.1.30 → cdxcore-0.1.31}/docs/source/conf.py +0 -0
  28. {cdxcore-0.1.30 → cdxcore-0.1.31}/setup.cfg +0 -0
  29. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_config.py +0 -0
  30. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_deferred.py +0 -0
  31. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_err.py +0 -0
  32. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_jcpool.py +0 -0
  33. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_npio.py +0 -0
  34. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_npshm.py +0 -0
  35. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_pretty.py +0 -0
  36. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_uniquehash.py +0 -0
  37. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_util.py +0 -0
  38. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_verbose.py +0 -0
  39. {cdxcore-0.1.30 → cdxcore-0.1.31}/tests/test_version.py +0 -0
  40. {cdxcore-0.1.30 → cdxcore-0.1.31}/tmp/filelock.py +0 -0
  41. {cdxcore-0.1.30 → cdxcore-0.1.31}/tmp/np.py +0 -0
  42. {cdxcore-0.1.30 → cdxcore-0.1.31}/tmp/npsh1.py +0 -0
  43. {cdxcore-0.1.30 → cdxcore-0.1.31}/tmp/sharedarray.py +0 -0
  44. {cdxcore-0.1.30 → cdxcore-0.1.31}/up/git_message.py +0 -0
  45. {cdxcore-0.1.30 → cdxcore-0.1.31}/up/pip_modify_setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cdxcore
3
- Version: 0.1.30
3
+ Version: 0.1.31
4
4
  Summary: Basic Python Tools; upgraded cdxbasics
5
5
  Author-email: Hans Buehler <github@buehler.london>
6
6
  License-Expression: MIT
@@ -4,4 +4,4 @@ Created on June 2022
4
4
  @author: hansb
5
5
  """
6
6
 
7
- __version__ = "0.1.30" # auto-updated by setup.py
7
+ __version__ = "0.1.31" # auto-updated by setup.py
@@ -628,12 +628,9 @@ class CacheController( object ):
628
628
  When a parameter object of this type
629
629
  is assigned to a :class:`cdxcore.subdir.SubDir`,
630
630
  then it is passed on when sub-directories are
631
- created. This way all ``SubDir`` have the same
632
- caching behaviour.
631
+ created. This way all sub directories have the same
632
+ caching behaviour.
633
633
 
634
- See :class:`cdxcore.subdir.CacheController` for
635
- a list of control parameters.
636
-
637
634
  Parameters
638
635
  ----------
639
636
  exclude_arg_types : list[type], optional
@@ -803,16 +800,18 @@ class SubDir(object):
803
800
  Parent directory.
804
801
 
805
802
  If ``parent`` is a :class:`cdxcore.subdir.SubDir` then its parameters are used
806
- as default values here.
803
+ as default values.
807
804
 
808
805
  ext : str | None, default ``None``
809
- Extension for files managed by this ``SubDir``. All files will share the same extension.
806
+ Extension for files managed by this ``SubDir``. All files managed by ``self`` will share the same extension.
810
807
 
811
- If set to ``""`` no extension is assigned to this directory. That means, for example, that
812
- :meth:`cdxcore.subdir.SubDir.files` returns all files contained in the directory, not
808
+ If set to ``""`` no extension is assigned to this directory. That mean that
809
+ all files are considered. For example,
810
+ :meth:`cdxcore.subdir.SubDir.files` then returns all files contained in the directory, not
813
811
  just files with a specific extension.
814
812
 
815
- If ``None``, use an extension depending on ``fmt``:
813
+ If ``ext`` is ``None``, then use ``parent.ext`` or if ``parent`` was provided, or otherwise
814
+ the extension defined by ``fmt``:
816
815
 
817
816
  * 'pck' for the default PICKLE format.
818
817
  * 'json' for JSON_PLAIN.
@@ -823,7 +822,9 @@ class SubDir(object):
823
822
  fmt : :class:`cdxcore.subdir.Format` | None, default ``Format.PICKLE``
824
823
 
825
824
  One of the :class:`cdxcore.subdir.Format` codes.
826
- If ``ext`` is left to ``None`` then setting the a format will also set the corrsponding ``ext``.
825
+
826
+ If ``ext`` is left to ``None`` and ``parent`` is ``None``
827
+ then setting the a format will also set the corrsponding ``ext``.
827
828
 
828
829
  create_directory : bool | None, default ``False``
829
830
 
@@ -836,7 +837,7 @@ class SubDir(object):
836
837
  cache_controller : :class:`cdxcore.subdir.CacheController` | None, default ``None``
837
838
 
838
839
  An object which fine-tunes the behaviour of :meth:`cdxcore.subdir.SubDir.cache`.
839
- See that function's documentation for further details. Default is ``None``.
840
+ See :class:`cdxcore.subdir.CacheController` documentation for further details.
840
841
 
841
842
  delete_everything : bool, default ``False``
842
843
 
@@ -849,7 +850,7 @@ class SubDir(object):
849
850
 
850
851
  Note, however, that this will only be executed once the object is garbage collected.
851
852
 
852
- Default is, for some good reason, ``False``.
853
+ Default is, for some good reason, is ``False``.
853
854
  """
854
855
 
855
856
  class __RETURN_SUB_DIRECTORY(object):
@@ -907,6 +908,7 @@ class SubDir(object):
907
908
 
908
909
  """
909
910
  create_directory = bool(create_directory) if not create_directory is None else None
911
+ ext = SubDir._extract_ext(ext) if not ext is None else None
910
912
 
911
913
  # copy constructor support
912
914
  if isinstance(name, SubDir):
@@ -918,6 +920,7 @@ class SubDir(object):
918
920
  self._cctrl = name._cctrl if cache_controller is None else cache_controller
919
921
  self._tclean = False # "_clean" is not inherited
920
922
  if delete_everything: raise ValueError( "Cannot use 'delete_everything' when cloning a directory")
923
+ assert self._ext=="" or self._ext==self.EXT_FMT_AUTO or self._ext[0] == ".", ("Extension error", self._ext)
921
924
  return
922
925
 
923
926
  # reconstruction from a dictionary
@@ -930,6 +933,7 @@ class SubDir(object):
930
933
  self._cctrl = name['_cctrl'] if cache_controller is None else cache_controller
931
934
  self._tclean = name['_tclean']
932
935
  if delete_everything: raise ValueError( "Cannot use 'delete_everything' when cloning a directory")
936
+ assert self._ext=="" or self._ext==self.EXT_FMT_AUTO or self._ext[0] == ".", ("Extension error", self._ext)
933
937
  return
934
938
 
935
939
  # parent
@@ -965,12 +969,15 @@ class SubDir(object):
965
969
  _ext = name[ext_i+3:]
966
970
  if not ext is None and ext != _ext:
967
971
  raise ValueError( txtfmt("Canot specify an extension both in the name string ('%s') and as 'ext' ('%s')", _name, ext))
968
- ext = _ext
972
+ ext = SubDir._extract_ext(_ext)
969
973
  name = name[:ext_i]
974
+ del _ext
975
+ del ext_i
970
976
  if ext is None:
971
977
  self._ext = self.EXT_FMT_AUTO if parent is None else parent._ext
972
978
  else:
973
- self._ext = SubDir._extract_ext(ext)
979
+ self._ext = ext
980
+ assert self._ext=="" or self._ext==self.EXT_FMT_AUTO or self._ext[0] == ".", ("Extension error", self._ext)
974
981
 
975
982
  # create_directory
976
983
  if create_directory is None:
@@ -1050,7 +1057,8 @@ class SubDir(object):
1050
1057
  If neither of these matches the first character, ``name``
1051
1058
  is returned as is.
1052
1059
 
1053
- This function does not support ``"?"``.
1060
+ This function does not support ``"?"`` because ``"?"`` used in the constructor
1061
+ represents a new directory every time it is used.
1054
1062
  """
1055
1063
  if len(name) < 2 or name[0] not in ['.','!','~'] or name[1] not in ["\\","/"]:
1056
1064
  return name
@@ -1146,6 +1154,7 @@ class SubDir(object):
1146
1154
  Returns the common extension of the files in this directory, including leading ``'.'``.
1147
1155
  Resolves ``"*"`` into the extension associated with the current :class:`cdxcore.subdir.Format`.
1148
1156
  """
1157
+ assert self._ext=="" or self._ext==self.EXT_FMT_AUTO or self._ext[0] == ".", ("Extension error", self._ext)
1149
1158
  return self._ext if self._ext != self.EXT_FMT_AUTO else self._auto_ext(self._fmt)
1150
1159
 
1151
1160
  def auto_ext( self, ext_or_fmt : str|Format = None ) -> str:
@@ -1167,10 +1176,13 @@ class SubDir(object):
1167
1176
  The extension with leading ``'.'``.
1168
1177
  """
1169
1178
  if isinstance(ext_or_fmt, Format):
1170
- return self._auto_ext(ext_or_fmt)
1179
+ r = self._auto_ext(ext_or_fmt)
1171
1180
  else:
1172
1181
  ext = self._ext if ext_or_fmt is None else SubDir._extract_ext(ext_or_fmt)
1173
- return ext if ext != self.EXT_FMT_AUTO else self._auto_ext(self._fmt)
1182
+ r = ext if ext != self.EXT_FMT_AUTO else self._auto_ext(self._fmt)
1183
+ del ext
1184
+ assert r=="" or r[0] == ".", ("Extension error", self._ext, ext_or_fmt)
1185
+ return r
1174
1186
 
1175
1187
  def auto_ext_fmt( self, *, ext : str = None, fmt : Format = None ) -> tuple[str]:
1176
1188
  """
@@ -1266,6 +1278,7 @@ class SubDir(object):
1266
1278
  # remove internal characters
1267
1279
  verify( ext[0] != "!", "Extension '%s' cannot start with '!' (this symbol indicates the temp directory)", ext, exception=ValueError )
1268
1280
  verify( ext[0] != "~", "Extension '%s' cannot start with '~' (this symbol indicates the user's directory)", ext, exception=ValueError )
1281
+ verify( ext[0] != "?", "Extension '%s' cannot start with '?' (this symbol indicates a temporary directory)", ext, exception=ValueError )
1269
1282
  return "." + ext
1270
1283
 
1271
1284
  # -- public utilities --
@@ -1302,6 +1315,7 @@ class SubDir(object):
1302
1315
  verify( file[0] != "?", "Key '%s' cannot start with '?' (this symbol indicates the user's directory)", file, exception=ValueError )
1303
1316
 
1304
1317
  ext = self.auto_ext( ext )
1318
+ assert len(ext) == 0 or ext[0]==".", ("Extension error", ext)
1305
1319
  if len(ext) > 0 and file[-len(ext):] != ext:
1306
1320
  return self._path + file + ext
1307
1321
  return self._path + file
@@ -2924,7 +2938,7 @@ class SubDir(object):
2924
2938
 
2925
2939
  You can define certain types as non-functional for *all* functions wrapped
2926
2940
  by :meth:`cdxcore.subdir.SubDir.cache` when construcing
2927
- the :class:`cdccore.cache.CacheController` parameter for in :class:`cdxcore.subdir.SubDir`:
2941
+ the :class:`cdxcore.cache.CacheController` parameter for in :class:`cdxcore.subdir.SubDir`:
2928
2942
 
2929
2943
  .. code-block:: python
2930
2944
 
@@ -2949,7 +2963,7 @@ class SubDir(object):
2949
2963
 
2950
2964
  Key default behaviours of :class:`cdxcore.uniquehash.NamedUniqueHash`:
2951
2965
 
2952
- * The ``NamedUniqueHash`` hashes objects via their ``__dict__`` or ``__slot__`` members.
2966
+ * :class:`cdxcore.uniquehash.NamedUniqueHash` hashes objects via their ``__dict__`` or ``__slot__`` members.
2953
2967
  This can be overwritten for a class by implementing ``__unique_hash__``; see :class:`cdxcore.uniquehash.NamedUniqueHash`.
2954
2968
 
2955
2969
  * Function members of objects or any members starting with '_' are not hashed
@@ -3133,7 +3147,8 @@ class SubDir(object):
3133
3147
  a.x = 2
3134
3148
  _ = a.f(y=1) # 'a' changed: compute f and store result
3135
3149
  b = A(x=2)
3136
- _ = b.f(y=1) # same unique call ID as previous call -> restore result from disk
3150
+ _ = b.f(y=1) # same unique call ID as previous call
3151
+ # -> restore result from disk
3137
3152
 
3138
3153
  **WARNING**
3139
3154
  :class:`cdxcore.uniquehash.UniqueHash` does *not* by default process members of objects or dictionaries
@@ -3154,7 +3169,8 @@ class SubDir(object):
3154
3169
  .. code-block:: python
3155
3170
 
3156
3171
  from cdxcore.subdir import SubDir, version
3157
- cache = SubDir("!/.cache", cache_controller : CacheController(debug_verbose=Context("all")))
3172
+ cache = SubDir("!/.cache", cache_controller =
3173
+ CacheController(debug_verbose=Context("all")))
3158
3174
  cache.delete_all_content() # for illustration
3159
3175
 
3160
3176
  class A(object):
@@ -3229,7 +3245,8 @@ class SubDir(object):
3229
3245
  @cache.cache_class("0.1")
3230
3246
  class A(object):
3231
3247
 
3232
- @cache.cache_init(uid=lambda x, debug: f"A.__init__(x={x})") # <-- 'self' is not passed to the lambda function
3248
+ # NOTE: 'self' is not passed to the lambda function "uid"
3249
+ @cache.cache_init(uid=lambda x, debug: f"A.__init__(x={x})")
3233
3250
  def __init__(self, x, debug):
3234
3251
  if debug:
3235
3252
  print("__init__",x)
@@ -3370,8 +3387,6 @@ class SubDir(object):
3370
3387
  function name. If there is already a parameter ``func_name`` for the function, an error will be raised.
3371
3388
  Use this flag to change the parameter name. Example::
3372
3389
 
3373
- .. code-block:: python
3374
-
3375
3390
  from cdxcore.subdir import SubDir
3376
3391
  cache = SubDir("?/temp")
3377
3392
 
@@ -3455,7 +3470,7 @@ class SubDir(object):
3455
3470
  xy = f( x=1, y=2 )
3456
3471
  uid = f.cache_info.filename
3457
3472
  """
3458
- return CacheCallable(subdir = self,
3473
+ return _CacheCallable(subdir = self,
3459
3474
  version = version,
3460
3475
  dependencies = dependencies,
3461
3476
  label = label,
@@ -3726,7 +3741,7 @@ def _expected_str_fmt_args(fmt: str):
3726
3741
  keywords=kws
3727
3742
  )
3728
3743
 
3729
- class CacheCallable(object):
3744
+ class _CacheCallable(object):
3730
3745
  """
3731
3746
  Wrapper for a cached function.
3732
3747
 
@@ -3857,7 +3872,7 @@ class CacheCallable(object):
3857
3872
  init_cache_callable = getattr(C__init__, "init_cache_callable", None)
3858
3873
  if init_cache_callable is None:
3859
3874
  raise RuntimeError("'{F.__qualname__}': must also decorate __init__")
3860
- assert type(init_cache_callable).__name__ == CacheCallable.__name__, (f"*** Internal error: '{C.__qualname__}': __init__ has wrong type for 'init_cache_callable': {type(init_cache_callable)} ?")
3875
+ assert type(init_cache_callable).__name__ == _CacheCallable.__name__, (f"*** Internal error: '{C.__qualname__}': __init__ has wrong type for 'init_cache_callable': {type(init_cache_callable)} ?")
3861
3876
 
3862
3877
  C__init__.init_cache_callable = None # tell the __init__ wrapper we have processed this information
3863
3878
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cdxcore
3
- Version: 0.1.30
3
+ Version: 0.1.31
4
4
  Summary: Basic Python Tools; upgraded cdxbasics
5
5
  Author-email: Hans Buehler <github@buehler.london>
6
6
  License-Expression: MIT
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "cdxcore"
9
- version = "0.1.30"
9
+ version = "0.1.31"
10
10
  description = "Basic Python Tools; upgraded cdxbasics"
11
11
  authors = [{ name = "Hans Buehler", email = "github@buehler.london" }]
12
12
  readme = "README.md"
@@ -196,15 +196,28 @@ class Test(unittest.TestCase):
196
196
  # wrong version
197
197
 
198
198
  def test_new(self):
199
- subdir = SubDir("my_directory") # relative to current working directory
200
- subdir = SubDir("./my_directory") # relative to current working directory
201
- subdir = SubDir("~/my_directory") # relative to home directory
202
- subdir = SubDir("!/my_directory") # relative to default temp directory
203
-
204
- subdir = SubDir("my_directory", "~") # relative to home directory
205
- subdir = SubDir("my_directory", "!") # relative to default temp directory
206
- subdir = SubDir("my_directory", ".") # relative to current directory
207
- subdir2 = SubDir("my_directory", subdir) # subdir2 is relative to `subdir`
199
+ subdir0 = SubDir("my_directory") # relative to current working directory
200
+ subdir1 = SubDir("./my_directory") # relative to current working directory
201
+ subdir2 = SubDir("~/my_directory") # relative to home directory
202
+ subdir3 = SubDir("!/my_directory") # relative to default temp directory
203
+
204
+ subdir11 = SubDir("my_directory", ".") # relative to home directory
205
+ subdir22 = SubDir("my_directory", "~") # relative to default temp directory
206
+ subdir33 = SubDir("my_directory", "!") # relative to current directory
207
+ subdir44 = SubDir("my_directory", subdir3) # subdir2 is relative to `subdir`
208
+
209
+
210
+ self.assertEqual( subdir0.path, subdir11.path )
211
+ self.assertEqual( subdir1.path, subdir11.path )
212
+ self.assertEqual( subdir2.path, subdir22.path )
213
+ self.assertEqual( subdir3.path, subdir33.path )
214
+ self.assertEqual( subdir3.path + "my_directory/", subdir44.path )
215
+
216
+ subdir1 = SubDir("?/test")
217
+ subdir2 = SubDir("?/test")
218
+
219
+ self.assertNotEqual( subdir1.path, subdir2.path )
220
+ del subdir1, subdir2
208
221
 
209
222
  # extension handling
210
223
 
@@ -218,7 +231,16 @@ class Test(unittest.TestCase):
218
231
  self.assertEqual( subdir.ext, ".json" )
219
232
  subdir = subdir("", fmt=SubDir.PICKLE )
220
233
  self.assertEqual( subdir.ext, ".pck" )
221
-
234
+
235
+ subdir0 = SubDir("!/temp;*.bin")
236
+ subdir1 = SubDir("!/temp", ext="bin")
237
+ subdir2 = SubDir("!/temp", ext=".bin")
238
+ self.assertEqual( subdir0, subdir1 )
239
+ self.assertEqual( subdir0, subdir2 )
240
+
241
+ with self.assertRaises(ValueError):
242
+ subdir = SubDir("!/temp;*.bin", ext="notbin")
243
+
222
244
  # version
223
245
 
224
246
  version = "0.1"
@@ -245,6 +267,37 @@ class Test(unittest.TestCase):
245
267
  test_format( SubDir.BLOSC, True )
246
268
  test_format( SubDir.GZIP, True )
247
269
  test_format( SubDir.JSON_PICKLE )
270
+
271
+ # copy constructor with overwrite
272
+
273
+ d1 = SubDir("?/test_subdir", ext="e1")
274
+ d2 = SubDir(d1)
275
+ self.assertEqual( d1.path, d2.path )
276
+ self.assertEqual( d1.fmt, d2.fmt )
277
+ self.assertEqual( d1.ext, d2.ext )
278
+
279
+ d1 = SubDir("?/test_subdir", ext="e1")
280
+ d2 = SubDir(d1, ext="e2")
281
+ self.assertEqual( d1.path, d2.path )
282
+ self.assertEqual( d1.fmt, d2.fmt )
283
+ self.assertEqual( d1.ext, ".e1" )
284
+ self.assertEqual( d2.ext, ".e2" )
285
+
286
+ d1 = SubDir("?/test_subdir", fmt=SubDir.BLOSC )
287
+ d2 = SubDir(d1, fmt=SubDir.GZIP )
288
+ self.assertEqual( d1.path, d2.path )
289
+ self.assertEqual( d1.fmt, SubDir.BLOSC )
290
+ self.assertEqual( d2.fmt, SubDir.GZIP )
291
+ self.assertEqual( d1.ext, ".zbsc" )
292
+ self.assertEqual( d2.ext, ".pgz" )
293
+
294
+ d1 = SubDir("?/test_subdir", ext="tmp", fmt=SubDir.BLOSC )
295
+ d2 = SubDir(d1, fmt=SubDir.GZIP )
296
+ self.assertEqual( d1.path, d2.path )
297
+ self.assertEqual( d1.fmt, SubDir.BLOSC )
298
+ self.assertEqual( d2.fmt, SubDir.GZIP )
299
+ self.assertEqual( d1.ext, ".tmp" )
300
+ self.assertEqual( d2.ext, d1.ext )
248
301
 
249
302
  def test_cache_mode(self):
250
303
 
@@ -288,12 +341,19 @@ class C(object):
288
341
  def f(self, y):
289
342
  return self.x*y
290
343
 
291
- class Test(unittest.TestCase):
344
+ class Test2(unittest.TestCase):
292
345
 
293
346
  def test_cache( self ):
294
347
 
348
+ sub = SubDir("!/xx", ext="ABC")
349
+ self.assertEqual( sub.ext, ".ABC")
350
+
295
351
  sub = VersionedCacheRoot("?/subdir_cache_test", exclude_arg_types=[A] )
296
-
352
+
353
+ subsub = sub("sub", ext="tst")
354
+ x = subsub.full_file_name( "hallo")
355
+ self.assertEqual( x[-9:], "hallo.tst" )
356
+
297
357
  @sub.cache("1.0")
298
358
  def f(x):
299
359
  return x
@@ -364,7 +424,7 @@ class Test(unittest.TestCase):
364
424
  return G(x)*F(x)
365
425
 
366
426
  _ = H(2.)
367
- self.assertEqual( H.cache_info.version, "H { Test.test_cache.<locals>.F: F, Test.test_cache.<loc 3fabc694" )
427
+ self.assertEqual( H.cache_info.version, "H { Test2.test_cache.<locals>.F: F, Test2.test_cache.<l 19b17778" )
368
428
  self.assertEqual( H.cache_info.version, H.version.unique_id64 )
369
429
 
370
430
  # decorate live member functions
@@ -406,8 +466,7 @@ class Test(unittest.TestCase):
406
466
  if debug:
407
467
  print(f"h(x={x},y={y})")
408
468
  return x*y
409
- h2(1,1)
410
- # %%
469
+ h2(1,1)
411
470
  self.assertEqual( h2.cache_info.filename, "h2(1,1)________________________________ 46a70d67" )
412
471
 
413
472
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes