testLayer_iaf_psc_exp.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #include <cxxtest/TestSuite.h>
  3. #include "debug.hpp"
  4. #include "simloop.hpp"
  5. #include "vconnection.hpp"
  6. #include "layer.hpp"
  7. #include "layer/iaf_psc_exp.h"
  8. #include "layerfactory.hpp"
  9. #include "chunkfile.h"
  10. #include <sys/stat.h>
  11. #include <fstream>
  12. using namespace std;
  13. const double NUMERIC_LIMIT = 0.0001;
  14. class IAF_PSC_EXP_Test : public CxxTest::TestSuite
  15. {
  16. public:
  17. void testDummy()
  18. {
  19. TS_ASSERT_EQUALS(4,4);
  20. // allocate and initialize layer
  21. int InputNx=2;
  22. int InputNy=3;
  23. layer* MyLayer = createLayer(InputNx*InputNy, NMType_iaf_psc_exp, NPType_Excitatory);
  24. MyLayer->SetName("MyLayer");
  25. MyLayer->SetupPositions(InputNx, InputNy, true);
  26. float* ExInput = MyLayer->GetInputPointer(csimInputChannel_AMPA);
  27. std::fstream f("output.txt", ios_base::out);
  28. TS_ASSERT(ExInput);
  29. TS_ASSERT_DELTA(ExInput[0], 0.0, NUMERIC_LIMIT);
  30. iaf_psc_exp* MyNestLayer = dynamic_cast<iaf_psc_exp*>(MyLayer);
  31. TS_ASSERT(MyNestLayer);
  32. TS_ASSERT_DELTA(MyNestLayer->pS_[0].V_m_, 0., NUMERIC_LIMIT);
  33. for (int i=0; i<900;++i)
  34. {
  35. if (i == 20 || i==240) {
  36. ExInput[0] += 47.1;
  37. }
  38. if (i == 300) {
  39. ExInput[0] += 1247.1;
  40. }
  41. if (i == 400) {
  42. ExInput[0] += 4247.1;
  43. }
  44. MyLayer->proceede(i);
  45. f << MyNestLayer->pS_[0].V_m_ << "\n";
  46. }
  47. TS_ASSERT_DELTA(MyNestLayer->pS_[0].V_m_, 0.3, NUMERIC_LIMIT);
  48. f.close();
  49. }
  50. };