Skip to content

Commit

Permalink
0.0.1dev0
Browse files Browse the repository at this point in the history
  • Loading branch information
celik-muhammed committed Dec 15, 2024
1 parent 45ccd0e commit 5f4b5a0
Show file tree
Hide file tree
Showing 97 changed files with 1,821 additions and 1,018 deletions.
5 changes: 2 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

[submodule "lightnumpy/_cpp_core/NumCpp"]
path = lightnumpy/_cpp_core/NumCpp
[submodule "third_party/NumCpp"]
path = third_party/NumCpp
url = https://github.com/scikit-plots/NumCpp.git
branch = gh_numcpp
6 changes: 6 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!--placeholder page so Github knows we have a CoC-->

Our Code of Conduct is at
https://scikit-plots.github.io/stable/project/code_of_conduct.html

It is rendered from `doc/source/project/code_of_conduct.rst`
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## Include all Python files (these are included by default, but it's good practice to be explicit)
## Include all files in the package source code
recursive-include scikitplot *
recursive-include lightnumpy *

## Include specific files with particular extensions in a subdirectory
#recursive-include assets *.png *.jpg *.svg
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## Makefile for Python Packaging Library

# Authors: The scikit-plots developers
# SPDX-License-Identifier: BSD-3-Clause

## This Makefile contains various "targets" for project management tasks such as "compiling" the project,
## "cleaning" up build files, "running" tests, "building" Docker images, and more.

Expand Down
47 changes: 17 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pip install lightnumpy
- **Scalable**: Ideal for IoT, embedded systems, and resource-limited devices.

## See Also
- https://scikit-plots.github.io/stable/api/scikitplot._numcpp_api.html
- [1] https://scikit-plots.github.io/stable/api/scikitplot._numcpp_api.html
- [2] https://github.com/dpilger26/NumCpp
---

## LightNumPy Project Structure
Expand All @@ -40,20 +40,14 @@ lightnumpy/
│ ├── __init__.py # Main package initializer
│ ├── .clang-format # Code formatting rules for C/C++, code formatting rules like braces placement, and spacing.
│ ├── .clang-tidy # Code linting rules for C/C++, code analysis, warnings, and bug detection.
│ ├── _c_core/ # Low-level C implementation sources
│ │ ├── include/ # C headers
│ │ │ ├── array.h # Array definitions
│ │ │ └── math_ops.h # Math operation headers
│ │ └── src/ # C source files
│ │ ├── array.c # Array operations
│ │ └── math_ops.c # Math implementations
│ ├── _cpp_core/ # Higher-level C++ implementation sources
│ │ ├── include/ # C++ headers
│ │ │ ├── tensor.hpp # Tensor operations
│ │ │ └── utilities.hpp # Helper utilities
│ │ └── src/ # C++ source files
│ │ ├── tensor.cpp # Tensor operation implementations
│ │ └── utilities.cpp # Utility function implementations
│ ├── _core/ # Low-level C and Higher-level C++ implementation sources
│ │ ├── include/ # C and C++ headers
│ │ │ ├── lightnumpy # lightnumpy core C and C++ headers
│ │ │ └── NumCpp # NumCpp Headers [2], Only available when packages installed
│ │ └── src/ # C and C++ source files
│ │ ├── dummymodule.c # Sample Module
│ │ ├── hello.c # Print and string operations
│ │ └── nc_version.cpp # NumCpp Headers versions
│ ├── _gpu_core/ # GPU operations
│ │ ├── include/ # GPU headers
│ │ │ ├── gpu_ops.hpp # GPU operation definitions
Expand All @@ -70,25 +64,18 @@ lightnumpy/
│ │ └── tpu_helpers.cpp # TPU utility functions
│ ├── cy_bindings/ # Cython implementation, Cython bridging native libraries with Python APIs
│ │ ├── __init__.py # Initialize the cython package
│ │ ├── include/ # Headers
│ │ └── src/ # TPU source files
│ │ ├── array_cy.pyx # Cython implementation of array module
│ │ ├── linalg_cy.pyx # Cython implementation of linalg operations
│ │ ├── utils_cy.pyx # Cython utilities
│ │ ├── gpu_cy.pyx # GPU-specific Cython bindings
│ │ ├── tpu_cy.pyx # TPU-specific Cython bindings
│ │ ├── include/ # Cython Headers
│ │ └── src/ # Cython Source files
│ │ └── cython_helpers.pxd # Shared Cython declarations (optional)
│ ├── py_bindings/ # Bindings for Python and native code, pybind11 bridging native libraries with Python APIs
│ │ ├── include/ # Headers
│ │ └── src/ # TPU source files
│ │ ├── c_bindings.c # C-Python bindings
│ │ ├── cpp_bindings.cpp # C++-Python bindings
│ │ ├── gpu_bindings.cu # CUDA-Python bindings
│ │ ├── tpu_bindings.cpp # TPU-Python bindings
│ │ ├── include/ # pybind11 Headers
│ │ └── src/ # pybind11 Source files
│ │ ├── py_math.cpp # Element-wise operations
│ │ ├── py_nc_random # Random array functionality pybind11 with NumCpp
│ │ └── pybind_utils.cpp # Helper functions for bindings
│ ├── python_api/ # Pure Python layer providing user-friendly interfaces for core functionality
│ │ ├── __init__.py # API entry point for `python_api`
│ │ ├── _utils_impl.py # get_c_include, get_cpp_include, and get_include for lightnumpy library's C and C++ headers
│ │ ├── _utils_impl.py # get_include for lightnumpy library's C and C++ _core Headers with NumCpp Headers [2]
│ │ ├── array.py # Array class implementation and basic methods
│ │ ├── core.py # Contains core array functionality
│ │ ├── linalg.py # Basic linear algebra operations (e.g., dot, transpose)
Expand Down
3 changes: 3 additions & 0 deletions lightnumpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@


