Skip to content

Commit

Permalink
Merge pull request htm-community#516 from htm-community/py-rename-to-htm
Browse files Browse the repository at this point in the history
Switched python package from "nupic" to "htm"
  • Loading branch information
ctrl-z-9000-times authored Jun 15, 2019
2 parents 75979dc + 10b6af1 commit 2848fc5
Show file tree
Hide file tree
Showing 66 changed files with 132 additions and 131 deletions.
4 changes: 2 additions & 2 deletions bindings/py/cpp_src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ target_include_directories(${math_shared_lib} PRIVATE

###################################################################
#
# Install targets into CMAKE_INSTALL_PREFIX/distr/src/nupic/bindings
# Install targets into CMAKE_INSTALL_PREFIX/distr/src/htm/bindings
#
###################################################################
install(TARGETS
Expand All @@ -251,6 +251,6 @@ install(TARGETS
math
${py_unit_test_executable}
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${distr}/src/nupic/bindings
LIBRARY DESTINATION ${distr}/src/htm/bindings
ARCHIVE DESTINATION lib)

Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ Argument extra
, py::arg("extra") = 0u
);

py_HTM.def("printParameters", &HTM_t::printParameters,
py_HTM.def("printParameters",
[](const HTM_t& self)
{ self.printParameters( std::cout ); },
py::call_guard<py::scoped_ostream_redirect,
py::scoped_estream_redirect>());

Expand Down
2 changes: 1 addition & 1 deletion bindings/py/cpp_src/bindings/sdr/py_SDR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ special, it is replaced with the system time The default seed is 0.)",
py::arg("sparsity"),
py::arg("seed") = 0u);

