semvec/pypi-packages huggingface dataset:
k3rangeset 0.1.4
Segmented range represented as sorted interleaving intervals
License: MIT
Requires Python: >=3.9
Keywords: range, rangeset, interval, segment

# k3rangeset

[![Action-CI](https://github.com/pykit3/k3rangeset/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3rangeset/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3rangeset/badge/?version=stable)](https://k3rangeset.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3rangeset)](https://pypi.org/project/k3rangeset)

segmented range which is represented in a list of sorted interleaving range.

k3rangeset is a component of [pykit3] project: a python3 toolkit set.


Segmented range which is represented in a list of sorted interleaving range.

A range set can be thought as: `[[1, 2], [5, 7]]`.




# Install

```
pip install k3rangeset
```

# Synopsis

```python

import k3rangeset

a = k3rangeset.RangeSet([[1, 5], [10, 20]])
a.has(1)  # True
a.has(8)  # False
a.add([5, 7])  # [[1, 7], [10, 20]]

inp = [
    [0, 1, [['a', 'b', 'ab'],
            ['b', 'd', 'bd'],
            ]],
    [1, 2, [['a', 'c', 'ac'],
            ['c', 'd', 'cd'],
            ]],
]

r = k3rangeset.RangeDict(inp, dimension=2)
print(r.get(0.5, 'a'))  # 'ab'
print(r.get(1.5, 'a'))  # 'ac'

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3pattern 0.1.4
Find common prefix of strings, tuples, and nested structures
License: MIT
Requires Python: >=3.9
Keywords: prefix, common-prefix, string, pattern

# k3pattern

[![Action-CI](https://github.com/pykit3/k3pattern/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3pattern/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3pattern/badge/?version=stable)](https://k3pattern.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3pattern)](https://pypi.org/project/k3pattern)

Find common prefix of several `string`s, tuples of string, or other nested structure, recursively by default.

k3pattern is a component of [pykit3] project: a python3 toolkit set.


Find common prefix of several string, tuples of string, or other nested structure, recursively by default.
It returns the shortest prefix: empty string or empty tuple is removed.



# Install

```
pip install k3pattern
```

# Synopsis

```python

import k3pattern

k3pattern.common_prefix('abc', 'abd')                   # 'ab'
k3pattern.common_prefix((1, 2, 'abc'), (1, 2, 'abd'))   # (1, 2, 'ab')
k3pattern.common_prefix((1, 2, 'abc'), (1, 2, 'xyz'))   # (1, 2); empty prefix of 'abc' and 'xyz' is removed
k3pattern.common_prefix((1, 2, (5, 6)), (1, 2, (5, 7))) # (1, 2, (5,) )
k3pattern.common_prefix('abc', 'abd', 'abe')            # 'ab'; common prefix of more than two
```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3http 0.1.5
HTTP/1.1 client with timeout support
License: MIT
Requires Python: >=3.9
Keywords: http, client, socket, timeout

# k3http

[![Action-CI](https://github.com/pykit3/k3http/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3http/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3http/badge/?version=stable)](https://k3http.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3http)](https://pypi.org/project/k3http)

We find that 'httplib' must work in blocking mode and it can not have a timeout when recving response.

k3http is a component of [pykit3] project: a python3 toolkit set.


HTTP/1.1 client

Use this module, we can set timeout, if timeout raise a 'socket.timeout'.



# Install

```
pip install k3http
```

# Synopsis

```python

import k3http
import urllib
import socket

headers = {
    'Host': '127.0.0.1',
    'Accept-Language': 'en, mi',
}

try:
    h = k3http.Client('127.0.0.1', 80)

    # send http reqeust without body
    # read response status line
    # read response headers
    h.request('/test.txt', method='GET', headers=headers)

    status = h.status
    # response code return from http server, type is int
    # 200
    # 302
    # 404
    # ...

    res_headers = h.headers
    # response headers except status line
    # res_headers = {
    #   'Content-Type': 'text/html;charset=utf-8',
    #   'Content-Length': 1024,
    #   ...
    # }

    # get response body
    print(h.read_body(None))
except (socket.error, k3http.HttpError) as e:
    print(repr(e))



content = urllib.urlencode({'f': 'foo', 'b': 'bar'})
headers = {
    'Host': 'www.example.com',
    'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
    'Content-Length': len(content),
}

try:
    h = k3http.Client('127.0.0.1', 80)

    # send http reqeust
    h.send_request('http://www.example.com', method='POST', headers=headers)

    # send http request body
    h.send_body(content)

    # read response status line and headers
    status, headers = h.read_response()

    # read response body
    print(h.read_body(None))
except (socket.error, k3http.HttpError) as e:
    print(repr(e))

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3modutil 0.1.4
Utilities for loading and inspecting Python submodules
License: MIT
Requires Python: >=3.9
Keywords: module, submodule, import, loader, introspection

# k3modutil

[![Action-CI](https://github.com/pykit3/k3modutil/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3modutil/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3modutil/badge/?version=stable)](https://k3modutil.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3modutil)](https://pypi.org/project/k3modutil)

Submodule Utilities.

k3modutil is a component of [pykit3] project: a python3 toolkit set.


Submodule Utilities.




# Install

```
pip install k3modutil
```

# Synopsis

```python

import k3modutil
import pykit

k3modutil.submodules(pykit)
# {
#    'modutil': <module> pykit.modutil,
#    ... ...
# }

k3modutil.submodule_tree(pykit)
# {
#    'modutil': {'module': <module> pykit.modutil,
#                'children': {
#                            'modutil': {
#                                    'module': <module> pykit.modutil.modutil,
#                                    'children': None,
#                                    },
#                            'test': {
#                                    'module': <module> pykit.modutil.test,
#                                    'children': {
#                                        'test_modutil': {
#                                            'module': <module> pykit.modutil.test.test_modutil,
#                                            'children': None,
#                                        },
#                                    },
#                            }
#                },
#               }
#    ... ...
# }

k3modutil.submodule_leaf_tree(pykit)
# {
#    'modutil': {
#                'modutil': <module> pykit.modutil.modutil,
#                'test': {'test_modutil': <module> pykit.modutil.test.test_modutil},
#                }
#    ... ...
# }

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3mime 0.1.6
MIME type detection by filename
License: MIT
Requires Python: >=3.9
Keywords: mime, mimetype, media-type, content-type

# k3mime

[![Action-CI](https://github.com/pykit3/k3mime/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3mime/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3mime/badge/?version=stable)](https://k3mime.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3mime)](https://pypi.org/project/k3mime)

This module provide some util methods to handle mime type.

k3mime is a component of [pykit3] project: a python3 toolkit set.


#   Table of Content

- [Name](#name)
- [Status](#status)
- [Synopsis](#synopsis)
- [Author](#author)
- [Copyright and License](#copyright-and-license)


#   Name

k3mime

#   Status

The library is considered production ready.




# Install

```
pip install k3mime
```

# Synopsis

```python

import k3mime

print(k3mime.get_by_filename('file.json'))
#  application/json


```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3math 0.1.6
A toy math implementation with Vector, Matrix, and Polynomial
License: MIT
Requires Python: >=3.9
Keywords: math, vector, matrix, polynomial, linear-algebra

# k3math

[![Build Status](https://github.com/pykit3/k3math/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3math/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3math/badge/?version=stable)](https://k3math.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3math)](https://pypi.org/project/k3math)

no desc

k3math is a component of [pykit3] project: a python3 toolkit set.


# Install

```
pip install k3math
```

# Synopsis

```python

xs = [1, 2, 3, 4]
ys = [6, 5, 7, 10]

# Fit polynomial curve with 4 points, at degree 0, 1, 2, 3:
for deg in (0, 1, 2, 3):
    poly = Polynomial.fit(xs, ys, degree=deg)
    print 'y =', poly

    # Evaluate y(5) with polynomial
    y5 = Polynomial.evaluate(poly, 5)
    print 'y(5) =', y5

    # Plot the curve and points
    lines = Polynomial.plot([(poly, '.')], (-1, 6),
                            width=30, height=10,
                            points=zip(xs + [5],
                                       ys + [y5],
                                       ['X', 'X', 'X', 'X', '*']))
    for l in lines:
        print l

# y = 7
# y(5) = 7.0
#                     X
#
#
#
# ...............X.........*....
#      X
#           X
# y = 3.5 + 1.4x
# y(5) = 10.5
#                              .
#                          *...
#                     X....
#                .....
#           .....X
#      X....X
# .....
# y = 8.5 - 3.6x + x²
# y(5) = 15.5
#                              .
#                             .
#                           ..
#                         .*
#                      ...
# ..               ...X
#   ...X....X....X.
# y = 12 - 9.166667x + 3.5x² - 0.333333x³
# y(5) = 12.0
#
# .                     ...*....
#  .                  X.
#   .               ..
#    .            ..
#     .         .X
#      X....X...

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3