diff --git a/Coffeelogy/Angularer/src.coffee b/Coffeelogy/Angularer/src.coffee new file mode 100755 index 00000000..1df4e5c1 --- /dev/null +++ b/Coffeelogy/Angularer/src.coffee @@ -0,0 +1,17 @@ + +phonecatApp = angular.module "phonecatApp", [] + +phonecatApp.controller "PhoneListCtrl", + ($scope)-> + $scope.phones = [ + name: "Nexus S", + snippet: "Fast just got faster with Nexus S.", + name: "Motorola XOOM™ with Wi-Fi", + snippet: "The Next, Next Generation tablet.", + name: "MOTOROLA XOOM™", + snippet: "The Next, Next Generation tablet." + ] + +console.log( + {name:3, surname:{name:4,surname: 'u'}} + ) diff --git a/Coffeelogy/Angularer/src.js b/Coffeelogy/Angularer/src.js new file mode 100644 index 00000000..caea07c1 --- /dev/null +++ b/Coffeelogy/Angularer/src.js @@ -0,0 +1,25 @@ +// Generated by CoffeeScript 1.9.2 +var phonecatApp; + +phonecatApp = angular.module("phonecatApp", []); + +phonecatApp.controller("PhoneListCtrl", function($scope) { + return $scope.phones = [ + { + name: "Nexus S", + snippet: "Fast just got faster with Nexus S.", + name: "Motorola XOOM™ with Wi-Fi", + snippet: "The Next, Next Generation tablet.", + name: "MOTOROLA XOOM™", + snippet: "The Next, Next Generation tablet." + } + ]; +}); + +console.log({ + name: 3, + surname: { + name: 4, + surname: 'u' + } +}); diff --git a/Coffeelogy/Coffeelogy.coffee b/Coffeelogy/Coffeelogy.coffee index 9a38c287..afff0933 100755 --- a/Coffeelogy/Coffeelogy.coffee +++ b/Coffeelogy/Coffeelogy.coffee @@ -1,16 +1,90 @@ -phonecatApp = angular.module "phonecatApp", [] - -phonecatApp.controller "PhoneListCtrl", - ($scope)-> - $scope.phones = [ - name: "Nexus S", - snippet: "Fast just got faster with Nexus S.", - name: "Motorola XOOM™ with Wi-Fi", - snippet: "The Next, Next Generation tablet.", - name: "MOTOROLA XOOM™", - snippet: "The Next, Next Generation tablet." - ] +###/#################/# +# Define a require +# server or client side working +###/### +#init +SYS = {} + +#Check +if typeof window!="undefined" + + #debug + ### + console.log( + "We are client side" + ) + ### + + #set + SYS.SideStr = "client" + + #set + exports = {} + + #alias + run = (_ScriptStr,_BackFunction) -> + require( + [_ScriptStr], + -> + #first extend + _.extend(SYS,exports) + + #call + _BackFunction() + ) + + + +else + + #debug + ### + console.log( + "We are server side" + ) + ### + + #require + SYS._ = require("underscore") + + #set + SYS.SideStr = "server" + + run = (_ScriptStr,_BackFunction) -> + + #require + ModuleObject = require(_ScriptStr) + + #debug + ### + console.log( + "ModuleObject is \n", + ModuleObject + ) + ### + + #extend + SYS._.extend(SYS,ModuleObject) + + #back call like... + _BackFunction() + +#debug console.log( - {name:3, surname:{name:4,surname: 'u'}} + "************************\n" + "Welcome to Coffeelogy \n", + "We are " + SYS.SideStr + " side ! \n", + #"require function is ", + #require +) + +#require +run( + "./Teamer/src.js", + -> + console.log( + "HHHH\n", + SYS.TeamerClass ) +) diff --git a/Coffeelogy/Coffeelogy.js b/Coffeelogy/Coffeelogy.js index caea07c1..29871aed 100644 --- a/Coffeelogy/Coffeelogy.js +++ b/Coffeelogy/Coffeelogy.js @@ -1,25 +1,53 @@ // Generated by CoffeeScript 1.9.2 -var phonecatApp; - -phonecatApp = angular.module("phonecatApp", []); - -phonecatApp.controller("PhoneListCtrl", function($scope) { - return $scope.phones = [ - { - name: "Nexus S", - snippet: "Fast just got faster with Nexus S.", - name: "Motorola XOOM™ with Wi-Fi", - snippet: "The Next, Next Generation tablet.", - name: "MOTOROLA XOOM™", - snippet: "The Next, Next Generation tablet." - } - ]; -}); -console.log({ - name: 3, - surname: { - name: 4, - surname: 'u' - } +/*/ */ + +/*/ */ +var SYS, exports, run; + +SYS = {}; + +if (typeof window !== "undefined") { + + /* + console.log( + "We are client side" + ) + */ + SYS.SideStr = "client"; + exports = {}; + run = function(_ScriptStr, _BackFunction) { + return require([_ScriptStr], function() { + _.extend(SYS, exports); + return _BackFunction(); + }); + }; +} else { + + /* + console.log( + "We are server side" + ) + */ + SYS._ = require("underscore"); + SYS.SideStr = "server"; + run = function(_ScriptStr, _BackFunction) { + var ModuleObject; + ModuleObject = require(_ScriptStr); + + /* + console.log( + "ModuleObject is \n", + ModuleObject + ) + */ + SYS._.extend(SYS, ModuleObject); + return _BackFunction(); + }; +} + +console.log("************************\n", "Welcome to Coffeelogy \n", "We are " + SYS.SideStr + " side ! \n"); + +run("./Teamer/src.js", function() { + return console.log("HHHH\n", SYS.TeamerClass); }); diff --git a/Coffeelogy/Manager/Manager.coffee b/Coffeelogy/Manager/src.coffee similarity index 70% rename from Coffeelogy/Manager/Manager.coffee rename to Coffeelogy/Manager/src.coffee index a6ed02ce..fb5b4944 100755 --- a/Coffeelogy/Manager/Manager.coffee +++ b/Coffeelogy/Manager/src.coffee @@ -2,11 +2,16 @@ Manager Class ### +#debug +console.log( + "import Manager \n" +) + #require -Teamer = require('../Teamer/Teamer.js') +Teamer = require('../Teamer/src.js') #define -class exports.ManagerClass extends Teamer.TeamerClass +class ManagerClass extends Teamer.TeamerClass #constructor: ManagementObject = {} @@ -35,3 +40,8 @@ class exports.ManagerClass extends Teamer.TeamerClass #return return this +#Check +if GLOBAL.SideStr == 'server' + + #export + exports.ManagerClass = ManagerClass \ No newline at end of file diff --git a/Coffeelogy/Manager/Manager.js b/Coffeelogy/Manager/src.js similarity index 84% rename from Coffeelogy/Manager/Manager.js rename to Coffeelogy/Manager/src.js index b44a447e..9a54ad0b 100644 --- a/Coffeelogy/Manager/Manager.js +++ b/Coffeelogy/Manager/src.js @@ -3,14 +3,16 @@ /* Manager Class */ -var Teamer, +var ManagerClass, Teamer, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; -Teamer = require('../Teamer/Teamer.js'); +console.log("import Manager \n"); -exports.ManagerClass = (function(superClass) { +Teamer = require('../Teamer/src.js'); + +ManagerClass = (function(superClass) { var ManagedParentVariable, ManagementObject; extend(ManagerClass, superClass); @@ -35,3 +37,7 @@ exports.ManagerClass = (function(superClass) { return ManagerClass; })(Teamer.TeamerClass); + +if (GLOBAL.SideStr === 'server') { + exports.ManagerClass = ManagerClass; +} diff --git a/Coffeelogy/Reacter/src.coffee b/Coffeelogy/Reacter/src.coffee new file mode 100755 index 00000000..1df4e5c1 --- /dev/null +++ b/Coffeelogy/Reacter/src.coffee @@ -0,0 +1,17 @@ + +phonecatApp = angular.module "phonecatApp", [] + +phonecatApp.controller "PhoneListCtrl", + ($scope)-> + $scope.phones = [ + name: "Nexus S", + snippet: "Fast just got faster with Nexus S.", + name: "Motorola XOOM™ with Wi-Fi", + snippet: "The Next, Next Generation tablet.", + name: "MOTOROLA XOOM™", + snippet: "The Next, Next Generation tablet." + ] + +console.log( + {name:3, surname:{name:4,surname: 'u'}} + ) diff --git a/Coffeelogy/Teamer/Teamer.coffee b/Coffeelogy/Teamer/src.coffee similarity index 76% rename from Coffeelogy/Teamer/Teamer.coffee rename to Coffeelogy/Teamer/src.coffee index dc0d5851..7e624503 100755 --- a/Coffeelogy/Teamer/Teamer.coffee +++ b/Coffeelogy/Teamer/src.coffee @@ -2,6 +2,18 @@ Teamer Class ### +#Check +if typeof window == "undefined" + SideStr = "server" +else + SideStr = "client" + +#debug +console.log( + "import Teamer \n", + "Side is "+SideStr +) + #define class exports.TeamerClass diff --git a/Coffeelogy/Teamer/Teamer.js b/Coffeelogy/Teamer/src.js similarity index 72% rename from Coffeelogy/Teamer/Teamer.js rename to Coffeelogy/Teamer/src.js index eaa7bde1..bdd49dc6 100644 --- a/Coffeelogy/Teamer/Teamer.js +++ b/Coffeelogy/Teamer/src.js @@ -3,7 +3,16 @@ /* Teamer Class */ -var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; +var SideStr, + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + +if (typeof window === "undefined") { + SideStr = "server"; +} else { + SideStr = "client"; +} + +console.log("import Teamer \n", "Side is " + SideStr); exports.TeamerClass = (function() { var TeamObject, TeamedParentVariable; diff --git a/Coffeelogy/bower.json b/Coffeelogy/bower.json index 54e04832..4096deb6 100644 --- a/Coffeelogy/bower.json +++ b/Coffeelogy/bower.json @@ -12,6 +12,7 @@ "bootstrap": "~3.1.1", "angular-route": "1.3.x", "angular-resource": "1.3.x", - "angular-animate": "1.3.x" + "angular-animate": "1.3.x", + "underscore":"1.8.x" } } diff --git a/Coffeelogy/index.html b/Coffeelogy/index.html index 96472b3a..7e063ce2 100644 --- a/Coffeelogy/index.html +++ b/Coffeelogy/index.html @@ -1,16 +1,28 @@ + + My HTML File - - + + + + + + + Salut + + + + \ No newline at end of file diff --git a/Coffeelogy/main.js b/Coffeelogy/main.js deleted file mode 100644 index 1dd05ab8..00000000 --- a/Coffeelogy/main.js +++ /dev/null @@ -1,5 +0,0 @@ -// Generated by CoffeeScript 1.9.2 -var MyStr, liveServer; - -liveServer = require('live-server').start(); - diff --git a/Coffeelogy/require.min.js b/Coffeelogy/require.min.js new file mode 100644 index 00000000..f296b923 --- /dev/null +++ b/Coffeelogy/require.min.js @@ -0,0 +1,36 @@ +/* + RequireJS 2.1.18 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved. + Available via the MIT or new BSD license. + see: http://github.com/jrburke/requirejs for details +*/ +var requirejs,require,define; +(function(ba){function G(b){return"[object Function]"===K.call(b)}function H(b){return"[object Array]"===K.call(b)}function v(b,c){if(b){var d;for(d=0;dthis.depCount&&!this.defined){if(G(l)){if(this.events.error&&this.map.isDefine||g.onError!==ca)try{f=i.execCb(c,l,b,f)}catch(d){a=d}else f=i.execCb(c,l,b,f);this.map.isDefine&&void 0===f&&((b=this.module)?f=b.exports:this.usingExports&& +(f=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",w(this.error=a)}else f=l;this.exports=f;if(this.map.isDefine&&!this.ignore&&(r[c]=f,g.onResourceLoad))g.onResourceLoad(i,this.map,this.depMaps);y(c);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a= +this.map,b=a.id,d=p(a.prefix);this.depMaps.push(d);q(d,"defined",u(this,function(f){var l,d;d=m(aa,this.map.id);var e=this.map.name,P=this.map.parentMap?this.map.parentMap.name:null,n=i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(f.normalize&&(e=f.normalize(e,function(a){return c(a,P,!0)})||""),f=p(a.prefix+"!"+e,this.map.parentMap),q(f,"defined",u(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=m(h,f.id)){this.depMaps.push(f); +if(this.events.error)d.on("error",u(this,function(a){this.emit("error",a)}));d.enable()}}else d?(this.map.url=i.nameToUrl(d),this.load()):(l=u(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),l.error=u(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];B(h,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&y(a.map.id)});w(a)}),l.fromText=u(this,function(f,c){var d=a.name,e=p(d),P=M;c&&(f=c);P&&(M=!1);s(e);t(j.config,b)&&(j.config[d]=j.config[b]);try{g.exec(f)}catch(h){return w(C("fromtexteval", +"fromText eval for "+b+" failed: "+h,h,[b]))}P&&(M=!0);this.depMaps.push(e);i.completeLoad(d);n([d],l)}),f.load(a.name,n,l,j))}));i.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){V[this.map.id]=this;this.enabling=this.enabled=!0;v(this.depMaps,u(this,function(a,b){var c,f;if("string"===typeof a){a=p(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=m(L,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;q(a,"defined",u(this,function(a){this.undefed|| +(this.defineDep(b,a),this.check())}));this.errback?q(a,"error",u(this,this.errback)):this.events.error&&q(a,"error",u(this,function(a){this.emit("error",a)}))}c=a.id;f=h[c];!t(L,c)&&(f&&!f.enabled)&&i.enable(a,this)}));B(this.pluginMaps,u(this,function(a){var b=m(h,a.id);b&&!b.enabled&&i.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){v(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}}; +i={config:j,contextName:b,registry:h,defined:r,urlFetched:S,defQueue:A,Module:Z,makeModuleMap:p,nextTick:g.nextTick,onError:w,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=j.shim,c={paths:!0,bundles:!0,config:!0,map:!0};B(a,function(a,b){c[b]?(j[b]||(j[b]={}),U(j[b],a,!0,!0)):j[b]=a});a.bundles&&B(a.bundles,function(a,b){v(a,function(a){a!==b&&(aa[a]=b)})});a.shim&&(B(a.shim,function(a,c){H(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn= +i.makeShimExports(a);b[c]=a}),j.shim=b);a.packages&&v(a.packages,function(a){var b,a="string"===typeof a?{name:a}:a;b=a.name;a.location&&(j.paths[b]=a.location);j.pkgs[b]=a.name+"/"+(a.main||"main").replace(ia,"").replace(Q,"")});B(h,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=p(b,null,!0))});if(a.deps||a.callback)i.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(ba,arguments));return b||a.exports&&da(a.exports)}},makeRequire:function(a, +e){function j(c,d,m){var n,q;e.enableBuildCallback&&(d&&G(d))&&(d.__requireJsBuild=!0);if("string"===typeof c){if(G(d))return w(C("requireargs","Invalid require call"),m);if(a&&t(L,c))return L[c](h[a.id]);if(g.get)return g.get(i,c,a,j);n=p(c,a,!1,!0);n=n.id;return!t(r,n)?w(C("notloaded",'Module name "'+n+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):r[n]}J();i.nextTick(function(){J();q=s(p(null,a));q.skipMap=e.skipMap;q.init(c,d,m,{enabled:!0});D()});return j}e=e||{};U(j, +{isBrowser:z,toUrl:function(b){var d,e=b.lastIndexOf("."),k=b.split("/")[0];if(-1!==e&&(!("."===k||".."===k)||1e.attachEvent.toString().indexOf("[native code"))&&!Y?(M=!0,e.attachEvent("onreadystatechange",b.onScriptLoad)):(e.addEventListener("load",b.onScriptLoad,!1),e.addEventListener("error",b.onScriptError,!1)),e.src=d,J=e,D?y.insertBefore(e,D):y.appendChild(e),J=null,e;if(ea)try{importScripts(d),b.completeLoad(c)}catch(m){b.onError(C("importscripts","importScripts failed for "+c+" at "+d,m,[c]))}};z&&!q.skipDataMain&&T(document.getElementsByTagName("script"),function(b){y||(y=b.parentNode);if(I=b.getAttribute("data-main"))return s= +I,q.baseUrl||(E=s.split("/"),s=E.pop(),O=E.length?E.join("/")+"/":"./",q.baseUrl=O),s=s.replace(Q,""),g.jsExtRegExp.test(s)&&(s=I),q.deps=q.deps?q.deps.concat(s):[s],!0});define=function(b,c,d){var e,g;"string"!==typeof b&&(d=c,c=b,b=null);H(c)||(d=c,c=null);!c&&G(d)&&(c=[],d.length&&(d.toString().replace(ka,"").replace(la,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));if(M){if(!(e=J))N&&"interactive"===N.readyState||T(document.getElementsByTagName("script"), +function(b){if("interactive"===b.readyState)return N=b}),e=N;e&&(b||(b=e.getAttribute("data-requiremodule")),g=F[e.getAttribute("data-requirecontext")])}(g?g.defQueue:R).push([b,c,d])};define.amd={jQuery:!0};g.exec=function(b){return eval(b)};g(q)}})(this); diff --git a/Coffeelogy/server.js b/Coffeelogy/server.js new file mode 100644 index 00000000..98cc603d --- /dev/null +++ b/Coffeelogy/server.js @@ -0,0 +1,4 @@ +//start +liveServer = require('live-server').start(); + + diff --git a/Pythonlogy/MANIFEST b/Pythonlogy/MANIFEST index 86c9ff12..9566b71a 100644 --- a/Pythonlogy/MANIFEST +++ b/Pythonlogy/MANIFEST @@ -481,6 +481,8 @@ ShareYourSystem/Standards/Interfacers/Numscipyer/06_ExampleCell.md ShareYourSystem/Standards/Interfacers/Numscipyer/07_ExampleCell.py ShareYourSystem/Standards/Interfacers/Numscipyer/08_ExampleCell.md ShareYourSystem/Standards/Interfacers/Numscipyer/09_ExampleCell.py +ShareYourSystem/Standards/Interfacers/Numscipyer/10_ExampleCell.md +ShareYourSystem/Standards/Interfacers/Numscipyer/11_ExampleCell.py ShareYourSystem/Standards/Interfacers/Numscipyer/__init__.py ShareYourSystem/Standards/Interfacers/Printer/001_DocumentDoc.md ShareYourSystem/Standards/Interfacers/Printer/002_GithubDoc.md @@ -968,9 +970,6 @@ ShareYourSystem/Standards/Recorders/Brianer/02_ExampleDoc.md ShareYourSystem/Standards/Recorders/Brianer/03_ExampleCell.py ShareYourSystem/Standards/Recorders/Brianer/04_ExampleDoc.md ShareYourSystem/Standards/Recorders/Brianer/05_ExampleCell.py -ShareYourSystem/Standards/Recorders/Brianer/06_ExampleDoc.md -ShareYourSystem/Standards/Recorders/Brianer/07_ExampleCell.py -ShareYourSystem/Standards/Recorders/Brianer/09_ExampleCell.py ShareYourSystem/Standards/Recorders/Brianer/Readme.md ShareYourSystem/Standards/Recorders/Brianer/Test.py ShareYourSystem/Standards/Recorders/Brianer/__init__.py @@ -1020,6 +1019,8 @@ ShareYourSystem/Standards/Recorders/Leaker/20_ExampleDoc.md ShareYourSystem/Standards/Recorders/Leaker/21_ExampleCell.py ShareYourSystem/Standards/Recorders/Leaker/22_ExampleDoc.md ShareYourSystem/Standards/Recorders/Leaker/23_ExampleCell.py +ShareYourSystem/Standards/Recorders/Leaker/24_ExampleDoc.md +ShareYourSystem/Standards/Recorders/Leaker/25_ExampleCell.py ShareYourSystem/Standards/Recorders/Leaker/__init__.py ShareYourSystem/Standards/Recorders/Leaker/draft/01_ExampleCell.py ShareYourSystem/Standards/Recorders/Leaker/draft/02_ExampleDoc.md diff --git a/Pythonlogy/ShareYourSystem/13_ExampleDoc.py b/Pythonlogy/ShareYourSystem/13_ExampleDoc.py index 6c697a3e..b063c99d 100755 --- a/Pythonlogy/ShareYourSystem/13_ExampleDoc.py +++ b/Pythonlogy/ShareYourSystem/13_ExampleDoc.py @@ -17,6 +17,21 @@ MyListDict.insert(1,'salut') MyListDict.insert(1,'bonjour','MyStr') +#np +import numpy as np + +#set +MyArray=np.array([[1,2]]) + +#insert +MyListDict.insert(0,MyArray,'MyArray') + +#move +MyListDict.move(0,3) + +#move +MyListDict.move('MyStr',0) + #print print('MyListDict is ') -print(MyListDict) \ No newline at end of file +print(MyListDict) diff --git a/Pythonlogy/ShareYourSystem/Standards/Interfacers/Numscipyer/10_ExampleCell.md b/Pythonlogy/ShareYourSystem/Standards/Interfacers/Numscipyer/10_ExampleCell.md new file mode 100755 index 00000000..717bb7f3 --- /dev/null +++ b/Pythonlogy/ShareYourSystem/Standards/Interfacers/Numscipyer/10_ExampleCell.md @@ -0,0 +1,8 @@ + + + +##Example + +Compute marges in the array \ No newline at end of file diff --git a/Pythonlogy/ShareYourSystem/Standards/Interfacers/Numscipyer/11_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Interfacers/Numscipyer/11_ExampleCell.py new file mode 100755 index 00000000..27e0e292 --- /dev/null +++ b/Pythonlogy/ShareYourSystem/Standards/Interfacers/Numscipyer/11_ExampleCell.py @@ -0,0 +1,52 @@ + +#import +import ShareYourSystem as SYS +from matplotlib import pyplot +import numpy as np + +#set +LenInt=10 +DimensionInt=2 + +#init +MyArray=np.zeros([LenInt]*DimensionInt,dtype=bool) + +#define +def _set(_RowInt,_ColInt): + + #set + CheckBool=True if _RowInt>_ColInt else False + + #set + MyArray.__setitem__( + (_RowInt,_ColInt), + CheckBool + ) + + #plot + pyplot.plot(_RowInt,_ColInt,marker='o',color="blue" if CheckBool else "red") + +#init +map( + lambda __RowInt: + map( + lambda __ColInt: + _set(__RowInt,__ColInt), + xrange(LenInt) + ), + xrange(LenInt) +) + +#get +ContourIntsArray=SYS.contour(MyArray) + +#plot +pyplot.plot( + ContourIntsArray[:,0], + ContourIntsArray[:,1], + '-' +) + +#plot +pyplot.show() + diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/01_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/01_ExampleCell.py index 36ca2b9b..0d528081 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/01_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/01_ExampleCell.py @@ -24,7 +24,7 @@ 'reset':'v=-70*mV' }, '-Traces':{ - '|*v':{ + '|v':{ 'NumscipyingStdFloat':0.001, '-Samples':{ '|Default':{ diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/03_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/03_ExampleCell.py index 5a52b384..e4e406fe 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/03_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/03_ExampleCell.py @@ -25,7 +25,7 @@ 'reset':'v=-70*mV' }, '-Traces':{ - '|*v':{ + '|v':{ 'NumscipyingStdFloat':0.001 } }, @@ -81,19 +81,3 @@ #Definition the AttestedStr print('MyBrianer is ') SYS._print(MyBrianer) - - -""" -from matplotlib import pyplot -pyplot.figure() -ME=MyBrianer['/-Populations/|E/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -MI=MyBrianer['/-Populations/|I/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -pyplot.plot(ME.t, ME.v.T,color='b') -pyplot.plot(MI.t, MI.v.T,color='r') -pyplot.figure() -ME=MyBrianer['/-Populations/|E/-Events/|Default'].BrianedSpikeMonitorVariable -MI=MyBrianer['/-Populations/|I/-Events/|Default'].BrianedSpikeMonitorVariable -pyplot.plot(ME.t, ME.i,'.') -pyplot.plot(MI.t, max(ME.i)+MI.i,'.',color='r') -pyplot.show() -""" \ No newline at end of file diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/05_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/05_ExampleCell.py index c3089e24..ce70f71b 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/05_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/05_ExampleCell.py @@ -65,11 +65,11 @@ ] }, '-Traces':{ - '|*v':{ + '|v':{ 'NumscipyingStdFloat':0.001, '-Samples':{ '|Default':{ - 'MoniteringLabelIndexIntsArray':[0,1] + 'RecordingLabelVariable':[0,1] } } } @@ -91,10 +91,29 @@ } } ).brian( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyBrianer.simulate( 500. ) - + +#/###################/# +# View +# + +MyBrianer.mapSet( + { + 'PyplotingGridVariable':(30,20) + } + ).view( + ).pyplot( + ).show( + ) + #/###################/# # Print # @@ -103,19 +122,3 @@ print('MyBrianer is ') SYS._print(MyBrianer) -#/###################/# -# Do one simulation -# - -from matplotlib import pyplot -pyplot.figure() -ME=MyBrianer['/-Populations/|E/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -MI=MyBrianer['/-Populations/|I/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -pyplot.plot(ME.t, ME.v.T,color='b') -pyplot.plot(MI.t, MI.v.T,color='r') -pyplot.figure() -ME=MyBrianer['/-Populations/|E/-Events/|Default'].BrianedSpikeMonitorVariable -MI=MyBrianer['/-Populations/|I/-Events/|Default'].BrianedSpikeMonitorVariable -pyplot.plot(ME.t, ME.i,'.') -pyplot.plot(MI.t, max(ME.i)+MI.i,'.',color='r') -pyplot.show() \ No newline at end of file diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/06_ExampleDoc.md b/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/06_ExampleDoc.md deleted file mode 100644 index ac7e13d3..00000000 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/06_ExampleDoc.md +++ /dev/null @@ -1,8 +0,0 @@ - - - -##Example - -Do a simple network of E I LIF connected neurongroups \ No newline at end of file diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/07_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/07_ExampleCell.py deleted file mode 100755 index de7cf9bc..00000000 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/07_ExampleCell.py +++ /dev/null @@ -1,115 +0,0 @@ -#/###################/# -# Import modules -# - -#ImportModules -import ShareYourSystem as SYS - -#/###################/# -# Build the model -# - -#Definition an instance -MyBrianer=SYS.BrianerClass( - ).mapSet( - { - '-Neurongroups': - { - 'set':{ - '#liarg:#lambda':{ - '|#NeuronStr':{ - '#copy:BrianingNeurongroupDict':{ - 'N':'#UnitsInt', - 'model': - ''' - Jr : 1 - dr/dt = -r + #TransferStr(Jr)/(20*ms) : volt - ''', - }, - 'set':{ - '#liarg:#lambda':{ - 'array':[ - [ - ['-Connectomes'], - ['|Postlets<->Prelets'], - ['-Connections'], - ['|#direct:_^_|E','|#direct:_^_|I'] - ], - [ - {}, - {}, - { - 'BrianingSynapsesDict':{ - 'pre':''' - #PreStr \n - ''' - }, - 'BrianingConnectVariable':0.2 - } - ] - ] - }, - '#map':[ - ['#PreStr'], - [ - ['ge+=0.1*mV'], - ['gi-=3*mV'] - ] - ] - }, - '-Traces':{ - '|*v':{ - 'NumscipyingStdFloat':0.001, - '-Samples':{ - '|Default':{ - 'MoniteringLabelIndexIntsArray':[0,1] - } - } - } - }, - '-Events':{ - '|Default':{ - } - }, - } - }, - '#map':[ - ['#NeuronStr','#UnitsInt'], - [ - ['E','80'], - ['I','20'] - ] - ] - } - } - } - ).brian( - ).simulate( - 500. - ) - -#/###################/# -# Print -# - - -#Definition the AttestedStr -print('MyBrianer is ') -SYS._print(MyBrianer) - -#/###################/# -# Do one simulation -# - -from matplotlib import pyplot -pyplot.figure() -ME=MyBrianer['/-Neurongroups/|E/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -MI=MyBrianer['/-Neurongroups/|I/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -pyplot.plot(ME.t, ME.v.T,color='b') -pyplot.plot(MI.t, MI.v.T,color='r') -pyplot.figure() -ME=MyBrianer['/-Neurongroups/|E/-Events/|Default'].BrianedSpikeMonitorVariable -MI=MyBrianer['/-Neurongroups/|I/-Events/|Default'].BrianedSpikeMonitorVariable -pyplot.plot(ME.t, ME.i,'.') -pyplot.plot(MI.t, max(ME.i)+MI.i,'.',color='r') -pyplot.show() \ No newline at end of file diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/09_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/09_ExampleCell.py deleted file mode 100644 index cc2ebfb5..00000000 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/09_ExampleCell.py +++ /dev/null @@ -1,79 +0,0 @@ -#/###################/# -# Import modules -# - -#ImportModules -import ShareYourSystem as SYS - -#/###################/# -# Build the model -# - -#Definition an instance -MyBrianer=SYS.BrianerClass( - ).mapSet( - { - 'BrianingNeurongroupDict':{ - 'N':10, - 'model': - ''' - dv/dt = (-(v+60*mV)+11*mV + 5.*mV*sqrt(20.*ms)*xi)/(20*ms) : volt - ''', - 'threshold':'v>-50*mV', - 'reset':'v=-70*mV' - }, - '-Projections':{ - '|/':{ - - } - }, - '-Traces':{ - '|*v':{ - 'NumscipyingStdFloat':0.001, - '-Samples':{ - '|Default':{ - 'RecordingLabelVariable':[0,1] - } - } - } - }, - '-Events':{ - '|Default':{ - } - } - } - ).brian( - ) - -#/###################/# -# Print -# - -#Definition the AttestedStr -print('MyBrianer is ') -SYS._print(MyBrianer) - -#/###################/# -# Do one simulation -# - -MyBrianer.simulate( - 500. - ) - -#/###################/# -# View -# - -#MyBrianer['/-Traces/|*v/-Samples/|Default'].view( -# ).pyplot( -# ) -#MyBrianer['/-Events/|Default'].view( -# ).pyplot( -# ) - -MyBrianer.view( - ).pyplot() - -SYS.matplotlib.pyplot.show() - diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/__init__.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/__init__.py index 49d2a450..136e5c8f 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/__init__.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Brianer/__init__.py @@ -634,20 +634,23 @@ def debugNeurongroup(): #debug - ''' self.debug( [ 'We set the tracers', - ('self.',self,['BrianedRecordKeyStrsList']) + ('self.',self,['BrianedRecordKeyStrsList']), + #'Recorder.RecordPrefixStr is '+str(Recorder.RecordPrefixStr), + #'BrianedTracesManager is '+SYS._str( + # BrianedTracesManager + #) ] ) - ''' - + #map self.BrianedTraceDeriveBrianersList=map( lambda __ManagementKeyStr,__RecordKeyStr: - BrianedTracesManager.manage( - __ManagementKeyStr, + BrianedTracesManager.getManager( + __ManagementKeyStr + ).mapSet( { 'RecordingKeyVariable':getattr( self.BrianedNeurongroupVariable, @@ -655,17 +658,7 @@ def debugNeurongroup(): ), 'RecordKeyStr':__RecordKeyStr } - ).ManagedValueVariable - if __ManagementKeyStr not in BrianedTracesManager.ManagementDict - else BrianedTracesManager.ManagementDict[__ManagementKeyStr].mapSet( - { - 'RecordingKeyVariable':getattr( - self.BrianedNeurongroupVariable, - __RecordKeyStr - ), - 'RecordKeyStr':__RecordKeyStr - } - ), + ), map( lambda __BrianedRecordKeyStr: Recorder.RecordPrefixStr+__BrianedRecordKeyStr, @@ -1907,6 +1900,7 @@ def mimic_view(self): def viewPopulation(self): #debug + ''' self.debug( [ 'we view population brian here', @@ -1915,6 +1909,7 @@ def viewPopulation(self): ]) ] ) + ''' #Check if self.BrianingViewNetworkBool==False: @@ -2104,25 +2099,39 @@ def viewPopulation(self): # Manage each Chart # + #get + ViewedPopulationRunChartsDerivePyploter=self.TeamDict[ + "Panels" + ].ManagementDict[ + "Run" + ].TeamDict[ + "Charts" + ] + + #get + ViewedPopulationRunChartDerivePyplotersList=ViewedPopulationRunChartsDerivePyploter.ManagementDict.values() + + #debug + LeakedTagVariable=map( + lambda __Variable: + (__Variable.ManagementIndexInt, + __Variable.ManagementTagStr), + ViewedPopulationRunChartDerivePyplotersList + ) + ''' + #debug self.debug( [ 'We map manage each Chart in the network one', - 'self.TeamDict["Charts"].ManagementDict.keys() is', - str(self.TeamDict["Charts"].ManagementDict.keys()) + 'ViewedPopulationRunChartsDerivePyploter.ManagementDict.keys() is', + str(ViewedPopulationRunChartsDerivePyploter.ManagementDict.keys() + ), + 'LeakedTagVariable is '+str(LeakedTagVariable) ] ) ''' - #get - ViewedPopulationRunChartDerivePyplotersList=self.TeamDict[ - "Panels" - ].ManagementDict[ - "Run" - ].TeamDict[ - "Charts" - ].ManagementDict.values() - #map ViewedNetworkRunChartDerivePyplotersList=map( lambda __ViewedPopulationRunChartDerivePyploter: @@ -3023,6 +3032,23 @@ def viewSample(self): self.BrianedParentDeriveRecorderVariable.ManagementTagStr ) + #debug + ''' + self.debug( + [ + 'We have managed this new Chart', + 'self.BrianedParentDeriveRecorderVariable.ManagementTagStr is '+str( + self.BrianedParentDeriveRecorderVariable.ManagementTagStr), + 'BrianedRunPopulationChartsDeriveManager.ManagementDict is '+str( + BrianedRunPopulationChartsDeriveManager.ManagementDict), + 'BrianedRunPopulationChartsDeriveManager.ManagementDict.keys() is '+str( + BrianedRunPopulationChartsDeriveManager.ManagementDict.keys() + ) + ] + ) + ''' + + #/####################/# # set to True # @@ -3156,6 +3182,7 @@ def viewSample(self): )-1: #Check + ''' self.debug( [ 'This is the last Sample for this record', @@ -3165,6 +3192,7 @@ def viewSample(self): ) ] ) + ''' #call self.BrianedParentDeriveRecorderVariable.viewTraceOrEvent() @@ -3566,6 +3594,12 @@ def mimic_simulate(self): def recordTrace(self): + #set + #self.RecordedTraceFloatsArray=getattr( + # self.BrianedParentPopulationDeriveBrianerVariable.BrianedNeurongroupVariable, + # self.RecordKeyStr + #) + #base method BaseClass.recordTrace(self) @@ -3601,6 +3635,16 @@ def recordTrace(self): def setBrianInit(self): + #debug + self.debug( + [ + 'we set brian init here', + ('self.',self,[ + 'RecordedTraceFloatsArray' + ]) + ] + ) + #Check if str(self.RecordedTraceFloatsArray.unit) in ['V']: diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/01_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/01_ExampleCell.py index df1b2219..b834c446 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/01_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/01_ExampleCell.py @@ -27,14 +27,15 @@ ).simulate( 500. ) - + #/###################/# # View # MyLeaker.view( ).pyplot( - ).show() + ).show( + ) #/###################/# # Print diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/03_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/03_ExampleCell.py index 4ca07342..2127359e 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/03_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/03_ExampleCell.py @@ -19,39 +19,36 @@ 'LeakingSymbolPrefixStr':'r', '-Inputs':{ '|Command':{ - #'LeakingWeigthVariable':'#scalar:3.*mV', - #'LeakingWeigthVariable':5., - #'LeakingWeigthVariable':5.*SYS.brian2.mV - #'LeakingWeigthVariable':[1.,3.], - #'LeakingWeigthVariable':SYS.getKrenelFloatsArray(), - #'LeakingWeigthVariable':'#equation:5.*mV*(1.+tanh(10.*(t-250.*ms)/ms))', - #'LeakingWeigthVariable':'#custom:#clock:10*ms:''' - # change=int(t>250*ms) - # #SymbolStr:5.*mV*change - #''', - #'LeakingWeigthVariable':'#custom:5.*mV*(ms/(t+1*ms))', - #'LeakingWeigthVariable':'#custom:#clock:200*ms:5.*mV*(t==200*ms)*(i==0)', - #'LeakingWeigthVariable':'#custom:#clock:200*ms:5.*mV*(t==200*ms)*(i==0)', - 'LeakingWeigthVariable':( - '#custom:#clock:100*ms', - [ - '5.*mV*int(t==200*ms)', - '-2.*mV*int(t==100*ms)' - ] - ), - #'LeakingWeigthVariable':( + #'LeakingWeightVariable':'#scalar:3.*mV', + #'LeakingWeightVariable':5., + #'LeakingWeightVariable':5.*SYS.brian2.mV, + #'LeakingWeightVariable':[1.,3.], + ##'LeakingWeightVariable':SYS.getKrenelFloatsArray, + #'LeakingWeightVariable':"#equation:5.*mV*(1.+tanh(10.*(t-250.*ms)/ms))", + #'LeakingWeightVariable':"#custom:#clock:10*ms:change=int(t>250*ms);#SymbolStr=5.*mV*change", + #'LeakingWeightVariable':'#custom:5.*mV*(ms/(t+1*ms))', + #'LeakingWeightVariable':'#custom:#clock:200*ms:5.*mV*(t==200*ms)*(i==0)', + 'LeakingWeightVariable':'#custom:#clock:200*ms:5.*mV*(t==200*ms)*(i==0)', + #'LeakingWeightVariable':( + # '#custom:#clock:100*ms', + # [ + # '5.*mV*int(t==200*ms)', + # '-2.*mV*int(t==100*ms)' + # ] + #), + #'LeakingWeightVariable':( # '#network:#clock:200*ms', # lambda _ActivityQuantity,_TimeQuantity: # 5.*SYS.brian2.mV # if _TimeQuantity==200.*SYS.brian2.ms # else 0.*SYS.brian2.mV #), - #'LeakingWeigthVariable':( + #'LeakingWeightVariable':( # '#network:#clock:1*ms', # lambda _ActivityQuantity,_TimeQuantity: # SYS.scipy.stats.norm.rvs(size=2)*SYS.brian2.mV #), - 'RecordingLabelVariable':[0,1] + #'RecordingLabelVariable':[0,1] } }, 'RecordingLabelVariable':[0,1] @@ -59,33 +56,28 @@ } } ).leak( - ).simulate( - 500. ) - #/###################/# -# View +# Do one simulation # -#MyLeaker[ -# '/-Populations/|Sensor/-Traces/|*I_Command/-Samples/|Default' -# ].view( -# ).pyplot( -# ) +MyLeaker.simulate( + 500. + ) -#MyLeaker[ -# '/-Populations/|Sensor/-Traces/|*U/-Samples/|Default' -# ].view( -# ).pyplot( -# ) +#/###################/# +# View +# -MyLeaker[ - '/-Populations/|Sensor' - ].view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( + ).show( ) -SYS.matplotlib.pyplot.show() #/###################/# # Print diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/05_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/05_ExampleCell.py index 9577ed4b..6c40b4eb 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/05_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/05_ExampleCell.py @@ -19,33 +19,51 @@ 'LeakingSymbolPrefixStr':'r', '-Inputs':{ '|Default':{ - #'LeakingWeigthVariable':'#scalar:4.*mV' - 'LeakingWeigthVariable':4. + #'LeakingWeightVariable':'#scalar:4.*mV' + 'LeakingWeightVariable':4. } }, '-Interactions':{ '|/':{ - #'LeakingWeigthVariable':'#scalar:0.', - #'LeakingWeigthVariable':'#scalar:-1.', - #'LeakingWeigthVariable':-1., - 'LeakingWeigthVariable':[-0.,-0.5,-0.,-0.], - #'LeakingWeigthVariable':[[0.,0.],[0.,-0.4]], - #'LeakingWeigthVariable':'#array', + #'LeakingWeightVariable':'#scalar:0.', + #'LeakingWeightVariable':'#scalar:-1.', + #'LeakingWeightVariable':-1., + 'LeakingWeightVariable':[-0.,-0.5,-0.,-0.], + #'LeakingWeightVariable':[[0.,0.],[0.,-0.4]], + #'LeakingWeightVariable':'#array', #'NumscipyingStdFloat':0.1, - 'LeakingVariableStr':'I_Default', + #'LeakingVariableStr':'I_Default', #'BrianingDebugVariable':0.1, } }, #'BrianingDebugVariable':0.1, - 'BrianingMonitorIndexIntsList':[0,1] + 'RecordingLabelVariable':[0,1] } } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 500. ) - + +#/###################/# +# View +# + +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(30,20) + } + ).view( + ).pyplot( + ).show( + ) #/###################/# # Print @@ -55,11 +73,3 @@ print('MyLeaker is ') SYS._print(MyLeaker) -#/###################/# -# View -# - -MyLeaker['/-Populations/|Default'].view( - ).pyplot() -#print(MyLeaker['/-Populations/|Default/-Interactions/|/'].BrianedSynapsesVariable.J[:]) -SYS.matplotlib.pyplot.show() diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/07_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/07_ExampleCell.py index 364b3c2f..c287ff53 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/07_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/07_ExampleCell.py @@ -19,12 +19,12 @@ 'LeakingSymbolPrefixStr':'r', '-Inputs':{ '|Default':{ - 'LeakingWeigthVariable':5. + 'LeakingWeightVariable':5. } }, '-Interactions':{ '|/':{ - 'LeakingWeigthVariable':-1., + 'LeakingWeightVariable':-1., } }, 'LeakingTransferVariable':'1.*mV*tanh((#CurrentStr)/(1.*mV))', @@ -34,7 +34,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 500. ) @@ -42,9 +48,14 @@ # View # -MyLeaker['/-Populations/|Default'].view( - ).pyplot() -SYS.matplotlib.pyplot.show() +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( + ).pyplot( + ).show( + ) #/###################/# # Print diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/09_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/09_ExampleCell.py index c24afc19..0246041b 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/09_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/09_ExampleCell.py @@ -20,10 +20,10 @@ 'LeakingSymbolPrefixStr':'V', '-Inputs':{ '|Rest':{ - 'LeakingWeigthVariable':'#scalar:-60*mV' + 'LeakingWeightVariable':'#scalar:-60*mV' }, '|External':{ - 'LeakingWeigthVariable':'#scalar:11*mV' + 'LeakingWeightVariable':'#scalar:11*mV' } }, 'LeakingThresholdVariable':'#scalar:V>-50*mV', @@ -41,7 +41,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 500. ) @@ -49,11 +55,14 @@ # View # -MyLeaker['/-Populations/|P'].view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( + ).show( ) -#print(MyLeaker['/-Populations/|Default/-Interactions/|/'].BrianedSynapsesVariable.J[:]) -SYS.matplotlib.pyplot.show() #/###################/# # Print @@ -64,27 +73,3 @@ SYS._print(MyLeaker) -""" -from brian2 import * -from matplotlib import pyplot -Vr=[0.5,0.6] -G=NeuronGroup(2,'''Vr:1 - dv/dt=(-v+1)/(1.*ms) : 1''',threshold='v>Vr',reset='v=0') -M=StateMonitor(G,'v',[0,1]) -N=Network() -N.add(G) -N.add(M) -print(G.Vr) -G.Vr[:]=Vr -N.run(5*ms) -pyplot.plot( - M.t,M.v.T -) -pyplot.show() -""" -""" -from brian2 import CodeObject - -print(help(CodeObject)) - -""" diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/11_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/11_ExampleCell.py index f0d8bd73..5bf7fe65 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/11_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/11_ExampleCell.py @@ -20,10 +20,10 @@ 'LeakingSymbolPrefixStr':'V', '-Inputs':{ '|Rest':{ - 'LeakingWeigthVariable':'#scalar:-60*mV' + 'LeakingWeightVariable':'#scalar:-60*mV' }, '|External':{ - 'LeakingWeigthVariable':'#scalar:11*mV' + 'LeakingWeightVariable':'#scalar:11*mV' } }, 'LeakingNoiseStdVariable':0.1, @@ -40,7 +40,7 @@ '-Interactions':{ '|/':{ 'BrianingDebugVariable':100, - 'LeakingWeigthVariable':[[0.,0.],[-2.,0.]],#[[0.,-0.01],[0.,0.]] + 'LeakingWeightVariable':[[0.,0.],[-2.,0.]],#[[0.,-0.01],[0.,0.]] 'LeakingInteractionStr':"Spike" } }, @@ -50,7 +50,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 500. ) @@ -58,7 +64,11 @@ # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( ).show( ) diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/13_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/13_ExampleCell.py index 93594b5b..593533eb 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/13_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/13_ExampleCell.py @@ -20,10 +20,10 @@ 'LeakingSymbolPrefixStr':'V', '-Inputs':{ '|Rest':{ - 'LeakingWeigthVariable':'#scalar:-60*mV' + 'LeakingWeightVariable':'#scalar:-60*mV' }, '|External':{ - 'LeakingWeigthVariable':'#scalar:11*mV' + 'LeakingWeightVariable':'#scalar:11*mV' } }, 'LeakingNoiseStdVariable':0.1, @@ -32,7 +32,7 @@ '-Interactions':{ '|/':{ 'BrianingDebugVariable':100, - 'LeakingWeigthVariable':[[0.,-1.],[-2.,0.]], + 'LeakingWeightVariable':[[0.,-1.],[-2.,0.]], 'LeakingInteractionStr':"Spike", #'LeakingDelayVariable':5., #ms #'LeakingDelayVariable':[[0.,1.],[5.,0.]], #ms @@ -44,7 +44,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 200. ) @@ -52,16 +58,15 @@ # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( + ).show( ) -#MyLeaker['/-Populations/|P'].view( -# ).pyplot( -# ) - -SYS.matplotlib.pyplot.show() - #/###################/# # Print # diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/15_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/15_ExampleCell.py index 0526d9c7..27fcffa0 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/15_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/15_ExampleCell.py @@ -22,7 +22,7 @@ '-Interactions':{ '|/':{ #'BrianingDebugVariable':10, - 'LeakingWeigthVariable':[[0.,-20.],[1.,0.]], + 'LeakingWeightVariable':[[0.,-20.],[1.,0.]], 'LeakingDelayVariable':5., #'LeakingDelayVariable':[[2.,1.],0.5], #PRE-POST matrix #'LeakingDelayPrepostBool':True, @@ -35,7 +35,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 10. ) @@ -43,9 +49,14 @@ # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( - ).show() + ).show( + ) #/###################/# # Print diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/17_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/17_ExampleCell.py index 16a76cbe..24c57edf 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/17_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/17_ExampleCell.py @@ -20,10 +20,10 @@ 'LeakingSymbolPrefixStr':'V', '-Inputs':{ '|Rest':{ - 'LeakingWeigthVariable':'#scalar:-60*mV' + 'LeakingWeightVariable':'#scalar:-60*mV' }, '|External':{ - 'LeakingWeigthVariable':'#scalar:11*mV' + 'LeakingWeightVariable':'#scalar:11*mV' } }, 'LeakingNoiseStdVariable':0.1, @@ -33,7 +33,7 @@ '-Interactions':{ '|/':{ 'BrianingDebugVariable':100, - 'LeakingWeigthVariable':[[0.,0.],[0.,0.]], + 'LeakingWeightVariable':[[0.,0.],[0.,0.]], 'LeakingInteractionStr':"Spike", 'LeakingPlasticVariable':"J+=(((V_post+60.*mV)/volt)+((1.+1.)/2.)*J)", #'LeakingPlasticVariable':"J-=0.5*J", @@ -46,24 +46,29 @@ } } ).leak( - ).simulate( - 200. ) #/###################/# -# View +# Do one simulation # -#MyLeaker.view( -# ).pyplot( -# ) +MyLeaker.simulate( + 500. + ) -MyLeaker['/-Populations/|P'].view( +#/###################/# +# View +# + +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( + ).show( ) -SYS.matplotlib.pyplot.show() - #/###################/# # Print # diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/19_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/19_ExampleCell.py index 5f8fb193..47ef105a 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/19_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/19_ExampleCell.py @@ -19,7 +19,7 @@ 'LeakingTransferVariable':'mV*tanh((#CurrentStr)/mV)', '-Interactions':{ '|/':{ - 'LeakingWeigthVariable':'#array', + 'LeakingWeightVariable':'#array', #'LeakingEigenBool':True } }, @@ -29,18 +29,29 @@ } } ).leak( - ).simulate( - 200. + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( + 500. ) #/###################/# # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( - ).show() - + ).show( + ) + #/###################/# # Print # diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/21_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/21_ExampleCell.py index a9231900..3beb19eb 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/21_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/21_ExampleCell.py @@ -20,10 +20,10 @@ 'LeakingSymbolPrefixStr':'V', '-Inputs':{ '|Rest':{ - 'LeakingWeigthVariable':'#scalar:-60*mV' + 'LeakingWeightVariable':'#scalar:-60*mV' }, '|External':{ - 'LeakingWeigthVariable':'#scalar:100*mV' + 'LeakingWeightVariable':'#scalar:100*mV' } }, 'LeakingNoiseStdVariable':0.1, @@ -35,7 +35,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 50. ) @@ -43,11 +49,15 @@ # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( ).show( ) - + #/###################/# # Print # diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/22_ExampleDoc.md b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/22_ExampleDoc.md index ae738e13..8599029d 100644 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/22_ExampleDoc.md +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/22_ExampleDoc.md @@ -5,4 +5,4 @@ FrozenIsBool False ##Example -Pick the max events in traces \ No newline at end of file +Pick the max events in traces and compute phase \ No newline at end of file diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/23_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/23_ExampleCell.py index 5fff49d7..85587763 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/23_ExampleCell.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/23_ExampleCell.py @@ -22,7 +22,7 @@ 'LeakingSymbolPrefixStr':'r', '-Inputs':{ '|External':{ - 'LeakingWeigthVariable':( + 'LeakingWeightVariable':( '#custom', [ '1.*mV*cos(2.*pi*t*0.1/ms)', @@ -39,7 +39,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 50. ) @@ -47,11 +53,18 @@ # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( ).show( ) +#print(MyLeaker['-Panels']) +#print(MyLeaker['/-Populations/|P/-Traces'].ManagementDict.keys()) + #/###################/# # Print # @@ -60,5 +73,5 @@ print('MyLeaker is ') SYS._print(MyLeaker) -""" + diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/24_ExampleDoc.md b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/24_ExampleDoc.md new file mode 100644 index 00000000..7379aaa8 --- /dev/null +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/24_ExampleDoc.md @@ -0,0 +1,8 @@ + + + +##Example + +Plot the relation between phase and J \ No newline at end of file diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/25_ExampleCell.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/25_ExampleCell.py new file mode 100755 index 00000000..550a687e --- /dev/null +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/25_ExampleCell.py @@ -0,0 +1,78 @@ + + +#/###################/# +# Import modules +# + + +#ImportModules +import ShareYourSystem as SYS + +#/###################/# +# Build the model +# + +#Define +MyLeaker=SYS.LeakerClass( + ).mapSet( + { + '-Populations':{ + '|P':{ + 'LeakingUnitsInt':2, + 'LeakingSymbolPrefixStr':'r', + '-Inputs':{ + '|External':{ + 'LeakingWeightVariable':'#custom:#clock:100*ms:1.*mV*(t==100.*ms)' + } + }, + '-Interactions':{ + '|/':{ + 'LeakingWeightVariable':[ + [1.5,-2.6], + [3.1,-0.9] + ] + } + }, + 'LeakingMaxBool':True, + 'RecordingLabelVariable':[0,1], + #'BrianingDebugVariable':100 + } + } + } + ).leak( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( + 300. + ) + +#/###################/# +# View +# + +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( + ).pyplot( + ).show( + ) + +#print(MyLeaker['-Panels']) +#print(MyLeaker['/-Populations/|P/-Traces'].ManagementDict.keys()) + +#/###################/# +# Print +# + +#print +print('MyLeaker is ') +SYS._print(MyLeaker) + + + diff --git a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/__init__.py b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/__init__.py index 208a6470..20d7a2ce 100755 --- a/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/__init__.py +++ b/Pythonlogy/ShareYourSystem/Standards/Recorders/Leaker/__init__.py @@ -79,7 +79,7 @@ class LeakerClass(BaseClass): def default_init(self, _LeakingUnitsInt=0, _LeakingTimeVariable='#scalar:10.*ms', - _LeakingWeigthVariable=None, + _LeakingWeightVariable=None, _LeakingQuantityStr='mV', _LeakingSymbolPrefixStr="", _LeakingInteractionStr="Rate", @@ -113,7 +113,7 @@ def default_init(self, _LeakedEquationStr="", _LeakedClockStr="", _LeakedTimeSymbolStr="", - _LeakedInteractionWeigthFloat=0., + _LeakedInteractionWeightFloat=0., _LeakedParentSingularStr="", _LeakedParentNetworkDeriveLeakerVariable=None, _LeakedParentPopulationDeriveLeakerVariable=None, @@ -618,20 +618,20 @@ def leakPopulation(self): [ 'Check if we add a weigth', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) ''' #type - LeakedType=type(self.LeakingWeigthVariable) + LeakedType=type(self.LeakingWeightVariable) #Check if LeakedType==str: #Check - if self.LeakingWeigthVariable in ['0','0.0']: + if self.LeakingWeightVariable in ['0','0.0']: #set the right self.LeakedModelStr+='(' @@ -639,7 +639,7 @@ def leakPopulation(self): else: #set the right - self.LeakedModelStr+='(-'+self.LeakingWeigthVariable+'*'+self.LeakedSymbolStr + self.LeakedModelStr+='(-'+self.LeakingWeightVariable+'*'+self.LeakedSymbolStr elif LeakedType in [list]: @@ -648,11 +648,11 @@ def leakPopulation(self): mu : 1 '''+self.LeakedModelStr - elif self.LeakingWeigthVariable!=None: + elif self.LeakingWeightVariable!=None: #set the right self.LeakedModelStr+='(-'+str( - self.LeakingWeigthVariable + self.LeakingWeightVariable )+'*'+self.LeakedSymbolStr else: @@ -830,18 +830,18 @@ def leakPopulation(self): ).TeamedValueVariable #manage - LeakedRecordDeriveLeaker=LeakedTracesDeriveManager.manage( - '*'+self.LeakedSymbolStr - ).ManagedValueVariable + LeakedRecordDeriveLeaker=LeakedTracesDeriveManager.getManager( + Recorder.RecordPrefixStr+self.LeakedSymbolStr + ) #set LeakedRecordDeriveLeaker.NumscipyingStdFloat=0.001 - LeakedSamplesDeriveLeaker=LeakedRecordDeriveLeaker.team( + LeakedSamplesDeriveLeaker=LeakedRecordDeriveLeaker.getTeamer( 'Samples' - ).TeamedValueVariable - LeakedDefaultDeriveLeaker=LeakedSamplesDeriveLeaker.manage( + ) + LeakedDefaultDeriveLeaker=LeakedSamplesDeriveLeaker.getManager( 'Default' - ).ManagedValueVariable + ) #/##################/# # Look for what to monitor @@ -913,11 +913,13 @@ def leakPopulation(self): if self.LeakingMaxBool: #debug + ''' self.debug( [ 'We build a variable that tracks the max events' ] ) + ''' #add self.LeakedModelStr+=self.LeakedSymbolStr+'_diff : '+self.LeakedDimensionStr+'\n' @@ -936,6 +938,7 @@ def leakPopulation(self): self.LeakedModelStr+=LeakedDiffStr #debug + ''' self.debug( [ 'In the end of max model', @@ -944,6 +947,7 @@ def leakPopulation(self): ]) ] ) + ''' ''' LeakedPhaseNeuronGroup=brian2.NeuronGroup( @@ -1400,16 +1404,19 @@ def leakInput(self): ''' #type - LeakedWeigthVariable=type(self.LeakingWeigthVariable) + LeakedWeightVariable=type(self.LeakingWeightVariable) #Check - if LeakedWeigthVariable!=None.__class__: + if LeakedWeightVariable!=None.__class__: + + #init + self.LeakedClampStr="Variable" #Check - if LeakedWeigthVariable==str: + if LeakedWeightVariable==str: #Check - if self.LeakingWeigthVariable.startswith( + if self.LeakingWeightVariable.startswith( LeakScalarPrefixStr ): @@ -1418,7 +1425,7 @@ def leakInput(self): #set self.LeakedSymbolStr=SYS.deprefix( - self.LeakingWeigthVariable, + self.LeakingWeightVariable, LeakScalarPrefixStr ) @@ -1438,7 +1445,7 @@ def leakInput(self): self.LeakedSymbolStr ) - elif self.LeakingWeigthVariable.startswith( + elif self.LeakingWeightVariable.startswith( LeakEquationPrefixStr ): @@ -1447,14 +1454,14 @@ def leakInput(self): #set self.LeakedOperationStr=SYS.deprefix( - self.LeakingWeigthVariable, + self.LeakingWeightVariable, LeakEquationPrefixStr ) #setOperation self.setOperation() - elif self.LeakingWeigthVariable.startswith( + elif self.LeakingWeightVariable.startswith( LeakCustomPrefixStr ): @@ -1463,7 +1470,7 @@ def leakInput(self): #set self.LeakedOperationStr=SYS.deprefix( - self.LeakingWeigthVariable, + self.LeakingWeightVariable, LeakCustomPrefixStr ) @@ -1498,106 +1505,118 @@ def leakInput(self): """ #Check - elif LeakedWeigthVariable in [list,tuple]: + elif LeakedWeightVariable in [list,tuple]: #Check - if self.LeakingWeigthVariable[0].startswith(LeakNetworkPrefixStr[:-1]): + if type(self.LeakingWeightVariable[0])==str: - #debug - ''' - self.debug( - [ - 'It is a network operation', - ('self.',self,[ - 'LeakingWeigthVariable' - ]) - ] - ) - ''' + #Check + if self.LeakingWeightVariable[0].startswith(LeakNetworkPrefixStr[:-1]): - #set - self.LeakedClampStr='Network' + #debug + ''' + self.debug( + [ + 'It is a network operation', + ('self.',self,[ + 'LeakingWeightVariable' + ]) + ] + ) + ''' - #set - self.LeakedOperationStr=SYS.deprefix( - self.LeakingWeigthVariable[0], - LeakNetworkPrefixStr - ) + #set + self.LeakedClampStr='Network' - #setOperation - self.setOperation() + #set + self.LeakedOperationStr=SYS.deprefix( + self.LeakingWeightVariable[0], + LeakNetworkPrefixStr + ) - elif self.LeakingWeigthVariable[0].startswith(LeakCustomPrefixStr[:-1]): + #setOperation + self.setOperation() - #debug - ''' - self.debug( - [ - 'It is a map of different input variables', - ('self.',self,[ - 'LeakingWeigthVariable' - ]) - ] - ) - ''' + elif self.LeakingWeightVariable[0].startswith( + LeakCustomPrefixStr[:-1] + ): - #set - self.LeakedClampStr='Custom' + #debug + ''' + self.debug( + [ + 'It is a map of different input variables', + ('self.',self,[ + 'LeakingWeightVariable' + ]) + ] + ) + ''' - #set - self.LeakedOperationStr=SYS.deprefix( - self.LeakingWeigthVariable[0], - LeakCustomPrefixStr[:-1] - ) + #set + self.LeakedClampStr='Custom' - #debug - ''' - self.debug( - [ - ('self.',self,[ - 'LeakedOperationStr' - ]) - ] - ) - ''' + #set + self.LeakedOperationStr=SYS.deprefix( + self.LeakingWeightVariable[0], + LeakCustomPrefixStr[:-1] + ) - #Check - if self.LeakedOperationStr[0]==':': - self.LeakedOperationStr=self.LeakedOperationStr[1:]+':' + #debug + ''' + self.debug( + [ + ('self.',self,[ + 'LeakedOperationStr' + ]) + ] + ) + ''' - #join - self.LeakedOperationStr+="+".join( - map( - lambda __IndexInt,__CustomOperationStr: - __CustomOperationStr+'*(i=='+str( - __IndexInt - )+')', - xrange(len(self.LeakingWeigthVariable[1])), - self.LeakingWeigthVariable[1] + #Check + if self.LeakedOperationStr!="" and self.LeakedOperationStr[0]==':': + self.LeakedOperationStr=self.LeakedOperationStr[1:]+':' + + #join + self.LeakedOperationStr+="+".join( + map( + lambda __IndexInt,__CustomOperationStr: + __CustomOperationStr+'*(i=='+str( + __IndexInt + )+')', + xrange(len(self.LeakingWeightVariable[1])), + self.LeakingWeightVariable[1] + ) ) - ) - #setOperation - self.setOperation() + #setOperation + self.setOperation() - else: + #debug + self.debug( + [ + 'Is it a variable', + ('self.',self,[ + 'LeakedClampStr' + ]) + ] + ) - #set - self.LeakedClampStr="Variable" + #Check + if self.LeakedClampStr=="Variable": #debug - ''' self.debug( [ 'It is a variable', ('self.',self,[ - 'LeakedSymbolStr' + 'LeakedSymbolStr', + 'LeakingRecordBool' ]), 'We append in the parent pop record skip', 'We define and add in the LeakedCurrentStr' ] ) - ''' #Check if self.LeakingRecordBool==False: @@ -1654,6 +1673,58 @@ def leakInput(self): ) ''' + #debug + ''' + self.debug( + [ + 'Should we have to take care of a record later', + ('self.',self,[ + 'LeakedClampStr' + ]) + ] + ) + ''' + + #Check + if self.LeakedClampStr not in ["Scalar","Variable"]: + + #/###############/# + # Make sure that trace of input is before trace trace of activity + # Look for a RecordingVariable + # + + #get + LeakedTraceDeriveLeaker=self.LeakedParentPopulationDeriveLeakerVariable.getTeamer( + "Traces" + ).manage( + Recorder.RecordPrefixStr+self.LeakedSymbolStr, + _IndexInt=0 + ).ManagedValueVariable + + #Check + if self.RecordingLabelVariable!=None: + + #debug + ''' + self.debug( + [ + 'In the input we set the recording label variable to the corresponding trace sample', + ('self.',self,['RecordingLabelVariable']) + ] + ) + ''' + + #set + LeakedTraceDeriveLeaker.getTeamer( + "Samples" + ).getManager( + "Default" + ).setAttr( + "RecordingLabelVariable", + self.RecordingLabelVariable + ) + + def leakInteraction(self): #/################/# @@ -1666,7 +1737,7 @@ def leakInteraction(self): [ 'It is an Interaction level', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) @@ -1766,19 +1837,19 @@ def leakInteraction(self): ''' self.debug( [ - 'What is LeakingWeigthVariable', + 'What is LeakingWeightVariable', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) ''' #Check - if type(self.LeakingWeigthVariable)==None.__class__: + if type(self.LeakingWeightVariable)==None.__class__: #set - self.LeakingWeigthVariable='#scalar:0.' + self.LeakingWeightVariable='#scalar:0.' #debug ''' @@ -1786,7 +1857,7 @@ def leakInteraction(self): [ 'We set a default J equal to scalar 0', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) @@ -1798,7 +1869,7 @@ def leakInteraction(self): [ 'We check the clamp of the interaction', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) @@ -1823,10 +1894,10 @@ def leakInteraction(self): self.LeakedClampStr="Variable" #Check - if type(self.LeakingWeigthVariable)==str: + if type(self.LeakingWeightVariable)==str: #Check - if self.LeakingWeigthVariable.startswith( + if self.LeakingWeightVariable.startswith( LeakScalarPrefixStr ): @@ -2053,16 +2124,16 @@ def leakInteraction(self): self.LeakedModelStr+=self.LeakedSymbolStr+"_post" #deprefix - LeakedInteractionWeigthStr=SYS.deprefix( - self.LeakingWeigthVariable, + LeakedInteractionWeightStr=SYS.deprefix( + self.LeakingWeightVariable, LeakScalarPrefixStr ) #set - self.LeakedInteractionWeigthFloat=float(LeakedInteractionWeigthStr) + self.LeakedInteractionWeightFloat=float(LeakedInteractionWeightStr) #add - self.LeakedModelStr+="="+LeakedInteractionWeigthStr+'*'+self.LeakedVariableStr+"_pre" + self.LeakedModelStr+="="+LeakedInteractionWeightStr+'*'+self.LeakedVariableStr+"_pre" elif self.LeakedClampStr=="Variable": @@ -2692,7 +2763,7 @@ def brianPopulation(self): self.TeamDict[ 'Traces' ].ManagementDict[ - '*Threshold' + Recorder.RecordPrefixStr+'Threshold' ].BrianingRecordInitBool=False #Check @@ -2903,8 +2974,8 @@ def brianPopulation(self): self.debug( [ 'We resort the inputs traces', - 'self.TeamDict["Inputs"].ManagementDict.keys() is ', - str(self.TeamDict["Inputs"].ManagementDict.keys()), + #'self.TeamDict["Inputs"].ManagementDict.keys() is ', + #str(self.TeamDict["Inputs"].ManagementDict.keys()), 'BrianedTracesManager.ManagementDict.keys() is ', str(BrianedTracesManager.ManagementDict.keys()) @@ -2923,21 +2994,15 @@ def brianPopulation(self): ) ) - #map - map( - lambda __IndexIntAndRecordKeyStr: - setattr( - BrianedTracesManager.ManagementDict[ - __IndexIntAndRecordKeyStr[1] - ], - 'GetSortInt', - __IndexIntAndRecordKeyStr[0] - ) if __IndexIntAndRecordKeyStr[1] in BrianedTracesManager.ManagementDict - else None, - enumerate( - self.LeakedInputKeyStrsList - ) + #debug + ''' + self.debug( + [ + + ('self.',self,['LeakedInputKeyStrsList']) + ] ) + ''' def brianInput(self): @@ -2951,7 +3016,7 @@ def brianInput(self): ''' #Check - if self.LeakingWeigthVariable!=None: + if self.LeakingWeightVariable!=None: #Check if self.LeakedClampStr=="Variable": @@ -2971,11 +3036,23 @@ def brianInput(self): ) ''' + #import + import numpy as np + #set setattr( self.LeakedParentPopulationDeriveLeakerVariable.BrianedNeurongroupVariable, self.LeakedSymbolStr, - self.LeakingWeigthVariable*Variable.unit + #self.LeakingWeightVariable*Variable.unit + self.LeakingWeightVariable*self.LeakedParentPopulationDeriveLeakerVariable.LeakedQuantityVariable + if type(self.LeakingWeightVariable) in [ + np.float64,float + ] else ( + self.LeakingWeightVariable*self.LeakedParentPopulationDeriveLeakerVariable.LeakedQuantityVariable + if type(self.LeakingWeightVariable[0]) in [ + np.float64,float + ] else self.LeakingWeightVariable + ) ) elif self.LeakedClampStr=='Equation': @@ -2999,7 +3076,7 @@ def brianInput(self): #init self.LeakedTimedArrayVariable=TimedArray( - self.LeakingWeigthVariable, + self.LeakingWeightVariable, dt=self.LeakedParentPopulationDeriveLeakerVariable.BrianedNeurongroupVariable.clock.dt ) @@ -3148,7 +3225,7 @@ def brianInput(self): def updateInput(): #get set - BrianedInputQuantity[:]=self.LeakingWeigthVariable[1]( + BrianedInputQuantity[:]=self.LeakingWeightVariable[1]( BrianedInputQuantity, BrianedNeurongroupVariable.clock.t ) @@ -3179,7 +3256,7 @@ def updateInput(): def updateInput(): #get set - BrianedInputQuantity[:]=self.LeakingWeigthVariable[1]( + BrianedInputQuantity[:]=self.LeakingWeightVariable[1]( BrianedInputQuantity, BrianedNeurongroupVariable.clock.t ) @@ -3202,7 +3279,7 @@ def brianInteraction(self): 'We brianInteraction leak here', 'We call first the base method', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) @@ -3222,7 +3299,7 @@ def brianInteraction(self): #get BrianedRowsInt=self.BrianedSynapsesVariable.source.N BrianedColsInt=self.BrianedSynapsesVariable.target.N - BrianedWeigthFloatsArray=None + BrianedWeightFloatsArray=None #/##################/# # Maybe we specify the connection @@ -3248,13 +3325,13 @@ def brianInteraction(self): self.debug( [ 'Look for a non nul connection', - ('self.',self,['LeakedInteractionWeigthFloat']) + ('self.',self,['LeakedInteractionWeightFloat']) ] ) ''' #Check - if self.LeakedInteractionWeigthFloat!=0.: + if self.LeakedInteractionWeightFloat!=0.: #debug ''' @@ -3274,7 +3351,7 @@ def brianInteraction(self): elif self.LeakedClampStr=="Variable": #type - BrianedInteractionType=type(self.LeakingWeigthVariable) + BrianedInteractionType=type(self.LeakingWeightVariable) #debug ''' @@ -3282,7 +3359,7 @@ def brianInteraction(self): [ 'We have to set the connect variable', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]), 'BrianedInteractionType is ', str(BrianedInteractionType) @@ -3303,14 +3380,14 @@ def brianInteraction(self): 'It is just one value', 'We set in the synapses if it is not null', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) ''' #Check - if self.LeakingWeigthVariable!=0.: + if self.LeakingWeightVariable!=0.: #debug ''' @@ -3318,7 +3395,7 @@ def brianInteraction(self): [ 'We are going to connect this Variable for each index', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) @@ -3333,7 +3410,7 @@ def brianInteraction(self): getattr( self.BrianedSynapsesVariable, self.LeakingSymbolPrefixStr - )[:]=self.LeakingWeigthVariable + )[:]=self.LeakingWeightVariable #debug @@ -3371,13 +3448,13 @@ def brianInteraction(self): self.numscipy() #alias - BrianedWeigthFloatsArray=self.NumscipiedValueFloatsArray + BrianedWeightFloatsArray=self.NumscipiedValueFloatsArray else: #shape - BrianedWeigthFloatsArray=getShapeArray( - self.LeakingWeigthVariable, + BrianedWeightFloatsArray=getShapeArray( + self.LeakingWeightVariable, BrianedRowsInt, BrianedColsInt ) @@ -3389,7 +3466,7 @@ def brianInteraction(self): #reshape BrianedFloatsArray=np.reshape( np.array( - BrianedWeigthFloatsArray + BrianedWeightFloatsArray ).T, BrianedRowsInt*BrianedColsInt ) @@ -3400,7 +3477,7 @@ def brianInteraction(self): [ 'It is an already defined array', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]), 'self.BrianedSynapsesVariable.source.N is '+str(self.BrianedSynapsesVariable.source.N), 'self.BrianedSynapsesVariable.target.N is '+str(self.BrianedSynapsesVariable.target.N), @@ -3565,8 +3642,6 @@ def brianInteraction(self): __IndexInt )+"="+LeakedSymbolStr+"_delayer_"+str( __IndexInt-1 - - ), xrange(self.LeakedDelayTotalIntVariable[0]-1,0,-1) )+[ @@ -4000,7 +4075,7 @@ def setDelay(): if self.LeakingEigenBool: #set - self.NumscipyingValueVariable=BrianedWeigthFloatsArray + self.NumscipyingValueVariable=BrianedWeightFloatsArray self.NumscipyingEigenvalueBool=True #debug @@ -4317,10 +4392,13 @@ def brianTrace(self): ) ''' - #Check - if self.ManagementTagStr.split( + #set + LeakedWordStr=self.ManagementTagStr.split( Recorder.RecordPrefixStr - )[1] in self.LeakedParentPopulationDeriveLeakerVariable.LeakedRecordSkipStrsList or ( + )[1] if len(Recorder.RecordPrefixStr)>0 else self.ManagementTagStr + + #Check + if LeakedWordStr in self.LeakedParentPopulationDeriveLeakerVariable.LeakedRecordSkipStrsList or ( self.LeakedParentPopulationDeriveLeakerVariable.LeakingTimeVariable in ['0',0.] ): @@ -4348,7 +4426,7 @@ def brianTrace(self): #Check if BrianedParentInteractionDeriveBrianerVariable.LeakingPlasticVariable!=None and type( - BrianedParentInteractionDeriveBrianerVariable.LeakingWeigthVariable + BrianedParentInteractionDeriveBrianerVariable.LeakingWeightVariable )!=None.__class__: #debug @@ -4956,6 +5034,151 @@ def simulatePopulation(self): self.NumscipyingGlobalBool=self.LeakingTotalBool self.numscipy() + #Check + if self.LeakingMaxBool: + + #debug + ''' + self.debug( + [ + 'We plot the max', + ('self.',self,[ + 'LeakedMaxSpikeMonitorVariable', + 'LeakedMaxStateMonitorVariable' + ]), + 'self.LeakedMaxSpikeMonitorVariable.t is '+str( + self.LeakedMaxSpikeMonitorVariable.t + ) + ] + ) + ''' + + #Check + if self.LeakingMinPhaseTimeVariable==None: + self.LeakingMinPhaseTimeVariable=1.*self.BrianedParentNetworkDeriveBrianerVariable.SimulatingStopTimeFloat*self.BrianedParentNetworkDeriveBrianerVariable.BrianedTimeQuantityVariable/2. + + #Check + #if self.LeakingMaxPhasesInt==None: + # #self.LeakingMaxPhasesInt=len(self.LeakedMaxSpikeMonitorVariable.t) + # self.LeakingMaxPhasesInt=2 + + #debug + self.debug( + [ + ('self.',self,[ + 'LeakingMinPhaseTimeVariable', + 'LeakingMaxPhasesInt' + ]) + ] + ) + + #init + self.LeakedPhaseList=[None]*self.LeakingUnitsInt + + #loop + for __IndexInt,__NeuronInt in enumerate( + self.LeakedMaxSpikeMonitorVariable.i + ): + + #debug + ''' + self.debug( + [ + '[__IndexInt,__NeuronInt] is '+str( + [__IndexInt,__NeuronInt] + ) + ] + ) + ''' + + #get + LeakedTimeVariable=self.LeakedMaxSpikeMonitorVariable.t[__IndexInt] + + #Check + if LeakedTimeVariable>self.LeakingMinPhaseTimeVariable: + + #init + if self.LeakedPhaseList[__NeuronInt]==None: + + #init + self.LeakedPhaseList[__NeuronInt]=[] + + #init + LeakedAppendList=[ + __IndexInt, + float(LeakedTimeVariable), + None + ] + + #len + LeakedLenghtInt=len(self.LeakedPhaseList[__NeuronInt]) + + #Check + if LeakedLenghtInt>0 and LeakedLenghtInt0 else SYS._filter( + lambda __KeyStr: + __KeyStr not in self.LeakedRecordSkipStrsList, + self.LeakedInputKeyStrsList + ) + + #map + map( + lambda __LeakedInputKeyStr: + LeakedRunPopulationChartsDerivePyploter.getManager( + __LeakedInputKeyStr + ), + LeakedInputKeyStrsList + ) + #/##################/# # base method # @@ -5005,19 +5278,17 @@ def viewPopulation(self): ''' #init - ViewedNetworkDrawsDerivePyploter=None + ViewedRunNetworkDrawsDerivePyploter=None #get - ViewedPopulationDrawsDerivePyploter=self.getTeamer( - 'Charts' - ).getManager( + ViewedPopulationRunDrawsDerivePyploter=LeakedRunPopulationChartsDerivePyploter.getManager( Recorder.RecordPrefixStr+self.LeakedSymbolStr ).getTeamer( 'Draws' ) #Check - if len(ViewedPopulationDrawsDerivePyploter.ManagementDict)>0: + if len(ViewedPopulationRunDrawsDerivePyploter.ManagementDict)>0: #Check if self.LeakingGlobalBool or self.LeakingTotalBool: @@ -5085,7 +5356,7 @@ def viewPopulation(self): ''' #add - ViewedPopulationDrawsDerivePyploter.getManager( + ViewedPopulationRunDrawsDerivePyploter.getManager( 'Global' ).PyplotingDrawVariable=[ ( @@ -5164,7 +5435,7 @@ def viewPopulation(self): # #alias - ViewedNetworkDrawsDerivePyploter=self.BrianedParentNetworkDeriveBrianerVariable.getTeamer( + ViewedRunNetworkDrawsDerivePyploter=self.BrianedParentNetworkDeriveBrianerVariable.getTeamer( 'Panels' ).getManager( 'Run' @@ -5177,9 +5448,9 @@ def viewPopulation(self): ) #get - ViewedNetworkDrawsDerivePyploter.getManager( + ViewedRunNetworkDrawsDerivePyploter.getManager( 'Global' - ).PyplotingDrawVariable=ViewedPopulationDrawsDerivePyploter.ManagementDict[ + ).PyplotingDrawVariable=ViewedRunPopulationDrawsDerivePyploter.ManagementDict[ 'Global' ].PyplotingDrawVariable @@ -5228,142 +5499,64 @@ def viewPopulation(self): #Check if self.LeakingMaxBool: - #debug - ''' - self.debug( - [ - 'We plot the max', - ('self.',self,[ - 'LeakedMaxSpikeMonitorVariable', - 'LeakedMaxStateMonitorVariable' - ]), - 'self.LeakedMaxSpikeMonitorVariable.t is '+str( - self.LeakedMaxSpikeMonitorVariable.t - ) - ] - ) - ''' - - #Check - if self.LeakingMinPhaseTimeVariable==None: - self.LeakingMinPhaseTimeVariable=1.*self.BrianedParentNetworkDeriveBrianerVariable.SimulatingStopTimeFloat*self.BrianedParentNetworkDeriveBrianerVariable.BrianedTimeQuantityVariable/2. - - #Check - #if self.LeakingMaxPhasesInt==None: - # #self.LeakingMaxPhasesInt=len(self.LeakedMaxSpikeMonitorVariable.t) - # self.LeakingMaxPhasesInt=2 - - #debug - self.debug( - [ - ('self.',self,[ - 'LeakingMinPhaseTimeVariable', - 'LeakingMaxPhasesInt' - ]) - ] - ) - - #init - self.LeakedPhaseList=[None]*self.LeakingUnitsInt - - #loop - for __IndexInt,__NeuronInt in enumerate( - self.LeakedMaxSpikeMonitorVariable.i - ): - - #debug - ''' - self.debug( - [ - '[__IndexInt,__NeuronInt] is '+str( - [__IndexInt,__NeuronInt] - ) - ] - ) - ''' - - #get - LeakedTimeVariable=self.LeakedMaxSpikeMonitorVariable.t[__IndexInt] - - #Check - if LeakedTimeVariable>self.LeakingMinPhaseTimeVariable: - - #init - if self.LeakedPhaseList[__NeuronInt]==None: - - #init - self.LeakedPhaseList[__NeuronInt]=[] - - #init - LeakedAppendList=[ - __IndexInt, - float(LeakedTimeVariable), - None - ] - - #len - LeakedLenghtInt=len(self.LeakedPhaseList[__NeuronInt]) - - #Check - if LeakedLenghtInt>0 and LeakedLenghtInt$' + 'label':'$mean('+self.LeakedSymbolStr+')$' + } ) - ) + } + ) + ] - #debug - ''' - self.debug( - [ - 'LeakedAppendList is '+str(LeakedAppendList) - ] - ) - ''' - #Check - if LeakedLenghtInt # -RecordPrefixStr='*' +RecordPrefixStr="" # # @@ -197,15 +197,15 @@ def recordTrace(self): # #debug - ''' self.debug( [ 'This is the Traces level', 'First get the array to trace', - ('self.',self,['RecordingKeyVariable']) + ('self.',self,[ + 'RecordingKeyVariable' + ]) ] ) - ''' #get RecordedTopDeriveRecorderVariable=self.ParentDeriveTeamerVariable.ParentDeriveTeamerVariable @@ -218,17 +218,18 @@ def recordTrace(self): if type(self.RecordingKeyVariable)==None.__class__: #Check - if self.ManagementTagStr.startswith(RecordPrefixStr): + if RecordPrefixStr!="" and self.ManagementTagStr.startswith(RecordPrefixStr): #debug ''' self.debug( [ - ('self.',self,['ManagementTagStr']) + ('self.',self,['ManagementTagStr']), + 'RecordedTopDeriveRecorderVariable is '+str(RecordedTopDeriveRecorderVariable) ] ) ''' - + #get self.RecordedTraceFloatsArray=getattr( RecordedTopDeriveRecorderVariable, diff --git a/Pythonlogy/ShareYourSystem/__init__.py b/Pythonlogy/ShareYourSystem/__init__.py index a5cab523..cd8955ee 100755 --- a/Pythonlogy/ShareYourSystem/__init__.py +++ b/Pythonlogy/ShareYourSystem/__init__.py @@ -690,11 +690,20 @@ def _filter(_Function,_List): return list(filter(_Function,_List)) def filterNone(_List): + + #Debug + """ + print("List is") + print(_List) + print("") + """ + + #return return _filter( - lambda __ListedVariable: - __ListedVariable!=None, - _List - ) + lambda __ListedVariable: + type(__ListedVariable)!=None.__class__, + _List + ) def flip(_Dict): return type(_Dict)( @@ -949,12 +958,148 @@ def arrayify(_VariablesList,_ShapeIntsList=None): ValueVariablesList ) - - - #return return VariablesArray - + +def split(_StartVariable=0,_StopInt=1,_SplitInt=2): + + #import + import numpy as np + + #Check + if type(_StartVariable)==int: + + #set + CutIntsList=np.linspace(_StartVariable,_StopInt,_SplitInt+1,dtype=int) + + #Debug + """ + print("SYS l 967 split") + print("CutIntsList is ") + print(CutIntsList) + print("") + """ + + #map + return map( + lambda __IndexIntAndCutInt: + [CutIntsList[__IndexIntAndCutInt[0]],__IndexIntAndCutInt[1]], + enumerate( + CutIntsList[1:] + ) + ) + + else: + + #map + SplitIntsListsList=map( + lambda __ShapeInt: + split(0,__ShapeInt,_SplitInt), + np.shape(_StartVariable) + ) + + #Debug + print("SYS l 991 split") + print("SplitIntsListsList is ") + print(SplitIntsListsList) + print("") + + #import + import itertools + + #product + return map( + lambda __GetIntsListsTuple: + _StartVariable.__getitem__( + map( + lambda __GetIntsList: + slice(__GetIntsList[0],__GetIntsList[1]), + __GetIntsListsTuple + ) + ), + list(itertools.product(*SplitIntsListsList)) + ) + +def getArray(_Array,_IndexIntsTuple,_LoopBool=True): + + #Debug + """ + print("_IndexIntsTuple is ") + print(_IndexIntsTuple) + print("-1 in _IndexIntsTuple is "+str(-1 in _IndexIntsTuple)) + print("") + """ + + #Check + if _LoopBool==False: + + #Check + if -1 in _IndexIntsTuple: + + #return + return None + + #try + try: + + #return + return _Array.__getitem__(_IndexIntsTuple) + except: + + #return + return None + +def contour(_GridBoolsArray,_ContourIntsList=None): + + #import + import numpy as np + + #get + LocalArray=getLocalArray(len(np.shape(_GridBoolsArray))) + + #Debug + """ + print('LocalArray is ') + print(LocalArray) + print('') + """ + + #map + return np.array( + map( + lambda __Tuple: + __Tuple[0], + _filter( + lambda __Tuple: + __Tuple[1], + map( + lambda __IndexIntsTupleAndValueVariableTuple: + ( + __IndexIntsTupleAndValueVariableTuple[0], + any( + map( + lambda __Value: + __Value!=__IndexIntsTupleAndValueVariableTuple[1], + filterNone( + map( + lambda __IndexIntsArray: + getArray(_GridBoolsArray,tuple(__IndexIntsArray),_LoopBool=False), + map( + lambda __LocalArray: + np.array(__IndexIntsTupleAndValueVariableTuple[0])+__LocalArray, + LocalArray + ) + ) + ) + ) + ) + ), + np.ndenumerate(_GridBoolsArray) + ) + ) + ) + ) + def where(_DictsList,_TuplesList,**_KwargsDict): if 'IsInCheckingBool' in _KwargsDict and _KwargsDict['IsInCheckingBool']: @@ -995,6 +1140,180 @@ def where(_DictsList,_TuplesList,**_KwargsDict): _DictsList ) +def find(_Array, _PredicateFunction, _ChunkSizeInt=1024): + """ + Find the indices of array elements that match the predicate. + + Parameters + ---------- + _Array : array_like + Input data, must be 1D. + + _PredicateFunction : function + A function which operates on sections of the given array, returning + element-wise True or False for each data value. + + _ChunkSizeInt : integer + The length of the chunks to use when searching for matching indices. + For high probability predicates, a smaller number will make this + function quicker, similarly choose a larger number for low + probabilities. + + Returns + ------- + index_generator : generator + A generator of (indices, data value) tuples which make the predicate + True. + + See Also + -------- + where, nonzero + + Notes + ----- + This function is best used for finding the first, or first few, data values + which match the predicate. + + Examples + -------- + >>> _Array = np.sin(np.linspace(0, np.pi, 200)) + >>> result = find(_Array, lambda arr: arr > 0.9) + >>> next(result) + ((71, ), 0.900479032457) + >>> np.where(_Array > 0.9)[0][0] + 71 + + """ + + #Check + if _Array.ndim != 1: + Array=_Array.flatten() + #raise ValueError('The array must be 1D, not {}.'.format(_Array.ndim)) + else: + Array=_Array + + #import + from itertools import chain, izip + + #init + InitInt = 0 + ChunkIndexIntsIterator = chain( + xrange( + _ChunkSizeInt, + Array.size, + _ChunkSizeInt + ), + [None] + ) + + #for + for _IndexInt in ChunkIndexIntsIterator: + ChunkArray = Array[InitInt:_IndexInt] + for __IndexList in izip(*_PredicateFunction(ChunkArray).nonzero()): + yield (__IndexList[0] + InitInt, ), ChunkArray[__IndexList] + InitInt = _IndexInt + + +def getIsConstantBool(_BoolsArray): + + #import + import numpy as np + + #get + ConstantBool=_BoolsArray.__getitem__(tuple([0]*len(np.shape(_BoolsArray)))) + OppositeBool=not ConstantBool + + #Debug + ''' + print("ConstantBool is ") + print(ConstantBool) + print("") + ''' + + #return + try: + + #next + next( + find( + _BoolsArray, + lambda __Bool:__Bool==OppositeBool + ) + ) + + #return True + return False + + except StopIteration: + + #return + return True + +def getFlattenedListWithVariablesList(_VariablesList): + return functools.reduce( + lambda x,y: + x+list(y) if type(y)==tuple + else list(x)+[y] if type(x) in [list,tuple] + else [x,y],_VariablesList + ) + +def getPermutedIntsListWithCategoriesIntAndLengthInt(_CategoriesInt,_LengthInt): + + #import + import itertools + + #return + return functools.reduce( + lambda x,y: + map( + lambda __IntOrTuple: + getFlattenedListWithVariablesList(list(__IntOrTuple)) + if type(__IntOrTuple)==tuple + else __IntOrTuple, + itertools.product(x,y) + ), + map(lambda Int:xrange(_LengthInt),xrange(_CategoriesInt)) + ) + +def getLocalArray(_DimensionInt,_DiagonalBool=False): + + #import + import numpy as np + + #Check + if _DiagonalBool: + + #array + PositiveArray=np.array( + getPermutedIntsListWithCategoriesIntAndLengthInt( + _DimensionInt, + 2 + ) + ) + + #return + return PositiveArray + + else: + + #diag + DiagonalArray=np.diag([1]*_DimensionInt) + + #init + LocalArray=np.zeros((2*_DimensionInt,_DimensionInt),dtype=int) + + #fill + LocalArray[:_DimensionInt,:]=DiagonalArray + LocalArray[_DimensionInt:,:]=-1.*DiagonalArray + + #return + return LocalArray + + + + + + def translate(_TextStr,_TranslationVariable): #Debug @@ -1396,10 +1715,10 @@ def chunk(_LimitStrsList,_TextStr,**_KwargVariablesDict): _LimitStrsList[0],_LimitStrsList[1],ChunksInt,_TextStr,**_KwargVariablesDict) def deprefix(_WordStr,_PrefixStr): - return _PrefixStr.join(_WordStr.split(_PrefixStr)[1:]) + return _PrefixStr.join(_WordStr.split(_PrefixStr)[1:]) if _PrefixStr!="" else _WordStr def desuffix(_WordStr,_SuffixStr): - return _SuffixStr.join(_WordStr.split(_SuffixStr)[:-1]) + return _SuffixStr.join(_WordStr.split(_SuffixStr)[:-1]) if _SuffixStr!="" else _WordStr def groupby(_FunctionPointer,_List): return getSplitListsListWithSplittedListAndFunctionPointer(_List,_FunctionPointer) @@ -2803,6 +3122,48 @@ def insert(self, xrange(len(ValueVariablesList)) ) + #return + return self + + def move(self,_OldIndexVariable,_NewIndexInt): + + #get + if type(_OldIndexVariable)==int: + TempKeyVariable,TempValueVariable=self.getItem(_OldIndexVariable) + else: + TempKeyVariable=_OldIndexVariable + TempValueVariable=self[TempKeyVariable] + + #Debug + ''' + print('move SYS l 2812') + print('TempKeyVariable,TempValueVariable') + print(TempKeyVariable,TempValueVariable) + print('_NewIndexInt is') + print(_NewIndexInt) + print('') + ''' + + #del + del self[TempKeyVariable] + + #insert + self.insert( + _NewIndexInt, + TempValueVariable, + _KeyVariable=TempKeyVariable + ) + + #Debug + ''' + print('self is') + print(self) + print('') + ''' + + #return + return self + class MethodDict(collections.OrderedDict): diff --git a/Pythonlogy/build/lib/ShareYourSystem/13_ExampleDoc.py b/Pythonlogy/build/lib/ShareYourSystem/13_ExampleDoc.py index 6c697a3e..b063c99d 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/13_ExampleDoc.py +++ b/Pythonlogy/build/lib/ShareYourSystem/13_ExampleDoc.py @@ -17,6 +17,21 @@ MyListDict.insert(1,'salut') MyListDict.insert(1,'bonjour','MyStr') +#np +import numpy as np + +#set +MyArray=np.array([[1,2]]) + +#insert +MyListDict.insert(0,MyArray,'MyArray') + +#move +MyListDict.move(0,3) + +#move +MyListDict.move('MyStr',0) + #print print('MyListDict is ') -print(MyListDict) \ No newline at end of file +print(MyListDict) diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/01_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/01_ExampleCell.py index 36ca2b9b..0d528081 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/01_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/01_ExampleCell.py @@ -24,7 +24,7 @@ 'reset':'v=-70*mV' }, '-Traces':{ - '|*v':{ + '|v':{ 'NumscipyingStdFloat':0.001, '-Samples':{ '|Default':{ diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/03_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/03_ExampleCell.py index 6a91093a..e4e406fe 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/03_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/03_ExampleCell.py @@ -25,7 +25,7 @@ 'reset':'v=-70*mV' }, '-Traces':{ - '|*v':{ + '|v':{ 'NumscipyingStdFloat':0.001 } }, @@ -65,7 +65,11 @@ # View # -MyBrianer.view( +MyBrianer.mapSet( + { + 'PyplotingGridVariable':(30,20) + } + ).view( ).pyplot( ).show( ) @@ -77,19 +81,3 @@ #Definition the AttestedStr print('MyBrianer is ') SYS._print(MyBrianer) - - -""" -from matplotlib import pyplot -pyplot.figure() -ME=MyBrianer['/-Populations/|E/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -MI=MyBrianer['/-Populations/|I/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -pyplot.plot(ME.t, ME.v.T,color='b') -pyplot.plot(MI.t, MI.v.T,color='r') -pyplot.figure() -ME=MyBrianer['/-Populations/|E/-Events/|Default'].BrianedSpikeMonitorVariable -MI=MyBrianer['/-Populations/|I/-Events/|Default'].BrianedSpikeMonitorVariable -pyplot.plot(ME.t, ME.i,'.') -pyplot.plot(MI.t, max(ME.i)+MI.i,'.',color='r') -pyplot.show() -""" \ No newline at end of file diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/05_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/05_ExampleCell.py index c3089e24..ce70f71b 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/05_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/05_ExampleCell.py @@ -65,11 +65,11 @@ ] }, '-Traces':{ - '|*v':{ + '|v':{ 'NumscipyingStdFloat':0.001, '-Samples':{ '|Default':{ - 'MoniteringLabelIndexIntsArray':[0,1] + 'RecordingLabelVariable':[0,1] } } } @@ -91,10 +91,29 @@ } } ).brian( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyBrianer.simulate( 500. ) - + +#/###################/# +# View +# + +MyBrianer.mapSet( + { + 'PyplotingGridVariable':(30,20) + } + ).view( + ).pyplot( + ).show( + ) + #/###################/# # Print # @@ -103,19 +122,3 @@ print('MyBrianer is ') SYS._print(MyBrianer) -#/###################/# -# Do one simulation -# - -from matplotlib import pyplot -pyplot.figure() -ME=MyBrianer['/-Populations/|E/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -MI=MyBrianer['/-Populations/|I/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -pyplot.plot(ME.t, ME.v.T,color='b') -pyplot.plot(MI.t, MI.v.T,color='r') -pyplot.figure() -ME=MyBrianer['/-Populations/|E/-Events/|Default'].BrianedSpikeMonitorVariable -MI=MyBrianer['/-Populations/|I/-Events/|Default'].BrianedSpikeMonitorVariable -pyplot.plot(ME.t, ME.i,'.') -pyplot.plot(MI.t, max(ME.i)+MI.i,'.',color='r') -pyplot.show() \ No newline at end of file diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/07_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/07_ExampleCell.py deleted file mode 100644 index de7cf9bc..00000000 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/07_ExampleCell.py +++ /dev/null @@ -1,115 +0,0 @@ -#/###################/# -# Import modules -# - -#ImportModules -import ShareYourSystem as SYS - -#/###################/# -# Build the model -# - -#Definition an instance -MyBrianer=SYS.BrianerClass( - ).mapSet( - { - '-Neurongroups': - { - 'set':{ - '#liarg:#lambda':{ - '|#NeuronStr':{ - '#copy:BrianingNeurongroupDict':{ - 'N':'#UnitsInt', - 'model': - ''' - Jr : 1 - dr/dt = -r + #TransferStr(Jr)/(20*ms) : volt - ''', - }, - 'set':{ - '#liarg:#lambda':{ - 'array':[ - [ - ['-Connectomes'], - ['|Postlets<->Prelets'], - ['-Connections'], - ['|#direct:_^_|E','|#direct:_^_|I'] - ], - [ - {}, - {}, - { - 'BrianingSynapsesDict':{ - 'pre':''' - #PreStr \n - ''' - }, - 'BrianingConnectVariable':0.2 - } - ] - ] - }, - '#map':[ - ['#PreStr'], - [ - ['ge+=0.1*mV'], - ['gi-=3*mV'] - ] - ] - }, - '-Traces':{ - '|*v':{ - 'NumscipyingStdFloat':0.001, - '-Samples':{ - '|Default':{ - 'MoniteringLabelIndexIntsArray':[0,1] - } - } - } - }, - '-Events':{ - '|Default':{ - } - }, - } - }, - '#map':[ - ['#NeuronStr','#UnitsInt'], - [ - ['E','80'], - ['I','20'] - ] - ] - } - } - } - ).brian( - ).simulate( - 500. - ) - -#/###################/# -# Print -# - - -#Definition the AttestedStr -print('MyBrianer is ') -SYS._print(MyBrianer) - -#/###################/# -# Do one simulation -# - -from matplotlib import pyplot -pyplot.figure() -ME=MyBrianer['/-Neurongroups/|E/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -MI=MyBrianer['/-Neurongroups/|I/-Traces/|*v/-Samples/|Default'].BrianedStateMonitorVariable -pyplot.plot(ME.t, ME.v.T,color='b') -pyplot.plot(MI.t, MI.v.T,color='r') -pyplot.figure() -ME=MyBrianer['/-Neurongroups/|E/-Events/|Default'].BrianedSpikeMonitorVariable -MI=MyBrianer['/-Neurongroups/|I/-Events/|Default'].BrianedSpikeMonitorVariable -pyplot.plot(ME.t, ME.i,'.') -pyplot.plot(MI.t, max(ME.i)+MI.i,'.',color='r') -pyplot.show() \ No newline at end of file diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/09_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/09_ExampleCell.py deleted file mode 100644 index cc2ebfb5..00000000 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/09_ExampleCell.py +++ /dev/null @@ -1,79 +0,0 @@ -#/###################/# -# Import modules -# - -#ImportModules -import ShareYourSystem as SYS - -#/###################/# -# Build the model -# - -#Definition an instance -MyBrianer=SYS.BrianerClass( - ).mapSet( - { - 'BrianingNeurongroupDict':{ - 'N':10, - 'model': - ''' - dv/dt = (-(v+60*mV)+11*mV + 5.*mV*sqrt(20.*ms)*xi)/(20*ms) : volt - ''', - 'threshold':'v>-50*mV', - 'reset':'v=-70*mV' - }, - '-Projections':{ - '|/':{ - - } - }, - '-Traces':{ - '|*v':{ - 'NumscipyingStdFloat':0.001, - '-Samples':{ - '|Default':{ - 'RecordingLabelVariable':[0,1] - } - } - } - }, - '-Events':{ - '|Default':{ - } - } - } - ).brian( - ) - -#/###################/# -# Print -# - -#Definition the AttestedStr -print('MyBrianer is ') -SYS._print(MyBrianer) - -#/###################/# -# Do one simulation -# - -MyBrianer.simulate( - 500. - ) - -#/###################/# -# View -# - -#MyBrianer['/-Traces/|*v/-Samples/|Default'].view( -# ).pyplot( -# ) -#MyBrianer['/-Events/|Default'].view( -# ).pyplot( -# ) - -MyBrianer.view( - ).pyplot() - -SYS.matplotlib.pyplot.show() - diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/__init__.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/__init__.py index 49d2a450..136e5c8f 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/__init__.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Brianer/__init__.py @@ -634,20 +634,23 @@ def debugNeurongroup(): #debug - ''' self.debug( [ 'We set the tracers', - ('self.',self,['BrianedRecordKeyStrsList']) + ('self.',self,['BrianedRecordKeyStrsList']), + #'Recorder.RecordPrefixStr is '+str(Recorder.RecordPrefixStr), + #'BrianedTracesManager is '+SYS._str( + # BrianedTracesManager + #) ] ) - ''' - + #map self.BrianedTraceDeriveBrianersList=map( lambda __ManagementKeyStr,__RecordKeyStr: - BrianedTracesManager.manage( - __ManagementKeyStr, + BrianedTracesManager.getManager( + __ManagementKeyStr + ).mapSet( { 'RecordingKeyVariable':getattr( self.BrianedNeurongroupVariable, @@ -655,17 +658,7 @@ def debugNeurongroup(): ), 'RecordKeyStr':__RecordKeyStr } - ).ManagedValueVariable - if __ManagementKeyStr not in BrianedTracesManager.ManagementDict - else BrianedTracesManager.ManagementDict[__ManagementKeyStr].mapSet( - { - 'RecordingKeyVariable':getattr( - self.BrianedNeurongroupVariable, - __RecordKeyStr - ), - 'RecordKeyStr':__RecordKeyStr - } - ), + ), map( lambda __BrianedRecordKeyStr: Recorder.RecordPrefixStr+__BrianedRecordKeyStr, @@ -1907,6 +1900,7 @@ def mimic_view(self): def viewPopulation(self): #debug + ''' self.debug( [ 'we view population brian here', @@ -1915,6 +1909,7 @@ def viewPopulation(self): ]) ] ) + ''' #Check if self.BrianingViewNetworkBool==False: @@ -2104,25 +2099,39 @@ def viewPopulation(self): # Manage each Chart # + #get + ViewedPopulationRunChartsDerivePyploter=self.TeamDict[ + "Panels" + ].ManagementDict[ + "Run" + ].TeamDict[ + "Charts" + ] + + #get + ViewedPopulationRunChartDerivePyplotersList=ViewedPopulationRunChartsDerivePyploter.ManagementDict.values() + + #debug + LeakedTagVariable=map( + lambda __Variable: + (__Variable.ManagementIndexInt, + __Variable.ManagementTagStr), + ViewedPopulationRunChartDerivePyplotersList + ) + ''' + #debug self.debug( [ 'We map manage each Chart in the network one', - 'self.TeamDict["Charts"].ManagementDict.keys() is', - str(self.TeamDict["Charts"].ManagementDict.keys()) + 'ViewedPopulationRunChartsDerivePyploter.ManagementDict.keys() is', + str(ViewedPopulationRunChartsDerivePyploter.ManagementDict.keys() + ), + 'LeakedTagVariable is '+str(LeakedTagVariable) ] ) ''' - #get - ViewedPopulationRunChartDerivePyplotersList=self.TeamDict[ - "Panels" - ].ManagementDict[ - "Run" - ].TeamDict[ - "Charts" - ].ManagementDict.values() - #map ViewedNetworkRunChartDerivePyplotersList=map( lambda __ViewedPopulationRunChartDerivePyploter: @@ -3023,6 +3032,23 @@ def viewSample(self): self.BrianedParentDeriveRecorderVariable.ManagementTagStr ) + #debug + ''' + self.debug( + [ + 'We have managed this new Chart', + 'self.BrianedParentDeriveRecorderVariable.ManagementTagStr is '+str( + self.BrianedParentDeriveRecorderVariable.ManagementTagStr), + 'BrianedRunPopulationChartsDeriveManager.ManagementDict is '+str( + BrianedRunPopulationChartsDeriveManager.ManagementDict), + 'BrianedRunPopulationChartsDeriveManager.ManagementDict.keys() is '+str( + BrianedRunPopulationChartsDeriveManager.ManagementDict.keys() + ) + ] + ) + ''' + + #/####################/# # set to True # @@ -3156,6 +3182,7 @@ def viewSample(self): )-1: #Check + ''' self.debug( [ 'This is the last Sample for this record', @@ -3165,6 +3192,7 @@ def viewSample(self): ) ] ) + ''' #call self.BrianedParentDeriveRecorderVariable.viewTraceOrEvent() @@ -3566,6 +3594,12 @@ def mimic_simulate(self): def recordTrace(self): + #set + #self.RecordedTraceFloatsArray=getattr( + # self.BrianedParentPopulationDeriveBrianerVariable.BrianedNeurongroupVariable, + # self.RecordKeyStr + #) + #base method BaseClass.recordTrace(self) @@ -3601,6 +3635,16 @@ def recordTrace(self): def setBrianInit(self): + #debug + self.debug( + [ + 'we set brian init here', + ('self.',self,[ + 'RecordedTraceFloatsArray' + ]) + ] + ) + #Check if str(self.RecordedTraceFloatsArray.unit) in ['V']: diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/01_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/01_ExampleCell.py index df1b2219..b834c446 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/01_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/01_ExampleCell.py @@ -27,14 +27,15 @@ ).simulate( 500. ) - + #/###################/# # View # MyLeaker.view( ).pyplot( - ).show() + ).show( + ) #/###################/# # Print diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/03_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/03_ExampleCell.py deleted file mode 100644 index 4ca07342..00000000 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/03_ExampleCell.py +++ /dev/null @@ -1,99 +0,0 @@ -#/###################/# -# Import modules -# - -#ImportModules -import ShareYourSystem as SYS - -#/###################/# -# Build the model -# - -#Define -MyLeaker=SYS.LeakerClass( - ).mapSet( - { - '-Populations':{ - '|Sensor':{ - 'LeakingUnitsInt':2, - 'LeakingSymbolPrefixStr':'r', - '-Inputs':{ - '|Command':{ - #'LeakingWeigthVariable':'#scalar:3.*mV', - #'LeakingWeigthVariable':5., - #'LeakingWeigthVariable':5.*SYS.brian2.mV - #'LeakingWeigthVariable':[1.,3.], - #'LeakingWeigthVariable':SYS.getKrenelFloatsArray(), - #'LeakingWeigthVariable':'#equation:5.*mV*(1.+tanh(10.*(t-250.*ms)/ms))', - #'LeakingWeigthVariable':'#custom:#clock:10*ms:''' - # change=int(t>250*ms) - # #SymbolStr:5.*mV*change - #''', - #'LeakingWeigthVariable':'#custom:5.*mV*(ms/(t+1*ms))', - #'LeakingWeigthVariable':'#custom:#clock:200*ms:5.*mV*(t==200*ms)*(i==0)', - #'LeakingWeigthVariable':'#custom:#clock:200*ms:5.*mV*(t==200*ms)*(i==0)', - 'LeakingWeigthVariable':( - '#custom:#clock:100*ms', - [ - '5.*mV*int(t==200*ms)', - '-2.*mV*int(t==100*ms)' - ] - ), - #'LeakingWeigthVariable':( - # '#network:#clock:200*ms', - # lambda _ActivityQuantity,_TimeQuantity: - # 5.*SYS.brian2.mV - # if _TimeQuantity==200.*SYS.brian2.ms - # else 0.*SYS.brian2.mV - #), - #'LeakingWeigthVariable':( - # '#network:#clock:1*ms', - # lambda _ActivityQuantity,_TimeQuantity: - # SYS.scipy.stats.norm.rvs(size=2)*SYS.brian2.mV - #), - 'RecordingLabelVariable':[0,1] - } - }, - 'RecordingLabelVariable':[0,1] - } - } - } - ).leak( - ).simulate( - 500. - ) - - -#/###################/# -# View -# - -#MyLeaker[ -# '/-Populations/|Sensor/-Traces/|*I_Command/-Samples/|Default' -# ].view( -# ).pyplot( -# ) - -#MyLeaker[ -# '/-Populations/|Sensor/-Traces/|*U/-Samples/|Default' -# ].view( -# ).pyplot( -# ) - -MyLeaker[ - '/-Populations/|Sensor' - ].view( - ).pyplot( - ) -SYS.matplotlib.pyplot.show() - -#/###################/# -# Print -# - -#Definition the AttestedStr -print('MyLeaker is ') -SYS._print(MyLeaker) - - - diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/05_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/05_ExampleCell.py index 9577ed4b..6c40b4eb 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/05_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/05_ExampleCell.py @@ -19,33 +19,51 @@ 'LeakingSymbolPrefixStr':'r', '-Inputs':{ '|Default':{ - #'LeakingWeigthVariable':'#scalar:4.*mV' - 'LeakingWeigthVariable':4. + #'LeakingWeightVariable':'#scalar:4.*mV' + 'LeakingWeightVariable':4. } }, '-Interactions':{ '|/':{ - #'LeakingWeigthVariable':'#scalar:0.', - #'LeakingWeigthVariable':'#scalar:-1.', - #'LeakingWeigthVariable':-1., - 'LeakingWeigthVariable':[-0.,-0.5,-0.,-0.], - #'LeakingWeigthVariable':[[0.,0.],[0.,-0.4]], - #'LeakingWeigthVariable':'#array', + #'LeakingWeightVariable':'#scalar:0.', + #'LeakingWeightVariable':'#scalar:-1.', + #'LeakingWeightVariable':-1., + 'LeakingWeightVariable':[-0.,-0.5,-0.,-0.], + #'LeakingWeightVariable':[[0.,0.],[0.,-0.4]], + #'LeakingWeightVariable':'#array', #'NumscipyingStdFloat':0.1, - 'LeakingVariableStr':'I_Default', + #'LeakingVariableStr':'I_Default', #'BrianingDebugVariable':0.1, } }, #'BrianingDebugVariable':0.1, - 'BrianingMonitorIndexIntsList':[0,1] + 'RecordingLabelVariable':[0,1] } } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 500. ) - + +#/###################/# +# View +# + +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(30,20) + } + ).view( + ).pyplot( + ).show( + ) #/###################/# # Print @@ -55,11 +73,3 @@ print('MyLeaker is ') SYS._print(MyLeaker) -#/###################/# -# View -# - -MyLeaker['/-Populations/|Default'].view( - ).pyplot() -#print(MyLeaker['/-Populations/|Default/-Interactions/|/'].BrianedSynapsesVariable.J[:]) -SYS.matplotlib.pyplot.show() diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/07_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/07_ExampleCell.py index 364b3c2f..c287ff53 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/07_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/07_ExampleCell.py @@ -19,12 +19,12 @@ 'LeakingSymbolPrefixStr':'r', '-Inputs':{ '|Default':{ - 'LeakingWeigthVariable':5. + 'LeakingWeightVariable':5. } }, '-Interactions':{ '|/':{ - 'LeakingWeigthVariable':-1., + 'LeakingWeightVariable':-1., } }, 'LeakingTransferVariable':'1.*mV*tanh((#CurrentStr)/(1.*mV))', @@ -34,7 +34,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 500. ) @@ -42,9 +48,14 @@ # View # -MyLeaker['/-Populations/|Default'].view( - ).pyplot() -SYS.matplotlib.pyplot.show() +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( + ).pyplot( + ).show( + ) #/###################/# # Print diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/09_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/09_ExampleCell.py index c24afc19..0246041b 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/09_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/09_ExampleCell.py @@ -20,10 +20,10 @@ 'LeakingSymbolPrefixStr':'V', '-Inputs':{ '|Rest':{ - 'LeakingWeigthVariable':'#scalar:-60*mV' + 'LeakingWeightVariable':'#scalar:-60*mV' }, '|External':{ - 'LeakingWeigthVariable':'#scalar:11*mV' + 'LeakingWeightVariable':'#scalar:11*mV' } }, 'LeakingThresholdVariable':'#scalar:V>-50*mV', @@ -41,7 +41,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 500. ) @@ -49,11 +55,14 @@ # View # -MyLeaker['/-Populations/|P'].view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( + ).show( ) -#print(MyLeaker['/-Populations/|Default/-Interactions/|/'].BrianedSynapsesVariable.J[:]) -SYS.matplotlib.pyplot.show() #/###################/# # Print @@ -64,27 +73,3 @@ SYS._print(MyLeaker) -""" -from brian2 import * -from matplotlib import pyplot -Vr=[0.5,0.6] -G=NeuronGroup(2,'''Vr:1 - dv/dt=(-v+1)/(1.*ms) : 1''',threshold='v>Vr',reset='v=0') -M=StateMonitor(G,'v',[0,1]) -N=Network() -N.add(G) -N.add(M) -print(G.Vr) -G.Vr[:]=Vr -N.run(5*ms) -pyplot.plot( - M.t,M.v.T -) -pyplot.show() -""" -""" -from brian2 import CodeObject - -print(help(CodeObject)) - -""" diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/11_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/11_ExampleCell.py index f0d8bd73..5bf7fe65 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/11_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/11_ExampleCell.py @@ -20,10 +20,10 @@ 'LeakingSymbolPrefixStr':'V', '-Inputs':{ '|Rest':{ - 'LeakingWeigthVariable':'#scalar:-60*mV' + 'LeakingWeightVariable':'#scalar:-60*mV' }, '|External':{ - 'LeakingWeigthVariable':'#scalar:11*mV' + 'LeakingWeightVariable':'#scalar:11*mV' } }, 'LeakingNoiseStdVariable':0.1, @@ -40,7 +40,7 @@ '-Interactions':{ '|/':{ 'BrianingDebugVariable':100, - 'LeakingWeigthVariable':[[0.,0.],[-2.,0.]],#[[0.,-0.01],[0.,0.]] + 'LeakingWeightVariable':[[0.,0.],[-2.,0.]],#[[0.,-0.01],[0.,0.]] 'LeakingInteractionStr':"Spike" } }, @@ -50,7 +50,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 500. ) @@ -58,7 +64,11 @@ # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( ).show( ) diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/13_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/13_ExampleCell.py index 93594b5b..593533eb 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/13_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/13_ExampleCell.py @@ -20,10 +20,10 @@ 'LeakingSymbolPrefixStr':'V', '-Inputs':{ '|Rest':{ - 'LeakingWeigthVariable':'#scalar:-60*mV' + 'LeakingWeightVariable':'#scalar:-60*mV' }, '|External':{ - 'LeakingWeigthVariable':'#scalar:11*mV' + 'LeakingWeightVariable':'#scalar:11*mV' } }, 'LeakingNoiseStdVariable':0.1, @@ -32,7 +32,7 @@ '-Interactions':{ '|/':{ 'BrianingDebugVariable':100, - 'LeakingWeigthVariable':[[0.,-1.],[-2.,0.]], + 'LeakingWeightVariable':[[0.,-1.],[-2.,0.]], 'LeakingInteractionStr':"Spike", #'LeakingDelayVariable':5., #ms #'LeakingDelayVariable':[[0.,1.],[5.,0.]], #ms @@ -44,7 +44,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 200. ) @@ -52,16 +58,15 @@ # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( + ).show( ) -#MyLeaker['/-Populations/|P'].view( -# ).pyplot( -# ) - -SYS.matplotlib.pyplot.show() - #/###################/# # Print # diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/15_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/15_ExampleCell.py index 0526d9c7..27fcffa0 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/15_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/15_ExampleCell.py @@ -22,7 +22,7 @@ '-Interactions':{ '|/':{ #'BrianingDebugVariable':10, - 'LeakingWeigthVariable':[[0.,-20.],[1.,0.]], + 'LeakingWeightVariable':[[0.,-20.],[1.,0.]], 'LeakingDelayVariable':5., #'LeakingDelayVariable':[[2.,1.],0.5], #PRE-POST matrix #'LeakingDelayPrepostBool':True, @@ -35,7 +35,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 10. ) @@ -43,9 +49,14 @@ # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( - ).show() + ).show( + ) #/###################/# # Print diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/17_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/17_ExampleCell.py index 16a76cbe..24c57edf 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/17_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/17_ExampleCell.py @@ -20,10 +20,10 @@ 'LeakingSymbolPrefixStr':'V', '-Inputs':{ '|Rest':{ - 'LeakingWeigthVariable':'#scalar:-60*mV' + 'LeakingWeightVariable':'#scalar:-60*mV' }, '|External':{ - 'LeakingWeigthVariable':'#scalar:11*mV' + 'LeakingWeightVariable':'#scalar:11*mV' } }, 'LeakingNoiseStdVariable':0.1, @@ -33,7 +33,7 @@ '-Interactions':{ '|/':{ 'BrianingDebugVariable':100, - 'LeakingWeigthVariable':[[0.,0.],[0.,0.]], + 'LeakingWeightVariable':[[0.,0.],[0.,0.]], 'LeakingInteractionStr':"Spike", 'LeakingPlasticVariable':"J+=(((V_post+60.*mV)/volt)+((1.+1.)/2.)*J)", #'LeakingPlasticVariable':"J-=0.5*J", @@ -46,24 +46,29 @@ } } ).leak( - ).simulate( - 200. ) #/###################/# -# View +# Do one simulation # -#MyLeaker.view( -# ).pyplot( -# ) +MyLeaker.simulate( + 500. + ) -MyLeaker['/-Populations/|P'].view( +#/###################/# +# View +# + +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( + ).show( ) -SYS.matplotlib.pyplot.show() - #/###################/# # Print # diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/19_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/19_ExampleCell.py index 5f8fb193..47ef105a 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/19_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/19_ExampleCell.py @@ -19,7 +19,7 @@ 'LeakingTransferVariable':'mV*tanh((#CurrentStr)/mV)', '-Interactions':{ '|/':{ - 'LeakingWeigthVariable':'#array', + 'LeakingWeightVariable':'#array', #'LeakingEigenBool':True } }, @@ -29,18 +29,29 @@ } } ).leak( - ).simulate( - 200. + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( + 500. ) #/###################/# # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( - ).show() - + ).show( + ) + #/###################/# # Print # diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/21_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/21_ExampleCell.py index a9231900..3beb19eb 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/21_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/21_ExampleCell.py @@ -20,10 +20,10 @@ 'LeakingSymbolPrefixStr':'V', '-Inputs':{ '|Rest':{ - 'LeakingWeigthVariable':'#scalar:-60*mV' + 'LeakingWeightVariable':'#scalar:-60*mV' }, '|External':{ - 'LeakingWeigthVariable':'#scalar:100*mV' + 'LeakingWeightVariable':'#scalar:100*mV' } }, 'LeakingNoiseStdVariable':0.1, @@ -35,7 +35,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 50. ) @@ -43,11 +49,15 @@ # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( ).show( ) - + #/###################/# # Print # diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/23_ExampleCell.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/23_ExampleCell.py index 5fff49d7..85587763 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/23_ExampleCell.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/23_ExampleCell.py @@ -22,7 +22,7 @@ 'LeakingSymbolPrefixStr':'r', '-Inputs':{ '|External':{ - 'LeakingWeigthVariable':( + 'LeakingWeightVariable':( '#custom', [ '1.*mV*cos(2.*pi*t*0.1/ms)', @@ -39,7 +39,13 @@ } } ).leak( - ).simulate( + ) + +#/###################/# +# Do one simulation +# + +MyLeaker.simulate( 50. ) @@ -47,11 +53,18 @@ # View # -MyLeaker.view( +MyLeaker.mapSet( + { + 'PyplotingGridVariable':(20,20) + } + ).view( ).pyplot( ).show( ) +#print(MyLeaker['-Panels']) +#print(MyLeaker['/-Populations/|P/-Traces'].ManagementDict.keys()) + #/###################/# # Print # @@ -60,5 +73,5 @@ print('MyLeaker is ') SYS._print(MyLeaker) -""" + diff --git a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/__init__.py b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/__init__.py index 208a6470..20d7a2ce 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/__init__.py +++ b/Pythonlogy/build/lib/ShareYourSystem/Standards/Recorders/Leaker/__init__.py @@ -79,7 +79,7 @@ class LeakerClass(BaseClass): def default_init(self, _LeakingUnitsInt=0, _LeakingTimeVariable='#scalar:10.*ms', - _LeakingWeigthVariable=None, + _LeakingWeightVariable=None, _LeakingQuantityStr='mV', _LeakingSymbolPrefixStr="", _LeakingInteractionStr="Rate", @@ -113,7 +113,7 @@ def default_init(self, _LeakedEquationStr="", _LeakedClockStr="", _LeakedTimeSymbolStr="", - _LeakedInteractionWeigthFloat=0., + _LeakedInteractionWeightFloat=0., _LeakedParentSingularStr="", _LeakedParentNetworkDeriveLeakerVariable=None, _LeakedParentPopulationDeriveLeakerVariable=None, @@ -618,20 +618,20 @@ def leakPopulation(self): [ 'Check if we add a weigth', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) ''' #type - LeakedType=type(self.LeakingWeigthVariable) + LeakedType=type(self.LeakingWeightVariable) #Check if LeakedType==str: #Check - if self.LeakingWeigthVariable in ['0','0.0']: + if self.LeakingWeightVariable in ['0','0.0']: #set the right self.LeakedModelStr+='(' @@ -639,7 +639,7 @@ def leakPopulation(self): else: #set the right - self.LeakedModelStr+='(-'+self.LeakingWeigthVariable+'*'+self.LeakedSymbolStr + self.LeakedModelStr+='(-'+self.LeakingWeightVariable+'*'+self.LeakedSymbolStr elif LeakedType in [list]: @@ -648,11 +648,11 @@ def leakPopulation(self): mu : 1 '''+self.LeakedModelStr - elif self.LeakingWeigthVariable!=None: + elif self.LeakingWeightVariable!=None: #set the right self.LeakedModelStr+='(-'+str( - self.LeakingWeigthVariable + self.LeakingWeightVariable )+'*'+self.LeakedSymbolStr else: @@ -830,18 +830,18 @@ def leakPopulation(self): ).TeamedValueVariable #manage - LeakedRecordDeriveLeaker=LeakedTracesDeriveManager.manage( - '*'+self.LeakedSymbolStr - ).ManagedValueVariable + LeakedRecordDeriveLeaker=LeakedTracesDeriveManager.getManager( + Recorder.RecordPrefixStr+self.LeakedSymbolStr + ) #set LeakedRecordDeriveLeaker.NumscipyingStdFloat=0.001 - LeakedSamplesDeriveLeaker=LeakedRecordDeriveLeaker.team( + LeakedSamplesDeriveLeaker=LeakedRecordDeriveLeaker.getTeamer( 'Samples' - ).TeamedValueVariable - LeakedDefaultDeriveLeaker=LeakedSamplesDeriveLeaker.manage( + ) + LeakedDefaultDeriveLeaker=LeakedSamplesDeriveLeaker.getManager( 'Default' - ).ManagedValueVariable + ) #/##################/# # Look for what to monitor @@ -913,11 +913,13 @@ def leakPopulation(self): if self.LeakingMaxBool: #debug + ''' self.debug( [ 'We build a variable that tracks the max events' ] ) + ''' #add self.LeakedModelStr+=self.LeakedSymbolStr+'_diff : '+self.LeakedDimensionStr+'\n' @@ -936,6 +938,7 @@ def leakPopulation(self): self.LeakedModelStr+=LeakedDiffStr #debug + ''' self.debug( [ 'In the end of max model', @@ -944,6 +947,7 @@ def leakPopulation(self): ]) ] ) + ''' ''' LeakedPhaseNeuronGroup=brian2.NeuronGroup( @@ -1400,16 +1404,19 @@ def leakInput(self): ''' #type - LeakedWeigthVariable=type(self.LeakingWeigthVariable) + LeakedWeightVariable=type(self.LeakingWeightVariable) #Check - if LeakedWeigthVariable!=None.__class__: + if LeakedWeightVariable!=None.__class__: + + #init + self.LeakedClampStr="Variable" #Check - if LeakedWeigthVariable==str: + if LeakedWeightVariable==str: #Check - if self.LeakingWeigthVariable.startswith( + if self.LeakingWeightVariable.startswith( LeakScalarPrefixStr ): @@ -1418,7 +1425,7 @@ def leakInput(self): #set self.LeakedSymbolStr=SYS.deprefix( - self.LeakingWeigthVariable, + self.LeakingWeightVariable, LeakScalarPrefixStr ) @@ -1438,7 +1445,7 @@ def leakInput(self): self.LeakedSymbolStr ) - elif self.LeakingWeigthVariable.startswith( + elif self.LeakingWeightVariable.startswith( LeakEquationPrefixStr ): @@ -1447,14 +1454,14 @@ def leakInput(self): #set self.LeakedOperationStr=SYS.deprefix( - self.LeakingWeigthVariable, + self.LeakingWeightVariable, LeakEquationPrefixStr ) #setOperation self.setOperation() - elif self.LeakingWeigthVariable.startswith( + elif self.LeakingWeightVariable.startswith( LeakCustomPrefixStr ): @@ -1463,7 +1470,7 @@ def leakInput(self): #set self.LeakedOperationStr=SYS.deprefix( - self.LeakingWeigthVariable, + self.LeakingWeightVariable, LeakCustomPrefixStr ) @@ -1498,106 +1505,118 @@ def leakInput(self): """ #Check - elif LeakedWeigthVariable in [list,tuple]: + elif LeakedWeightVariable in [list,tuple]: #Check - if self.LeakingWeigthVariable[0].startswith(LeakNetworkPrefixStr[:-1]): + if type(self.LeakingWeightVariable[0])==str: - #debug - ''' - self.debug( - [ - 'It is a network operation', - ('self.',self,[ - 'LeakingWeigthVariable' - ]) - ] - ) - ''' + #Check + if self.LeakingWeightVariable[0].startswith(LeakNetworkPrefixStr[:-1]): - #set - self.LeakedClampStr='Network' + #debug + ''' + self.debug( + [ + 'It is a network operation', + ('self.',self,[ + 'LeakingWeightVariable' + ]) + ] + ) + ''' - #set - self.LeakedOperationStr=SYS.deprefix( - self.LeakingWeigthVariable[0], - LeakNetworkPrefixStr - ) + #set + self.LeakedClampStr='Network' - #setOperation - self.setOperation() + #set + self.LeakedOperationStr=SYS.deprefix( + self.LeakingWeightVariable[0], + LeakNetworkPrefixStr + ) - elif self.LeakingWeigthVariable[0].startswith(LeakCustomPrefixStr[:-1]): + #setOperation + self.setOperation() - #debug - ''' - self.debug( - [ - 'It is a map of different input variables', - ('self.',self,[ - 'LeakingWeigthVariable' - ]) - ] - ) - ''' + elif self.LeakingWeightVariable[0].startswith( + LeakCustomPrefixStr[:-1] + ): - #set - self.LeakedClampStr='Custom' + #debug + ''' + self.debug( + [ + 'It is a map of different input variables', + ('self.',self,[ + 'LeakingWeightVariable' + ]) + ] + ) + ''' - #set - self.LeakedOperationStr=SYS.deprefix( - self.LeakingWeigthVariable[0], - LeakCustomPrefixStr[:-1] - ) + #set + self.LeakedClampStr='Custom' - #debug - ''' - self.debug( - [ - ('self.',self,[ - 'LeakedOperationStr' - ]) - ] - ) - ''' + #set + self.LeakedOperationStr=SYS.deprefix( + self.LeakingWeightVariable[0], + LeakCustomPrefixStr[:-1] + ) - #Check - if self.LeakedOperationStr[0]==':': - self.LeakedOperationStr=self.LeakedOperationStr[1:]+':' + #debug + ''' + self.debug( + [ + ('self.',self,[ + 'LeakedOperationStr' + ]) + ] + ) + ''' - #join - self.LeakedOperationStr+="+".join( - map( - lambda __IndexInt,__CustomOperationStr: - __CustomOperationStr+'*(i=='+str( - __IndexInt - )+')', - xrange(len(self.LeakingWeigthVariable[1])), - self.LeakingWeigthVariable[1] + #Check + if self.LeakedOperationStr!="" and self.LeakedOperationStr[0]==':': + self.LeakedOperationStr=self.LeakedOperationStr[1:]+':' + + #join + self.LeakedOperationStr+="+".join( + map( + lambda __IndexInt,__CustomOperationStr: + __CustomOperationStr+'*(i=='+str( + __IndexInt + )+')', + xrange(len(self.LeakingWeightVariable[1])), + self.LeakingWeightVariable[1] + ) ) - ) - #setOperation - self.setOperation() + #setOperation + self.setOperation() - else: + #debug + self.debug( + [ + 'Is it a variable', + ('self.',self,[ + 'LeakedClampStr' + ]) + ] + ) - #set - self.LeakedClampStr="Variable" + #Check + if self.LeakedClampStr=="Variable": #debug - ''' self.debug( [ 'It is a variable', ('self.',self,[ - 'LeakedSymbolStr' + 'LeakedSymbolStr', + 'LeakingRecordBool' ]), 'We append in the parent pop record skip', 'We define and add in the LeakedCurrentStr' ] ) - ''' #Check if self.LeakingRecordBool==False: @@ -1654,6 +1673,58 @@ def leakInput(self): ) ''' + #debug + ''' + self.debug( + [ + 'Should we have to take care of a record later', + ('self.',self,[ + 'LeakedClampStr' + ]) + ] + ) + ''' + + #Check + if self.LeakedClampStr not in ["Scalar","Variable"]: + + #/###############/# + # Make sure that trace of input is before trace trace of activity + # Look for a RecordingVariable + # + + #get + LeakedTraceDeriveLeaker=self.LeakedParentPopulationDeriveLeakerVariable.getTeamer( + "Traces" + ).manage( + Recorder.RecordPrefixStr+self.LeakedSymbolStr, + _IndexInt=0 + ).ManagedValueVariable + + #Check + if self.RecordingLabelVariable!=None: + + #debug + ''' + self.debug( + [ + 'In the input we set the recording label variable to the corresponding trace sample', + ('self.',self,['RecordingLabelVariable']) + ] + ) + ''' + + #set + LeakedTraceDeriveLeaker.getTeamer( + "Samples" + ).getManager( + "Default" + ).setAttr( + "RecordingLabelVariable", + self.RecordingLabelVariable + ) + + def leakInteraction(self): #/################/# @@ -1666,7 +1737,7 @@ def leakInteraction(self): [ 'It is an Interaction level', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) @@ -1766,19 +1837,19 @@ def leakInteraction(self): ''' self.debug( [ - 'What is LeakingWeigthVariable', + 'What is LeakingWeightVariable', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) ''' #Check - if type(self.LeakingWeigthVariable)==None.__class__: + if type(self.LeakingWeightVariable)==None.__class__: #set - self.LeakingWeigthVariable='#scalar:0.' + self.LeakingWeightVariable='#scalar:0.' #debug ''' @@ -1786,7 +1857,7 @@ def leakInteraction(self): [ 'We set a default J equal to scalar 0', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) @@ -1798,7 +1869,7 @@ def leakInteraction(self): [ 'We check the clamp of the interaction', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) @@ -1823,10 +1894,10 @@ def leakInteraction(self): self.LeakedClampStr="Variable" #Check - if type(self.LeakingWeigthVariable)==str: + if type(self.LeakingWeightVariable)==str: #Check - if self.LeakingWeigthVariable.startswith( + if self.LeakingWeightVariable.startswith( LeakScalarPrefixStr ): @@ -2053,16 +2124,16 @@ def leakInteraction(self): self.LeakedModelStr+=self.LeakedSymbolStr+"_post" #deprefix - LeakedInteractionWeigthStr=SYS.deprefix( - self.LeakingWeigthVariable, + LeakedInteractionWeightStr=SYS.deprefix( + self.LeakingWeightVariable, LeakScalarPrefixStr ) #set - self.LeakedInteractionWeigthFloat=float(LeakedInteractionWeigthStr) + self.LeakedInteractionWeightFloat=float(LeakedInteractionWeightStr) #add - self.LeakedModelStr+="="+LeakedInteractionWeigthStr+'*'+self.LeakedVariableStr+"_pre" + self.LeakedModelStr+="="+LeakedInteractionWeightStr+'*'+self.LeakedVariableStr+"_pre" elif self.LeakedClampStr=="Variable": @@ -2692,7 +2763,7 @@ def brianPopulation(self): self.TeamDict[ 'Traces' ].ManagementDict[ - '*Threshold' + Recorder.RecordPrefixStr+'Threshold' ].BrianingRecordInitBool=False #Check @@ -2903,8 +2974,8 @@ def brianPopulation(self): self.debug( [ 'We resort the inputs traces', - 'self.TeamDict["Inputs"].ManagementDict.keys() is ', - str(self.TeamDict["Inputs"].ManagementDict.keys()), + #'self.TeamDict["Inputs"].ManagementDict.keys() is ', + #str(self.TeamDict["Inputs"].ManagementDict.keys()), 'BrianedTracesManager.ManagementDict.keys() is ', str(BrianedTracesManager.ManagementDict.keys()) @@ -2923,21 +2994,15 @@ def brianPopulation(self): ) ) - #map - map( - lambda __IndexIntAndRecordKeyStr: - setattr( - BrianedTracesManager.ManagementDict[ - __IndexIntAndRecordKeyStr[1] - ], - 'GetSortInt', - __IndexIntAndRecordKeyStr[0] - ) if __IndexIntAndRecordKeyStr[1] in BrianedTracesManager.ManagementDict - else None, - enumerate( - self.LeakedInputKeyStrsList - ) + #debug + ''' + self.debug( + [ + + ('self.',self,['LeakedInputKeyStrsList']) + ] ) + ''' def brianInput(self): @@ -2951,7 +3016,7 @@ def brianInput(self): ''' #Check - if self.LeakingWeigthVariable!=None: + if self.LeakingWeightVariable!=None: #Check if self.LeakedClampStr=="Variable": @@ -2971,11 +3036,23 @@ def brianInput(self): ) ''' + #import + import numpy as np + #set setattr( self.LeakedParentPopulationDeriveLeakerVariable.BrianedNeurongroupVariable, self.LeakedSymbolStr, - self.LeakingWeigthVariable*Variable.unit + #self.LeakingWeightVariable*Variable.unit + self.LeakingWeightVariable*self.LeakedParentPopulationDeriveLeakerVariable.LeakedQuantityVariable + if type(self.LeakingWeightVariable) in [ + np.float64,float + ] else ( + self.LeakingWeightVariable*self.LeakedParentPopulationDeriveLeakerVariable.LeakedQuantityVariable + if type(self.LeakingWeightVariable[0]) in [ + np.float64,float + ] else self.LeakingWeightVariable + ) ) elif self.LeakedClampStr=='Equation': @@ -2999,7 +3076,7 @@ def brianInput(self): #init self.LeakedTimedArrayVariable=TimedArray( - self.LeakingWeigthVariable, + self.LeakingWeightVariable, dt=self.LeakedParentPopulationDeriveLeakerVariable.BrianedNeurongroupVariable.clock.dt ) @@ -3148,7 +3225,7 @@ def brianInput(self): def updateInput(): #get set - BrianedInputQuantity[:]=self.LeakingWeigthVariable[1]( + BrianedInputQuantity[:]=self.LeakingWeightVariable[1]( BrianedInputQuantity, BrianedNeurongroupVariable.clock.t ) @@ -3179,7 +3256,7 @@ def updateInput(): def updateInput(): #get set - BrianedInputQuantity[:]=self.LeakingWeigthVariable[1]( + BrianedInputQuantity[:]=self.LeakingWeightVariable[1]( BrianedInputQuantity, BrianedNeurongroupVariable.clock.t ) @@ -3202,7 +3279,7 @@ def brianInteraction(self): 'We brianInteraction leak here', 'We call first the base method', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) @@ -3222,7 +3299,7 @@ def brianInteraction(self): #get BrianedRowsInt=self.BrianedSynapsesVariable.source.N BrianedColsInt=self.BrianedSynapsesVariable.target.N - BrianedWeigthFloatsArray=None + BrianedWeightFloatsArray=None #/##################/# # Maybe we specify the connection @@ -3248,13 +3325,13 @@ def brianInteraction(self): self.debug( [ 'Look for a non nul connection', - ('self.',self,['LeakedInteractionWeigthFloat']) + ('self.',self,['LeakedInteractionWeightFloat']) ] ) ''' #Check - if self.LeakedInteractionWeigthFloat!=0.: + if self.LeakedInteractionWeightFloat!=0.: #debug ''' @@ -3274,7 +3351,7 @@ def brianInteraction(self): elif self.LeakedClampStr=="Variable": #type - BrianedInteractionType=type(self.LeakingWeigthVariable) + BrianedInteractionType=type(self.LeakingWeightVariable) #debug ''' @@ -3282,7 +3359,7 @@ def brianInteraction(self): [ 'We have to set the connect variable', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]), 'BrianedInteractionType is ', str(BrianedInteractionType) @@ -3303,14 +3380,14 @@ def brianInteraction(self): 'It is just one value', 'We set in the synapses if it is not null', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) ''' #Check - if self.LeakingWeigthVariable!=0.: + if self.LeakingWeightVariable!=0.: #debug ''' @@ -3318,7 +3395,7 @@ def brianInteraction(self): [ 'We are going to connect this Variable for each index', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]) ] ) @@ -3333,7 +3410,7 @@ def brianInteraction(self): getattr( self.BrianedSynapsesVariable, self.LeakingSymbolPrefixStr - )[:]=self.LeakingWeigthVariable + )[:]=self.LeakingWeightVariable #debug @@ -3371,13 +3448,13 @@ def brianInteraction(self): self.numscipy() #alias - BrianedWeigthFloatsArray=self.NumscipiedValueFloatsArray + BrianedWeightFloatsArray=self.NumscipiedValueFloatsArray else: #shape - BrianedWeigthFloatsArray=getShapeArray( - self.LeakingWeigthVariable, + BrianedWeightFloatsArray=getShapeArray( + self.LeakingWeightVariable, BrianedRowsInt, BrianedColsInt ) @@ -3389,7 +3466,7 @@ def brianInteraction(self): #reshape BrianedFloatsArray=np.reshape( np.array( - BrianedWeigthFloatsArray + BrianedWeightFloatsArray ).T, BrianedRowsInt*BrianedColsInt ) @@ -3400,7 +3477,7 @@ def brianInteraction(self): [ 'It is an already defined array', ('self.',self,[ - 'LeakingWeigthVariable' + 'LeakingWeightVariable' ]), 'self.BrianedSynapsesVariable.source.N is '+str(self.BrianedSynapsesVariable.source.N), 'self.BrianedSynapsesVariable.target.N is '+str(self.BrianedSynapsesVariable.target.N), @@ -3565,8 +3642,6 @@ def brianInteraction(self): __IndexInt )+"="+LeakedSymbolStr+"_delayer_"+str( __IndexInt-1 - - ), xrange(self.LeakedDelayTotalIntVariable[0]-1,0,-1) )+[ @@ -4000,7 +4075,7 @@ def setDelay(): if self.LeakingEigenBool: #set - self.NumscipyingValueVariable=BrianedWeigthFloatsArray + self.NumscipyingValueVariable=BrianedWeightFloatsArray self.NumscipyingEigenvalueBool=True #debug @@ -4317,10 +4392,13 @@ def brianTrace(self): ) ''' - #Check - if self.ManagementTagStr.split( + #set + LeakedWordStr=self.ManagementTagStr.split( Recorder.RecordPrefixStr - )[1] in self.LeakedParentPopulationDeriveLeakerVariable.LeakedRecordSkipStrsList or ( + )[1] if len(Recorder.RecordPrefixStr)>0 else self.ManagementTagStr + + #Check + if LeakedWordStr in self.LeakedParentPopulationDeriveLeakerVariable.LeakedRecordSkipStrsList or ( self.LeakedParentPopulationDeriveLeakerVariable.LeakingTimeVariable in ['0',0.] ): @@ -4348,7 +4426,7 @@ def brianTrace(self): #Check if BrianedParentInteractionDeriveBrianerVariable.LeakingPlasticVariable!=None and type( - BrianedParentInteractionDeriveBrianerVariable.LeakingWeigthVariable + BrianedParentInteractionDeriveBrianerVariable.LeakingWeightVariable )!=None.__class__: #debug @@ -4956,6 +5034,151 @@ def simulatePopulation(self): self.NumscipyingGlobalBool=self.LeakingTotalBool self.numscipy() + #Check + if self.LeakingMaxBool: + + #debug + ''' + self.debug( + [ + 'We plot the max', + ('self.',self,[ + 'LeakedMaxSpikeMonitorVariable', + 'LeakedMaxStateMonitorVariable' + ]), + 'self.LeakedMaxSpikeMonitorVariable.t is '+str( + self.LeakedMaxSpikeMonitorVariable.t + ) + ] + ) + ''' + + #Check + if self.LeakingMinPhaseTimeVariable==None: + self.LeakingMinPhaseTimeVariable=1.*self.BrianedParentNetworkDeriveBrianerVariable.SimulatingStopTimeFloat*self.BrianedParentNetworkDeriveBrianerVariable.BrianedTimeQuantityVariable/2. + + #Check + #if self.LeakingMaxPhasesInt==None: + # #self.LeakingMaxPhasesInt=len(self.LeakedMaxSpikeMonitorVariable.t) + # self.LeakingMaxPhasesInt=2 + + #debug + self.debug( + [ + ('self.',self,[ + 'LeakingMinPhaseTimeVariable', + 'LeakingMaxPhasesInt' + ]) + ] + ) + + #init + self.LeakedPhaseList=[None]*self.LeakingUnitsInt + + #loop + for __IndexInt,__NeuronInt in enumerate( + self.LeakedMaxSpikeMonitorVariable.i + ): + + #debug + ''' + self.debug( + [ + '[__IndexInt,__NeuronInt] is '+str( + [__IndexInt,__NeuronInt] + ) + ] + ) + ''' + + #get + LeakedTimeVariable=self.LeakedMaxSpikeMonitorVariable.t[__IndexInt] + + #Check + if LeakedTimeVariable>self.LeakingMinPhaseTimeVariable: + + #init + if self.LeakedPhaseList[__NeuronInt]==None: + + #init + self.LeakedPhaseList[__NeuronInt]=[] + + #init + LeakedAppendList=[ + __IndexInt, + float(LeakedTimeVariable), + None + ] + + #len + LeakedLenghtInt=len(self.LeakedPhaseList[__NeuronInt]) + + #Check + if LeakedLenghtInt>0 and LeakedLenghtInt0 else SYS._filter( + lambda __KeyStr: + __KeyStr not in self.LeakedRecordSkipStrsList, + self.LeakedInputKeyStrsList + ) + + #map + map( + lambda __LeakedInputKeyStr: + LeakedRunPopulationChartsDerivePyploter.getManager( + __LeakedInputKeyStr + ), + LeakedInputKeyStrsList + ) + #/##################/# # base method # @@ -5005,19 +5278,17 @@ def viewPopulation(self): ''' #init - ViewedNetworkDrawsDerivePyploter=None + ViewedRunNetworkDrawsDerivePyploter=None #get - ViewedPopulationDrawsDerivePyploter=self.getTeamer( - 'Charts' - ).getManager( + ViewedPopulationRunDrawsDerivePyploter=LeakedRunPopulationChartsDerivePyploter.getManager( Recorder.RecordPrefixStr+self.LeakedSymbolStr ).getTeamer( 'Draws' ) #Check - if len(ViewedPopulationDrawsDerivePyploter.ManagementDict)>0: + if len(ViewedPopulationRunDrawsDerivePyploter.ManagementDict)>0: #Check if self.LeakingGlobalBool or self.LeakingTotalBool: @@ -5085,7 +5356,7 @@ def viewPopulation(self): ''' #add - ViewedPopulationDrawsDerivePyploter.getManager( + ViewedPopulationRunDrawsDerivePyploter.getManager( 'Global' ).PyplotingDrawVariable=[ ( @@ -5164,7 +5435,7 @@ def viewPopulation(self): # #alias - ViewedNetworkDrawsDerivePyploter=self.BrianedParentNetworkDeriveBrianerVariable.getTeamer( + ViewedRunNetworkDrawsDerivePyploter=self.BrianedParentNetworkDeriveBrianerVariable.getTeamer( 'Panels' ).getManager( 'Run' @@ -5177,9 +5448,9 @@ def viewPopulation(self): ) #get - ViewedNetworkDrawsDerivePyploter.getManager( + ViewedRunNetworkDrawsDerivePyploter.getManager( 'Global' - ).PyplotingDrawVariable=ViewedPopulationDrawsDerivePyploter.ManagementDict[ + ).PyplotingDrawVariable=ViewedRunPopulationDrawsDerivePyploter.ManagementDict[ 'Global' ].PyplotingDrawVariable @@ -5228,142 +5499,64 @@ def viewPopulation(self): #Check if self.LeakingMaxBool: - #debug - ''' - self.debug( - [ - 'We plot the max', - ('self.',self,[ - 'LeakedMaxSpikeMonitorVariable', - 'LeakedMaxStateMonitorVariable' - ]), - 'self.LeakedMaxSpikeMonitorVariable.t is '+str( - self.LeakedMaxSpikeMonitorVariable.t - ) - ] - ) - ''' - - #Check - if self.LeakingMinPhaseTimeVariable==None: - self.LeakingMinPhaseTimeVariable=1.*self.BrianedParentNetworkDeriveBrianerVariable.SimulatingStopTimeFloat*self.BrianedParentNetworkDeriveBrianerVariable.BrianedTimeQuantityVariable/2. - - #Check - #if self.LeakingMaxPhasesInt==None: - # #self.LeakingMaxPhasesInt=len(self.LeakedMaxSpikeMonitorVariable.t) - # self.LeakingMaxPhasesInt=2 - - #debug - self.debug( - [ - ('self.',self,[ - 'LeakingMinPhaseTimeVariable', - 'LeakingMaxPhasesInt' - ]) - ] - ) - - #init - self.LeakedPhaseList=[None]*self.LeakingUnitsInt - - #loop - for __IndexInt,__NeuronInt in enumerate( - self.LeakedMaxSpikeMonitorVariable.i - ): - - #debug - ''' - self.debug( - [ - '[__IndexInt,__NeuronInt] is '+str( - [__IndexInt,__NeuronInt] - ) - ] - ) - ''' - - #get - LeakedTimeVariable=self.LeakedMaxSpikeMonitorVariable.t[__IndexInt] - - #Check - if LeakedTimeVariable>self.LeakingMinPhaseTimeVariable: - - #init - if self.LeakedPhaseList[__NeuronInt]==None: - - #init - self.LeakedPhaseList[__NeuronInt]=[] - - #init - LeakedAppendList=[ - __IndexInt, - float(LeakedTimeVariable), - None - ] - - #len - LeakedLenghtInt=len(self.LeakedPhaseList[__NeuronInt]) - - #Check - if LeakedLenghtInt>0 and LeakedLenghtInt$' + 'label':'$mean('+self.LeakedSymbolStr+')$' + } ) - ) + } + ) + ] - #debug - ''' - self.debug( - [ - 'LeakedAppendList is '+str(LeakedAppendList) - ] - ) - ''' - #Check - if LeakedLenghtInt # -RecordPrefixStr='*' +RecordPrefixStr="" # # @@ -197,15 +197,15 @@ def recordTrace(self): # #debug - ''' self.debug( [ 'This is the Traces level', 'First get the array to trace', - ('self.',self,['RecordingKeyVariable']) + ('self.',self,[ + 'RecordingKeyVariable' + ]) ] ) - ''' #get RecordedTopDeriveRecorderVariable=self.ParentDeriveTeamerVariable.ParentDeriveTeamerVariable @@ -218,17 +218,18 @@ def recordTrace(self): if type(self.RecordingKeyVariable)==None.__class__: #Check - if self.ManagementTagStr.startswith(RecordPrefixStr): + if RecordPrefixStr!="" and self.ManagementTagStr.startswith(RecordPrefixStr): #debug ''' self.debug( [ - ('self.',self,['ManagementTagStr']) + ('self.',self,['ManagementTagStr']), + 'RecordedTopDeriveRecorderVariable is '+str(RecordedTopDeriveRecorderVariable) ] ) ''' - + #get self.RecordedTraceFloatsArray=getattr( RecordedTopDeriveRecorderVariable, diff --git a/Pythonlogy/build/lib/ShareYourSystem/__init__.py b/Pythonlogy/build/lib/ShareYourSystem/__init__.py index a5cab523..cd8955ee 100644 --- a/Pythonlogy/build/lib/ShareYourSystem/__init__.py +++ b/Pythonlogy/build/lib/ShareYourSystem/__init__.py @@ -690,11 +690,20 @@ def _filter(_Function,_List): return list(filter(_Function,_List)) def filterNone(_List): + + #Debug + """ + print("List is") + print(_List) + print("") + """ + + #return return _filter( - lambda __ListedVariable: - __ListedVariable!=None, - _List - ) + lambda __ListedVariable: + type(__ListedVariable)!=None.__class__, + _List + ) def flip(_Dict): return type(_Dict)( @@ -949,12 +958,148 @@ def arrayify(_VariablesList,_ShapeIntsList=None): ValueVariablesList ) - - - #return return VariablesArray - + +def split(_StartVariable=0,_StopInt=1,_SplitInt=2): + + #import + import numpy as np + + #Check + if type(_StartVariable)==int: + + #set + CutIntsList=np.linspace(_StartVariable,_StopInt,_SplitInt+1,dtype=int) + + #Debug + """ + print("SYS l 967 split") + print("CutIntsList is ") + print(CutIntsList) + print("") + """ + + #map + return map( + lambda __IndexIntAndCutInt: + [CutIntsList[__IndexIntAndCutInt[0]],__IndexIntAndCutInt[1]], + enumerate( + CutIntsList[1:] + ) + ) + + else: + + #map + SplitIntsListsList=map( + lambda __ShapeInt: + split(0,__ShapeInt,_SplitInt), + np.shape(_StartVariable) + ) + + #Debug + print("SYS l 991 split") + print("SplitIntsListsList is ") + print(SplitIntsListsList) + print("") + + #import + import itertools + + #product + return map( + lambda __GetIntsListsTuple: + _StartVariable.__getitem__( + map( + lambda __GetIntsList: + slice(__GetIntsList[0],__GetIntsList[1]), + __GetIntsListsTuple + ) + ), + list(itertools.product(*SplitIntsListsList)) + ) + +def getArray(_Array,_IndexIntsTuple,_LoopBool=True): + + #Debug + """ + print("_IndexIntsTuple is ") + print(_IndexIntsTuple) + print("-1 in _IndexIntsTuple is "+str(-1 in _IndexIntsTuple)) + print("") + """ + + #Check + if _LoopBool==False: + + #Check + if -1 in _IndexIntsTuple: + + #return + return None + + #try + try: + + #return + return _Array.__getitem__(_IndexIntsTuple) + except: + + #return + return None + +def contour(_GridBoolsArray,_ContourIntsList=None): + + #import + import numpy as np + + #get + LocalArray=getLocalArray(len(np.shape(_GridBoolsArray))) + + #Debug + """ + print('LocalArray is ') + print(LocalArray) + print('') + """ + + #map + return np.array( + map( + lambda __Tuple: + __Tuple[0], + _filter( + lambda __Tuple: + __Tuple[1], + map( + lambda __IndexIntsTupleAndValueVariableTuple: + ( + __IndexIntsTupleAndValueVariableTuple[0], + any( + map( + lambda __Value: + __Value!=__IndexIntsTupleAndValueVariableTuple[1], + filterNone( + map( + lambda __IndexIntsArray: + getArray(_GridBoolsArray,tuple(__IndexIntsArray),_LoopBool=False), + map( + lambda __LocalArray: + np.array(__IndexIntsTupleAndValueVariableTuple[0])+__LocalArray, + LocalArray + ) + ) + ) + ) + ) + ), + np.ndenumerate(_GridBoolsArray) + ) + ) + ) + ) + def where(_DictsList,_TuplesList,**_KwargsDict): if 'IsInCheckingBool' in _KwargsDict and _KwargsDict['IsInCheckingBool']: @@ -995,6 +1140,180 @@ def where(_DictsList,_TuplesList,**_KwargsDict): _DictsList ) +def find(_Array, _PredicateFunction, _ChunkSizeInt=1024): + """ + Find the indices of array elements that match the predicate. + + Parameters + ---------- + _Array : array_like + Input data, must be 1D. + + _PredicateFunction : function + A function which operates on sections of the given array, returning + element-wise True or False for each data value. + + _ChunkSizeInt : integer + The length of the chunks to use when searching for matching indices. + For high probability predicates, a smaller number will make this + function quicker, similarly choose a larger number for low + probabilities. + + Returns + ------- + index_generator : generator + A generator of (indices, data value) tuples which make the predicate + True. + + See Also + -------- + where, nonzero + + Notes + ----- + This function is best used for finding the first, or first few, data values + which match the predicate. + + Examples + -------- + >>> _Array = np.sin(np.linspace(0, np.pi, 200)) + >>> result = find(_Array, lambda arr: arr > 0.9) + >>> next(result) + ((71, ), 0.900479032457) + >>> np.where(_Array > 0.9)[0][0] + 71 + + """ + + #Check + if _Array.ndim != 1: + Array=_Array.flatten() + #raise ValueError('The array must be 1D, not {}.'.format(_Array.ndim)) + else: + Array=_Array + + #import + from itertools import chain, izip + + #init + InitInt = 0 + ChunkIndexIntsIterator = chain( + xrange( + _ChunkSizeInt, + Array.size, + _ChunkSizeInt + ), + [None] + ) + + #for + for _IndexInt in ChunkIndexIntsIterator: + ChunkArray = Array[InitInt:_IndexInt] + for __IndexList in izip(*_PredicateFunction(ChunkArray).nonzero()): + yield (__IndexList[0] + InitInt, ), ChunkArray[__IndexList] + InitInt = _IndexInt + + +def getIsConstantBool(_BoolsArray): + + #import + import numpy as np + + #get + ConstantBool=_BoolsArray.__getitem__(tuple([0]*len(np.shape(_BoolsArray)))) + OppositeBool=not ConstantBool + + #Debug + ''' + print("ConstantBool is ") + print(ConstantBool) + print("") + ''' + + #return + try: + + #next + next( + find( + _BoolsArray, + lambda __Bool:__Bool==OppositeBool + ) + ) + + #return True + return False + + except StopIteration: + + #return + return True + +def getFlattenedListWithVariablesList(_VariablesList): + return functools.reduce( + lambda x,y: + x+list(y) if type(y)==tuple + else list(x)+[y] if type(x) in [list,tuple] + else [x,y],_VariablesList + ) + +def getPermutedIntsListWithCategoriesIntAndLengthInt(_CategoriesInt,_LengthInt): + + #import + import itertools + + #return + return functools.reduce( + lambda x,y: + map( + lambda __IntOrTuple: + getFlattenedListWithVariablesList(list(__IntOrTuple)) + if type(__IntOrTuple)==tuple + else __IntOrTuple, + itertools.product(x,y) + ), + map(lambda Int:xrange(_LengthInt),xrange(_CategoriesInt)) + ) + +def getLocalArray(_DimensionInt,_DiagonalBool=False): + + #import + import numpy as np + + #Check + if _DiagonalBool: + + #array + PositiveArray=np.array( + getPermutedIntsListWithCategoriesIntAndLengthInt( + _DimensionInt, + 2 + ) + ) + + #return + return PositiveArray + + else: + + #diag + DiagonalArray=np.diag([1]*_DimensionInt) + + #init + LocalArray=np.zeros((2*_DimensionInt,_DimensionInt),dtype=int) + + #fill + LocalArray[:_DimensionInt,:]=DiagonalArray + LocalArray[_DimensionInt:,:]=-1.*DiagonalArray + + #return + return LocalArray + + + + + + def translate(_TextStr,_TranslationVariable): #Debug @@ -1396,10 +1715,10 @@ def chunk(_LimitStrsList,_TextStr,**_KwargVariablesDict): _LimitStrsList[0],_LimitStrsList[1],ChunksInt,_TextStr,**_KwargVariablesDict) def deprefix(_WordStr,_PrefixStr): - return _PrefixStr.join(_WordStr.split(_PrefixStr)[1:]) + return _PrefixStr.join(_WordStr.split(_PrefixStr)[1:]) if _PrefixStr!="" else _WordStr def desuffix(_WordStr,_SuffixStr): - return _SuffixStr.join(_WordStr.split(_SuffixStr)[:-1]) + return _SuffixStr.join(_WordStr.split(_SuffixStr)[:-1]) if _SuffixStr!="" else _WordStr def groupby(_FunctionPointer,_List): return getSplitListsListWithSplittedListAndFunctionPointer(_List,_FunctionPointer) @@ -2803,6 +3122,48 @@ def insert(self, xrange(len(ValueVariablesList)) ) + #return + return self + + def move(self,_OldIndexVariable,_NewIndexInt): + + #get + if type(_OldIndexVariable)==int: + TempKeyVariable,TempValueVariable=self.getItem(_OldIndexVariable) + else: + TempKeyVariable=_OldIndexVariable + TempValueVariable=self[TempKeyVariable] + + #Debug + ''' + print('move SYS l 2812') + print('TempKeyVariable,TempValueVariable') + print(TempKeyVariable,TempValueVariable) + print('_NewIndexInt is') + print(_NewIndexInt) + print('') + ''' + + #del + del self[TempKeyVariable] + + #insert + self.insert( + _NewIndexInt, + TempValueVariable, + _KeyVariable=TempKeyVariable + ) + + #Debug + ''' + print('self is') + print(self) + print('') + ''' + + #return + return self + class MethodDict(collections.OrderedDict): diff --git a/Sublimes/MyServer.sublime-build b/Sublimes/MyServer.sublime-build new file mode 100755 index 00000000..b37134e0 --- /dev/null +++ b/Sublimes/MyServer.sublime-build @@ -0,0 +1,4 @@ +{ + "cmd": ["/usr/local/bin/node","/Users/ledoux/Documents/ShareYourSystem/Coffeelogy/server.js"], + "selector": "source.js" +}