Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #1024 and #1025 #1030

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ git clone https://github.com/htm-community/htm.core

2) At a command prompt, `cd` to the root directory of this repository.

3) Run: `python setup.py install --user --force`
3) Run: `pip install . --user --force`

This will build and install a release version of htm.core. The `--user` option prevents the system installed site-packages folder from being changed and avoids the need for admin privileges. The `--force` option forces the package to be replaced if it already exists from a previous build. Alternatively you can type `pip uninstall htm.core` to remove a previous package before performing a build.

* If you are using `virtualenv` you may not need the --user or --force options.
* If you are using a uv virtual environment then you only need to run: `uv pip install .`
* If you are using Anaconda Python you must run within the `Anaconda Prompt` on Windows. Do not use --user or --force options.

* If you run into problems due to caching of arguments in CMake, delete the
Expand Down Expand Up @@ -439,8 +440,10 @@ You should run tests locally, and tests are also run as a part of the CI.
There are two sets (somewhat duplicit) tests for c++ and python.

* C++ Unit tests -- to run: `./build/Release/bin/unit_tests`
* Python Unit tests -- to run: `python setup.py test` (runs also the C++ tests above)
- `py/tests/`
* Python Unit tests -- to run
1. Run `pytest ./py`
2. Run `pytest ./bindings`

- `bindings/py/tests/`


Expand Down
4 changes: 2 additions & 2 deletions bindings/py/tests/sdr/SDR_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def testSparsity(self):
seed += 1
sdrs.append( inp )
X.intersection( sdrs )
mean_sparsity = np.product( sparsities )
mean_sparsity = np.prod( sparsities )
assert( X.getSparsity() >= (2./3.) * mean_sparsity )
assert( X.getSparsity() <= (4./3.) * mean_sparsity )

Expand Down Expand Up @@ -499,7 +499,7 @@ def testSparsity(self):
seed += 1
sdrs.append( inp )
X.union( sdrs )
mean_sparsity = np.product(list( 1 - s for s in sparsities ))
mean_sparsity = np.prod(list( 1 - s for s in sparsities ))
assert( X.getSparsity() >= (2./3.) * (1 - mean_sparsity) )
assert( X.getSparsity() <= (4./3.) * (1 - mean_sparsity) )

Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[project]
name = "htm.core"
version = "2.1.16"
description = "This is a Community Fork of the nupic.core"
readme = "README.md"
requires-python = ">=3"
dependencies = [
"numpy",
"hexy",
"pybind11",
"pytest-cov",
"hexy",
"mock",
"cmake",
"requests",
"prettytable",
"setuptools>=75.8.0",
]

[build-system]
fcr marked this conversation as resolved.
Show resolved Hide resolved
requires = ["setuptools", "cmake"]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pip>=22.3.1
wheel>=0.38.4
cmake>=3.14 #>=3.7, >=3.14 needed for MSVC 2019, >=3.21 needed for MSVC 2022
## for python bindings (in /bindings/py/)
numpy==1.23 # For a newer numpy such as V2.x, you must be running at least Python 3.9
numpy # For a newer numpy such as V2.x, you must be running at least Python 3.9
pytest>=4.6.5 #4.6.x series is last to support python2, once py2 dropped, we can switch to 5.x
## for python code (in /py/)
hexy>=1.4.4 # for grid cell encoder
Expand Down
11 changes: 11 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ description-file = README.md
[build_ext]
inplace=1

[options]
install_requires =
numpy
pybind11
pytest-cov
hexy
mock
cmake
requests
prettytable

[tool:pytest]
# NOTE the ci builds rely on these settings
addopts =
Expand Down
49 changes: 0 additions & 49 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import json

from setuptools import Command, find_packages, setup
from setuptools.command.test import test as BaseTestCommand
# see https://stackoverflow.com/questions/44323474/distutils-core-vs-setuptools-with-c-extension
from setuptools import Extension
from pathlib import Path
Expand Down Expand Up @@ -146,52 +145,6 @@ def findRequirements(platform, fileName="requirements.txt"):
]



class TestCommand(BaseTestCommand):
user_options = [("pytest-args=", "a", "Arguments to pass to py.test")]


def initialize_options(self):
BaseTestCommand.initialize_options(self)
self.pytest_args = [] # pylint: disable=W0201


def finalize_options(self):
BaseTestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True


def run_tests(self):
import pytest
cwd = os.getcwd()
errno = 0
os.chdir(REPO_DIR)
# run c++ tests (from python)
cpp_tests = os.path.join(REPO_DIR, "build", "Release", "bin", "unit_tests")
subprocess.check_call([cpp_tests])
os.chdir(cwd)


# run python bindings tests (in /bindings/py/tests/)
try:
os.chdir(os.path.join(REPO_DIR, "bindings", "py","tests"))
errno = pytest.main(self.pytest_args)
finally:
os.chdir(cwd)
if errno != 0:
sys.exit(errno)

# python tests (in /py/tests/)
try:
os.chdir(os.path.join(REPO_DIR, "py", "tests"))
errno = pytest.main(self.pytest_args)
finally:
os.chdir(cwd)
sys.exit(errno)



def getPlatformInfo():
"""Identify platform."""
if "linux" in sys.platform:
Expand All @@ -206,7 +159,6 @@ def getPlatformInfo():
return platform



def getExtensionFileNames(platform, build_type):
# look for extension libraries in Repository/build/Release/distr/src/htm/bindings
# library filenames:
Expand Down Expand Up @@ -451,7 +403,6 @@ def configure(platform, build_type):
zip_safe=False,
cmdclass={
"clean": CleanCommand,
"test": TestCommand,
"configure": ConfigureCommand,
},
author="Numenta & HTM Community",
Expand Down