from .python_api import *; del python_api;
from . import (
_core,
)

# Remove symbols imported for internal use
del (
Expand Down
21 changes: 21 additions & 0 deletions lightnumpy/_build_utils/copyfiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
Platform independent file copier script
"""
#!/usr/bin/env python
import shutil
import argparse


def main():
parser = argparse.ArgumentParser()
parser.add_argument("infiles", nargs='+',
help="Paths to the input files")
parser.add_argument("outdir",
help="Path to the output directory")
args = parser.parse_args()
for infile in args.infiles:
shutil.copy2(infile, args.outdir)


if __name__ == "__main__":
main()
37 changes: 37 additions & 0 deletions lightnumpy/_build_utils/system_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def combine_dict(*dicts, **kw):
"""
Combine Numpy distutils style library configuration dictionaries.
Parameters
----------
*dicts
Dictionaries of keys. List-valued keys will be concatenated.
Otherwise, duplicate keys with different values result to
an error. The input arguments are not modified.
**kw
Keyword arguments are treated as an additional dictionary
(the first one, i.e., prepended).
Returns
-------
combined
Dictionary with combined values.
"""
new_dict = {}

for d in (kw,) + dicts:
for key, value in d.items():
if new_dict.get(key, None) is not None:
old_value = new_dict[key]
if isinstance(value, (list, tuple)):
if isinstance(old_value, (list, tuple)):
new_dict[key] = list(old_value) + list(value)
continue
elif value == old_value:
continue

raise ValueError(f"Conflicting configuration dicts: {new_dict!r} {d!r}")
else:
new_dict[key] = value

return new_dict
71 changes: 71 additions & 0 deletions lightnumpy/_build_utils/tempita.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env python3
import os
import sys
import argparse

# XXX: If this import ever fails (does it really?), vendor either
# cython.tempita or numpy/npy_tempita.
from Cython import Tempita as tempita


def process_tempita(fromfile, outfile=None):
"""Process tempita templated file and write out the result.
The template file is expected to end in `.c.in` or `.pyx.in`:
E.g. processing `template.c.in` generates `template.c`.
"""
# template = tempita.Template.from_filename(
# fromfile,
# encoding=sys.getdefaultencoding()
# )
with open(fromfile, "r", encoding="utf-8") as f:
template_content = f.read()
template = tempita.Template(template_content)
content = template.substitute()

with open(outfile, "w", encoding="utf-8") as f:
f.write(content)


def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"infile",
type=str,
help="Path to the input file"
)
parser.add_argument(
"-o",
"--outfile",
type=str,
help="Path to the output file"
)
parser.add_argument(
"-i",
"--ignore",
type=str,
help="An ignored input - may be useful to add a "
"dependency between custom targets",
)
args = parser.parse_args()

if not args.infile.endswith('.in'):
raise ValueError(f"Unexpected extension: {args.infile}")

if not args.outfile:
raise ValueError("Missing `--outfile` argument to tempita.py")

if os.path.isabs(args.outfile):
raise ValueError("`--outfile` must relative to the current directory")

outdir_abs = os.path.join(os.getcwd(), args.outfile)
outfile = os.path.join(
outdir_abs, os.path.splitext(os.path.split(args.infile)[1])[0]
)

process_tempita(args.infile, outfile)


if __name__ == "__main__":
main()
1 change: 0 additions & 1 deletion lightnumpy/_c_core/include/array.h

This file was deleted.

4 changes: 0 additions & 4 deletions lightnumpy/_c_core/include/config_c_core.h

This file was deleted.

41 changes: 0 additions & 41 deletions lightnumpy/_c_core/include/hello.h

This file was deleted.

1 change: 0 additions & 1 deletion lightnumpy/_c_core/include/math_ops.h

This file was deleted.

4 changes: 0 additions & 4 deletions lightnumpy/_c_core/include/numpy_c.h

This file was deleted.

4 changes: 0 additions & 4 deletions lightnumpy/_c_core/include/python_c.h

This file was deleted.

6 changes: 0 additions & 6 deletions lightnumpy/_c_core/include/std_lib_c.h

This file was deleted.

Loading

0 comments on commit 5f4b5a0

Please sign in to comment.