large-image-source-test 1.35.1__tar.gz → 1.35.1.dev2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: large-image-source-test
3
- Version: 1.35.1
3
+ Version: 1.35.1.dev2
4
4
  Summary: A fractal test tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.14
17
17
  Requires-Python: >=3.10
18
18
  Description-Content-Type: text/x-rst
19
19
  License-File: LICENSE
20
- Requires-Dist: large-image>=1.35.1
20
+ Requires-Dist: large-image>=1.35.1.dev2
21
21
  Dynamic: author
22
22
  Dynamic: author-email
23
23
  Dynamic: classifier
@@ -49,7 +49,7 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
49
49
  def __init__(self, ignored_path=None, minLevel=0, maxLevel=9,
50
50
  tileWidth=256, tileHeight=256, sizeX=None, sizeY=None,
51
51
  fractal=False, frames=None, monochrome=False, bands=None,
52
- failBelowMinLevel=True, **kwargs):
52
+ **kwargs):
53
53
  """
54
54
  Initialize the tile class. See the base class for other available
55
55
  parameters.
@@ -77,11 +77,6 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
77
77
  the specified ranges. The internal dtype with be uint8, uint16, or
78
78
  float depending on the union of the specified ranges. If no ranges
79
79
  are specified at all, it is the same as 0-255.
80
- :param failBelowMinLevel: if True and a tile is requested outside of
81
- the minLevel and maxLevel, throw an error. If false, interpolate
82
- lower level tiles. Throwing is useful when testing how viewers
83
- handle missing levels; interpolating is useful for testing
84
- interpolation functions.
85
80
  """
86
81
  if not kwargs.get('encoding'):
87
82
  kwargs = kwargs.copy()
@@ -105,10 +100,8 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
105
100
  self.sizeX / self.tileWidth, self.sizeY / self.tileHeight)))))
106
101
  self.minLevel = min(self.minLevel, self.maxLevel)
107
102
  self.monochrome = bool(monochrome)
108
- self._failBelowMinLevel = bool(failBelowMinLevel)
109
103
  self._bands = None
110
104
  self._dtype = np.uint8
111
- self._bandCount = 1 if self.monochrome else 3
112
105
  if bands:
