qrotor 4.4.0__tar.gz → 4.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qrotor
3
- Version: 4.4.0
3
+ Version: 4.4.1
4
4
  Summary: QRotor
5
5
  Author: Pablo Gila-Herranz
6
6
  Author-email: pgila001@ikasle.ehu.eus
@@ -11,5 +11,5 @@ https://semver.org/
11
11
  ---
12
12
  """
13
13
 
14
- __version__ = "v4.4.0"
14
+ __version__ = "v4.4.1"
15
15
 
@@ -324,11 +324,13 @@ def filter_tags(
324
324
  systems:list,
325
325
  include:str='',
326
326
  exclude:str='',
327
+ strict:bool=False,
327
328
  ) -> list:
328
329
  """Returns a filtered list of systems with or without specific tags.
329
-
330
- Tags are separated by blank spaces.
331
- Include tags from `include`, exclude tags from `exclude`.
330
+
331
+ You can `include` or `exclude` any number of tags, separated by blank spaces.
332
+ By default, the filters are triggered if any tag is found, i.e. *tag1 OR tag2*.
333
+ Set `strict=True` to require all tags to match, i.e. *tag1 AND tag2*.
332
334
  """
333
335
  systems = as_list(systems)
334
336
  included_tags = include.split()
@@ -336,12 +338,16 @@ def filter_tags(
336
338
  filtered_systems = []
337
339
  for i in systems:
338
340
  tags_found = list_tags(i)
339
- if excluded_tags and any(tag in excluded_tags for tag in tags_found):
340
- continue
341
+ if excluded_tags:
342
+ if strict and all(tag in tags_found for tag in excluded_tags):
343
+ continue
344
+ elif not strict and any(tag in tags_found for tag in excluded_tags):
345
+ continue
341
346
  if included_tags:
342
- if any(tag in included_tags for tag in tags_found):
343
- filtered_systems.append(i)
344
- else:
345
- filtered_systems.append(i)
347
+ if strict and not all(tag in tags_found for tag in included_tags):
348
+ continue
349
+ elif not strict and not any(tag in tags_found for tag in included_tags):
350
+ continue
351
+ filtered_systems.append(i)
346
352
  return filtered_systems
347
353
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qrotor
3
- Version: 4.4.0
3
+ Version: 4.4.1
4
4
  Summary: QRotor
5
5
  Author: Pablo Gila-Herranz
6
6
  Author-email: pgila001@ikasle.ehu.eus
@@ -15,8 +15,10 @@ qrotor.egg-info/SOURCES.txt
15
15
  qrotor.egg-info/dependency_links.txt
16
16
  qrotor.egg-info/requires.txt
17
17
  qrotor.egg-info/top_level.txt
18
+ tests/__init__.py
18
19
  tests/test_constants.py
19
20
  tests/test_potential.py
20
21
  tests/test_rotate.py
21
22
  tests/test_solve.py
22
- tests/test_system.py
23
+ tests/test_system.py
24
+ tests/test_systems.py
@@ -1 +1,2 @@
1
1
  qrotor
2
+ tests
File without changes
@@ -0,0 +1,30 @@
1
+ import qrotor as qr
2
+
3
+
4
+ def test_tags():
5
+ sys1 = qr.System(tags='tag1 tag2 tag3', comment='sys1', potential_name='zero')
6
+ sys2 = qr.System(tags='tag2 tag3 tag4', comment='sys2')
7
+ sys3 = qr.System(tags='tag4 tag5 tag6', comment='sys3')
8
+ sys1.solve(100)
9
+ test1 = qr.systems.filter_tags(sys1, include='tag4')
10
+ assert test1 == []
11
+ test2 = qr.systems.filter_tags([sys1, sys2], include='tag4 tag5', strict=False)
12
+ assert len(test2) == 1
13
+ assert test2[0].comment == 'sys2'
14
+ test3 = qr.systems.filter_tags([sys1, sys2], include='tag4 tag5', strict=True)
15
+ assert test3 == []
16
+ test4 = qr.systems.filter_tags([sys1, sys2, sys3], include='tag3 tag4', strict=False)
17
+ assert len(test4) == 3
18
+ test5 = qr.systems.filter_tags([sys1, sys2, sys3], include='tag3 tag4', strict=True)
19
+ assert len(test5) == 1
20
+ assert test5[0].comment == 'sys2'
21
+ test6 = qr.systems.filter_tags([sys1, sys2, sys3], include='tag3 tag4', exclude='tag6', strict=False)
22
+ assert len(test6) == 2
23
+ test7 = qr.systems.filter_tags([sys1, sys2, sys3], include='tag4', exclude='tag5 tag6', strict=True)
24
+ assert len(test7) == 1
25
+ assert test7[0].comment == 'sys2'
26
+ test8 = qr.systems.filter_tags([sys1, sys2, sys3], include='', exclude='tag1 tag2', strict=True)
27
+ assert len(test8) == 2
28
+ test9 = qr.systems.filter_tags([sys1, sys2, sys3], include='', exclude='tag1 tag2', strict=False)
29
+ assert test9[0].comment == 'sys3'
30
+
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes