uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
83b5ca5e8bb389663fc9b7a4 | train | function | def generate_samples_shifted(samples, shape, shift):
plane_points = []
for i in samples:
point = shape(i)
tangent = derivative(shape, i)
tangent = np.array([-tangent[1], tangent[0]])
point += tangent*(shift/2)
plane_points += [point]
return np.array(plane_points)
| def generate_samples_shifted(samples, shape, shift):
| plane_points = []
for i in samples:
point = shape(i)
tangent = derivative(shape, i)
tangent = np.array([-tangent[1], tangent[0]])
point += tangent*(shift/2)
plane_points += [point]
return np.array(plane_points)
| points += [point]
ex = derivative(shape, i)
ez = np.array([ex[1], -ex[0]])
tangents += [np.array([ez, ex])]
return np.array(points), np.array(tangents)
def generate_samples_shifted(samples, shape, shift):
| 64 | 64 | 75 | 11 | 53 | ragarciafran/OpenSfM | opensfm/synthetic_data/synthetic_generator.py | Python | generate_samples_shifted | generate_samples_shifted | 44 | 52 | 44 | 44 | 22010e1ce2f59066339d73bc216eae9bcaa2b63f | bigcode/the-stack | train |
451234dc4e3d0ccbb9435db0 | train | function | def generate_cameras(samples, shape, height):
positions, rotations = generate_samples_and_local_frame(samples, shape)
positions = np.insert(positions, 2, values=height, axis=1)
rotations = np.insert(rotations, 2, values=0, axis=2)
rotations = np.insert(rotations, 1, values=np.array([0, 0, -1]), axis=1)
... | def generate_cameras(samples, shape, height):
| positions, rotations = generate_samples_and_local_frame(samples, shape)
positions = np.insert(positions, 2, values=height, axis=1)
rotations = np.insert(rotations, 2, values=0, axis=2)
rotations = np.insert(rotations, 1, values=np.array([0, 0, -1]), axis=1)
return positions, rotations
| xy1, xy2), axis=0)
def generate_street(samples, shape, height, width):
walls = generate_xy_planes(samples, shape, height, width)
floor = generate_z_plane(samples, shape, width)
return walls, floor
def generate_cameras(samples, shape, height):
| 64 | 64 | 95 | 10 | 53 | ragarciafran/OpenSfM | opensfm/synthetic_data/synthetic_generator.py | Python | generate_cameras | generate_cameras | 84 | 89 | 84 | 84 | 5a09e13e1adbe466bf8da53b1abe9b792efb99af | bigcode/the-stack | train |
2e6801e38d57d69fe8d92342 | train | function | def generate_samples_and_local_frame(samples, shape):
points = []
tangents = []
for i in samples:
point = shape(i)
points += [point]
ex = derivative(shape, i)
ez = np.array([ex[1], -ex[0]])
tangents += [np.array([ez, ex])]
return np.array(points), np.array(tangent... | def generate_samples_and_local_frame(samples, shape):
| points = []
tangents = []
for i in samples:
point = shape(i)
points += [point]
ex = derivative(shape, i)
ez = np.array([ex[1], -ex[0]])
tangents += [np.array([ez, ex])]
return np.array(points), np.array(tangents)
| (start, length, interval, interval_noise):
samples = np.linspace(start/length, 1, num=int(length/interval))
samples += np.random.normal(0.0,
float(interval_noise)/float(length),
samples.shape)
return samples
def generate_samples_and_local_frame... | 64 | 64 | 84 | 10 | 53 | ragarciafran/OpenSfM | opensfm/synthetic_data/synthetic_generator.py | Python | generate_samples_and_local_frame | generate_samples_and_local_frame | 32 | 41 | 32 | 32 | 69c7f897fad98a5260914403367c127405d507d5 | bigcode/the-stack | train |
d956248dbfe1c788402696f4 | train | function | def generate_street(samples, shape, height, width):
walls = generate_xy_planes(samples, shape, height, width)
floor = generate_z_plane(samples, shape, width)
return walls, floor
| def generate_street(samples, shape, height, width):
| walls = generate_xy_planes(samples, shape, height, width)
floor = generate_z_plane(samples, shape, width)
return walls, floor
| , axis=1)
xy2 = np.insert(xy2, 2, values=np.random.rand(
xy2.shape[0])*z_size, axis=1)
return np.concatenate((xy1, xy2), axis=0)
def generate_street(samples, shape, height, width):
| 64 | 64 | 44 | 12 | 52 | ragarciafran/OpenSfM | opensfm/synthetic_data/synthetic_generator.py | Python | generate_street | generate_street | 78 | 81 | 78 | 78 | a725f720026467e634801944d2315c2cd749d9c6 | bigcode/the-stack | train |
b6991f6097abd9af13e6288a | train | function | def _check_depth(point, shot, maximum_depth):
return shot.pose.transform(point.coordinates)[2] < maximum_depth
| def _check_depth(point, shot, maximum_depth):
| return shot.pose.transform(point.coordinates)[2] < maximum_depth
| _key), obs)
features[shot_index] = np.array(projections_inside)
colors[shot_index] = np.array(colors_inside)
descriptors[shot_index] = np.array(descriptors_inside)
return features, descriptors, colors, tracks_manager
def _check_depth(point, shot, maximum_depth):
| 64 | 64 | 25 | 11 | 52 | ragarciafran/OpenSfM | opensfm/synthetic_data/synthetic_generator.py | Python | _check_depth | _check_depth | 260 | 261 | 260 | 260 | 081d00f80fa7e4d67f8c2986cd604bb65496cfc4 | bigcode/the-stack | train |
e0b3075f97899a715e1775d2 | train | class | class TrustBoundaryDAO(CairisDAO):
def __init__(self, session_id):
"""
:raise CairisHTTPError:
"""
CairisDAO.__init__(self, session_id)
def get_trust_boundaries(self, constraint_id = -1):
"""
:rtype: dict[str,TrustBoundary]
:return
:raise ARMHTTPError:
"""
try:
tbs = ... | class TrustBoundaryDAO(CairisDAO):
| def __init__(self, session_id):
"""
:raise CairisHTTPError:
"""
CairisDAO.__init__(self, session_id)
def get_trust_boundaries(self, constraint_id = -1):
"""
:rtype: dict[str,TrustBoundary]
:return
:raise ARMHTTPError:
"""
try:
tbs = self.db_proxy.getTrustBoundaries(con... | "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITH... | 256 | 256 | 1,054 | 9 | 247 | khanghuynhle/cairis | cairis/data/TrustBoundaryDAO.py | Python | TrustBoundaryDAO | TrustBoundaryDAO | 31 | 176 | 31 | 32 | eb06afdf7398b87f23ef27fa72f6f48ee36efa22 | bigcode/the-stack | train |
0d3ec3bdf370f5f80a40e0a8 | train | class | class Ui_MainWindow(object):
def closeEvent(self, event):
event.accept()
print("jiaisjindas")
def FileUI(self, MainWindow):
# super().__init__()
MainWindow.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False)
MainWindow.setObjectName("MainWindow")
MainWindow.res... | class Ui_MainWindow(object):
| def closeEvent(self, event):
event.accept()
print("jiaisjindas")
def FileUI(self, MainWindow):
# super().__init__()
MainWindow.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False)
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1200, 700)
MainWi... | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'FileScreen.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, Q... | 123 | 256 | 1,267 | 6 | 117 | shahzaibk23/Trash-Visualiser | src/GUI/$RA0AJ5B/FileScreen.py | Python | Ui_MainWindow | Ui_MainWindow | 15 | 115 | 15 | 15 | ccff9831f36ca984d01e8a12ad078078c125b11e | bigcode/the-stack | train |
703956ca47c9096357fdb3e6 | train | function | def get_dataloader(args):
args.nclass = ClassDict.len() + (args.nsilence != 0)
splits = ['train', 'val', 'test']
transform, s_transform = get_transform(args)
dataset = utils.read_splits(args.data_root)
if args.debug != -1:
dataset = {split: dataset[split][:args.debug] for split in splits}... | def get_dataloader(args):
| args.nclass = ClassDict.len() + (args.nsilence != 0)
splits = ['train', 'val', 'test']
transform, s_transform = get_transform(args)
dataset = utils.read_splits(args.data_root)
if args.debug != -1:
dataset = {split: dataset[split][:args.debug] for split in splits}
dataset = {split: AS... | (args.mask_time),
torchaudio.transforms.TimeMasking(args.mask_time),
torchaudio.transforms.FrequencyMasking(args.mask_freq),
])
return {'train': train_transform, 'val': test_trasform, 'test': test_trasform}, silence_transform
def get_dataloader(args):
| 64 | 64 | 196 | 6 | 57 | fresher96/arabic-speech-commands | src/data.py | Python | get_dataloader | get_dataloader | 142 | 163 | 142 | 142 | d7a7c4ab94eb98f17159cdfc326e372b0ee9a4ae | bigcode/the-stack | train |
54ebae377d38efe726f9475f | train | function | def get_transform(args):
melkwargs = {
'n_mels': args.nfilt,
'n_fft': args.nfft,
'win_length': int(args.winlen * args.signal_sr),
'hop_length': int(args.winstep * args.signal_sr),
}
args.signal_samples = int(args.signal_sr * args.signal_len)
args.signal_width = 1 + args.... | def get_transform(args):
| melkwargs = {
'n_mels': args.nfilt,
'n_fft': args.nfft,
'win_length': int(args.winlen * args.signal_sr),
'hop_length': int(args.winstep * args.signal_sr),
}
args.signal_samples = int(args.signal_sr * args.signal_len)
args.signal_width = 1 + args.signal_samples // melkwarg... | _samples)
silence = signal[start_index : start_index + self.signal_samples]
tensor = self.s_transform(silence)
return tensor
def load_path(self, path):
x, sr = torchaudio.load(path)
x = x.squeeze()
return x
def load_audio(self, idx):
x = self.cache[idx]... | 157 | 157 | 526 | 5 | 151 | fresher96/arabic-speech-commands | src/data.py | Python | get_transform | get_transform | 79 | 139 | 79 | 80 | d4c2fb2b8a14268a0456a92a73f0ee4925b5755a | bigcode/the-stack | train |
b18e20b8e52c53289bccf3cd | train | class | class ASCDataset(torch.utils.data.Dataset):
def __init__(self, data_root, dataset, transform, s_transform, nsilence, signal_samples, signal_sr, noise_pkg):
super().__init__()
self.transform = transform
self.s_transform = s_transform
self.data_root = data_root
self.signal_sa... | class ASCDataset(torch.utils.data.Dataset):
| def __init__(self, data_root, dataset, transform, s_transform, nsilence, signal_samples, signal_sr, noise_pkg):
super().__init__()
self.transform = transform
self.s_transform = s_transform
self.data_root = data_root
self.signal_samples = signal_samples
self.signal_sr... | import torch
import numpy as np
import os
import torchaudio
from src import utils
from src import transforms
from src.ClassDict import ClassDict
import random
class ASCDataset(torch.utils.data.Dataset):
| 46 | 150 | 500 | 9 | 36 | fresher96/arabic-speech-commands | src/data.py | Python | ASCDataset | ASCDataset | 13 | 76 | 13 | 14 | da856b36409317249aaabe254eb26ca3bc2d5b25 | bigcode/the-stack | train |
531aedf63d80a3e930a9d144 | train | function | @app.route('/predict', methods=['POST','GET'])
def predict():
ME = float(request.form['ME'])
PE = float(request.form['PE'])
Budg = float(request.form['Budg'])
ML = float(request.form['ML'])
ACT_r = float(request.form['ACT_r'])
ACS_r = float(request.form['ACS_r'])
DR = float(request.f... | @app.route('/predict', methods=['POST','GET'])
def predict():
| ME = float(request.form['ME'])
PE = float(request.form['PE'])
Budg = float(request.form['Budg'])
ML = float(request.form['ML'])
ACT_r = float(request.form['ACT_r'])
ACS_r = float(request.form['ACS_r'])
DR = float(request.form['DR'])
PR = float(request.form['PR'])
CR = float(r... | from flask import Flask,render_template,request
import pickle
app = Flask(__name__,template_folder='template')
#load the model
model = pickle.load(open('moviecollectionmodel.pkl','rb'))
@app.route('/')
def home():
return render_template('s.html',**locals())
@app.route('/predict', methods=['POST','GE... | 76 | 99 | 331 | 14 | 62 | YashwantSaiarjun/Movie-Collection-Prediction-System | box-office-collection/deploy.py | Python | predict | predict | 14 | 51 | 14 | 15 | e5dd4bb945e78ff11f812d2ac66c83b9fbf2f9c3 | bigcode/the-stack | train |
25ddaae8f39367ac87736c84 | train | function | @app.route('/')
def home():
return render_template('s.html',**locals())
| @app.route('/')
def home():
| return render_template('s.html',**locals())
| from flask import Flask,render_template,request
import pickle
app = Flask(__name__,template_folder='template')
#load the model
model = pickle.load(open('moviecollectionmodel.pkl','rb'))
@app.route('/')
def home():
| 50 | 64 | 18 | 7 | 43 | YashwantSaiarjun/Movie-Collection-Prediction-System | box-office-collection/deploy.py | Python | home | home | 10 | 12 | 10 | 11 | 184f36f832ad729aacc2fff368d556ca020be999 | bigcode/the-stack | train |
e86ea8159d380910b209f905 | train | class | class WorkCar(Car):
def show_speed(self):
super().show_speed()
if self.speed > 40:
print('Car ', self.name, ' color ', self.color, ' is_police', self.is_police, ' BREAKS SPEED LIMIT!')
| class WorkCar(Car):
| def show_speed(self):
super().show_speed()
if self.speed > 40:
print('Car ', self.name, ' color ', self.color, ' is_police', self.is_police, ' BREAKS SPEED LIMIT!')
| def show_speed(self):
super().show_speed()
if self.speed > 60:
print('Car ', self.name, ' color ', self.color, ' is_police', self.is_police, ' BREAKS SPEED LIMIT!')
class SportCar(Car):
pass
class WorkCar(Car):
| 64 | 64 | 55 | 5 | 58 | alexartwww/geekbrains | lesson_06/04.py | Python | WorkCar | WorkCar | 47 | 51 | 47 | 47 | 93a63ca13a11fb977b47b6ee4c8f74e971cf9e2e | bigcode/the-stack | train |
9405ac35051a683ba2d42a3f | train | class | class SportCar(Car):
pass
| class SportCar(Car):
| pass
| self.speed)
class TownCar(Car):
def show_speed(self):
super().show_speed()
if self.speed > 60:
print('Car ', self.name, ' color ', self.color, ' is_police', self.is_police, ' BREAKS SPEED LIMIT!')
class SportCar(Car):
| 63 | 64 | 8 | 5 | 59 | alexartwww/geekbrains | lesson_06/04.py | Python | SportCar | SportCar | 43 | 44 | 43 | 43 | 0c35bb7d188a959efa0447fa9b40219fd54e8993 | bigcode/the-stack | train |
b946564fb4a999efde64a01c | train | class | class PoliceCar(Car):
def __init__(self, name, color, speed):
super().__init__(name, color, speed)
self.is_police = True
| class PoliceCar(Car):
| def __init__(self, name, color, speed):
super().__init__(name, color, speed)
self.is_police = True
| pass
class WorkCar(Car):
def show_speed(self):
super().show_speed()
if self.speed > 40:
print('Car ', self.name, ' color ', self.color, ' is_police', self.is_police, ' BREAKS SPEED LIMIT!')
class PoliceCar(Car):
| 63 | 64 | 37 | 5 | 59 | alexartwww/geekbrains | lesson_06/04.py | Python | PoliceCar | PoliceCar | 54 | 57 | 54 | 54 | 3629583f13fbb9207859c32120aa39e277bbd524 | bigcode/the-stack | train |
a1ebb6f5485090a9113559a4 | train | class | class Car:
def __init__(self, name, color, speed):
self.name = name
self.color = color
self.speed = speed
self.is_police = False
def go(self):
print('Car ', self.name, ' color ', self.color, ' is_police', self.is_police, ' is going now')
def stop(self):
prin... | class Car:
| def __init__(self, name, color, speed):
self.name = name
self.color = color
self.speed = speed
self.is_police = False
def go(self):
print('Car ', self.name, ' color ', self.color, ' is_police', self.is_police, ' is going now')
def stop(self):
print('Car ', s... | 40 (WorkCar) должно выводиться сообщение
о превышении скорости.
Создайте экземпляры классов, передайте значения атрибутов. Выполните доступ
к атрибутам, выведите результат. Выполните вызов методов и также покажите результат.
'''
class Car:
| 63 | 64 | 187 | 3 | 60 | alexartwww/geekbrains | lesson_06/04.py | Python | Car | Car | 15 | 33 | 15 | 15 | ea4c4887f0dfc63a4c60c4b770f3db2d838f2951 | bigcode/the-stack | train |
ae07b222afab7a03751d11f3 | train | class | class TownCar(Car):
def show_speed(self):
super().show_speed()
if self.speed > 60:
print('Car ', self.name, ' color ', self.color, ' is_police', self.is_police, ' BREAKS SPEED LIMIT!')
| class TownCar(Car):
| def show_speed(self):
super().show_speed()
if self.speed > 60:
print('Car ', self.name, ' color ', self.color, ' is_police', self.is_police, ' BREAKS SPEED LIMIT!')
| .color, ' is_police', self.is_police, ' turns on ', direction,
' direction')
def show_speed(self):
print('Car ', self.name, ' color ', self.color, ' is_police', self.is_police, ' speed = ', self.speed)
class TownCar(Car):
| 64 | 64 | 55 | 5 | 59 | alexartwww/geekbrains | lesson_06/04.py | Python | TownCar | TownCar | 36 | 40 | 36 | 36 | 1feb157acd3dc21066b91f73830f2be2ac4ec844 | bigcode/the-stack | train |
5088099839f18b9986f3167f | train | class | class GameSerializer(serializers.Serializer):
id = serializers.IntegerField(read_only=True)
name = serializers.CharField(max_length=255)
max_players = serializers.IntegerField()
description = serializers.CharField(style={'base_template': 'textarea.html'})
#img = serializers.ImageField(upload_to='gam... | class GameSerializer(serializers.Serializer):
| id = serializers.IntegerField(read_only=True)
name = serializers.CharField(max_length=255)
max_players = serializers.IntegerField()
description = serializers.CharField(style={'base_template': 'textarea.html'})
#img = serializers.ImageField(upload_to='games/', allow_blank=True)
def create(self, ... | from rest_framework import serializers
from .models import Game
class GameSerializer(serializers.Serializer):
| 18 | 64 | 197 | 6 | 11 | juliusz-musik/gamerent | gamerent/games/serializers.py | Python | GameSerializer | GameSerializer | 5 | 27 | 5 | 5 | 94eaec307969cb457c9420282793418995ec2f71 | bigcode/the-stack | train |
1e058f73feec08a4fa08885a | train | function | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
@pytest.mark.parametrize('mode', ['gray', 'rgb', 'planar'])
@pytest.mark.parametrize('tile', [False, True])
@pytest.mark.parametrize(
'dtype', ['u1', 'u2', 'u4', 'i1', 'i2', 'i4', 'f2', 'f4', 'f8']
)
@pytest.mark.parametrize('byteorder', ['>', '<'])
def test_write_pre... | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
@pytest.mark.parametrize('mode', ['gray', 'rgb', 'planar'])
@pytest.mark.parametrize('tile', [False, True])
@pytest.mark.parametrize(
'dtype', ['u1', 'u2', 'u4', 'i1', 'i2', 'i4', 'f2', 'f4', 'f8']
)
@pytest.mark.parametrize('byteorder', ['>', '<'])
def test_write_pre... | """Test predictors."""
tile = (32, 32) if tile else None
f4 = imread(public_file('tifffile/gray.f4.tif'))
if mode == 'rgb':
photometric = RGB
planarconfig = CONTIG
data = numpy.empty((83, 111, 3), 'f4')
data[..., 0] = f4
data[..., 1] = f4[::-1]
data[..., 2... | _decode_method(page)
assert__str__(tif)
if (
imagecodecs.TIFF
and codec not in ('png', 'jpegxr', 'jpeg2000', 'jpegxl')
and mode != 'planar'
):
im = imagecodecs.imread(fname, index=None)
# if codec == 'jpeg':
# # tiff... | 222 | 222 | 742 | 110 | 112 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_predictor | test_write_predictor | 9,680 | 9,763 | 9,680 | 9,687 | 254ad1aeac05519b9acb369d55e2461ce58e75cd | bigcode/the-stack | train |
f8dcb53c33e380596f39e628 | train | function | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_incomplete_tile_contig():
"""Test read PackBits compressed incomplete tile, contig RGB."""
fname = public_file('GDAL/contig_tiled.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '>'
assert len(tif.pages) ... | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_incomplete_tile_contig():
| """Test read PackBits compressed incomplete tile, contig RGB."""
fname = public_file('GDAL/contig_tiled.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '>'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# assert page properties
page = tif.pages[0]
... | assert data.shape == (200, 256, 4)
assert data.dtype == numpy.uint8
assert tuple(data[65, 139, :]) == (43, 34, 17, 91)
assert_aszarr_method(tif, data)
assert_decode_method(page)
assert__str__(tif)
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_incom... | 99 | 99 | 332 | 27 | 72 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_incomplete_tile_contig | test_read_incomplete_tile_contig | 4,349 | 4,380 | 4,349 | 4,350 | 1e88a906f1c42cf6758cfde5d6b1dd9987363e39 | bigcode/the-stack | train |
e859d69b44ffce5ce2b147ff | train | function | def test_func_matlabstr2py():
"""Test matlabstr2py function."""
assert matlabstr2py('1') == 1
assert matlabstr2py(
"['x y z' true false; 1 2.0 -3e4; Inf Inf @class;[1;2;3][1 2] 3]"
) == [
['x y z', True, False],
[1, 2.0, -30000.0],
[float('inf'), float('inf'), '@class'],
... | def test_func_matlabstr2py():
| """Test matlabstr2py function."""
assert matlabstr2py('1') == 1
assert matlabstr2py(
"['x y z' true false; 1 2.0 -3e4; Inf Inf @class;[1;2;3][1 2] 3]"
) == [
['x y z', True, False],
[1, 2.0, -30000.0],
[float('inf'), float('inf'), '@class'],
[[[1], [2], [3]], [1, ... | if
# Flat_field: (nil)
# Trim_file: p300k0101_E8048_T4024_vrf_m0p15.bin
# Beam_xy (243.12, 309.12) pixels
# Image_path: /ramdisk/
Invalid
# Unknown 1 2 3 4 5""".strip().replace(
' ', ''
)
attr = pilatus_description_metadata(header)
asse... | 211 | 211 | 705 | 9 | 202 | bioturing/tifffile | tests/test_tifffile.py | Python | test_func_matlabstr2py | test_func_matlabstr2py | 2,773 | 2,843 | 2,773 | 2,773 | 5f1d77799380f92cd7c30f8e0d6a836bac5ac362 | bigcode/the-stack | train |
5f5bc9879c14d047a71930af | train | function | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_read_ome_multi_channel_z_series():
"""Test read OME multi-channel volume."""
# 3D (5 focal planes, 3 channels)
fname = public_file(
'OME/bioformats-artificial/multi-channel-z-series.ome.tiff'
)
with TiffFile(fname) as tif:
asse... | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_read_ome_multi_channel_z_series():
| """Test read OME multi-channel volume."""
# 3D (5 focal planes, 3 channels)
fname = public_file(
'OME/bioformats-artificial/multi-channel-z-series.ome.tiff'
)
with TiffFile(fname) as tif:
assert tif.is_ome
assert tif.byteorder == '>'
assert len(tif.pages) == 15
... | ) == 'TCZYXS'
assert not series.is_multifile
# assert data
data = tif.asarray()
assert isinstance(data, numpy.ndarray)
assert data.shape == (5, 167, 439)
assert data.dtype == numpy.int8
assert data[4, 158, 428] == 91
assert_aszarr_method(tif, data)
... | 116 | 116 | 387 | 23 | 93 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_ome_multi_channel_z_series | test_read_ome_multi_channel_z_series | 7,169 | 7,205 | 7,169 | 7,170 | 7295a40ce686cb5e1e10b4db8ce181c72a7c90b8 | bigcode/the-stack | train |
bbedcc284edd38d9efd9ed77 | train | function | def test_write_extrasamples_contig_rgb2():
"""Test write contig RGB with large number of extrasamples."""
data = random_data(numpy.uint8, (3, 219, 301))
with TempFileName('extrasamples_contig_rgb2') as fname:
imwrite(fname, data, photometric=RGB, planarconfig=CONTIG)
assert_valid_tiff(fname)... | def test_write_extrasamples_contig_rgb2():
| """Test write contig RGB with large number of extrasamples."""
data = random_data(numpy.uint8, (3, 219, 301))
with TempFileName('extrasamples_contig_rgb2') as fname:
imwrite(fname, data, photometric=RGB, planarconfig=CONTIG)
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
... | (tif.pages) == 1
page = tif.pages[0]
assert page.is_contiguous
assert page.planarconfig == SEPARATE
assert page.photometric == RGB
assert page.imagewidth == 301
assert page.imagelength == 219
assert page.samplesperpixel == 3
... | 115 | 115 | 384 | 11 | 104 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_extrasamples_contig_rgb2 | test_write_extrasamples_contig_rgb2 | 11,539 | 11,575 | 11,539 | 11,539 | 404f9544bae36b234dc6ee04307b0a56444a57dc | bigcode/the-stack | train |
4f219328e2ac0eda2c98bf56 | train | function | def test_issue_version_mismatch():
"""Test 'tifffile.__version__' matches docstrings."""
ver = ':Version: ' + tifffile.__version__
assert ver in __doc__
assert ver in tifffile.__doc__
| def test_issue_version_mismatch():
| """Test 'tifffile.__version__' matches docstrings."""
ver = ':Version: ' + tifffile.__version__
assert ver in __doc__
assert ver in tifffile.__doc__
| pass
numpy.set_printoptions(suppress=True, precision=5)
###############################################################################
# Tests for specific issues
def test_issue_star_import():
"""Test from tifffile import *."""
assert STAR_IMPORTED is not None
assert lsm2bin not in STAR_IMPORTED
de... | 64 | 64 | 54 | 7 | 56 | bioturing/tifffile | tests/test_tifffile.py | Python | test_issue_version_mismatch | test_issue_version_mismatch | 412 | 416 | 412 | 412 | dda4e256b303406c1323803b13f79d275f46c2be | bigcode/the-stack | train |
23b3ca34f1e2a68c419195af | train | function | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_read_ome_modulo_spim():
"""Test read OME modulo SPIM."""
# 2x2 tile of planes each recorded at 4 angles
fname = public_file('OME/modulo/SPIM-ModuloAlongZ.ome.tiff')
with TiffFile(fname) as tif:
assert tif.is_ome
assert tif.byteorde... | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_read_ome_modulo_spim():
| """Test read OME modulo SPIM."""
# 2x2 tile of planes each recorded at 4 angles
fname = public_file('OME/modulo/SPIM-ModuloAlongZ.ome.tiff')
with TiffFile(fname) as tif:
assert tif.is_ome
assert tif.byteorder == '<'
assert len(tif.pages) == 192
assert len(tif.series) == 1... |
# assert data
data = tif.asarray()
assert isinstance(data, numpy.ndarray)
assert data.shape == (2, 8, 2, 200, 180)
assert data.dtype == numpy.int8
assert data[1, 7, 1, 190, 161] == 92
assert_aszarr_method(tif, data)
assert__str__(tif)
@pytest.mark.skipif(... | 113 | 113 | 377 | 23 | 90 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_ome_modulo_spim | test_read_ome_modulo_spim | 7,438 | 7,470 | 7,438 | 7,439 | 9ab6c6579b7316c9fb6a5396726a8107078c7b37 | bigcode/the-stack | train |
fdc6bf2c0a62106510aa3244 | train | function | @pytest.mark.skipif(
SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON
)
def test_read_bif(caplog):
"""Test read Ventana BIF slide."""
fname = private_file('VentanaBIF/OS-2.bif')
with TiffFile(fname) as tif:
assert tif.is_bif
assert len(tif.pages) == 12
assert len... | @pytest.mark.skipif(
SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON
)
def test_read_bif(caplog):
| """Test read Ventana BIF slide."""
fname = private_file('VentanaBIF/OS-2.bif')
with TiffFile(fname) as tif:
assert tif.is_bif
assert len(tif.pages) == 12
assert len(tif.series) == 3
# first page
page = tif.pages[0]
assert page.is_bif
assert page.photom... | .pages[4]
assert page.is_svs
assert page.is_reduced
assert page.photometric == RGB
assert page.compression == LZW
assert page.shape == (422, 415, 3)
metadata = svs_description_metadata(page.description)
assert 'label 415x422' in metadata['Header']
assert_a... | 125 | 125 | 418 | 36 | 89 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_bif | test_read_bif | 6,806 | 6,850 | 6,806 | 6,809 | a308119962ec8ffd3b6ad2fcff482278c65716cc | bigcode/the-stack | train |
848b0f51bd3a420e948ef964 | train | function | @pytest.mark.skipif(SKIP_CODECS, reason=REASON)
def test_write_compression_lzma():
"""Test write LZMA compression."""
data = WRITE_DATA
with TempFileName('compression_lzma') as fname:
imwrite(fname, data, compression=LZMA, photometric=RGB)
assert_valid_tiff(fname)
with TiffFile(fname... | @pytest.mark.skipif(SKIP_CODECS, reason=REASON)
def test_write_compression_lzma():
| """Test write LZMA compression."""
data = WRITE_DATA
with TempFileName('compression_lzma') as fname:
imwrite(fname, data, compression=LZMA, photometric=RGB)
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
assert len(tif.pages) == 1
page = tif.pages[0]
... |
assert page.samplesperpixel == 3
image = tif.asarray()
assert_array_equal(data, image)
assert_aszarr_method(tif, image)
assert__str__(tif)
@pytest.mark.skipif(SKIP_CODECS, reason=REASON)
def test_write_compression_lzma():
| 67 | 67 | 226 | 23 | 44 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_compression_lzma | test_write_compression_lzma | 10,826 | 10,848 | 10,826 | 10,827 | dd23669fd2cb18fc34579a8940ccb70d6a6858c7 | bigcode/the-stack | train |
ce12e29bf3feada0a6ddc329 | train | function | def assert_page_flags(tiff_page):
"""Access all flags of TiffPage."""
for flag in PAGE_FLAGS:
getattr(tiff_page, flag)
| def assert_page_flags(tiff_page):
| """Access all flags of TiffPage."""
for flag in PAGE_FLAGS:
getattr(tiff_page, flag)
| data = numpy.random.rand(*shape) * 255
data = data.astype(dtype)
return data
def assert_file_flags(tiff_file):
"""Access all flags of TiffFile."""
for flag in FILE_FLAGS:
getattr(tiff_file, flag)
def assert_page_flags(tiff_page):
| 64 | 64 | 33 | 8 | 56 | bioturing/tifffile | tests/test_tifffile.py | Python | assert_page_flags | assert_page_flags | 319 | 322 | 319 | 319 | 574fb9f4a6ec6ffd275b46e31e2477f075fbdb2c | bigcode/the-stack | train |
61e24bd56cb8b980bf3cd553 | train | function | def test_issue_write_separated():
"""Test write SEPARATED colorspace."""
# https://github.com/cgohlke/tifffile/issues/37
contig = random_data(numpy.uint8, (63, 95, 4))
separate = random_data(numpy.uint8, (4, 63, 95))
extrasample = random_data(numpy.uint8, (63, 95, 5))
with TempFileName('issue_wr... | def test_issue_write_separated():
| """Test write SEPARATED colorspace."""
# https://github.com/cgohlke/tifffile/issues/37
contig = random_data(numpy.uint8, (63, 95, 4))
separate = random_data(numpy.uint8, (4, 63, 95))
extrasample = random_data(numpy.uint8, (63, 95, 5))
with TempFileName('issue_write_separated') as fname:
... | with pytest.raises(ValueError):
tif.write(data, shape=(10, 10, 10), dtype=numpy.uint8)
with TiffWriter(fname) as tif:
with pytest.raises(ValueError):
tif.write(
data,
shape=(10, 10, 10),
dtype=numpy.uint8,
... | 88 | 88 | 295 | 7 | 81 | bioturing/tifffile | tests/test_tifffile.py | Python | test_issue_write_separated | test_issue_write_separated | 1,077 | 1,101 | 1,077 | 1,077 | 2e360f1e73122f67c181284f9069f8ba558125d6 | bigcode/the-stack | train |
44ee6d680f7f7be8129223b9 | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_ome_zen_2chzt():
"""Test read OME time-series of two-channel volumes by ZEN 2011."""
fname = private_file('OME/zen_2chzt.ome.tiff')
with TiffFile(fname) as tif:
assert tif.is_ome
assert tif.byteorder == '<'
assert len(tif... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_ome_zen_2chzt():
| """Test read OME time-series of two-channel volumes by ZEN 2011."""
fname = private_file('OME/zen_2chzt.ome.tiff')
with TiffFile(fname) as tif:
assert tif.is_ome
assert tif.byteorder == '<'
assert len(tif.pages) == 798
assert len(tif.series) == 1
# assert page propert... | data = tif.asarray(series=i)
assert isinstance(data, numpy.ndarray)
assert data.shape == (10, 256, 256)
assert data.dtype == numpy.uint16
assert data[5, 128, 128] == (18661, 16235)[i]
assert_aszarr_method(series, data)
assert__str__(tif)
@pytest.m... | 104 | 104 | 349 | 25 | 79 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_ome_zen_2chzt | test_read_ome_zen_2chzt | 7,586 | 7,617 | 7,586 | 7,587 | d2a0f96fc2c346b3931da71655a9af2e74b48801 | bigcode/the-stack | train |
2a612c3decad8eb72c16a37c | train | function | @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON)
def test_issue_incorrect_rowsperstrip_count():
"""Test read incorrect count for rowsperstrip; bitspersample = 4."""
# https://github.com/python-pillow/Pillow/issues/1544
fname = private_file('bad/incorrect_count.tiff')
with TiffFile(fname) ... | @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON)
def test_issue_incorrect_rowsperstrip_count():
| """Test read incorrect count for rowsperstrip; bitspersample = 4."""
# https://github.com/python-pillow/Pillow/issues/1544
fname = private_file('bad/incorrect_count.tiff')
with TiffFile(fname) as tif:
assert len(tif.pages) == 1
page = tif.pages[0]
assert page.photometric == PALET... | assert image.shape == (556, 518, 2)
assert image.dtype == numpy.uint8
assert_aszarr_method(tif, image)
del image
assert__str__(tif)
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON)
def test_issue_incorrect_rowsperstrip_count():
| 74 | 74 | 248 | 28 | 46 | bioturing/tifffile | tests/test_tifffile.py | Python | test_issue_incorrect_rowsperstrip_count | test_issue_incorrect_rowsperstrip_count | 637 | 659 | 637 | 638 | 9c98b9676ca98f1c15ab12b6859cc26c684c3685 | bigcode/the-stack | train |
7acae36eebb209873ca99a24 | train | function | def test_write_extrasamples_contig():
"""Test write contig grayscale with large number of extrasamples."""
data = random_data(numpy.uint8, (3, 219, 301))
with TempFileName('extrasamples_contig') as fname:
imwrite(fname, data, planarconfig=CONTIG)
assert_valid_tiff(fname)
with TiffFil... | def test_write_extrasamples_contig():
| """Test write contig grayscale with large number of extrasamples."""
data = random_data(numpy.uint8, (3, 219, 301))
with TempFileName('extrasamples_contig') as fname:
imwrite(fname, data, planarconfig=CONTIG)
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
assert le... | 1
page = tif.pages[0]
assert page.is_contiguous
assert page.photometric == RGB
assert page.imagewidth == 301
assert page.imagelength == 219
assert page.samplesperpixel == 6
assert page.extrasamples == (1, 2, 0)
image = tif.a... | 112 | 112 | 374 | 9 | 103 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_extrasamples_contig | test_write_extrasamples_contig | 11,500 | 11,536 | 11,500 | 11,500 | 5d407698e2db17e7fdf13419d4764e0bc7377bd2 | bigcode/the-stack | train |
cd6b4eef2941550bcd18f290 | train | function | def test_func_parse_filenames():
"""Test parse_filenames function."""
def func(*args, **kwargs):
labels, shape, indices, _ = parse_filenames(*args, **kwargs)
return ''.join(labels), shape, indices
files = ['c1t001.ext', 'c1t002.ext', 'c2t002.ext'] # 'c2t001.ext' missing
# group names
... | def test_func_parse_filenames():
| """Test parse_filenames function."""
def func(*args, **kwargs):
labels, shape, indices, _ = parse_filenames(*args, **kwargs)
return ''.join(labels), shape, indices
files = ['c1t001.ext', 'c1t002.ext', 'c2t002.ext'] # 'c2t001.ext' missing
# group names
p = r'(?P<a>\d).[!\d](?P<b>\d... | shape == (1, 0)
assert reshape_nd(numpy.empty(1), 3).shape == (1, 1, 1)
assert reshape_nd(numpy.empty((2, 3)), 3).shape == (1, 2, 3)
assert reshape_nd(numpy.empty((2, 3, 4)), 3).shape == (2, 3, 4)
assert reshape_nd((0,), 2) == (1, 0)
assert reshape_nd((1,), 3) == (1, 1, 1)
assert reshape_nd((2,... | 256 | 256 | 1,390 | 7 | 249 | bioturing/tifffile | tests/test_tifffile.py | Python | test_func_parse_filenames | test_func_parse_filenames | 2,437 | 2,516 | 2,437 | 2,437 | 050a7f4b95cd38d23ae513a0d869ce95f32cbb55 | bigcode/the-stack | train |
f5203c837ab7c7312fc0665c | train | function | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_reopen():
"""Test FileHandle close and open."""
try:
fh = FileHandle(FILEHANDLE_NAME)
assert not fh.closed
assert fh.is_file
fh.close()
assert fh.closed
fh.open()
assert not fh.closed
... | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_reopen():
| """Test FileHandle close and open."""
try:
fh = FileHandle(FILEHANDLE_NAME)
assert not fh.closed
assert fh.is_file
fh.close()
assert fh.closed
fh.open()
assert not fh.closed
assert fh.is_file
assert fh.name == 'test_FileHandle.bin'
... | ) as fh:
assert fh.name == 'test_FileHandle@333.bin'
assert fh.is_file
assert_filehandle(fh, offset=FILEHANDLE_OFFSET)
assert not fhandle.closed
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_reopen():
| 64 | 64 | 103 | 20 | 43 | bioturing/tifffile | tests/test_tifffile.py | Python | test_filehandle_reopen | test_filehandle_reopen | 3,541 | 3,556 | 3,541 | 3,542 | bb943f2f81350d35697f941378edeb324973e5bc | bigcode/the-stack | train |
be859837eb1305f71900e41c | train | function | def test_issue_iterable_compression():
"""Test writing iterable of pages with compression."""
# https://github.com/cgohlke/tifffile/issues/20
data = numpy.random.rand(10, 10, 10) * 127
data = data.astype(numpy.int8)
with TempFileName('issue_iterable_compression') as fname:
with TiffWriter(fn... | def test_issue_iterable_compression():
| """Test writing iterable of pages with compression."""
# https://github.com/cgohlke/tifffile/issues/20
data = numpy.random.rand(10, 10, 10) * 127
data = data.astype(numpy.int8)
with TempFileName('issue_iterable_compression') as fname:
with TiffWriter(fname) as tif:
tif.write(data... | SKIP_CODECS, reason=REASON)
def test_issue_lzw_corrupt():
"""Test decoding corrupted LZW segment raises RuntimeError."""
# reported by S Richter on 2020.2.17
fname = private_file('issues/lzw_corrupt.tiff')
with pytest.raises(RuntimeError):
with TiffFile(fname) as tif:
tif.asarray()
... | 88 | 88 | 296 | 8 | 80 | bioturing/tifffile | tests/test_tifffile.py | Python | test_issue_iterable_compression | test_issue_iterable_compression | 1,046 | 1,074 | 1,046 | 1,046 | 19874e3a013141f959ea8f2945fa3ac2d059e7b6 | bigcode/the-stack | train |
0848199b43603b94b4195954 | train | function | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_bytesio_offset():
"""Test FileHandle from BytesIO with offset."""
with open(FILEHANDLE_NAME, 'rb') as fh:
stream = BytesIO(fh.read())
with FileHandle(
stream, offset=FILEHANDLE_OFFSET, size=FILEHANDLE_LENGTH
) as fh:
... | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_bytesio_offset():
| """Test FileHandle from BytesIO with offset."""
with open(FILEHANDLE_NAME, 'rb') as fh:
stream = BytesIO(fh.read())
with FileHandle(
stream, offset=FILEHANDLE_OFFSET, size=FILEHANDLE_LENGTH
) as fh:
assert fh.name == 'Unnamed binary stream'
assert not fh.is_file
a... | :
stream = BytesIO(fh.read())
with FileHandle(stream) as fh:
assert fh.name == 'Unnamed binary stream'
assert not fh.is_file
assert_filehandle(fh)
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_bytesio_offset():
| 64 | 64 | 109 | 21 | 43 | bioturing/tifffile | tests/test_tifffile.py | Python | test_filehandle_bytesio_offset | test_filehandle_bytesio_offset | 3,480 | 3,490 | 3,480 | 3,481 | ebcb937eded407ca812afa114fdcb1f6ef607442 | bigcode/the-stack | train |
3e88ed87ac44042e837d4d48 | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_lena_be_rgb48():
"""Test read RGB48."""
fname = private_file('PS/lena_be_rgb48.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '>'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# assert page pr... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_lena_be_rgb48():
| """Test read RGB48."""
fname = private_file('PS/lena_be_rgb48.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '>'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# assert page properties
page = tif.pages[0]
assert not page.is_reduced
... | 512)
assert data.dtype == numpy.float32
assert_array_almost_equal(
data[:, 256, 256], (0.456386, 0.052867, 0.064795)
)
assert_aszarr_method(tif, data, series=0)
assert__str__(tif)
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_lena_be_rgb48():
| 92 | 92 | 309 | 22 | 70 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_lena_be_rgb48 | test_read_lena_be_rgb48 | 5,322 | 5,352 | 5,322 | 5,323 | cb2815937740355f2c5ebbd97cdbc116d4e8477a | bigcode/the-stack | train |
07fa2f91a0aa90cd28b15983 | train | function | def test_class_tifftagregistry():
"""Test TiffTagRegistry."""
numtags = 635
tags = TIFF.TAGS
assert len(tags) == numtags
assert tags[11] == 'ProcessingSoftware'
assert tags['ProcessingSoftware'] == 11
assert tags.getall(11) == ['ProcessingSoftware']
assert tags.getall('ProcessingSoftware... | def test_class_tifftagregistry():
| """Test TiffTagRegistry."""
numtags = 635
tags = TIFF.TAGS
assert len(tags) == numtags
assert tags[11] == 'ProcessingSoftware'
assert tags['ProcessingSoftware'] == 11
assert tags.getall(11) == ['ProcessingSoftware']
assert tags.getall('ProcessingSoftware') == [11]
tags.add(11, 'Proce... | tags.items()]
assert list(tags.values()) == [t for t in tags]
tag270 = tags[270]
del tags[270]
assert 270 not in tags
assert 'ImageDescription' not in tags
with pytest.raises(KeyError):
del tags[270]
with pytest.raises... | 180 | 180 | 601 | 8 | 171 | bioturing/tifffile | tests/test_tifffile.py | Python | test_class_tifftagregistry | test_class_tifftagregistry | 1,946 | 2,006 | 1,946 | 1,946 | 841fc6b9133b449c7cc6a44224fb8d5794ee1432 | bigcode/the-stack | train |
73a6e60ac0bc9164af741779 | train | function | @pytest.mark.skipif(
SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.LJPEG, reason=REASON
)
def test_read_dng_jpeglossy():
"""Test read JPEG_LOSSY in DNG."""
fname = private_file('DNG/Adobe DNG Converter.dng')
with TiffFile(fname) as tif:
assert len(tif.pages) == 1
assert len(tif.series) ... | @pytest.mark.skipif(
SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.LJPEG, reason=REASON
)
def test_read_dng_jpeglossy():
| """Test read JPEG_LOSSY in DNG."""
fname = private_file('DNG/Adobe DNG Converter.dng')
with TiffFile(fname) as tif:
assert len(tif.pages) == 1
assert len(tif.series) == 6
for series in tif.series:
image = series.asarray()
assert_aszarr_method(series, image)
... | 62792969),
)
assert_aszarr_method(tif, image)
assert__str__(tif)
@pytest.mark.skipif(
SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.LJPEG, reason=REASON
)
def test_read_dng_jpeglossy():
| 64 | 64 | 130 | 39 | 25 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_dng_jpeglossy | test_read_dng_jpeglossy | 3,910 | 3,922 | 3,910 | 3,913 | a23466be5440ff189c3e4cb6f2b15dc4c87fe7db | bigcode/the-stack | train |
044bce9d2b9b360f6f236c37 | train | function | @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON)
def test_issue_packbits_dtype():
"""Test read and efficiently write PackBits compressed int16 image."""
# https://github.com/blink1073/tifffile/issues/61
# requires imagecodecs > 2021.6.8
fname = private_file('packbits/imstack_packbits-int... | @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON)
def test_issue_packbits_dtype():
| """Test read and efficiently write PackBits compressed int16 image."""
# https://github.com/blink1073/tifffile/issues/61
# requires imagecodecs > 2021.6.8
fname = private_file('packbits/imstack_packbits-int16.tif')
with TiffFile(fname) as tif:
assert len(tif.pages) == 519
page = ti... | ,
'LineCameraSkew': -0.000424,
'LineAreaXOffset': 0.019265,
'LineAreaYOffset': -0.000313,
'Focus Offset': 0.0,
'ImageID': 1004486,
'OriginalWidth': 46000,
'Originalheight': 33014,
'Filtered': 5,
'OriginalHeight': 32914,
}
@pytest.mark.skipif(SK... | 120 | 120 | 401 | 25 | 95 | bioturing/tifffile | tests/test_tifffile.py | Python | test_issue_packbits_dtype | test_issue_packbits_dtype | 1,402 | 1,443 | 1,402 | 1,403 | 490943f604ec1fade1524d3adeca63a1335215b1 | bigcode/the-stack | train |
fe07e1ecd9f3ab182d8fd368 | train | function | @pytest.mark.skipif(
SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.LERC, reason=REASON
)
def test_read_lerc():
"""Test read LERC compression."""
if not hasattr(imagecodecs, 'LERC'):
pytest.skip('LERC codec missing')
fname = public_file('imagecodecs/rgb.u2.lerc.tif')
with TiffFile(fname) as ... | @pytest.mark.skipif(
SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.LERC, reason=REASON
)
def test_read_lerc():
| """Test read LERC compression."""
if not hasattr(imagecodecs, 'LERC'):
pytest.skip('LERC codec missing')
fname = public_file('imagecodecs/rgb.u2.lerc.tif')
with TiffFile(fname) as tif:
assert len(tif.pages) == 1
page = tif.pages[0]
assert page.compression == LERC
... | 25, 1] == 122
assert image[25, 25, 2] == 37
assert_aszarr_method(tif, image)
assert__str__(tif)
@pytest.mark.skipif(
SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.LERC, reason=REASON
)
def test_read_lerc():
| 78 | 78 | 263 | 34 | 44 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_lerc | test_read_lerc | 5,060 | 5,086 | 5,060 | 5,063 | 97654cc2f6f987ae8df8465a335e53cf2a001cf5 | bigcode/the-stack | train |
fdc85475dae7ad816b687a9e | train | function | def test_write_auto_rgb_planar():
"""Test write auto planar RGB."""
data = random_data(numpy.uint8, (3, 219, 301))
with TempFileName('auto_rgb_planar') as fname:
with pytest.warns(DeprecationWarning):
imwrite(fname, data) # photometric=RGB, planarconfig=SEPARATE
assert_valid_tif... | def test_write_auto_rgb_planar():
| """Test write auto planar RGB."""
data = random_data(numpy.uint8, (3, 219, 301))
with TempFileName('auto_rgb_planar') as fname:
with pytest.warns(DeprecationWarning):
imwrite(fname, data) # photometric=RGB, planarconfig=SEPARATE
assert_valid_tiff(fname)
with TiffFile(fna... | 301
assert page.imagelength == 219
assert page.samplesperpixel == 3
image = tif.asarray()
assert_array_equal(data, image)
assert_aszarr_method(tif, image)
assert__str__(tif)
def test_write_auto_rgb_planar():
| 64 | 64 | 205 | 8 | 56 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_auto_rgb_planar | test_write_auto_rgb_planar | 11,791 | 11,810 | 11,791 | 11,791 | a90faaf54cc64167a4e4109c4450fe3c4dd8153e | bigcode/the-stack | train |
5e8c7dde1b01ec71a05607fa | train | function | def assert_valid_omexml(omexml):
"""Validate OME-XML schema."""
OmeXml.validate(omexml, assert_=True)
| def assert_valid_omexml(omexml):
| """Validate OME-XML schema."""
OmeXml.validate(omexml, assert_=True)
| iff_page, flag)
def assert__str__(tif, detail=3):
"""Call the TiffFile.__str__ function."""
for i in range(detail + 1):
TiffFile.__str__(tif, detail=i)
def assert_valid_omexml(omexml):
| 64 | 64 | 34 | 12 | 52 | bioturing/tifffile | tests/test_tifffile.py | Python | assert_valid_omexml | assert_valid_omexml | 331 | 333 | 331 | 331 | d0d383b85a5ed0ddd2ff0528feb4ea5c73919769 | bigcode/the-stack | train |
ec84cd11a0c6cf2a1052cbdf | train | function | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON)
def test_read_movie():
"""Test read 30000 pages, uint16."""
fname = public_file('tifffile/movie.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '<'
assert len(tif.pages) == 30000
assert len(tif.series) == 1
... | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON)
def test_read_movie():
| """Test read 30000 pages, uint16."""
fname = public_file('tifffile/movie.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '<'
assert len(tif.pages) == 30000
assert len(tif.series) == 1
assert tif.is_uniform
# assert series properties
series = tif.ser... | file
assert isinstance(data, numpy.core.memmap)
assert data.flags['C_CONTIGUOUS']
assert data.shape == (30000, 30000)
assert data.dtype == numpy.float32
assert data[6597, 8135] == 0.008780896663665771
assert_aszarr_method(tif, data)
del data
assert not ti... | 121 | 121 | 404 | 23 | 98 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_movie | test_read_movie | 5,391 | 5,432 | 5,391 | 5,392 | f629d5001325a6f8e48c9effcf79ffe49e2571ec | bigcode/the-stack | train |
aa0ec596abaedc97f0654c20 | train | function | def test_func_json_description_metadata():
"""Test json_description_metadata function."""
assert json_description_metadata('shape=(256, 256, 3)') == {
'shape': (256, 256, 3)
}
assert json_description_metadata(
'{"shape": [256, 256, 3], "axes": "YXS"}'
) == {'shape': [256, 256, 3], 'a... | def test_func_json_description_metadata():
| """Test json_description_metadata function."""
assert json_description_metadata('shape=(256, 256, 3)') == {
'shape': (256, 256, 3)
}
assert json_description_metadata(
'{"shape": [256, 256, 3], "axes": "YXS"}'
) == {'shape': [256, 256, 3], 'axes': 'YXS'}
| _json_description():
"""Test json_description function."""
descr = json_description((256, 256, 3), axes='YXS')
assert json.loads(descr) == {'shape': [256, 256, 3], 'axes': 'YXS'}
def test_func_json_description_metadata():
| 63 | 64 | 98 | 7 | 56 | bioturing/tifffile | tests/test_tifffile.py | Python | test_func_json_description_metadata | test_func_json_description_metadata | 2,656 | 2,663 | 2,656 | 2,656 | 03af6fb7326780e0e57551733d66a2bde453a2ba | bigcode/the-stack | train |
f0fb78c9678ff522a24bcb07 | train | function | def test_func_tiffcomment():
"""Test tiffcomment function."""
data = random_data(numpy.uint8, (33, 31, 3))
with TempFileName('func_tiffcomment') as fname:
comment = 'A comment'
imwrite(
fname, data, photometric=RGB, description=comment, metadata=None
)
assert comm... | def test_func_tiffcomment():
| """Test tiffcomment function."""
data = random_data(numpy.uint8, (33, 31, 3))
with TempFileName('func_tiffcomment') as fname:
comment = 'A comment'
imwrite(
fname, data, photometric=RGB, description=comment, metadata=None
)
assert comment == tiffcomment(fname)
... | 3umintervals_5cycles.lsm'
)
# fname = private_file(
# 'LSM/fish01-wt-t01-10_ForTest-20zplanes10timepoints.lsm')
lsm2bin(fname, '', verbose=True)
def test_func_tiffcomment():
| 64 | 64 | 118 | 7 | 57 | bioturing/tifffile | tests/test_tifffile.py | Python | test_func_tiffcomment | test_func_tiffcomment | 3,206 | 3,218 | 3,206 | 3,206 | fd6edb164a118aec706e2e606a6eb1662623fcdf | bigcode/the-stack | train |
99e407880ac5fe120c563b1c | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_django():
"""Test read 3x480x320, uint16, palette, raw."""
fname = private_file('django.tiff')
with TiffFile(fname) as tif:
assert tif.byteorder == '<'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# asse... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_django():
| """Test read 3x480x320, uint16, palette, raw."""
fname = private_file('django.tiff')
with TiffFile(fname) as tif:
assert tif.byteorder == '<'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# assert page properties
page = tif.pages[0]
assert page.photom... | == numpy.uint8
assert tuple(data[:, 19, 31]) == (50, 50, 50)
assert tuple(data[:, 36, 34]) == (70, 70, 70)
assert_aszarr_method(page, data)
assert_decode_method(page)
assert__str__(tif)
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_django():
| 90 | 90 | 300 | 19 | 71 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_django | test_read_django | 4,417 | 4,446 | 4,417 | 4,418 | d3b4fa1755fa1f22fb502be59dbc7f3046d32cd0 | bigcode/the-stack | train |
bf77d8b327a641465b690c7c | train | function | def test_write_scalar_3d():
"""Test write 3D grayscale."""
data = random_data(numpy.uint8, (63, 219, 301))
with TempFileName('scalar_3d') as fname:
imwrite(fname, data)
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
assert len(tif.pages) == 63
page = ti... | def test_write_scalar_3d():
| """Test write 3D grayscale."""
data = random_data(numpy.uint8, (63, 219, 301))
with TempFileName('scalar_3d') as fname:
imwrite(fname, data)
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
assert len(tif.pages) == 63
page = tif.pages[62]
asse... | 301
assert page.imagelength == 219
assert page.samplesperpixel == 1
image = tif.asarray()
assert_array_equal(data, image)
assert_aszarr_method(tif, image)
assert__str__(tif)
def test_write_scalar_3d():
| 64 | 64 | 188 | 8 | 56 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_scalar_3d | test_write_scalar_3d | 11,685 | 11,704 | 11,685 | 11,685 | 82de92c2da4ede041dbe3dae1c78f60aa6a55769 | bigcode/the-stack | train |
5d4294df9d4e2cd85db22c01 | train | function | @pytest.mark.skipif(
SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON
)
def test_issue_jpeg_palette():
"""Test invalid JPEG compressed intensity image with palette."""
# https://forum.image.sc/t/viv-and-avivator/45999/24
fname = private_file('issues/FL_cells.ome.tif')
with TiffFile... | @pytest.mark.skipif(
SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON
)
def test_issue_jpeg_palette():
| """Test invalid JPEG compressed intensity image with palette."""
# https://forum.image.sc/t/viv-and-avivator/45999/24
fname = private_file('issues/FL_cells.ome.tif')
with TiffFile(fname) as tif:
page = tif.pages[0]
assert page.compression == JPEG
assert page.colormap is not None
... | [[0, 0], [255, 255]]], dtype=numpy.uint8),
)
assert__str__(tif)
@pytest.mark.skipif(
SKIP_PRIVATE or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON
)
def test_issue_jpeg_palette():
| 64 | 64 | 182 | 35 | 29 | bioturing/tifffile | tests/test_tifffile.py | Python | test_issue_jpeg_palette | test_issue_jpeg_palette | 512 | 528 | 512 | 515 | 0ddf237b0b9f996758ce4606d1ede0d6d1e47c14 | bigcode/the-stack | train |
25597a69922090c403aa1f8b | train | function | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_filename_offset():
"""Test FileHandle from filename with offset."""
with FileHandle(
FILEHANDLE_NAME, offset=FILEHANDLE_OFFSET, size=FILEHANDLE_LENGTH
) as fh:
assert fh.name == 'test_FileHandle.bin'
assert fh.is_fil... | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_filename_offset():
| """Test FileHandle from filename with offset."""
with FileHandle(
FILEHANDLE_NAME, offset=FILEHANDLE_OFFSET, size=FILEHANDLE_LENGTH
) as fh:
assert fh.name == 'test_FileHandle.bin'
assert fh.is_file
assert_filehandle(fh, FILEHANDLE_OFFSET)
| ():
"""Test FileHandle from filename."""
with FileHandle(FILEHANDLE_NAME) as fh:
assert fh.name == 'test_FileHandle.bin'
assert fh.is_file
assert_filehandle(fh)
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_filename_offset():
| 64 | 64 | 85 | 20 | 44 | bioturing/tifffile | tests/test_tifffile.py | Python | test_filehandle_filename_offset | test_filehandle_filename_offset | 3,458 | 3,466 | 3,458 | 3,459 | c2fac10bf7eb1174ebcabecc4a553a01363decde | bigcode/the-stack | train |
7089bf918d733114946a3943 | train | function | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_filename():
"""Test FileHandle from filename."""
with FileHandle(FILEHANDLE_NAME) as fh:
assert fh.name == 'test_FileHandle.bin'
assert fh.is_file
assert_filehandle(fh)
| @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_filename():
| """Test FileHandle from filename."""
with FileHandle(FILEHANDLE_NAME) as fh:
assert fh.name == 'test_FileHandle.bin'
assert fh.is_file
assert_filehandle(fh)
| ))
assert buf.read(len(value)) == value
buf.seek(2)
with FileHandle(buf, offset=len(pad), size=len(value)) as fh:
assert fh.read(len(value)) == value
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_filehandle_filename():
| 64 | 64 | 62 | 19 | 44 | bioturing/tifffile | tests/test_tifffile.py | Python | test_filehandle_filename | test_filehandle_filename | 3,449 | 3,455 | 3,449 | 3,450 | 6fac134f9e1ef36d4012a5f4ff09288218315b71 | bigcode/the-stack | train |
cc2be0006b880688f13d1d16 | train | function | @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON)
def test_read_lena_be_f16_lzw_planar():
"""Test read big endian, float16, LZW, horizontal differencing."""
fname = private_file('PS/lena_be_f16_lzw_planar.tif')
with TiffFile(fname, is_imagej=False) as tif:
assert tif.byteorder == '>'
... | @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON)
def test_read_lena_be_f16_lzw_planar():
| """Test read big endian, float16, LZW, horizontal differencing."""
fname = private_file('PS/lena_be_f16_lzw_planar.tif')
with TiffFile(fname, is_imagej=False) as tif:
assert tif.byteorder == '>'
assert len(tif.pages) == 1
assert len(tif.series) == 1
assert not tif.is_imagej
... | (512, 512, 3)
assert data.dtype == numpy.float16
assert_array_almost_equal(data[256, 256], (0.4563, 0.052856, 0.064819))
assert_aszarr_method(tif, data, series=0)
assert_decode_method(page)
assert__str__(tif)
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON)
def te... | 109 | 109 | 365 | 31 | 78 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_lena_be_f16_lzw_planar | test_read_lena_be_f16_lzw_planar | 5,213 | 5,247 | 5,213 | 5,214 | 29942e5a5c44279aa0aeb9387283da79c8a4fbc5 | bigcode/the-stack | train |
f92f496286ee9a5cf9f48033 | train | function | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_oxford():
"""Test read 601x81, uint8, PackBits."""
fname = public_file('juicypixels/oxford.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '>'
assert len(tif.pages) == 1
assert len(tif.series) == ... | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_oxford():
| """Test read 601x81, uint8, PackBits."""
fname = public_file('juicypixels/oxford.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '>'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# assert page properties
page = tif.pages[0]
assert page.plan... | OUS']
assert data.shape == (128, 128, 128)
assert data.dtype == numpy.float32
assert data[64, 64, 64] == 0.0
assert_decode_method(page)
assert_aszarr_method(tif, data)
assert__str__(tif)
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_oxford()... | 93 | 93 | 311 | 25 | 68 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_oxford | test_read_oxford | 4,075 | 4,105 | 4,075 | 4,076 | 61df15a44b556d29c506382ed13535977446a57c | bigcode/the-stack | train |
df17848b4c62e2bcbc1f763e | train | function | @pytest.mark.parametrize('key', [None, 0, 3, 'series'])
@pytest.mark.parametrize('out', [None, 'empty', 'memmap', 'dir', 'name'])
def test_func_create_output_asarray(out, key):
"""Test create_output function in context of asarray."""
data = random_data(numpy.uint16, (5, 219, 301))
with TempFileName(f'out_{... | @pytest.mark.parametrize('key', [None, 0, 3, 'series'])
@pytest.mark.parametrize('out', [None, 'empty', 'memmap', 'dir', 'name'])
def test_func_create_output_asarray(out, key):
| """Test create_output function in context of asarray."""
data = random_data(numpy.uint16, (5, 219, 301))
with TempFileName(f'out_{key}_{out}') as fname:
imwrite(fname, data)
# assert file
with TiffFile(fname) as tif:
tif.pages.useframes = True
tif.pages._load... | dtype)
assert isinstance(a, numpy.core.memmap)
del a
# 'memmap:tempdir'
a = create_output(f'memmap:{os.path.abspath(TEMP_DIR)}', shape, dtype)
assert isinstance(a, numpy.core.memmap)
del a
# filename
with TempFileName('nopages') as fname:
a = create_output(fname, shape, dtype)
... | 143 | 143 | 477 | 51 | 91 | bioturing/tifffile | tests/test_tifffile.py | Python | test_func_create_output_asarray | test_func_create_output_asarray | 3,245 | 3,307 | 3,245 | 3,247 | 935c3b9be930177d248107dfe9f98b52e061cf7c | bigcode/the-stack | train |
5c415d76c889153896d047b8 | train | function | def test_write_extrasamples_gray_planar():
"""Test write planar grayscale with extrasamples."""
data = random_data(numpy.uint8, (2, 301, 219))
with TempFileName('extrasamples_gray_planar') as fname:
imwrite(fname, data, planarconfig=SEPARATE, extrasamples=UNASSALPHA)
assert_valid_tiff(fname)... | def test_write_extrasamples_gray_planar():
| """Test write planar grayscale with extrasamples."""
data = random_data(numpy.uint8, (2, 301, 219))
with TempFileName('extrasamples_gray_planar') as fname:
imwrite(fname, data, planarconfig=SEPARATE, extrasamples=UNASSALPHA)
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
... | page.samplesperpixel == 2
assert page.extrasamples[0] == 2
image = tif.asarray()
assert_array_equal(data, image)
assert_aszarr_method(tif, image)
assert__str__(tif)
def test_write_extrasamples_gray_planar():
| 64 | 64 | 215 | 10 | 54 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_extrasamples_gray_planar | test_write_extrasamples_gray_planar | 11,384 | 11,403 | 11,384 | 11,384 | f3a5580dfc4708ea74635fd379d8a17fe9aba968 | bigcode/the-stack | train |
07abcaf24bfc397be712b0bf | train | function | def test_issue_specific_pages():
"""Test read second page."""
data = random_data(numpy.uint8, (3, 21, 31))
with TempFileName('specific_pages') as fname:
imwrite(fname, data, photometric=MINISBLACK)
image = imread(fname)
assert image.shape == (3, 21, 31)
# UserWarning: can not... | def test_issue_specific_pages():
| """Test read second page."""
data = random_data(numpy.uint8, (3, 21, 31))
with TempFileName('specific_pages') as fname:
imwrite(fname, data, photometric=MINISBLACK)
image = imread(fname)
assert image.shape == (3, 21, 31)
# UserWarning: can not reshape (21, 31) to (3, 21, 31)
... |
data = tif.asarray()
assert data.shape == (4, 1024, 1024)
assert data.dtype == numpy.uint8
assert data[2, 512, 512] == 10
assert_aszarr_method(tif, data)
assert__str__(tif)
def test_issue_specific_pages():
| 73 | 73 | 246 | 6 | 67 | bioturing/tifffile | tests/test_tifffile.py | Python | test_issue_specific_pages | test_issue_specific_pages | 531 | 549 | 531 | 531 | ac290dd7db2778f101888ed797015826b67be294 | bigcode/the-stack | train |
811a5a2e49bd58f6eff17fec | train | function | def test_func_apply_colormap():
"""Test apply_colormap function."""
image = numpy.arange(256, dtype=numpy.uint8)
colormap = numpy.vstack([image, image, image]).astype(numpy.uint16) * 256
assert_array_equal(apply_colormap(image, colormap)[-1], colormap[:, -1])
| def test_func_apply_colormap():
| """Test apply_colormap function."""
image = numpy.arange(256, dtype=numpy.uint8)
colormap = numpy.vstack([image, image, image]).astype(numpy.uint16) * 256
assert_array_equal(apply_colormap(image, colormap)[-1], colormap[:, -1])
| 1, 1, 1)
assert reshape_nd((2, 3), 3) == (1, 2, 3)
assert reshape_nd((2, 3, 4), 3) == (2, 3, 4)
def test_func_apply_colormap():
| 64 | 64 | 74 | 7 | 57 | bioturing/tifffile | tests/test_tifffile.py | Python | test_func_apply_colormap | test_func_apply_colormap | 2,430 | 2,434 | 2,430 | 2,430 | 92ec8133b2661cb635a720f31a412b5828a4c1d7 | bigcode/the-stack | train |
386de351d6aa53c4ae29352d | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_exif_paint():
"""Test read EXIF tags."""
fname = private_file('exif/paint.tif')
with TiffFile(fname) as tif:
exif = tif.pages[0].tags['ExifTag'].value
assert exif['ColorSpace'] == 65535
assert exif['ExifVersion'] == '0230... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_exif_paint():
| """Test read EXIF tags."""
fname = private_file('exif/paint.tif')
with TiffFile(fname) as tif:
exif = tif.pages[0].tags['ExifTag'].value
assert exif['ColorSpace'] == 65535
assert exif['ExifVersion'] == '0230'
assert exif['UserComment'] == 'paint'
assert_aszarr_method(... | 64:
dtype = numpy.uint64
assert data.dtype == dtype
assert_decode_method(page, data)
assert_aszarr_method(page, data)
assert__str__(tif)
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_exif_paint():
| 64 | 64 | 123 | 21 | 43 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_exif_paint | test_read_exif_paint | 3,670 | 3,680 | 3,670 | 3,671 | 9c4ba15896f4fbf5decf1cd990e4c1731bfb76fc | bigcode/the-stack | train |
a8e25cc4b0592f9668a45d83 | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_depend_oiffile():
"""Test oiffile.OifFile."""
from oiffile import OifFile
fname = private_file(
'oib/MB231cell1_paxgfp_PDMSgasket_PMMAflat_30nm_378sli.oib'
)
with OifFile(fname) as oib:
assert oib.is_oib
tifs = oib.se... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_depend_oiffile():
| """Test oiffile.OifFile."""
from oiffile import OifFile
fname = private_file(
'oib/MB231cell1_paxgfp_PDMSgasket_PMMAflat_30nm_378sli.oib'
)
with OifFile(fname) as oib:
assert oib.is_oib
tifs = oib.series[0]
assert len(tifs) == 756
assert tifs.shape == (2, 378... | [17, :, 1500, 1000]) == (95, 109, 3597, 0, 0, 0)
del im
assert_valid_tiff(tif)
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_depend_oiffile():
| 64 | 64 | 216 | 20 | 44 | bioturing/tifffile | tests/test_tifffile.py | Python | test_depend_oiffile | test_depend_oiffile | 14,322 | 14,342 | 14,322 | 14,323 | a997d66cb5928dab95d4cc0b52a35c9c4afd24de | bigcode/the-stack | train |
584800b0a56b8d9b27db5fbc | train | function | def test_write_append_not_exists():
"""Test append to non existing file."""
with TempFileName('append_not_exists.bin') as fname:
# with self.assertRaises(ValueError):
with TiffWriter(fname, append=True):
pass
| def test_write_append_not_exists():
| """Test append to non existing file."""
with TempFileName('append_not_exists.bin') as fname:
# with self.assertRaises(ValueError):
with TiffWriter(fname, append=True):
pass
| TiffWriter(fname) as tif:
pass
with TiffFile(fname) as tif:
assert len(tif.pages) == 0
tif.asarray()
if not SKIP_VALIDATE:
with pytest.raises(ValueError):
assert_valid_tiff(fname)
def test_write_append_not_exists():
| 64 | 64 | 52 | 7 | 57 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_append_not_exists | test_write_append_not_exists | 10,029 | 10,034 | 10,029 | 10,029 | e0ebf3366e1701634d761d7a3e2259ecdbcf8be0 | bigcode/the-stack | train |
0131e44fc0608fb519ee40c7 | train | function | def test_write_scalar():
"""Test write 2D grayscale."""
data = random_data(numpy.uint8, (219, 301))
with TempFileName('scalar') as fname:
imwrite(fname, data)
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
assert len(tif.pages) == 1
page = tif.pages[0]
... | def test_write_scalar():
| """Test write 2D grayscale."""
data = random_data(numpy.uint8, (219, 301))
with TempFileName('scalar') as fname:
imwrite(fname, data)
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
assert len(tif.pages) == 1
page = tif.pages[0]
assert page.i... | .imagewidth == 3
assert page.imagelength == 301
assert page.samplesperpixel == 1
image = tif.asarray()
assert_array_equal(data, image)
assert_aszarr_method(tif, image)
assert__str__(tif)
def test_write_scalar():
| 64 | 64 | 171 | 5 | 59 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_scalar | test_write_scalar | 11,664 | 11,682 | 11,664 | 11,664 | debc88ce32535e16a8bac74c7ff32ade1b721058 | bigcode/the-stack | train |
00ea216edfc1948e42bb0586 | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_eer(caplog):
"""Test read EER metadata."""
# https://github.com/fei-company/EerReaderLib/issues/1
fname = private_file('EER/Example_1.eer')
with TiffFile(fname) as tif:
assert not caplog.text # no warning
assert tif.is_bigti... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_eer(caplog):
| """Test read EER metadata."""
# https://github.com/fei-company/EerReaderLib/issues/1
fname = private_file('EER/Example_1.eer')
with TiffFile(fname) as tif:
assert not caplog.text # no warning
assert tif.is_bigtiff
assert tif.is_eer
assert tif.byteorder == '<'
ass... | File(fname) as tif:
image = tif.asarray()
store = tif.aszarr()
try:
data = zarr.open(store, mode='r')
assert_array_equal(image, data)
del data
finally:
store.close()
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_eer(caplog):
| 75 | 75 | 251 | 21 | 54 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_eer | test_read_eer | 9,471 | 9,497 | 9,471 | 9,472 | 10f78483c8e335048717e2a176e5b12a866370d1 | bigcode/the-stack | train |
13467a5b93bc2ac0def16a81 | train | function | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_read_subifd8():
"""Test read BigTIFFSubIFD8."""
fname = public_file('twelvemonkeys/bigtiff/BigTIFFSubIFD8.tif')
with TiffFile(fname) as tif:
assert len(tif.series) == 1
assert len(tif.pages) == 2
page = tif.pages[0]
ass... | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_read_subifd8():
| """Test read BigTIFFSubIFD8."""
fname = public_file('twelvemonkeys/bigtiff/BigTIFFSubIFD8.tif')
with TiffFile(fname) as tif:
assert len(tif.series) == 1
assert len(tif.pages) == 2
page = tif.pages[0]
assert page.photometric == RGB
assert page.imagewidth == 64
... | OUS']
assert image.shape == (32, 32, 3)
assert image.dtype == numpy.uint8
assert image[15, 15, 0] == 255
assert image[16, 16, 2] == 0
assert_aszarr_method(page)
assert__str__(tif)
@pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_read_subifd8():
| 94 | 94 | 315 | 21 | 73 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_subifd8 | test_read_subifd8 | 5,719 | 5,748 | 5,719 | 5,720 | 7869b73159a84c2518bccd22b20274c2a05be081 | bigcode/the-stack | train |
5a0d69e35c7577ad07f36297 | train | function | def test_issue_rational_rounding():
"""Test rational are rounded to 64-bit."""
# https://github.com/cgohlke/tifffile/issues/81
data = numpy.array([[255]])
with TempFileName('issue_rational_rounding') as fname:
imwrite(fname, data, resolution=(7411.824413635355, 7411.824413635355))
wit... | def test_issue_rational_rounding():
| """Test rational are rounded to 64-bit."""
# https://github.com/cgohlke/tifffile/issues/81
data = numpy.array([[255]])
with TempFileName('issue_rational_rounding') as fname:
imwrite(fname, data, resolution=(7411.824413635355, 7411.824413635355))
with TiffFile(fname) as tif:
... | (5760, 8640, 3)
assert page.dtype == numpy.uint8
data = page.asarray()
assert tuple(data[60, 80]) == (243, 238, 218)
assert_aszarr_method(page, data)
def test_issue_rational_rounding():
| 64 | 64 | 125 | 8 | 56 | bioturing/tifffile | tests/test_tifffile.py | Python | test_issue_rational_rounding | test_issue_rational_rounding | 1,323 | 1,336 | 1,323 | 1,323 | 4f8f4b64b02b5e9335b61c79b0f453d9c9d604bd | bigcode/the-stack | train |
8f82e0a3b1ca82c9408ee78b | train | function | def test_write_extrasamples_planar_rgb():
"""Test write planar RGB with extrasamples."""
data = random_data(numpy.uint8, (8, 219, 301))
with TempFileName('extrasamples_planar') as fname:
imwrite(fname, data, photometric=RGB)
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
... | def test_write_extrasamples_planar_rgb():
| """Test write planar RGB with extrasamples."""
data = random_data(numpy.uint8, (8, 219, 301))
with TempFileName('extrasamples_planar') as fname:
imwrite(fname, data, photometric=RGB)
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
assert len(tif.pages) == 1
... | trasamples) == 5
assert page.extrasamples[0] == UNSPECIFIED
image = tif.asarray()
assert_array_equal(data, image)
assert_aszarr_method(tif, image)
assert__str__(tif)
def test_write_extrasamples_planar_rgb():
| 64 | 64 | 215 | 10 | 54 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_extrasamples_planar_rgb | test_write_extrasamples_planar_rgb | 11,881 | 11,901 | 11,881 | 11,881 | 411cf6cbeff39161523cc061aebfafc48bdb459f | bigcode/the-stack | train |
b5129a639da31af04e86f219 | train | function | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_read_ome_4d_series():
"""Test read OME time-series of volumes."""
# 4D (7 time points, 5 focal planes)
fname = public_file('OME/bioformats-artificial/4D-series.ome.tiff')
with TiffFile(fname) as tif:
assert tif.is_ome
assert tif.by... | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_read_ome_4d_series():
| """Test read OME time-series of volumes."""
# 4D (7 time points, 5 focal planes)
fname = public_file('OME/bioformats-artificial/4D-series.ome.tiff')
with TiffFile(fname) as tif:
assert tif.is_ome
assert tif.byteorder == '>'
assert len(tif.pages) == 35
assert len(tif.serie... | 167, 439)
assert data.dtype == numpy.int8
assert data[6, 2, 158, 428] == 91
assert_aszarr_method(tif, data)
# don't squeeze
data = tif.asarray(squeeze=False)
assert_aszarr_method(tif, data, squeeze=False)
assert__str__(tif)
@pytest.mark.skipif(SKIP_PUBLIC, reason=... | 103 | 103 | 344 | 23 | 80 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_ome_4d_series | test_read_ome_4d_series | 7,287 | 7,319 | 7,287 | 7,288 | 02b5a90c1c5bd91f3c5f5267b4642ef9322d945d | bigcode/the-stack | train |
a517cb84bd345c62ada9b80a | train | function | def test_func_sequence():
"""Test sequence function."""
assert sequence(1) == (1,)
assert sequence([1]) == [1]
| def test_func_sequence():
| """Test sequence function."""
assert sequence(1) == (1,)
assert sequence([1]) == [1]
| 'string\x00string'
)
def test_func_stripascii():
"""Test stripascii function."""
assert stripascii(b'string\x00string\n\x01\x00') == b'string\x00string\n'
assert stripascii(b'\x00') == b''
def test_func_sequence():
| 63 | 64 | 31 | 5 | 58 | bioturing/tifffile | tests/test_tifffile.py | Python | test_func_sequence | test_func_sequence | 2,577 | 2,580 | 2,577 | 2,577 | 0d796371f629f584536b991e96747092b3b6d5f3 | bigcode/the-stack | train |
ddf7401a6e05e7bfbf5a43ec | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_depend_lfdfiles():
"""Test lfdfiles conversion to TIFF."""
from lfdfiles import SimfcsZ64 # noqa
filename = private_file('SimFCS/simfcs.Z64')
with TempFileName('simfcsz_z64', ext='.tif') as outfile:
with SimfcsZ64(filename) as z64:
... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_depend_lfdfiles():
| """Test lfdfiles conversion to TIFF."""
from lfdfiles import SimfcsZ64 # noqa
filename = private_file('SimFCS/simfcs.Z64')
with TempFileName('simfcsz_z64', ext='.tif') as outfile:
with SimfcsZ64(filename) as z64:
data = z64.asarray()
z64.totiff(outfile)
with Tif... | ImagejRoi.fromfile(private_file('imagej/IJMetadata.tif')):
assert roi == ImagejRoi.frombytes(roi.tobytes())
roi.coordinates()
roi.__str__()
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_depend_lfdfiles():
| 63 | 64 | 183 | 21 | 43 | bioturing/tifffile | tests/test_tifffile.py | Python | test_depend_lfdfiles | test_depend_lfdfiles | 14,232 | 14,247 | 14,232 | 14,233 | e0a6caafc5e11f24145adfffa9bcb42599a52244 | bigcode/the-stack | train |
fa44045ec30ed4dabb639778 | train | function | def test_write_zero_size():
"""Test write zero size array no longer fails."""
# with pytest.raises(ValueError):
with pytest.warns(UserWarning):
with TempFileName('empty') as fname:
imwrite(fname, numpy.empty(0))
| def test_write_zero_size():
| """Test write zero size array no longer fails."""
# with pytest.raises(ValueError):
with pytest.warns(UserWarning):
with TempFileName('empty') as fname:
imwrite(fname, numpy.empty(0))
| del image
image = page.asarray(out='memmap:')
assert isinstance(image, numpy.core.memmap)
assert image.dtype == numpy.dtype('=f4')
assert_array_equal(data[1], image)
del image
assert__str__(tif)
def test_write_zero_size():
| 64 | 64 | 54 | 6 | 58 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_zero_size | test_write_zero_size | 11,198 | 11,203 | 11,198 | 11,198 | 21f12520f2c3a6b8190e1c35e4117ada14a546fa | bigcode/the-stack | train |
62b7e8390a94e8ca996a06f4 | train | function | def test_write_tileiter_separate():
"""Test write separate tiles from iterator."""
data = numpy.arange(2 * 3 * 4 * 16 * 16, dtype=numpy.uint16)
data = data.reshape((2 * 3 * 4, 16, 16))
def tiles():
for i in range(data.shape[0]):
yield data[i]
with TempFileName('write_tile_iter_... | def test_write_tileiter_separate():
| """Test write separate tiles from iterator."""
data = numpy.arange(2 * 3 * 4 * 16 * 16, dtype=numpy.uint16)
data = data.reshape((2 * 3 * 4, 16, 16))
def tiles():
for i in range(data.shape[0]):
yield data[i]
with TempFileName('write_tile_iter_separate') as fname:
imwrit... | page.shape == (43, 61)
assert page.tilelength == 16
assert page.tilewidth == 16
image = page.asarray()
assert_array_equal(image[:16, :16], data[0])
for i, segment in enumerate(page.segments()):
assert_array_equal(numpy.squeeze(segment[0]), dat... | 81 | 81 | 273 | 8 | 73 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_tileiter_separate | test_write_tileiter_separate | 12,135 | 12,166 | 12,135 | 12,135 | 4b01bf406c3d182136e2e9e7232b4fccaa195843 | bigcode/the-stack | train |
730994862d74c4134e7b8626 | train | function | def test_func_imagej_description_metadata():
"""Test imagej_description_metadata function."""
imagej_str = (
'ImageJ=1.11a\nimages=510\nchannels=2\nslices=5\n'
'frames=51\nhyperstack=true\nmode=grayscale\nloop=false\n'
)
imagej_dict = {
'ImageJ': '1.11a',
'images': 510,
... | def test_func_imagej_description_metadata():
| """Test imagej_description_metadata function."""
imagej_str = (
'ImageJ=1.11a\nimages=510\nchannels=2\nslices=5\n'
'frames=51\nhyperstack=true\nmode=grayscale\nloop=false\n'
)
imagej_dict = {
'ImageJ': '1.11a',
'images': 510,
'channels': 2,
'slices': 5,
... | XS')
with pytest.raises(ValueError):
imagej_description((196, 171, 2), axes='TYXS')
with pytest.raises(ValueError):
imagej_description((3, 196, 171, 3), axes='ZTYX')
def test_func_imagej_description_metadata():
| 64 | 64 | 152 | 8 | 56 | bioturing/tifffile | tests/test_tifffile.py | Python | test_func_imagej_description_metadata | test_func_imagej_description_metadata | 2,722 | 2,738 | 2,722 | 2,722 | bd501382cb1b8fea9971ed255df158de406787da | bigcode/the-stack | train |
977059d07b554bebfdcd1555 | train | function | @pytest.mark.parametrize('byteorder', ['>', '<'])
def test_issue_valueoffset(byteorder):
"""Test read TiffTag.valueoffsets."""
unpack = struct.unpack
data = random_data(byteorder + 'u2', (2, 19, 31))
software = 'test_tifffile'
bo = {'>': 'be', '<': 'le'}[byteorder]
with TempFileName(f'valueoffse... | @pytest.mark.parametrize('byteorder', ['>', '<'])
def test_issue_valueoffset(byteorder):
| """Test read TiffTag.valueoffsets."""
unpack = struct.unpack
data = random_data(byteorder + 'u2', (2, 19, 31))
software = 'test_tifffile'
bo = {'>': 'be', '<': 'le'}[byteorder]
with TempFileName(f'valueoffset_{bo}') as fname:
imwrite(
fname,
data,
soft... | ['channels'] == 3
# assert data
data = tif.asarray()
assert isinstance(data, numpy.ndarray)
assert data.shape == (512, 672, 3)
assert data.dtype == numpy.uint16
assert tuple(data[255, 336]) == (440, 378, 298)
assert_aszarr_method(tif, data)
assert__str__(t... | 107 | 107 | 358 | 19 | 88 | bioturing/tifffile | tests/test_tifffile.py | Python | test_issue_valueoffset | test_issue_valueoffset | 778 | 814 | 778 | 779 | 024333a52f1be9c04d1dc4255c5b030d25285d95 | bigcode/the-stack | train |
215ad2baaafef04e77d81bd5 | train | function | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON)
def test_read_movie_memmap():
"""Test read 30000 pages memory-mapped."""
fname = public_file('tifffile/movie.tif')
with TiffFile(fname) as tif:
# assert data
data = tif.asarray(out='memmap')
assert isinstance(data, numpy.c... | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON)
def test_read_movie_memmap():
| """Test read 30000 pages memory-mapped."""
fname = public_file('tifffile/movie.tif')
with TiffFile(fname) as tif:
# assert data
data = tif.asarray(out='memmap')
assert isinstance(data, numpy.core.memmap)
assert data.flags['C_CONTIGUOUS']
assert data.shape == (30000, 6... | 3, 64, 64)
assert data[2, 32, 32] == 460
del data
assert__str__(tif, 0)
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON)
def test_read_movie_memmap():
| 64 | 64 | 163 | 25 | 39 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_movie_memmap | test_read_movie_memmap | 5,435 | 5,449 | 5,435 | 5,436 | f2ee8b0b0cd357b96746ef9849432cc374979f5a | bigcode/the-stack | train |
6c8806fe1ab7f9943e8b78da | train | function | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_incomplete_tile_separate():
"""Test read PackBits compressed incomplete tile, separate RGB."""
fname = public_file('GDAL/separate_tiled.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '>'
assert len(tif.p... | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_incomplete_tile_separate():
| """Test read PackBits compressed incomplete tile, separate RGB."""
fname = public_file('GDAL/separate_tiled.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '>'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# assert page properties
page = tif.pages[... | assert data.dtype == numpy.uint8
assert tuple(data[19, 31]) == (50, 50, 50)
assert tuple(data[36, 34]) == (70, 70, 70)
assert_aszarr_method(page, data)
assert_decode_method(page)
assert__str__(tif)
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_inco... | 99 | 99 | 333 | 27 | 72 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_incomplete_tile_separate | test_read_incomplete_tile_separate | 4,383 | 4,414 | 4,383 | 4,384 | db4356bcb67728c42b5903e172556e570dd53512 | bigcode/the-stack | train |
8ddd0b1bd1098ff4aced971d | train | function | @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON)
def test_sequence_leica_series():
"""Test TiffSequence with Leica TIFF series, memory mapped."""
fname = private_file('leicaseries/Series019_*.tif')
tifs = TiffSequence(fname, pattern='axes')
assert len(tifs) == 46
assert tifs.shape == ... | @pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON)
def test_sequence_leica_series():
| """Test TiffSequence with Leica TIFF series, memory mapped."""
fname = private_file('leicaseries/Series019_*.tif')
tifs = TiffSequence(fname, pattern='axes')
assert len(tifs) == 46
assert tifs.shape == (46,)
assert tifs.axes == 'Y'
# memory map
data = tifs.asarray(out='memmap')
asser... | 29
if not SKIP_ZARR:
with tifs.aszarr() as store:
assert_array_equal(data, zarr.open(store, mode='r'))
del data
@pytest.mark.skipif(SKIP_PRIVATE or SKIP_CODECS, reason=REASON)
def test_sequence_leica_series():
| 66 | 66 | 221 | 25 | 40 | bioturing/tifffile | tests/test_tifffile.py | Python | test_sequence_leica_series | test_sequence_leica_series | 14,097 | 14,115 | 14,097 | 14,098 | 6de4f21a710bbc048aca1de1f35c1ec6012fff18 | bigcode/the-stack | train |
e69def1c16fcc6048a2006f0 | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_write_palette_django():
"""Test write palette read from existing file."""
fname = private_file('django.tiff')
with TiffFile(fname) as tif:
page = tif.pages[0]
assert page.photometric == PALETTE
assert page.imagewidth == 320
... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_write_palette_django():
| """Test write palette read from existing file."""
fname = private_file('django.tiff')
with TiffFile(fname) as tif:
page = tif.pages[0]
assert page.photometric == PALETTE
assert page.imagewidth == 320
assert page.imagelength == 480
data = page.asarray() # .squeeze() ... | page.imagewidth == 301
assert page.imagelength == 219
assert page.samplesperpixel == 1
for i, page in enumerate(tif.pages):
assert_array_equal(apply_colormap(data[i], cmap), page.asrgb())
assert__str__(tif)
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)... | 83 | 83 | 278 | 20 | 63 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_palette_django | test_write_palette_django | 12,711 | 12,737 | 12,711 | 12,712 | 809c00871f07f3c011cad027fa81cd39c14ed7c5 | bigcode/the-stack | train |
d63e73e5a004978f3e59457c | train | function | def test_issue_tile_partial():
"""Test writing single tiles larger than image data."""
# https://github.com/cgohlke/tifffile/issues/3
data = random_data(numpy.uint8, (3, 15, 15, 15))
with TempFileName('tile_partial_2d') as fname:
imwrite(fname, data[0, 0], tile=(16, 16))
with TiffFile(fn... | def test_issue_tile_partial():
| """Test writing single tiles larger than image data."""
# https://github.com/cgohlke/tifffile/issues/3
data = random_data(numpy.uint8, (3, 15, 15, 15))
with TempFileName('tile_partial_2d') as fname:
imwrite(fname, data[0, 0], tile=(16, 16))
with TiffFile(fname) as tif:
assert... | MINISBLACK,
append=True,
metadata={'axes': 'ZYX'},
)
imwrite(fname, data[-1], append=True)
with TiffFile(fname) as tif:
assert len(tif.pages) == 10
assert len(tif.series) == 3
page = tif.pages[1]
assert page.is_contiguous
... | 207 | 207 | 691 | 6 | 201 | bioturing/tifffile | tests/test_tifffile.py | Python | test_issue_tile_partial | test_issue_tile_partial | 860 | 936 | 860 | 860 | 9451b6fc3af357476ff22e5068b5bf3ce5163be2 | bigcode/the-stack | train |
b40ab7e8d81d6eb7df30fbd7 | train | function | def test_func_pformat_numpy():
"""Test pformat function with numpy array."""
value = numpy.array(
(
60.0,
0.0,
0.0,
600000.0,
0.0,
-60.0,
0.0,
5900040.0,
60.0,
0.0,
0.0,
... | def test_func_pformat_numpy():
| """Test pformat function with numpy array."""
value = numpy.array(
(
60.0,
0.0,
0.0,
600000.0,
0.0,
-60.0,
0.0,
5900040.0,
60.0,
0.0,
0.0,
600000.0,
... | 600000.0, 0.0, -60.0, 0.0, 5900040.0, 60.0,\n'
' 0.0, 0.0, 600000.0, 0.0, -60.0, 0.0, 5900040.0)'
)
def test_func_pformat_numpy():
| 83 | 83 | 279 | 7 | 76 | bioturing/tifffile | tests/test_tifffile.py | Python | test_func_pformat_numpy | test_func_pformat_numpy | 3,126 | 3,158 | 3,126 | 3,126 | 287d607daa7830a93ea939860e5561d1b70d028c | bigcode/the-stack | train |
3a2b8cc5518a13aeca40f2fe | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
@pytest.mark.parametrize('bits', [16, 32])
def test_read_complexint(bits):
"""Test read complex integer images."""
fname = private_file(f'gdal/cint{bits}.tif')
with TiffFile(fname) as tif:
assert tif.is_geotiff
assert tif.byteorder == '<'
... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
@pytest.mark.parametrize('bits', [16, 32])
def test_read_complexint(bits):
| """Test read complex integer images."""
fname = private_file(f'gdal/cint{bits}.tif')
with TiffFile(fname) as tif:
assert tif.is_geotiff
assert tif.byteorder == '<'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# assert page properties
page = tif.pages... |
assert not page.is_contiguous
data = page.asarray()
data[9, 11] == 0 + 0j
assert_aszarr_method(page, data)
assert__str__(tif)
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
@pytest.mark.parametrize('bits', [16, 32])
def test_read_complexint(bits):
| 81 | 81 | 271 | 32 | 49 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_complexint | test_read_complexint | 9,134 | 9,159 | 9,134 | 9,136 | 63ca3d6a797143432d65e6b8d079aa20a55b58f7 | bigcode/the-stack | train |
a9127b52bfb597b6bfda9206 | train | function | def test_write_auto_rgb_contig():
"""Test write auto contig RGB."""
data = random_data(numpy.uint8, (219, 301, 3))
with TempFileName('auto_rgb_contig') as fname:
imwrite(fname, data) # photometric=RGB
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
assert len(tif.p... | def test_write_auto_rgb_contig():
| """Test write auto contig RGB."""
data = random_data(numpy.uint8, (219, 301, 3))
with TempFileName('auto_rgb_contig') as fname:
imwrite(fname, data) # photometric=RGB
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
assert len(tif.pages) == 1
page = tif.... | 301
assert page.imagelength == 219
assert page.samplesperpixel == 2
image = tif.asarray()
assert_array_equal(data, image)
assert_aszarr_method(tif, image)
assert__str__(tif)
def test_write_auto_rgb_contig():
| 64 | 64 | 187 | 8 | 56 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_auto_rgb_contig | test_write_auto_rgb_contig | 11,770 | 11,788 | 11,770 | 11,770 | f204c6c3abfba3bbe0dad869dcdf7ded638bdd92 | bigcode/the-stack | train |
cc0ee755adc53cf610abed01 | train | function | def test_func_stripascii():
"""Test stripascii function."""
assert stripascii(b'string\x00string\n\x01\x00') == b'string\x00string\n'
assert stripascii(b'\x00') == b''
| def test_func_stripascii():
| """Test stripascii function."""
assert stripascii(b'string\x00string\n\x01\x00') == b'string\x00string\n'
assert stripascii(b'\x00') == b''
| (b'string\x00string\x00\x00', first=False)
== b'string\x00string'
)
assert (
stripnull('string\x00string\x00\x00', null='\0', first=False)
== 'string\x00string'
)
def test_func_stripascii():
| 64 | 64 | 50 | 6 | 58 | bioturing/tifffile | tests/test_tifffile.py | Python | test_func_stripascii | test_func_stripascii | 2,571 | 2,574 | 2,571 | 2,571 | 43adcde682fd727ee6b1dbf0421b9de9d40e355c | bigcode/the-stack | train |
1dbf6e8ed45c7100d5e1b92b | train | function | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON)
def test_read_100000_pages_movie():
"""Test read 100000x64x64 big endian in memory."""
fname = public_file('tifffile/100000_pages.tif')
with TiffFile(fname, _useframes=True) as tif:
assert tif.is_imagej
assert tif.byteorder == '>'... | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON)
def test_read_100000_pages_movie():
| """Test read 100000x64x64 big endian in memory."""
fname = public_file('tifffile/100000_pages.tif')
with TiffFile(fname, _useframes=True) as tif:
assert tif.is_imagej
assert tif.byteorder == '>'
assert len(tif.pages) == 100000
assert len(tif.series) == 1
# assert seri... | data = tif.asarray(out='memmap')
assert isinstance(data, numpy.core.memmap)
assert data.flags['C_CONTIGUOUS']
assert data.shape == (30000, 64, 64)
assert data.dtype == numpy.dtype('<u2')
assert data[29999, 32, 32] == 460
del data
assert not tif.filehandle.... | 124 | 124 | 416 | 27 | 97 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_100000_pages_movie | test_read_100000_pages_movie | 5,452 | 5,488 | 5,452 | 5,453 | 678f643595ec6f01acd09d6fbfa4140dedcf5d67 | bigcode/the-stack | train |
8a94595ac59976080c7fbe2e | train | function | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON)
def test_read_chart_bl():
"""Test read 13228x18710, 1 bit, no bitspersample tag."""
fname = public_file('tifffile/chart_bl.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '<'
assert len(tif.pages) == 1
assert le... | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON)
def test_read_chart_bl():
| """Test read 13228x18710, 1 bit, no bitspersample tag."""
fname = public_file('tifffile/chart_bl.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '<'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# assert page properties
page = tif.pages[0]
... | 100000, 64, 64)
assert data.dtype == numpy.uint16
assert round(abs(data[7310, 25, 25] - 100), 7) == 0
# too slow: assert_aszarr_method(tif, data)
del data
assert__str__(tif, 0)
@pytest.mark.skipif(SKIP_PUBLIC or SKIP_LARGE, reason=REASON)
def test_read_chart_bl():
| 98 | 98 | 329 | 24 | 74 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_chart_bl | test_read_chart_bl | 5,491 | 5,522 | 5,491 | 5,492 | 3d3f02b6e101a7812e85d1feb6be73170e04c2bf | bigcode/the-stack | train |
6fbd6dd45e94f0a64294236a | train | function | def test_write_tiled_planar():
"""Test write planar tiles."""
data = random_data(numpy.uint8, (4, 219, 301))
with TempFileName('tiled_planar') as fname:
imwrite(
fname, data, tile=(96, 64), photometric=RGB, planarconfig=SEPARATE
)
assert_valid_tiff(fname)
with Tif... | def test_write_tiled_planar():
| """Test write planar tiles."""
data = random_data(numpy.uint8, (4, 219, 301))
with TempFileName('tiled_planar') as fname:
imwrite(
fname, data, tile=(96, 64), photometric=RGB, planarconfig=SEPARATE
)
assert_valid_tiff(fname)
with TiffFile(fname) as tif:
... | 219
assert page.tilewidth == 64
assert page.tilelength == 96
assert page.samplesperpixel == 1
image = tif.asarray()
assert_array_equal(data, image)
assert_aszarr_method(tif, image)
assert__str__(tif)
def test_write_tiled_planar():
| 71 | 71 | 237 | 8 | 63 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_tiled_planar | test_write_tiled_planar | 11,998 | 12,022 | 11,998 | 11,998 | 78f6ad065e04371f774309c8352feed41001ece3 | bigcode/the-stack | train |
8a3e31f8852ea463ac9b7222 | train | function | def test_write_imagej_metadata():
"""Test write additional ImageJ metadata."""
data = numpy.empty((4, 256, 256), dtype=numpy.uint16)
data[:] = numpy.arange(256 * 256, dtype=numpy.uint16).reshape(1, 256, 256)
with TempFileName('imagej_metadata') as fname:
imwrite(fname, data, imagej=True, metadat... | def test_write_imagej_metadata():
| """Test write additional ImageJ metadata."""
data = numpy.empty((4, 256, 256), dtype=numpy.uint16)
data[:] = numpy.arange(256 * 256, dtype=numpy.uint16).reshape(1, 256, 256)
with TempFileName('imagej_metadata') as fname:
imwrite(fname, data, imagej=True, metadata={'unit': 'um'})
with Tif... | 256)
assert series.get_axes(False) == 'TZCYXS'
assert series.get_shape(False) == (1, 4, 1, 256, 256, 1)
assert__str__(tif)
assert_valid_tiff(fname)
def test_write_imagej_metadata():
| 64 | 64 | 151 | 7 | 57 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_imagej_metadata | test_write_imagej_metadata | 13,125 | 13,136 | 13,125 | 13,125 | d757001011616bdfb6893bed0b4282ac94fa8ce0 | bigcode/the-stack | train |
8469daff1dfee186f8af790d | train | function | @pytest.mark.skipif(SKIP_LARGE, reason=REASON)
def test_write_volumetric_tiled_contig_rgb_empty():
"""Test write empty 6D array as contig RGB volumes."""
shape = (2, 3, 256, 64, 96, 3)
with TempFileName('volumetric_tiled_contig_rgb_empty') as fname:
with TiffWriter(fname) as tif:
tif.wri... | @pytest.mark.skipif(SKIP_LARGE, reason=REASON)
def test_write_volumetric_tiled_contig_rgb_empty():
| """Test write empty 6D array as contig RGB volumes."""
shape = (2, 3, 256, 64, 96, 3)
with TempFileName('volumetric_tiled_contig_rgb_empty') as fname:
with TiffWriter(fname) as tif:
tif.write(
shape=shape,
dtype=numpy.uint8,
tile=(256, 64, ... |
image = tif.asarray()
assert_array_equal(data, image)
# assert iterating over series.pages
data = data.reshape(6, 256, 64, 96, 3)
for i, page in enumerate(series.pages):
image = page.asarray()
assert_array_equal(data[i], image)... | 114 | 114 | 380 | 27 | 87 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_volumetric_tiled_contig_rgb_empty | test_write_volumetric_tiled_contig_rgb_empty | 12,397 | 12,435 | 12,397 | 12,398 | 0f84df37b59772c6b58e4ffdf01a28259a9eae87 | bigcode/the-stack | train |
c57769838a6ec505aeb03151 | train | function | @pytest.mark.skipif(SKIP_EXTENDED, reason=REASON)
@pytest.mark.parametrize(
'shape, axes',
[
((219, 301, 1), None),
((219, 301, 2), None),
((219, 301, 3), None),
((219, 301, 4), None),
((219, 301, 5), None),
((1, 219, 301), None),
((2, 219, 301), None),
... | @pytest.mark.skipif(SKIP_EXTENDED, reason=REASON)
@pytest.mark.parametrize(
'shape, axes',
[
((219, 301, 1), None),
((219, 301, 2), None),
((219, 301, 3), None),
((219, 301, 4), None),
((219, 301, 5), None),
((1, 219, 301), None),
((2, 219, 301), None),
... | """Test write OME-TIFF format."""
photometric = None
planarconfig = None
if shape[-1] in (3, 4):
photometric = RGB
planarconfig = CONTIG
elif shape[-3] in (3, 4):
photometric = RGB
planarconfig = SEPARATE
metadata = {'axes': axes} if axes is not None else {}
... | @pytest.mark.skipif(SKIP_EXTENDED, reason=REASON)
@pytest.mark.parametrize(
'shape, axes',
[
((219, 301, 1), None),
((219, 301, 2), None),
((219, 301, 3), None),
((219, 301, 4), None),
((219, 301, 5), None),
((1, 219, 301), None),
((2, 219, 301), None),
... | 465 | 219 | 732 | 465 | 0 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_ome | test_write_ome | 13,383 | 13,447 | 13,383 | 13,415 | 9c828f337eae641d677099d990fa27c4e0769582 | bigcode/the-stack | train |
761c3d4dd1d39410dbf820ab | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_nih_scala_media():
"""Test read multi-page NIH."""
# 36x54x84 palette
fname = private_file('nihimage/scala-media.tif')
with TiffFile(fname) as tif:
assert tif.is_nih
assert tif.byteorder == '>'
assert len(tif.pages) =... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_nih_scala_media():
| """Test read multi-page NIH."""
# 36x54x84 palette
fname = private_file('nihimage/scala-media.tif')
with TiffFile(fname) as tif:
assert tif.is_nih
assert tif.byteorder == '>'
assert len(tif.pages) == 36
assert len(tif.series) == 1
# assert page properties
... | '] == 109
# assert data
data = page.asrgb()
assert isinstance(data, numpy.ndarray)
assert data.shape == (187, 259, 3)
assert data.dtype == numpy.uint16
assert tuple(data[86, 102, :]) == (26214, 39321, 39321)
assert__str__(tif)
@pytest.mark.skipif(SKIP_PRIVATE, rea... | 103 | 103 | 344 | 22 | 81 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_nih_scala_media | test_read_nih_scala_media | 8,164 | 8,199 | 8,164 | 8,165 | 34fc0c65f9dcae0aadb6b7d73b6f648df5abdbea | bigcode/the-stack | train |
88a7304165440c3bf49ffc73 | train | function | def config():
"""Return test configuration."""
this = sys.modules[__name__]
return ' | '.join(
a for a in dir(this) if a.startswith('SKIP_') and getattr(this, a)
)
| def config():
| """Return test configuration."""
this = sys.modules[__name__]
return ' | '.join(
a for a in dir(this) if a.startswith('SKIP_') and getattr(this, a)
)
| :
zarr = None
SKIP_ZARR = True
if SKIP_DASK:
dask = None
else:
try:
import dask # type: ignore
except ImportError:
dask = None
SKIP_DASK = True
def config():
| 64 | 64 | 50 | 3 | 60 | bioturing/tifffile | tests/test_tifffile.py | Python | config | config | 277 | 282 | 277 | 277 | 37ca807aef48921fb1781f91a4b5dbfde62e51b9 | bigcode/the-stack | train |
56d02b3bd816b30566be8dd5 | train | function | def test_issue_fcontiguous():
"""Test writing F-contiguous arrays."""
# https://github.com/cgohlke/tifffile/issues/24
data = numpy.asarray(random_data(numpy.uint8, (31, 33)), order='F')
with TempFileName('fcontiguous') as fname:
imwrite(fname, data, compression=ADOBE_DEFLATE)
with TiffFi... | def test_issue_fcontiguous():
| """Test writing F-contiguous arrays."""
# https://github.com/cgohlke/tifffile/issues/24
data = numpy.asarray(random_data(numpy.uint8, (31, 33)), order='F')
with TempFileName('fcontiguous') as fname:
imwrite(fname, data, compression=ADOBE_DEFLATE)
with TiffFile(fname) as tif:
... | fname,
tiles(data, (16, 16)),
dtype=data.dtype,
shape=data.shape,
tile=(16, 16),
photometric=photometric,
)
assert_array_equal(imread(fname), data)
assert_valid_tiff(fname)
def test_issue_fcontiguous():
| 64 | 64 | 131 | 7 | 57 | bioturing/tifffile | tests/test_tifffile.py | Python | test_issue_fcontiguous | test_issue_fcontiguous | 977 | 987 | 977 | 977 | ec8eaf90be33b096afe9430b1a7740049b2e6d51 | bigcode/the-stack | train |
fa0403fed90ed4d762699af3 | train | function | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_hopper_4bit():
"""Test read 4-bit, fillorder=lsb2msb."""
# https://github.com/python-pillow/Pillow/pull/1789
fname = public_file('pillow/tiff_gray_2_4_bpp/hopper4.tif')
with TiffFile(fname) as tif:
assert tif.byteorder ... | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_hopper_4bit():
| """Test read 4-bit, fillorder=lsb2msb."""
# https://github.com/python-pillow/Pillow/pull/1789
fname = public_file('pillow/tiff_gray_2_4_bpp/hopper4.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '<'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# asse... | = tif.pages[0]
assert page.photometric == MINISWHITE
assert_array_equal(tif.asarray(), 3 - data)
assert_aszarr_method(tif)
assert__str__(tif)
# inverted and reversed
fname = public_file('pillow/tiff_gray_2_4_bpp/hopper2IR.tif')
with TiffFile(fname) as tif:
page = tif... | 161 | 161 | 537 | 27 | 134 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_hopper_4bit | test_read_hopper_4bit | 3,741 | 3,791 | 3,741 | 3,742 | bfe70b92e41b98401f7ebb87c6b3ced2d7f80ad9 | bigcode/the-stack | train |
7bb34e47454739dcc4f8b399 | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_iss_vista():
"""Test read bogus imagedepth tag by ISS Vista."""
fname = private_file('iss/10um_beads_14stacks_ch1.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '<'
assert len(tif.pages) == 14
assert len(tif.s... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_iss_vista():
| """Test read bogus imagedepth tag by ISS Vista."""
fname = private_file('iss/10um_beads_14stacks_ch1.tif')
with TiffFile(fname) as tif:
assert tif.byteorder == '<'
assert len(tif.pages) == 14
assert len(tif.series) == 1
# assert page properties
page = tif.pages[0]
... | formats(fname, caplog):
"""Test parse unsupported RAW formats."""
fname = private_file(f'RAWformats/{fname}')
with TiffFile(fname) as tif:
assert 'RAW format' in caplog.text
assert__str__(tif)
@pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_iss_vista():
| 76 | 76 | 256 | 21 | 55 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_iss_vista | test_read_iss_vista | 3,962 | 3,986 | 3,962 | 3,963 | e5675bd2e20b1716f35d7966cc588305afb23f4d | bigcode/the-stack | train |
3834366e8bf43e76ff4c5f34 | train | function | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_nih_silver_lake():
"""Test read NIH palette."""
# 259x187 16 bit palette
fname = private_file('nihimage/silver lake.tiff')
with TiffFile(fname) as tif:
assert tif.is_nih
assert tif.byteorder == '>'
assert len(tif.page... | @pytest.mark.skipif(SKIP_PRIVATE, reason=REASON)
def test_read_nih_silver_lake():
| """Test read NIH palette."""
# 259x187 16 bit palette
fname = private_file('nihimage/silver lake.tiff')
with TiffFile(fname) as tif:
assert tif.is_nih
assert tif.byteorder == '>'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# assert page properties
... | tif.asarray()
assert isinstance(data, numpy.ndarray)
assert data.shape == (252, 388)
assert data.dtype == numpy.uint8
assert data[195, 144] == 41
assert_aszarr_method(tif, data)
assert_aszarr_method(tif, data, chunkmode='page')
assert__str__(tif)
@pytest.mark.ski... | 102 | 102 | 341 | 23 | 79 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_nih_silver_lake | test_read_nih_silver_lake | 8,127 | 8,161 | 8,127 | 8,128 | ff0556223cec989b41fa9cddec17f0f6937273b4 | bigcode/the-stack | train |
9ab280a0a30548bac7d26a9b | train | function | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_imagej_rrggbb():
"""Test read planar RGB ImageJ file created by Bio-Formats."""
fname = public_file('tifffile/rrggbb.ij.tif')
with TiffFile(fname) as tif:
assert tif.is_imagej
assert tif.byteorder == '<'
ass... | @pytest.mark.skipif(SKIP_PUBLIC or SKIP_CODECS, reason=REASON)
def test_read_imagej_rrggbb():
| """Test read planar RGB ImageJ file created by Bio-Formats."""
fname = public_file('tifffile/rrggbb.ij.tif')
with TiffFile(fname) as tif:
assert tif.is_imagej
assert tif.byteorder == '<'
assert len(tif.pages) == 1
assert len(tif.series) == 1
# assert page properties
... | assert NIH tags
tags = tif.nih_metadata
assert tags['Version'] == 160
assert tags['nLines'] == 54
# assert data
data = tif.asarray()
assert isinstance(data, numpy.ndarray)
assert data.shape == (36, 54, 84)
assert data.dtype == numpy.uint8
assert d... | 152 | 152 | 509 | 27 | 125 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_imagej_rrggbb | test_read_imagej_rrggbb | 8,202 | 8,248 | 8,202 | 8,203 | cb4ea8f5d4243bd7c3d6e2dbbb6cd5f2df2edfc1 | bigcode/the-stack | train |
000ca8daa3428bebfb15133e | train | function | def assert_aszarr_method(obj, image=None, chunkmode=None, **kwargs):
"""Assert aszarr returns same data as asarray."""
if SKIP_ZARR:
return
if image is None:
image = obj.asarray(**kwargs)
with obj.aszarr(chunkmode=chunkmode, **kwargs) as store:
data = zarr.open(store, mode='r')
... | def assert_aszarr_method(obj, image=None, chunkmode=None, **kwargs):
| """Assert aszarr returns same data as asarray."""
if SKIP_ZARR:
return
if image is None:
image = obj.asarray(**kwargs)
with obj.aszarr(chunkmode=chunkmode, **kwargs) as store:
data = zarr.open(store, mode='r')
if isinstance(data, zarr.Group):
data = data[0]
... | ile = fh.read(b)
strile, index, shape = page.decode(strile, i)
assert image.reshape(page.shaped)[index] == strile[0, 0, 0, 0]
def assert_aszarr_method(obj, image=None, chunkmode=None, **kwargs):
| 64 | 64 | 113 | 18 | 46 | bioturing/tifffile | tests/test_tifffile.py | Python | assert_aszarr_method | assert_aszarr_method | 361 | 372 | 361 | 361 | d6e3e082252fb161d3c1f77edea0d613c4519151 | bigcode/the-stack | train |
3fe33370c542ef0e4b0bef52 | train | function | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_read_lsm_2chzt():
"""Test read LSM: ZCYX (Stack mode) uint8."""
fname = public_file('scif.io/2chZT.lsm')
with TiffFile(fname) as tif:
assert tif.is_lsm
assert tif.byteorder == '<'
assert len(tif.pages) == 798
assert len... | @pytest.mark.skipif(SKIP_PUBLIC, reason=REASON)
def test_read_lsm_2chzt():
| """Test read LSM: ZCYX (Stack mode) uint8."""
fname = public_file('scif.io/2chZT.lsm')
with TiffFile(fname) as tif:
assert tif.is_lsm
assert tif.byteorder == '<'
assert len(tif.pages) == 798
assert len(tif.series) == 2
# assert page properties
page = tif.pages... | DimensionY'] == 512
assert tags['DimensionZ'] == 1
assert tags['DimensionTime'] == 1
assert tags['DimensionChannels'] == 1
# assert lsm_scan_info tags
tags = tif.lsm_metadata['ScanInformation']
assert tags['ScanMode'] == 'Plane'
assert tags['User'] == 'LSM User'
... | 256 | 256 | 858 | 23 | 233 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_lsm_2chzt | test_read_lsm_2chzt | 5,958 | 6,035 | 5,958 | 5,959 | 9a2b46cafa6a4722a771c0822a003c5afb330e64 | bigcode/the-stack | train |
fa7148be8a6f3b92ba64951c | train | function | def test_write_append_bytesio():
"""Test append to existing TIFF file in BytesIO."""
data = random_data(numpy.uint8, (21, 31))
offset = 11
file = BytesIO()
file.write(b'a' * offset)
with TiffWriter(file) as tif:
pass
file.seek(offset)
with TiffFile(file) as tif:
assert l... | def test_write_append_bytesio():
| """Test append to existing TIFF file in BytesIO."""
data = random_data(numpy.uint8, (21, 31))
offset = 11
file = BytesIO()
file.write(b'a' * offset)
with TiffWriter(file) as tif:
pass
file.seek(offset)
with TiffFile(file) as tif:
assert len(tif.pages) == 0
file.seek... | File(fname) as tif:
assert len(tif.series) == 2
assert len(tif.pages) == 3
page = tif.pages[0]
assert page.imagewidth == 31
assert page.imagelength == 21
assert_array_equal(tif.asarray(series=1)[1], data)
assert__str__(tif)
ass... | 92 | 92 | 308 | 7 | 85 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_append_bytesio | test_write_append_bytesio | 10,103 | 10,140 | 10,103 | 10,103 | 0a255cda96d6cb8a6f1cdd58664b33a968cce975 | bigcode/the-stack | train |
7ee75051e4869b2950afc0f9 | train | function | def test_write_compression_tiled():
"""Test write compressed tiles."""
data = WRITE_DATA
with TempFileName('compression_tiled') as fname:
imwrite(
fname,
data,
compression=ADOBE_DEFLATE,
tile=(32, 32),
photometric=RGB,
)
ass... | def test_write_compression_tiled():
| """Test write compressed tiles."""
data = WRITE_DATA
with TempFileName('compression_tiled') as fname:
imwrite(
fname,
data,
compression=ADOBE_DEFLATE,
tile=(32, 32),
photometric=RGB,
)
assert_valid_tiff(fname)
with T... | pixel == 3
assert page.rowsperstrip == 32
assert len(page.dataoffsets) == 21
image = tif.asarray()
assert_array_equal(data, image)
assert_aszarr_method(tif, image)
assert__str__(tif)
def test_write_compression_tiled():
| 68 | 68 | 227 | 8 | 60 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_compression_tiled | test_write_compression_tiled | 11,006 | 11,033 | 11,006 | 11,006 | bd86058e7a4250923aff22907e51eb35d268679e | bigcode/the-stack | train |
c80e7db5a134f4e292467d50 | train | function | def test_write_auto_rgba_planar():
"""Test write auto planar RGBA."""
data = random_data(numpy.uint8, (4, 219, 301))
with TempFileName('auto_rgba_planar') as fname:
with pytest.warns(DeprecationWarning):
imwrite(fname, data) # photometric=RGB, planarconfig=SEPARATE
assert_valid_... | def test_write_auto_rgba_planar():
| """Test write auto planar RGBA."""
data = random_data(numpy.uint8, (4, 219, 301))
with TempFileName('auto_rgba_planar') as fname:
with pytest.warns(DeprecationWarning):
imwrite(fname, data) # photometric=RGB, planarconfig=SEPARATE
assert_valid_tiff(fname)
with TiffFile(f... | assert page.samplesperpixel == 4
assert page.extrasamples[0] == UNASSALPHA
image = tif.asarray()
assert_array_equal(data, image)
assert_aszarr_method(tif, image)
assert__str__(tif)
def test_write_auto_rgba_planar():
| 66 | 66 | 223 | 9 | 57 | bioturing/tifffile | tests/test_tifffile.py | Python | test_write_auto_rgba_planar | test_write_auto_rgba_planar | 11,835 | 11,855 | 11,835 | 11,835 | 3eb940d8e0bf42570566a806a18646425e138505 | bigcode/the-stack | train |
59e1fe656beebad0c3079f82 | train | function | @pytest.mark.skipif(
SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON
)
def test_read_svs_cmu1():
"""Test read Aperio SVS slide, JPEG and LZW."""
fname = private_file('AperioSVS/CMU-1.svs')
with TiffFile(fname) as tif:
assert tif.is_svs
assert not tif.is_scanimage
... | @pytest.mark.skipif(
SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON
)
def test_read_svs_cmu1():
| """Test read Aperio SVS slide, JPEG and LZW."""
fname = private_file('AperioSVS/CMU-1.svs')
with TiffFile(fname) as tif:
assert tif.is_svs
assert not tif.is_scanimage
assert len(tif.pages) == 6
assert len(tif.series) == 4
for page in tif.pages:
svs_descrip... | [3].shape == (4368, 8736)
data = series.levels[3].asarray()
assert data[1000, 1000] == 1095
assert_aszarr_method(series.levels[3], data)
assert__str__(tif)
@pytest.mark.skipif(
SKIP_PUBLIC or SKIP_CODECS or not imagecodecs.JPEG, reason=REASON
)
def test_read_svs_cmu1():
| 100 | 100 | 335 | 37 | 63 | bioturing/tifffile | tests/test_tifffile.py | Python | test_read_svs_cmu1 | test_read_svs_cmu1 | 6,732 | 6,766 | 6,732 | 6,735 | 34c04f7b96460727466cb74b088be897756c943b | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.