Skip to content

Commit

Permalink
refactor: namespaces in Core (#142)
Browse files Browse the repository at this point in the history
* refactor: rename ctnr namespace to containers

* Revert "refactor: rename ctnr namespace to containers"

This reverts commit 928ef0f.

* refactor: align on singular namespaces

* refactor: a few missed renamings

* refactor: a couple of missed test folder names
  • Loading branch information
kyle-cochran authored Jan 23, 2024
1 parent 24146bb commit 1b924bb
Show file tree
Hide file tree
Showing 113 changed files with 1,841 additions and 1,841 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Documentation is available here:
The library exhibits the following structure:

```txt
├── Types
├── Type
│ ├── Integer
│ ├── Real
│ ├── String
Expand All @@ -102,7 +102,7 @@ The library exhibits the following structure:
│ ├── Unique
│ ├── Shared
│ └── Weak
├── Containers
├── Container
│ ├── Array
│ ├── List
│ ├── Map
Expand Down Expand Up @@ -138,10 +138,11 @@ The library exhibits the following structure:
│ ├── Undefined
│ ├── Wrong
│ └── To Be Implemented
└── Utilities
├── Iterators
└── Utility
├── Iterator
└── Version
```

</p>
</details>

Expand Down Expand Up @@ -202,8 +203,8 @@ Or to run them manually:

## Dependencies

| Name | Version | License | Link |
| ----------- | -------- | ------------ | ---------------------------------------------------------------------- |
| Name | Version | License | Link |
| ----------- | ---------- | ------------ | ------------------------------------------------------------------- |
| Pybind11 | `2.10.1` | BSD-3-Clause | [github.com/pybind/pybind11](https://github.com/pybind/pybind11) |
| RapidJSON | `master` | MIT | [rapidjson.org](http://rapidjson.org) |
| yaml-cpp | `0.7.0` | MIT | [github.com/jbeder/yaml-cpp](https://github.com/jbeder/yaml-cpp) |
Expand Down
42 changes: 21 additions & 21 deletions bindings/python/docs/Reference.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"metadata": {},
"outputs": [],
"source": [
"types = core.types"
"type = core.type"
]
},
{
Expand All @@ -66,7 +66,7 @@
"metadata": {},
"outputs": [],
"source": [
"Integer = types.Integer"
"Integer = type.Integer"
]
},
{
Expand All @@ -82,7 +82,7 @@
"metadata": {},
"outputs": [],
"source": [
"Real = types.Real"
"Real = type.Real"
]
},
{
Expand All @@ -98,7 +98,7 @@
"metadata": {},
"outputs": [],
"source": [
"String = types.String"
"String = type.String"
]
},
{
Expand All @@ -114,7 +114,7 @@
"metadata": {},
"outputs": [],
"source": [
"containers = core.containers"
"container = core.container"
]
},
{
Expand All @@ -130,11 +130,11 @@
"metadata": {},
"outputs": [],
"source": [
"[i for i in containers.get_int_array()]\n",
"[i for i in containers.get_double_array()]\n",
"[i for i in containers.get_integer_array()]\n",
"[i for i in containers.get_real_array()]\n",
"[i for i in containers.get_string_array()];"
"[i for i in container.get_int_array()]\n",
"[i for i in container.get_double_array()]\n",
"[i for i in container.get_integer_array()]\n",
"[i for i in container.get_real_array()]\n",
"[i for i in container.get_string_array()];"
]
},
{
Expand All @@ -143,8 +143,8 @@
"metadata": {},
"outputs": [],
"source": [
"containers.set_int_array([1, 2, 3])\n",
"containers.set_int_array((1, 2, 3))"
"container.set_int_array([1, 2, 3])\n",
"container.set_int_array((1, 2, 3))"
]
},
{
Expand All @@ -153,8 +153,8 @@
"metadata": {},
"outputs": [],
"source": [
"containers.set_double_array([1.0, 2.0, 3.0])\n",
"containers.set_double_array((1.0, 2.0, 3.0))"
"container.set_double_array([1.0, 2.0, 3.0])\n",
"container.set_double_array((1.0, 2.0, 3.0))"
]
},
{
Expand All @@ -163,8 +163,8 @@
"metadata": {},
"outputs": [],
"source": [
"containers.set_integer_array([1, 2, 3])\n",
"containers.set_integer_array((1, 2, 3))"
"container.set_integer_array([1, 2, 3])\n",
"container.set_integer_array((1, 2, 3))"
]
},
{
Expand All @@ -173,8 +173,8 @@
"metadata": {},
"outputs": [],
"source": [
"containers.set_real_array([1.0, 2.0, 3.0])\n",
"containers.set_real_array((1.0, 2.0, 3.0))"
"container.set_real_array([1.0, 2.0, 3.0])\n",
"container.set_real_array((1.0, 2.0, 3.0))"
]
},
{
Expand All @@ -183,8 +183,8 @@
"metadata": {},
"outputs": [],
"source": [
"containers.set_string_array([\"abc\", \"def\", \"ghi\"])\n",
"containers.set_string_array((\"abc\", \"def\", \"ghi\"))"
"container.set_string_array([\"abc\", \"def\", \"ghi\"])\n",
"container.set_string_array((\"abc\", \"def\", \"ghi\"))"
]
},
{
Expand Down Expand Up @@ -216,4 +216,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
12 changes: 6 additions & 6 deletions bindings/python/src/OpenSpaceToolkitCorePy.cxx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/// Apache License 2.0

#include <OpenSpaceToolkitCorePy/Utilities/ShiftToString.hpp>
#include <OpenSpaceToolkitCorePy/Utility/ShiftToString.hpp>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>

#include <OpenSpaceToolkitCorePy/Containers.cpp>
#include <OpenSpaceToolkitCorePy/Container.cpp>
#include <OpenSpaceToolkitCorePy/FileSystem.cpp>
#include <OpenSpaceToolkitCorePy/Types.cpp>
#include <OpenSpaceToolkitCorePy/Type.cpp>

PYBIND11_MODULE(OpenSpaceToolkitCorePy, m)
{
// Add optional docstring for package OpenSpaceToolkitCorePy
m.doc() = "Fundamental types, containers and utilities for OpenSpaceToolkit.";
m.doc() = "Fundamental types, container and utility for OpenSpaceToolkit.";

// Add __path__ attribute to python package
m.attr("__path__") = "ostk.core";
Expand All @@ -27,7 +27,7 @@ PYBIND11_MODULE(OpenSpaceToolkitCorePy, m)
#endif

// Add python submodules to OpenSpaceToolkitCorePy
OpenSpaceToolkitCorePy_Types(m);
OpenSpaceToolkitCorePy_Containers(m);
OpenSpaceToolkitCorePy_Type(m);
OpenSpaceToolkitCorePy_Container(m);
OpenSpaceToolkitCorePy_FileSystem(m);
}
19 changes: 19 additions & 0 deletions bindings/python/src/OpenSpaceToolkitCorePy/Container.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// Apache License 2.0

#include <OpenSpaceToolkitCorePy/Container/Array.cpp>
#include <OpenSpaceToolkitCorePy/Container/Dictionary.cpp>
#include <OpenSpaceToolkitCorePy/Container/Object.cpp>

inline void OpenSpaceToolkitCorePy_Container(pybind11::module& aModule)
{
// Create "container" python submodule
auto container = aModule.def_submodule("container");

// Add __path__ attribute for "container" submodule
container.attr("__path__") = "ostk.core.container";

// Add objects to python "container" submodules
OpenSpaceToolkitCorePy_Container_Array(container);
OpenSpaceToolkitCorePy_Container_Object(container);
OpenSpaceToolkitCorePy_Container_Dictionary(container);
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/// Apache License 2.0

#include <OpenSpaceToolkitCorePy/Containers/ArrayCasting.hpp>
#include <OpenSpaceToolkitCorePy/Container/ArrayCasting.hpp>

#include <OpenSpaceToolkit/Core/Containers/Array.hpp>
#include <OpenSpaceToolkit/Core/Types/Integer.hpp>
#include <OpenSpaceToolkit/Core/Types/Real.hpp>
#include <OpenSpaceToolkit/Core/Types/String.hpp>
#include <OpenSpaceToolkit/Core/Container/Array.hpp>
#include <OpenSpaceToolkit/Core/Type/Integer.hpp>
#include <OpenSpaceToolkit/Core/Type/Real.hpp>
#include <OpenSpaceToolkit/Core/Type/String.hpp>

using ostk::core::ctnr::Array;
using ostk::core::types::Integer;
using ostk::core::types::Real;
using ostk::core::types::String;
using ostk::core::container::Array;
using ostk::core::type::Integer;
using ostk::core::type::Real;
using ostk::core::type::String;

/// @brief Set and Get Array functions
///
Expand Down Expand Up @@ -73,15 +73,15 @@ Array<String> getStringArray()
return vector;
}

inline void OpenSpaceToolkitCorePy_Containers_Array(pybind11::module& aModule)
inline void OpenSpaceToolkitCorePy_Container_Array(pybind11::module& aModule)
{
using namespace pybind11;

using ostk::core::types::Integer;
using ostk::core::types::Real;
using ostk::core::types::String;
using ostk::core::type::Integer;
using ostk::core::type::Real;
using ostk::core::type::String;

using ostk::core::ctnr::Array;
using ostk::core::container::Array;

aModule.def("set_int_array", overload_cast<const Array<int>&>(&setIntArray));
aModule.def("set_double_array", overload_cast<const Array<double>&>(&setDoubleArray));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include <OpenSpaceToolkit/Core/Containers/Array.hpp>
#include <OpenSpaceToolkit/Core/Container/Array.hpp>

namespace pybind11
{
namespace detail
{

using ostk::core::ctnr::Array;
using ostk::core::container::Array;

template <typename T>
struct type_caster<Array<T>> : list_caster<Array<T>, T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

#include <pybind11/stl_bind.h>

#include <OpenSpaceToolkit/Core/Containers/Dictionary.hpp>
#include <OpenSpaceToolkit/Core/Containers/Object.hpp>
#include <OpenSpaceToolkit/Core/Types/String.hpp>
#include <OpenSpaceToolkit/Core/Container/Dictionary.hpp>
#include <OpenSpaceToolkit/Core/Container/Object.hpp>
#include <OpenSpaceToolkit/Core/Type/String.hpp>

using ostk::core::ctnr::Object;
using ostk::core::ctnr::Dictionary;
using ostk::core::container::Object;
using ostk::core::container::Dictionary;

Object objectFromPythonHandle(const pybind11::handle& anObject)
{
using namespace pybind11;

using ostk::core::ctnr::Array;
using ostk::core::container::Array;

if (isinstance<bool_>(anObject))
{
Expand Down Expand Up @@ -62,13 +62,13 @@ Object objectFromPythonHandle(const pybind11::handle& anObject)
throw ostk::core::error::RuntimeError("Object type is wrong.");
}

inline void OpenSpaceToolkitCorePy_Containers_Dictionary(pybind11::module& aModule)
inline void OpenSpaceToolkitCorePy_Container_Dictionary(pybind11::module& aModule)
{
using namespace pybind11;

using ostk::core::types::String;
using ostk::core::ctnr::Object;
using ostk::core::ctnr::Dictionary;
using ostk::core::type::String;
using ostk::core::container::Object;
using ostk::core::container::Dictionary;

class_<Dictionary> dictionary_class(aModule, "Dictionary");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/// Apache License 2.0

#include <OpenSpaceToolkit/Core/Containers/Object.hpp>
#include <OpenSpaceToolkit/Core/Types/Integer.hpp>
#include <OpenSpaceToolkit/Core/Types/Real.hpp>
#include <OpenSpaceToolkit/Core/Types/String.hpp>
#include <OpenSpaceToolkit/Core/Container/Object.hpp>
#include <OpenSpaceToolkit/Core/Type/Integer.hpp>
#include <OpenSpaceToolkit/Core/Type/Real.hpp>
#include <OpenSpaceToolkit/Core/Type/String.hpp>

inline void OpenSpaceToolkitCorePy_Containers_Object(pybind11::module& aModule)
inline void OpenSpaceToolkitCorePy_Container_Object(pybind11::module& aModule)
{
using namespace pybind11;

using ostk::core::types::Index;
using ostk::core::types::Integer;
using ostk::core::types::Real;
using ostk::core::types::String;
using ostk::core::ctnr::Object;
using ostk::core::type::Index;
using ostk::core::type::Integer;
using ostk::core::type::Real;
using ostk::core::type::String;
using ostk::core::container::Object;

class_<Object> object_class(aModule, "Object");

Expand Down
19 changes: 0 additions & 19 deletions bindings/python/src/OpenSpaceToolkitCorePy/Containers.cpp

This file was deleted.

21 changes: 21 additions & 0 deletions bindings/python/src/OpenSpaceToolkitCorePy/Type.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// Apache License 2.0

#include <OpenSpaceToolkitCorePy/Type/Integer.cpp>
#include <OpenSpaceToolkitCorePy/Type/Real.cpp>
#include <OpenSpaceToolkitCorePy/Type/Sign.cpp>
#include <OpenSpaceToolkitCorePy/Type/String.cpp>

inline void OpenSpaceToolkitCorePy_Type(pybind11::module& aModule)
{
// Create "type" python submodule
auto type = aModule.def_submodule("type");

// Add __path__ attribute for "type" submodule
type.attr("__path__") = "ostk.core.type";

// Add custom type to python "type" submodule
OpenSpaceToolkitCorePy_Type_Sign(type);
OpenSpaceToolkitCorePy_Type_Integer(type);
OpenSpaceToolkitCorePy_Type_Real(type);
OpenSpaceToolkitCorePy_Type_String(type);
}
Loading

0 comments on commit 1b924bb

Please sign in to comment.