istr-python 1.1.4.post0__tar.gz → 1.1.5__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.
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/PKG-INFO +28 -2
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/README.md +27 -1
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/istr/istr.py +11 -17
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/istr_python.egg-info/PKG-INFO +28 -2
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/pyproject.toml +1 -1
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/istr/LICENSE.txt +0 -0
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/istr/__init__.py +0 -0
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/istr_python.egg-info/SOURCES.txt +0 -0
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/istr_python.egg-info/dependency_links.txt +0 -0
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/istr_python.egg-info/top_level.txt +0 -0
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/setup.cfg +0 -0
- {istr_python-1.1.4.post0 → istr_python-1.1.5}/tests/test_istr.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: istr-python
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.5
|
|
4
4
|
Summary: istr - strings you can count on
|
|
5
5
|
Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/salabim/istr
|
|
@@ -362,7 +362,7 @@ istr.is_odd(5) ==> True
|
|
|
362
362
|
```
|
|
363
363
|
#### test for square
|
|
364
364
|
|
|
365
|
-
It is possible to test whether the value is a perfect
|
|
365
|
+
It is possible to test whether the value is a perfect square (provided the istr can be interpreted as an int) with the `is_square` method, e.g.
|
|
366
366
|
|
|
367
367
|
```
|
|
368
368
|
istr(4).is_square() ==> True
|
|
@@ -372,7 +372,33 @@ It is also possible to test for square of an ordinary int:
|
|
|
372
372
|
```
|
|
373
373
|
istr.is_square(4) ==> True
|
|
374
374
|
istr.is_square(5) ==> False
|
|
375
|
+
|
|
376
|
+
#### test for cube
|
|
377
|
+
|
|
378
|
+
It is possible to test whether the value is a perfect cube (provided the istr can be interpreted as an int) with the `is_cube` method, e.g.
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
istr(27).is_cube() ==> True
|
|
382
|
+
istr(28).is_cube()) ==> False
|
|
383
|
+
```
|
|
384
|
+
It is also possible to test for cube of an ordinary int:
|
|
385
|
+
```
|
|
386
|
+
istr.is_cube(27) ==> True
|
|
387
|
+
istr.is_cube(28 ==> False
|
|
388
|
+
|
|
389
|
+
#### test for power of
|
|
390
|
+
|
|
391
|
+
It is possible to test whether the value is a perfect power of a given exponent (provided the istr can be interpreted as an int) with the `is_power_of` method, e.g.
|
|
392
|
+
|
|
375
393
|
```
|
|
394
|
+
istr(81).is_power_of(4) ==> True
|
|
395
|
+
istr(82).is_power_of(4) ==> False
|
|
396
|
+
```
|
|
397
|
+
It is also possible to test for power of of an ordinary int:
|
|
398
|
+
```
|
|
399
|
+
istr.is_power_of(81, 4) ==> True
|
|
400
|
+
istr.is_power_of(82, 4) ==> False
|
|
401
|
+
|
|
376
402
|
#### test for prime
|
|
377
403
|
|
|
378
404
|
It is possible to test whether the value is a prime number (provided the istr can be interpreted as an int) with the `is_prime` method, e.g.
|
|
@@ -349,7 +349,7 @@ istr.is_odd(5) ==> True
|
|
|
349
349
|
```
|
|
350
350
|
#### test for square
|
|
351
351
|
|
|
352
|
-
It is possible to test whether the value is a perfect
|
|
352
|
+
It is possible to test whether the value is a perfect square (provided the istr can be interpreted as an int) with the `is_square` method, e.g.
|
|
353
353
|
|
|
354
354
|
```
|
|
355
355
|
istr(4).is_square() ==> True
|
|
@@ -359,7 +359,33 @@ It is also possible to test for square of an ordinary int:
|
|
|
359
359
|
```
|
|
360
360
|
istr.is_square(4) ==> True
|
|
361
361
|
istr.is_square(5) ==> False
|
|
362
|
+
|
|
363
|
+
#### test for cube
|
|
364
|
+
|
|
365
|
+
It is possible to test whether the value is a perfect cube (provided the istr can be interpreted as an int) with the `is_cube` method, e.g.
|
|
366
|
+
|
|
367
|
+
```
|
|
368
|
+
istr(27).is_cube() ==> True
|
|
369
|
+
istr(28).is_cube()) ==> False
|
|
370
|
+
```
|
|
371
|
+
It is also possible to test for cube of an ordinary int:
|
|
372
|
+
```
|
|
373
|
+
istr.is_cube(27) ==> True
|
|
374
|
+
istr.is_cube(28 ==> False
|
|
375
|
+
|
|
376
|
+
#### test for power of
|
|
377
|
+
|
|
378
|
+
It is possible to test whether the value is a perfect power of a given exponent (provided the istr can be interpreted as an int) with the `is_power_of` method, e.g.
|
|
379
|
+
|
|
362
380
|
```
|
|
381
|
+
istr(81).is_power_of(4) ==> True
|
|
382
|
+
istr(82).is_power_of(4) ==> False
|
|
383
|
+
```
|
|
384
|
+
It is also possible to test for power of of an ordinary int:
|
|
385
|
+
```
|
|
386
|
+
istr.is_power_of(81, 4) ==> True
|
|
387
|
+
istr.is_power_of(82, 4) ==> False
|
|
388
|
+
|
|
363
389
|
#### test for prime
|
|
364
390
|
|
|
365
391
|
It is possible to test whether the value is a prime number (provided the istr can be interpreted as an int) with the `is_prime` method, e.g.
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
# |_||___/ \__||_|
|
|
6
6
|
# strings you can count on
|
|
7
7
|
|
|
8
|
-
__version__ = "1.1.
|
|
8
|
+
__version__ = "1.1.5"
|
|
9
9
|
import functools
|
|
10
|
-
import math
|
|
11
10
|
import itertools
|
|
12
11
|
import types
|
|
13
12
|
import sys
|
|
@@ -371,23 +370,23 @@ class istr(str):
|
|
|
371
370
|
def is_cube(self):
|
|
372
371
|
return istr._is_power_of(self, 3)
|
|
373
372
|
|
|
374
|
-
def is_power_of(self,
|
|
375
|
-
return istr._is_power_of(self,
|
|
373
|
+
def is_power_of(self, exponent):
|
|
374
|
+
return istr._is_power_of(self, exponent)
|
|
376
375
|
|
|
377
376
|
@staticmethod
|
|
378
|
-
def _is_power_of(self,
|
|
377
|
+
def _is_power_of(self, exponent):
|
|
379
378
|
if isinstance(self, istr):
|
|
380
379
|
if not self.is_int():
|
|
381
380
|
raise TypeError(f"not interpretable as int: {self._frepr(self)}")
|
|
382
381
|
n = self._as_int
|
|
383
382
|
else:
|
|
384
383
|
n = int(self)
|
|
385
|
-
if
|
|
386
|
-
raise ValueError(f"
|
|
387
|
-
if not isinstance(
|
|
388
|
-
raise TypeError(f"
|
|
384
|
+
if exponent < 1:
|
|
385
|
+
raise ValueError(f"exponent must be >=1; not {exponent}")
|
|
386
|
+
if not isinstance(exponent, int):
|
|
387
|
+
raise TypeError(f"exponent must be int; not {type(exponent)}")
|
|
389
388
|
|
|
390
|
-
return n >= 0 and self == round(n ** (1 /
|
|
389
|
+
return n >= 0 and self == round(n ** (1 / exponent)) ** exponent
|
|
391
390
|
|
|
392
391
|
def is_prime(self):
|
|
393
392
|
if isinstance(self, istr):
|
|
@@ -654,12 +653,9 @@ class istr(str):
|
|
|
654
653
|
istr.type = type(istr(0))
|
|
655
654
|
|
|
656
655
|
|
|
657
|
-
def main(): ...
|
|
658
|
-
|
|
659
|
-
|
|
660
656
|
class istrModule(types.ModuleType):
|
|
661
657
|
def __call__(self, *args, **kwargs):
|
|
662
|
-
return istr
|
|
658
|
+
return istr(*args, **kwargs)
|
|
663
659
|
|
|
664
660
|
def __setattr__(self, item, value):
|
|
665
661
|
setattr(istr, item, value)
|
|
@@ -668,7 +664,5 @@ class istrModule(types.ModuleType):
|
|
|
668
664
|
return getattr(istr, item)
|
|
669
665
|
|
|
670
666
|
|
|
671
|
-
if __name__
|
|
672
|
-
main()
|
|
673
|
-
else:
|
|
667
|
+
if __name__ != "__main__":
|
|
674
668
|
sys.modules["istr"].__class__ = istrModule
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: istr-python
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.5
|
|
4
4
|
Summary: istr - strings you can count on
|
|
5
5
|
Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/salabim/istr
|
|
@@ -362,7 +362,7 @@ istr.is_odd(5) ==> True
|
|
|
362
362
|
```
|
|
363
363
|
#### test for square
|
|
364
364
|
|
|
365
|
-
It is possible to test whether the value is a perfect
|
|
365
|
+
It is possible to test whether the value is a perfect square (provided the istr can be interpreted as an int) with the `is_square` method, e.g.
|
|
366
366
|
|
|
367
367
|
```
|
|
368
368
|
istr(4).is_square() ==> True
|
|
@@ -372,7 +372,33 @@ It is also possible to test for square of an ordinary int:
|
|
|
372
372
|
```
|
|
373
373
|
istr.is_square(4) ==> True
|
|
374
374
|
istr.is_square(5) ==> False
|
|
375
|
+
|
|
376
|
+
#### test for cube
|
|
377
|
+
|
|
378
|
+
It is possible to test whether the value is a perfect cube (provided the istr can be interpreted as an int) with the `is_cube` method, e.g.
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
istr(27).is_cube() ==> True
|
|
382
|
+
istr(28).is_cube()) ==> False
|
|
383
|
+
```
|
|
384
|
+
It is also possible to test for cube of an ordinary int:
|
|
385
|
+
```
|
|
386
|
+
istr.is_cube(27) ==> True
|
|
387
|
+
istr.is_cube(28 ==> False
|
|
388
|
+
|
|
389
|
+
#### test for power of
|
|
390
|
+
|
|
391
|
+
It is possible to test whether the value is a perfect power of a given exponent (provided the istr can be interpreted as an int) with the `is_power_of` method, e.g.
|
|
392
|
+
|
|
375
393
|
```
|
|
394
|
+
istr(81).is_power_of(4) ==> True
|
|
395
|
+
istr(82).is_power_of(4) ==> False
|
|
396
|
+
```
|
|
397
|
+
It is also possible to test for power of of an ordinary int:
|
|
398
|
+
```
|
|
399
|
+
istr.is_power_of(81, 4) ==> True
|
|
400
|
+
istr.is_power_of(82, 4) ==> False
|
|
401
|
+
|
|
376
402
|
#### test for prime
|
|
377
403
|
|
|
378
404
|
It is possible to test whether the value is a prime number (provided the istr can be interpreted as an int) with the `is_prime` method, e.g.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|