semvec/pypi-packages huggingface dataset:
rect-intersection 0.10
Checks if two rectangles intersect
License: MIT
Keywords: rectangles,intersect


# Checks if two rectangles intersect 


```python
# Tested with:
# Python 3.9.13
# Windows 10

from rect_intersection import intersects

# Allowed formats for box1/box2 
format_1x4 = (0, 0, 100, 200)
format_4x2 = [(0, 0), (100, 0), (100, 200), (0, 200)]
format_2x2 = [(0, 0), (100, 200)]

box1 = (0, 0, 100, 200)


box2 = (1000, 1000, 2000, 2000)
print(intersects(box1, box2))
box2 = (50, 20, 2000, 2000)
print(intersects(box1, box2))
box2 = [(50, 20), (2000, 20), (2000, 2000), (50, 2000)]
print(intersects(box1, box2))
box2 = [(50, 20), (2000, 2000)]
print(intersects(box1, box2))


box2 = (1000, 1000, 2000, 2000)
print(intersects(box1, box2))
box2 = (50, 20, 2000, 2000)
print(intersects(box1, box2))
box2 = [(50, 20), (2000, 20), (2000, 2000), (50, 2000)]
print(intersects(box1, box2))
box2 = [(50, 20), (2000, 2000)]
print(intersects(box1, box2))

box2 = (1000, 1000, 2000, 2000)
print(intersects(box1, box2))
box2 = (50, 20, 2000, 2000)
print(intersects(box1, box2))
box2 = [(50, 20), (2000, 20), (2000, 2000), (50, 2000)]
print(intersects(box1, box2))
box2 = [(50, 20), (2000, 2000)]
print(intersects(box1, box2))



False
True
True
True
False
True
True
True
False
True
True
True

	
```
write-read-file 0.10
Some useful functions for reading/writing files
License: MIT
Keywords: files,read,write


# Some useful functions for reading/writing files 


```python
# Tested with:
# Python 3.9.13
# Windows 10

from write_read_file import write_utf8, write_bytes, read_bytes, copy_file, read_and_decode, iterread_bytes, iterread_text

import numpy as np

alldata = [
    np.array([[1, 2, 3], [54, 56, 77]]),
    [10, 12, 44, 1, "gjad", ""],
    "This is a text",
    b"this is a text",
    {1: 22, 33: "hithere"},
]
path = "f:\\test_write_file\\myfile.txt"
path2 = "f:\\test_write_file\\myfile2.txt"

for data in alldata:
    write_utf8(path, data, endofline="\n")
    print("""iterread_text""")
    for line in iterread_text(
        path, encoding="utf-8", strip_newline=True, ignore_empty_lines=True
    ):
        print(line)
    print("""iterread_bytes""")

    for chunk in iterread_bytes(path, chunksize=128):
        print(chunk)
    print("""write_bytes""")

    write_bytes(path, data=[str(x).encode() for x in data], endofline=b"\n")
    print("""iterread_bytes""")

    for chunk in iterread_bytes(path, chunksize=128):
        print(chunk)
    print("""read_and_decode""")

    bytestostring = read_and_decode(
        path, decodeformat="utf-8", on_encoding_errors="replace"
    )
    print(bytestostring)
    print("""copy_file""")

    copy_file(path, path2)
    print("""iterread_bytes""")

    for chunk in iterread_bytes(path2, chunksize=128):
        print(chunk)
    print("""read_bytes""")

    bytedata = read_bytes(path2)
    print(bytedata)

Output: 
iterread_text
1
2
3
54
56
77
iterread_bytes
b'1\r\n2\r\n3\r\n54\r\n56\r\n77\r\n'
write_bytes
iterread_bytes
b'[1 2 3]\n[54 56 77]\n'
read_and_decode
[1 2 3]
[54 56 77]
copy_file
iterread_bytes
b'[1 2 3]\n[54 56 77]\n'
read_bytes
b'[1 2 3]\n[54 56 77]\n'
iterread_text
10
12
44
1
gjad
iterread_bytes
b'10\r\n12\r\n44\r\n1\r\ngjad\r\n\r\n'
write_bytes
iterread_bytes
b'10\n12\n44\n1\ngjad\n\n'
read_and_decode
10
12
44
1
gjad
copy_file
iterread_bytes
b'10\n12\n44\n1\ngjad\n\n'
read_bytes
b'10\n12\n44\n1\ngjad\n\n'
iterread_text
This is a text
iterread_bytes
b'This is a text\r\n'
write_bytes
iterread_bytes
b'T\nh\ni\ns\n \ni\ns\n \na\n \nt\ne\nx\nt\n'
read_and_decode
T
h
i
s
 
i
s
 
a
 
t
e
x
t
copy_file
iterread_bytes
b'T\nh\ni\ns\n \ni\ns\n \na\n \nt\ne\nx\nt\n'
read_bytes
b'T\nh\ni\ns\n \ni\ns\n \na\n \nt\ne\nx\nt\n'
iterread_text
b'this is a text'
iterread_bytes
b"b'this is a text'\r\n"
write_bytes
iterread_bytes
b'116\n104\n105\n115\n32\n105\n115\n32\n97\n32\n116\n101\n120\n116\n'
read_and_decode
116
104
105
115
32
105
115
32
97
32
116
101
120
116
copy_file
iterread_bytes
b'116\n104\n105\n115\n32\n105\n115\n32\n97\n32\n116\n101\n120\n116\n'
read_bytes
b'116\n104\n105\n115\n32\n105\n115\n32\n97\n32\n116\n101\n120\n116\n'
iterread_text
22
hithere
iterread_bytes
b'22\r\nhithere\r\n'
write_bytes
iterread_bytes
b'1\n33\n'
read_and_decode
1
33
copy_file
iterread_bytes
b'1\n33\n'
read_bytes
b'1\n33\n'
	
	
```
flake8-empty-init-modules 1.0.1
flake8 plugin that checks for code in `__init__.py` modules
License: MIT
Requires Python: >=3.8

# flake8-empty-init-modules

flake8 plugin that disallows code in `__init__.py` modules.

## installation

```sh
python -m pip install flake8-empty-init-modules
```

## checks

### EIM001

Disallows all code in any `__init__.py` module.

### EIM002

Allows imports and assignment to `__all__` in `__init__.py` modules, but nothing
else.

This check is disabled by default. To use this check instead of `EIM001` add the
following to your `setup.cfg`

```ini
[flake8]
ignore = EIM001
enable-extensions=EIM002
```

## rationale

Code in `__init__.py` modules is often unwanted because:

- it runs at import-time - this can cause surprising import-time side-effects
- these modules are often empty, so code there is easily missed

The relaxed version of this check allows convenience imports in `__init__.py`
modules without allowing 'real' code to hide out there.