Skip to main content

CI CI

Installation

$ pip install numpy_fn

Usage

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Time-stamp: "2024-04-07 21:56:35 (ywatanabe)"

from numpy_fn import numpy_fn

import numpy as np
import pandas as pd
import scipy
import torch


@numpy_fn
def numpy_softmax(*args, **kwargs):
    return scipy.special.softmax(*args, **kwargs)


def custom_print(x):
    print(type(x), x)


# Test the decorator with different input types
x = [1, 2, 3]
x_list = x
x_array = np.array(x)
x_df = pd.DataFrame({"col1": x})
x_tensor = torch.tensor(x).float()
if torch.cuda.is_available():
    x_tensor_cuda = torch.tensor(x).float().cuda()

custom_print(numpy_softmax(x_list, axis=-1))
# <class 'numpy.ndarray'> [0.09003057 0.24472847 0.66524096]

custom_print(numpy_softmax(x_array, axis=-1))
# <class 'numpy.ndarray'> [0.09003057 0.24472847 0.66524096]

custom_print(numpy_softmax(x_df, axis=-1))
# <class 'numpy.ndarray'> [0.09003057 0.24472847 0.66524096]

custom_print(numpy_softmax(x_tensor, axis=-1))
# /home/ywatanabe/proj/numpy_fn/src/numpy_fn/_numpy_fn.py:57: UserWarning: Converted from  <class 'numpy.ndarray'> to <class 'torch.Tensor'> (cpu)
#   warnings.warn(
# <class 'torch.Tensor'> tensor([0.0900, 0.2447, 0.6652])

if torch.cuda.is_available():
    custom_print(numpy_softmax(x_tensor_cuda, axis=-1))
# /home/ywatanabe/proj/numpy_fn/src/numpy_fn/_numpy_fn.py:57: UserWarning: Converted from  <class 'numpy.ndarray'> to <class 'torch.Tensor'> (cuda:0)
#   warnings.warn(
# <class 'torch.Tensor'> tensor([0.0900, 0.2447, 0.6652], device='cuda:0')

Metadata

Release files for numpy-fn 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for numpy-fn 1.0.0
File Size Uploaded Provenance
numpy_fn-1.0.0.tar.gz 4.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for numpy-fn 1.0.0
File Interpreter ABI Platform
numpy_fn-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / numpy_fn-1.0.0.tar.gz

Download URL numpy_fn-1.0.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
abfd4b6b118ccc4087b8fef3c40b85daab094081ee2818b69dd464df7230f44f
BLAKE2b-256 checksum
How to use checksums
a96aa1e646a6dfe39b70570b64565430a43702b13d9ae1a04012f0b001565016
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / numpy_fn-1.0.0-py3-none-any.whl

Download URL numpy_fn-1.0.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ac08fed655529a1214248d4db19fe168333b2d7b27937e46874bfb19bbeaf72
BLAKE2b-256 checksum
How to use checksums
5fcea7462156327392f82a3e075cd055823e6daa1743a11d0922f5393aa59c25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Security for numpy-fn 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page