forked from litalbarkai/open-redatam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleaner build (tidied #include abc everywhere)
- Loading branch information
1 parent
fb4be72
commit 10b4275
Showing
100 changed files
with
1,068 additions
and
768 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/sh | ||
|
||
# cmd | ||
|
||
echo "=====================================" | ||
echo "===== TESTING COMMAND LINE TOOL =====" | ||
echo "=====================================" | ||
|
||
make clean | ||
|
||
make | ||
|
||
./redatam test/uru2011mini/uru2011mini.dic test/uru2011mini/dic-to-csv | ||
|
||
./redatam test/uru2011mini/uru2011mini.dicx test/uru2011mini/dicx-to-csv | ||
|
||
validate_csv() { | ||
local file=$1 | ||
local expected_lines=$2 | ||
local expected_columns=$3 | ||
|
||
# Get the number of lines | ||
actual_lines=$(wc -l < "$file") | ||
# Get the number of columns (assuming the first line contains the headers) | ||
actual_columns=$(head -n 1 "$file" | awk -F';' '{print NF}') | ||
|
||
if [[ "$actual_lines" -eq "$expected_lines" && "$actual_columns" -eq "$expected_columns" ]]; then | ||
echo "Validation passed for $file" | ||
else | ||
echo "Validation failed for $file: expected $expected_lines lines and $expected_columns columns, but got $actual_lines lines and $actual_columns columns" | ||
exit 1 | ||
fi | ||
} | ||
|
||
validate_csv "test/uru2011mini/dic-to-csv/SEXO.csv" 38 4 | ||
validate_csv "test/uru2011mini/dicx-to-csv/SEXO.csv" 38 4 | ||
|
||
# r | ||
|
||
echo "=========================" | ||
echo "===== TESTING R PKG =====" | ||
echo "=========================" | ||
|
||
cd rpkg | ||
|
||
Rscript -e "devtools::clean_dll(); devtools::check()" | ||
|
||
cd .. | ||
|
||
# py | ||
|
||
echo "==========================" | ||
echo "===== TESTING PY PKG =====" | ||
echo "==========================" | ||
|
||
cd pypkg | ||
|
||
source venv/bin/activate | ||
rm -rf build dist redatam.egg-info | ||
pip install --use-pep517 . | ||
python tests/basic-test.py | ||
deactivate | ||
|
||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 14 additions & 14 deletions
28
pypkg/redatamlib/entity/RedatamDatabase.cpp → ...g/redatamlib/database/RedatamDatabase.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
#include <cctype> // std::tolower | ||
#include <pybind11/pybind11.h> | ||
#include <stdexcept> // std::invalid_argument | ||
#include <string> // find_last_of, substr, npos | ||
#include "RedatamDatabase.hpp" | ||
|
||
#include <string> // find_last_of, substr, npos | ||
|
||
#include "FuzzyEntityParser.hpp" | ||
#include "PyDictExporter.hpp" | ||
#include "RedatamDatabase.hpp" | ||
#include "XMLParser.hpp" | ||
#include "utils.hpp" // ThrowIfBad, GetFileExtension | ||
#include "utils/utils.hpp" // ThrowIfBad, GetFileExtension | ||
|
||
namespace RedatamLib { | ||
|
||
using pybind11::dict; | ||
using pybind11::print; | ||
using std::invalid_argument; | ||
using std::string; | ||
using std::vector; | ||
|
||
RedatamDatabase::RedatamDatabase(const string &fileName) { | ||
pybind11::print("Opening dictionary file..."); | ||
print("Opening dictionary file..."); | ||
OpenDictionary(fileName); | ||
} | ||
|
||
pybind11::dict RedatamDatabase::ExportPyLists() const { | ||
ListExporter exporter(""); | ||
dict RedatamDatabase::ExportPyLists() const { | ||
PyDictExporter exporter(""); | ||
return exporter.ExportAllPy(m_entities); | ||
} | ||
|
||
void RedatamDatabase::OpenDictionary(const string &fileName) { | ||
string ext = GetFileExtension(fileName); | ||
|
||
if (".dic" == ext) { | ||
if (ext == ".dic") { | ||
FuzzyEntityParser parser(fileName); | ||
m_entities = parser.ParseEntities(); | ||
} else if (".dicx" == ext) { | ||
} else if (ext == ".dicx") { | ||
XMLParser parser; | ||
m_entities = parser.ParseFile(fileName); | ||
} else { | ||
ThrowIfBad<invalid_argument>( | ||
false, | ||
invalid_argument( | ||
"Error: Dictionary file's extension must be .dic or .dicx .")); | ||
false, "Error: Dictionary file's extension must be .dic or .dicx."); | ||
} | ||
} | ||
|
||
} // namespace RedatamLib |
17 changes: 7 additions & 10 deletions
17
pypkg/redatamlib/entity/RedatamDatabase.hpp → ...g/redatamlib/database/RedatamDatabase.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
#ifndef REDATAMLIB_REDATAMDATABASE_HPP | ||
#define REDATAMLIB_REDATAMDATABASE_HPP | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <pybind11/pybind11.h> | ||
|
||
#include "Entity.hpp" | ||
#include <pybind11/pybind11.h> | ||
|
||
namespace RedatamLib { | ||
using pybind11::dict; | ||
using std::string; | ||
using std::vector; | ||
|
||
class RedatamDatabase { | ||
public: | ||
// Throws invalid_argument | ||
public: | ||
explicit RedatamDatabase(const string &fileName); | ||
~RedatamDatabase() = default; | ||
|
||
RedatamDatabase(const RedatamDatabase &) = delete; | ||
RedatamDatabase &operator=(const RedatamDatabase &) = delete; | ||
|
||
pybind11::dict ExportPyLists() const; | ||
dict ExportPyLists() const; | ||
|
||
private: | ||
private: | ||
vector<Entity> m_entities; | ||
|
||
void OpenDictionary(const string &fileName); | ||
}; | ||
|
||
} // namespace RedatamLib | ||
} // namespace RedatamLib | ||
|
||
#endif // REDATAMLIB_REDATAMDATABASE_HPP | ||
#endif // REDATAMLIB_REDATAMDATABASE_HPP |
Oops, something went wrong.