py::module::import("nupic.bindings.math");
py::module::import("htm.bindings.math");
py_SDR.def("randomize",
[](SDR *self, Real sparsity, Random rng) {
self->randomize( sparsity, rng );
Expand Down
2 changes: 0 additions & 2 deletions bindings/py/cpp_src/bindings/sdr/sdr_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ namespace nupic_ext
using namespace nupic_ext;

PYBIND11_MODULE(sdr, m) {
m.doc() = "nupic.core.sdr plugin"; // optional module docstring

init_SDR(m);
init_SDR_Metrics(m);
}
32 changes: 16 additions & 16 deletions bindings/py/packaging/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# http://numenta.org/licenses/
# ----------------------------------------------------------------------

"""This file builds and installs the NuPIC Core Python bindings."""
"""This file builds and installs the HTM Core Python bindings."""

import glob
import os
Expand Down Expand Up @@ -157,20 +157,20 @@ def getPlatformInfo():


def getExtensionFileNames(platform):
# look for extension libraries in Repository/build/Release/distr/src/nupic/bindings
# look for extension libraries in Repository/build/Release/distr/src/htm/bindings
# library filenames:
# nupic.core.algorithms.so
# nupic.core.engine.so
# nupic.core.math.so
# nupic.core.encoders.so
# nupic.core.sdr.so
# htm.core.algorithms.so
# htm.core.engine.so
# htm.core.math.so
# htm.core.encoders.so
# htm.core.sdr.so
if platform in WINDOWS_PLATFORMS:
libExtension = "pyd"
else:
libExtension = "so"
libNames = ("sdr", "encoders", "algorithms", "engine_internal", "math")
libFiles = ["nupic.bindings.{}.{}".format(name, libExtension) for name in libNames]
files = [os.path.join(DISTR_DIR, "src", "nupic", "bindings", name)
libFiles = ["htm.bindings.{}.{}".format(name, libExtension) for name in libNames]
files = [os.path.join(DISTR_DIR, "src", "htm", "bindings", name)
for name in list(libFiles)]
return files

Expand Down Expand Up @@ -227,9 +227,9 @@ def generateExtensions():
# Run CMake if extension files are missing.
getExtensionFiles(platform)

# Copy the python code into place. (from /py/nupic/)
# Copy the python code into place. (from /py/htm/)
distutils.dir_util.copy_tree(
os.path.join(REPO_DIR, "py", "nupic"), os.path.join(DISTR_DIR, "src", "nupic"))
os.path.join(REPO_DIR, "py", "htm"), os.path.join(DISTR_DIR, "src", "htm"))
"""
set the default directory to the distr, and package it.
"""
Expand All @@ -247,14 +247,14 @@ def generateExtensions():
# This distribution contains platform-specific C++ libraries, but they are not
# built with distutils. So we must create a dummy Extension object so when we
# create a binary file it knows to make it platform-specific.
ext_modules=[Extension('nupic.dummy', sources = ['dummy.c'])],
ext_modules=[Extension('htm.dummy', sources = ['dummy.c'])],
package_dir = {"": "src"},
packages=find_packages("src"),
namespace_packages=["nupic"],
namespace_packages=["htm"],
install_requires=findRequirements(platform),
package_data={
"nupic.bindings": ["*.so", "*.pyd"],
"nupic.examples": ["*.csv"],
"htm.bindings": ["*.so", "*.pyd"],
"htm.examples": ["*.csv"],
},
extras_require = {},
zip_safe=False,
Expand Down Expand Up @@ -284,7 +284,7 @@ def generateExtensions():
],
entry_points = {
"console_scripts": [
"nupic-bindings-check = nupic.bindings.check:checkMain",
"htm-bindings-check = htm.bindings.check:checkMain",
],
},
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ def _import_helper(name):
from os.path import dirname, join

# Fast path: see if the module has already been imported.
#print("name={}".format(name))
try:
return sys.modules[name]
except KeyError:
pass

_mod = None
basename = name[15:]
basename = name[len("htm.bindings."):]
if sys.version_info[0]+sys.version_info[1]/10 <= 3.4 :
# For Python 2.7
import imp
Expand Down Expand Up @@ -63,15 +62,17 @@ def _import_helper(name):
if filename:
spec = importlib.util.spec_from_file_location(name, filename[0])
if spec is None:
print("name=nupic.bindings.{} no import library found".format(name))
print("name=htm.bindings.{} no import library found".format(name))
else:
_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(_mod);
sys.modules[name] = _mod
return _mod;

algorithms = _import_helper('nupic.bindings.algorithms')
engine_internal = _import_helper('nupic.bindings.engine_internal')
math = _import_helper('nupic.bindings.math')
sdr = _import_helper('nupic.bindings.sdr')
encoders = _import_helper('nupic.bindings.encoders')
import sys
if sys.version_info[0] < 3:
algorithms = _import_helper('htm.bindings.algorithms')
engine_internal = _import_helper('htm.bindings.engine_internal')
math = _import_helper('htm.bindings.math')
sdr = _import_helper('htm.bindings.sdr')
encoders = _import_helper('htm.bindings.encoders')
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,48 @@


def checkImportBindingsInstalled():
"""Check that nupic.bindings is installed (can be imported).
"""Check that htm.bindings is installed (can be imported).
Throws ImportError on failure.
"""
import nupic.bindings
import htm.bindings



def checkImportBindingsExtensions():
"""Check that nupic.bindings extension libraries can be imported.
"""Check that htm.bindings extension libraries can be imported.
Throws ImportError on failure.
"""
import nupic.bindings.math
import nupic.bindings.algorithms
import nupic.bindings.engine_internal
import nupic.bindings.encoders
import nupic.bindings.sdr
import htm.bindings.math
import htm.bindings.algorithms
import htm.bindings.engine_internal
import htm.bindings.encoders
import htm.bindings.sdr



def checkMain():
"""
This script performs two checks. First it tries to import nupic.bindings
This script performs two checks. First it tries to import htm.bindings
to check that it is correctly installed. Then it tries to import the C
extensions under nupic.bindings. Appropriate user-friendly status messages
extensions under htm.bindings. Appropriate user-friendly status messages
are printed depend on the outcome.
"""
try:
checkImportBindingsInstalled()
except ImportError as e:
print ("Could not import nupic.bindings. It must be installed before use. "
print ("Could not import htm.bindings. It must be installed before use. "
"Error message:")
print(e.message)
return

try:
checkImportBindingsExtensions()
except ImportError as e:
print ("Could not import C extensions for nupic.bindings. Make sure that "
print ("Could not import C extensions for htm.bindings. Make sure that "
"the package was properly installed. Error message:")
print(e.message)
return

print("Successfully imported nupic.bindings.")
print("Successfully imported htm.bindings.")
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import numpy

from nupic.bindings.regions.PyRegion import PyRegion
from htm.bindings.regions.PyRegion import PyRegion


class TestNode(PyRegion):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import json
import time

import nupic.bindings.engine_internal as engine
from nupic.bindings.tools.serialization_test_py_region import \
import htm.bindings.engine_internal as engine
from htm.bindings.tools.serialization_test_py_region import \
SerializationTestPyRegion


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import time

from nupic.bindings.math import Random
from htm.bindings.math import Random



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
performance tool.
"""

from nupic.bindings.math import Random
from nupic.bindings.regions.PyRegion import PyRegion
from htm.bindings.math import Random
from htm.bindings.regions.PyRegion import PyRegion



Expand Down
4 changes: 2 additions & 2 deletions bindings/py/tests/algorithms/sdr_classifier_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import tempfile
import unittest

from nupic.bindings.sdr import SDR
from nupic.bindings.algorithms import Classifier, Predictor
from htm.bindings.sdr import SDR
from htm.bindings.algorithms import Classifier, Predictor


class ClassifierTest(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions bindings/py/tests/algorithms/spatial_pooler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import unittest

from nupic.bindings.sdr import SDR
from nupic.algorithms import SpatialPooler as SP
from htm.bindings.sdr import SDR
from htm.algorithms import SpatialPooler as SP
import numpy as np

class SpatialPoolerTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion bindings/py/tests/check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# ----------------------------------------------------------------------

import unittest
import nupic.bindings.check as check
import htm.bindings.check as check



Expand Down
4 changes: 2 additions & 2 deletions bindings/py/tests/encoders/rdse_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import numpy as np
import unittest

from nupic.bindings.sdr import SDR, Metrics
from nupic.bindings.encoders import RDSE, RDSE_Parameters
from htm.bindings.sdr import SDR, Metrics
from htm.bindings.encoders import RDSE, RDSE_Parameters

class RDSE_Test(unittest.TestCase):
def testConstructor(self):
Expand Down
4 changes: 2 additions & 2 deletions bindings/py/tests/encoders/scalar_encoder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import pytest
import time

from nupic.bindings.encoders import ScalarEncoder, ScalarEncoderParameters
from nupic.bindings.sdr import SDR, Metrics
from htm.bindings.encoders import ScalarEncoder, ScalarEncoderParameters
from htm.bindings.sdr import SDR, Metrics

class ScalarEncoder_Test(unittest.TestCase):
def testConstructor(self):
Expand Down
6 changes: 3 additions & 3 deletions bindings/py/tests/network_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import pytest


from nupic.bindings.regions.PyRegion import PyRegion
from htm.bindings.regions.PyRegion import PyRegion

import nupic.bindings.engine_internal as engine
from nupic.bindings.tools.serialization_test_py_region import \
import htm.bindings.engine_internal as engine
from htm.bindings.tools.serialization_test_py_region import \
SerializationTestPyRegion


Expand Down
2 changes: 1 addition & 1 deletion bindings/py/tests/nupic_random_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import numpy


from nupic.bindings.math import Random
from htm.bindings.math import Random



Expand Down
2 changes: 1 addition & 1 deletion bindings/py/tests/pyregion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import unittest

from nupic.bindings.regions.PyRegion import PyRegion
from htm.bindings.regions.PyRegion import PyRegion



Expand Down
2 changes: 1 addition & 1 deletion bindings/py/tests/sdr/Metrics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import unittest
import pytest

from nupic.bindings import sdr
from htm.bindings import sdr

class MetricsTest(unittest.TestCase):
def testSparsityExample(self):
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 @@ -26,8 +26,8 @@
import pytest
import time

from nupic.bindings.sdr import SDR
from nupic.bindings.math import Random
from htm.bindings.sdr import SDR
from htm.bindings.math import Random

class SdrTest(unittest.TestCase):
def testExampleUsage(self):
Expand Down
4 changes: 2 additions & 2 deletions bindings/py/tests/sparse_link_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

import numpy as np
from numpy.testing import assert_array_equal
from nupic.bindings.regions.PyRegion import PyRegion
import nupic.bindings.engine_internal as engine
from htm.bindings.regions.PyRegion import PyRegion
import htm.bindings.engine_internal as engine

TEST_DATA_SPARSE = np.array([4, 7])
MAX_ACTIVE = TEST_DATA_SPARSE.size
Expand Down
2 changes: 1 addition & 1 deletion bindings/py/tests/temporal_memory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TemporalMemoryBindingsTest(unittest.TestCase):
def testIssue807():
# The following should silently pass. Previous versions segfaulted.
# See https://github.com/numenta/nupic.core/issues/807 for context
from nupic.bindings.algorithms import TemporalMemory
from htm.bindings.algorithms import TemporalMemory

tm = TemporalMemory()
tm.compute(set(), True)
Loading

0 comments on commit 2848fc5

Please sign in to comment.