113
106
  bands = [re.match(
114
107
  r'^(?P<key>[^=]+)(|=(?P<low>[+-]?((\d+(|\.\d*)))|(\.\d+))-(?P<high>[+-]?((\d+(|\.\d*))|(\.\d+))))$', # noqa
@@ -133,7 +126,6 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
133
126
  self._dtype = np.dtype(float)
134
127
  elif low >= 256 or high >= 256:
135
128
  self._dtype = np.uint16
136
- self._bandCount = len(self._bands) if not self.monochrome else 1
137
129
  # Used for reporting tile information
138
130
  self.levels = self.maxLevel + 1
139
131
  if frames:
@@ -274,65 +266,52 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
274
266
  )
275
267
  return image
276
268
 
277
- def _nonemptyLevelsList(self, frame=0):
278
- """
279
- Return a list of one value per level where the value is None if the
280
- level does not exist in the file and any other value if it does.
281
-
282
- :param frame: the frame number.
283
- :returns: a list of levels length.
284
- """
285
- return [True if self.minLevel <= idx <= self.maxLevel else None
286
- for idx in range(self.levels)]
287
-
288
269
  @methodcache()
289
270
  def getTile(self, x, y, z, *args, **kwargs):
290
271
  frame = self._getFrame(**kwargs)
291
272
  self._xyzInRange(x, y, z, frame, len(self._frames) if hasattr(self, '_frames') else None)
292
- if z < self.minLevel and not self._failBelowMinLevel:
293
- image, format = self._getTileFromEmptyLevel(x, y, z, **kwargs)
294
- else:
295
- if not (self.minLevel <= z <= self.maxLevel):
296
- msg = 'z layer does not exist'
297
- raise TileSourceError(msg)
298
- _counters['tiles'] += 1
299
-
300
- xFraction = (x + 0.5) * self.tileWidth * 2 ** (self.levels - 1 - z) / self.sizeX
301
- yFraction = (y + 0.5) * self.tileHeight * 2 ** (self.levels - 1 - z) / self.sizeY
302
- fFraction = yFraction
303
- if hasattr(self, '_frames'):
304
- fFraction = float(frame) / (len(self._frames) - 1)
305
-
306
- backgroundColor = colorsys.hsv_to_rgb(
307
- h=xFraction,
308
- s=(0.3 + (0.7 * fFraction)),
309
- v=(0.3 + (0.7 * yFraction)),
310
- )
311
- rgbColor = tuple(int(val * 255) for val in backgroundColor)
312
273
 
313
- if not self._bands or len(self._bands) == (1 if self.monochrome else 3):
314
- image = self._tileImage(rgbColor, x, y, z, frame)
315
- if self.monochrome:
316
- image = image.convert('L')
317
- format = TILE_FORMAT_PIL
318
- else:
319
- image = np.zeros(
320
- (self.tileHeight, self.tileWidth, len(self._bands)), dtype=self._dtype)
321
- for bandnum, band in enumerate(self._bands):
322
- bandimg = self._tileImage(rgbColor, x, y, z, frame, band, bandnum)
323
- if self.monochrome or band.upper() in {'grey', 'gray', 'alpha'}:
324
- bandimg = bandimg.convert('L')
325
- bandimg = _imageToNumpy(bandimg)[0]
326
- if (self._dtype != np.uint8 or
327
- self._bands[band]['low'] != 0 or
328
- self._bands[band]['high'] != 255):
329
- bandimg = bandimg.astype(float)
330
- bandimg = (bandimg / 255) * (
331
- self._bands[band]['high'] - self._bands[band]['low']
332
- ) + self._bands[band]['low']
333
- bandimg = bandimg.astype(self._dtype)
334
- image[:, :, bandnum] = bandimg[:, :, bandnum % bandimg.shape[2]]
335
- format = TILE_FORMAT_NUMPY
274
+ if not (self.minLevel <= z <= self.maxLevel):
275
+ msg = 'z layer does not exist'
276
+ raise TileSourceError(msg)
277
+ _counters['tiles'] += 1
278
+
279
+ xFraction = (x + 0.5) * self.tileWidth * 2 ** (self.levels - 1 - z) / self.sizeX
280
+ yFraction = (y + 0.5) * self.tileHeight * 2 ** (self.levels - 1 - z) / self.sizeY
281
+ fFraction = yFraction
282
+ if hasattr(self, '_frames'):
283
+ fFraction = float(frame) / (len(self._frames) - 1)
284
+
285
+ backgroundColor = colorsys.hsv_to_rgb(
286
+ h=xFraction,
287
+ s=(0.3 + (0.7 * fFraction)),
288
+ v=(0.3 + (0.7 * yFraction)),
289
+ )
290
+ rgbColor = tuple(int(val * 255) for val in backgroundColor)
291
+
292
+ if not self._bands or len(self._bands) == (1 if self.monochrome else 3):
293
+ image = self._tileImage(rgbColor, x, y, z, frame)
294
+ if self.monochrome:
295
+ image = image.convert('L')
296
+ format = TILE_FORMAT_PIL
297
+ else:
298
+ image = np.zeros(
299
+ (self.tileHeight, self.tileWidth, len(self._bands)), dtype=self._dtype)
300
+ for bandnum, band in enumerate(self._bands):
301
+ bandimg = self._tileImage(rgbColor, x, y, z, frame, band, bandnum)
302
+ if self.monochrome or band.upper() in {'grey', 'gray', 'alpha'}:
303
+ bandimg = bandimg.convert('L')
304
+ bandimg = _imageToNumpy(bandimg)[0]
305
+ if (self._dtype != np.uint8 or
306
+ self._bands[band]['low'] != 0 or
307
+ self._bands[band]['high'] != 255):
308
+ bandimg = bandimg.astype(float)
309
+ bandimg = (bandimg / 255) * (
310
+ self._bands[band]['high'] - self._bands[band]['low']
311
+ ) + self._bands[band]['low']
312
+ bandimg = bandimg.astype(self._dtype)
313
+ image[:, :, bandnum] = bandimg[:, :, bandnum % bandimg.shape[2]]
314
+ format = TILE_FORMAT_NUMPY
336
315
  return self._outputTile(image, format, x, y, z, **kwargs)
337
316
 
338
317
  @staticmethod
@@ -344,7 +323,7 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
344
323
  kwargs.get('tileWidth'), kwargs.get('tileHeight'),
345
324
  kwargs.get('fractal'), kwargs.get('sizeX'), kwargs.get('sizeY'),
346
325
  kwargs.get('frames'), kwargs.get('monochrome'),
347
- kwargs.get('bands'), kwargs.get('failBelowMinLevel'),
326
+ kwargs.get('bands'),
348
327
  )
349
328
 
350
329
  def getState(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: large-image-source-test
3
- Version: 1.35.1
3
+ Version: 1.35.1.dev2
4
4
  Summary: A fractal test tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.14
17
17
  Requires-Python: >=3.10
18
18
  Description-Content-Type: text/x-rst
19
19
  License-File: LICENSE
20
- Requires-Dist: large-image>=1.35.1
20
+ Requires-Dist: large-image>=1.35.1.dev2
21
21
  Dynamic: author
22
22
  Dynamic: author-email
23
23
  Dynamic: classifier