Skip to content

Commit fd6addf

Browse files
authored
Merge pull request #532 from jgrewe/bitsandpieces
addresses a few issues
2 parents 8bfbb4c + 64a501f commit fd6addf

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

nixio/entity.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ def __init__(self, nixfile, nixparent, h5group):
2121
@classmethod
2222
def create_new(cls, nixfile, nixparent, h5parent, name=None, type_=None):
2323
if name and type_:
24-
util.check_entity_name_and_type(name, type_)
2524
id_ = util.create_id()
26-
else:
25+
if not name:
2726
name = util.create_id()
2827
id_ = name
28+
util.check_entity_name_and_type(name, type_)
29+
2930
h5group = h5parent.open_group(name)
3031
h5group.set_attr("name", name)
3132
h5group.set_attr("type", type_)

nixio/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def create_block(self, name="", type_="", compression=Compression.Auto,
419419
return self.blocks[entity_id]
420420

421421
if name in self._data:
422-
raise ValueError("Block with the given name already exists!")
422+
raise DuplicateName("Block with the given name already exists!")
423423
if compression == Compression.Auto:
424424
compression = self._compr
425425
block = Block.create_new(self, self._data, name, type_, compression)

nixio/info.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"VERSION": "1.5.1",
2+
"VERSION": "1.5.2",
33
"STATUS": "Release",
4-
"RELEASE": "1.5.1 Release",
4+
"RELEASE": "1.5.2 Release",
55
"AUTHOR": "Christian Kellner, Adrian Stoewer, Andrey Sobolev, Jan Grewe, Balint Morvai, Achilleas Koutsou",
6-
"COPYRIGHT": "2014-2020, German Neuroinformatics Node, Christian Kellner, Adrian Stoewer, Andrey Sobolev, Jan Grewe, Balint Morvai, Achilleas Koutsou",
6+
"COPYRIGHT": "2014-2021, German Neuroinformatics Node, Christian Kellner, Adrian Stoewer, Andrey Sobolev, Jan Grewe, Balint Morvai, Achilleas Koutsou",
77
"CONTACT": "[email protected]",
88
"BRIEF": "Python reimplementation of NIXIO (http://g-node.github.io/nix/)",
99
"HOMEPAGE": "https://github.com/G-Node/nixpy"

nixio/test/test_file.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
# modification, are permitted under the terms of the BSD License. See
88
# LICENSE file in the root of the Project.
99
import os
10-
import unittest
10+
import time
1111
import h5py
12+
import unittest
1213
import numpy as np
13-
import time
1414

1515
import nixio as nix
1616
import nixio.file as filepy
17-
from nixio.exceptions import InvalidFile
17+
from nixio.exceptions import InvalidFile, DuplicateName
18+
1819
from .tmp import TempDir
1920

2021

@@ -47,7 +48,8 @@ def test_file_blocks(self):
4748
assert len(self.file.blocks) == 0
4849

4950
block = self.file.create_block("test block", "recordingsession")
50-
51+
with self.assertRaises(DuplicateName):
52+
self.file.create_block("test block", "recordingsession")
5153
assert len(self.file.blocks) == 1
5254

5355
assert block in self.file.blocks
@@ -61,6 +63,13 @@ def test_file_blocks(self):
6163

6264
assert len(self.file.blocks) == 0
6365

66+
with self.assertRaises(ValueError):
67+
self.file.create_block()
68+
self.file.create_block(name="a name")
69+
70+
b = self.file.create_block(type_="type_a")
71+
assert b.id == b.name
72+
6473
def test_file_sections(self):
6574
assert len(self.file.sections) == 0
6675

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
__author__ = 'Christian Kellner, Achilleas Koutsou'
88

9+
if sys.version_info.major < 3 or (sys.version_info.major > 2 and sys.version_info.minor < 6):
10+
sys.exit('Sorry, nixio requires python >= 3.6!')
911

1012
with open('README.rst') as f:
1113
description_text = f.read()
@@ -72,6 +74,7 @@ def get_wheel_data():
7274
license='BSD',
7375
packages=packages,
7476
scripts=[],
77+
python_requires=">=3.6",
7578
tests_require=['pytest', 'scipy', 'pillow', 'matplotlib'],
7679
test_suite='pytest',
7780
setup_requires=['pytest-runner'],

0 commit comments

Comments
 (0)