Ver Detective Chinatown 3 online pelicula completa Detective Chinatown 3 pelicula completa en español latino ver Detective Chinatown 3 2021 pelicula completa en chilena| Película “Detective Chinatown 3 ” completa del 2021 en español latino Detective Chinatown 3 “. Detective Chinatown 3 .película Detective Chinatown 3 completa del 2021 en español latinocastellano y subtitulada. descargar gratis Estrenos | Pelispedia | Pelisplus | Gnula | Repelisplus | Repelis | Pelis | Pelisplus| | Netflix | Cine | Cinema | Calidad | Mejor | Chile | filtrada ◉

Ver Detective Chinatown 3 online pelicula completa , Detective Chinatown 3 pelicula completa en español latino…

1000 Animated Avatars_Pack PHPfox Module Download

1000 Animated Avatars_Pack PHPfox Module Download. phpFox is a software or a platform you can use…

Roadmap to becoming a web developer in 2021 kamranahmedse Full Script Code

Roadmap to becoming a web developer in 2021 kamranahmedse – Full Script Code Free Download PHP…

Perfex v2.8.2 – Powerful Open Source CRM PHP Script 2021

Perfex v2.8.2 – Powerful Open Source CRM Demo: https://codecanyon.net/item/perfex-powerful-open-source-crm/14013737 Zippyshare.comDownload Ul.toDownload Ulozto.netDownload Sendspace.comDownload Novafile.comDownload Nippyshare.comDownload Mirrored.toDownload…

Roadmap to becoming an ASP.NET Core developer in 2021 MoienTajik Full Script Code

Roadmap to becoming an ASP.NET Core developer in 2021 MoienTajik – Full Script Code Free Download…

Roadmap to becoming a data engineer in 2021 datastacktv Full Script Code

Roadmap to becoming a data engineer in 2021 datastacktv – Full Script Code Free Download PHP…

Simple Banner Rotatorlisting 2021 Components | PHP Script

This is a simple xml banner rotator made in Flash CS3 and Action Script 2.0 You…

All resources and notes from the Complete Web Developer in 2021 Zero to Mastery course zerotomastery Full Script Code

All resources and notes from the Complete Web Developer in 2021: Zero to Mastery course zero-to-mastery…

Course materials for DSGA 3001 Tools and Techniques for Machine Learning Spring 2021 davidrosenberg Full Script Code

Course materials for DSGA 3001: Tools and Techniques for Machine Learning (Spring 2021) davidrosenberg – Full…

Quiz Maker App Generator for BlackBerry 10 Developers. Generated over 1000+ Apps to BlackBerry World nemoryoliver Full Script Code

Quiz Maker App Generator for BlackBerry 10 Developers. Generated over 1000+ Apps to BlackBerry World nemoryoliver…

Code for paper “FuSeConv Fully Separable Convolutions for Fast Inference on Systolic Arrays” published at DATE 2021 iitmsysdl Full Script Code

Code for paper “FuSeConv Fully Separable Convolutions for Fast Inference on Systolic Arrays” published at DATE…

Buy and Sell flash files Over 1000 components Components | PHP Script

At mmfiles.com you can buy and sell flash components like navigation systems, photo galleries, flash site…

TravelAffiliateGuru Automated Hotel Flight Cruises Search Engine Script Earn 1000+ /m Affiliate Programs | PHP Script

About Travel Affiliate Guru It’s include 2,360,426 hotels worldwide, Search in 30 different languages. This website…

C Extension Methods | Over 1000 extension methods zzzprojects Full Script Code

C# Extension Methods | Over 1000 extension methods: zzzprojects – Full Script Code Free Download PHP…

Final Project This assignment demonstrates your understanding of the concepts from the CMIS 141 class Before attempting this project be sure you have completed all of the reading assignments handson labs discussions and assignments to date. Design a Java application that will read a file containing data related to the US. Crime statistics from 19942013. The description of the file is at the end of this file. The application should provide statistical results on the data including a. Population growth in percentages from each consecutive year e.g. 19941995 calculation is 262803276260327021/260327021 1000.9512 19951996 would be 265228572262803276/2628032761000.9229 Years where the maximum and minimum Murder rates occurred Years where the maximum and minimum Robbery rates occurred b. C. The following are some design criteria and specific requirements that need to be addressed Use command line arguments to send in the name of the US Crime Data file You should also use Java classes to their full extent to include multiple methods and at least two classes You are not allowed to modify the Crimecsv Statistic data file included in this assignment Use arrays and Java classes to store the data. Hint You can and should create a USCrimeClass to store the fields. You can also have an Array of US Crime Objects. You should create separate methods for each of the required functionality. e.g. getMaxMurderYear will return the Year where the Murder rate was highest. A userfriendly and wellorganized menu should be used for users to select which data to return. A sample menu is shown in run example. You are free to enhance your design and you should add additional menu items and functionality The menu system should be displayed at the command prompt and continue to redisplay after results are returned or unti Q is selected If a user enters an invalid menu item the system should redisplay the menu with a prompt asking them to enter a valid menu selection The application should keep track of the elapsed time in seconds between once the application starts and when the user quits the program. After the program is exited the application should provide a prompt thanking the user for trying the US Crime Statistics program and providing the total time elapsed. Hint When reading the Crimes file read one line at a timeSee ReadEmail.java and then within the loop parse each line into the USCrimeClass fields and then store that USCrimeClass Object into an array. Note you can use String·split”” to split the CSV line into a the fields for setting the USCrimeClass Object Autumn808 Full Script Code

Final Project This assignment demonstrates your understanding of the concepts from the CMIS 141 class Before…

var config { name KTN Bot userid function { return toIdthis.name } group join true rooms [lobby] punishvals { 1 warn 2 mute 3 hourmute 4 roomban 5 ban } privaterooms [staff] hosting {} laddering true ladderPercentage 70 debug false } / On server start this sets up fake user connection for bot and uses a fake ip. It gets a the fake user from the users list and modifies it properties. In addition it sets up rooms that bot will join and adding the bot user to Users list and removing the fake user created which already filled its purpose of easily filling in the gaps of all the users property. / function joinServer { if process.uptime > 5 return // to avoid running this function again when reloading var worker newrequire./fakeprocess.js.FakeProcess Users.socketConnectworker.server undefined 1 76.19.156.198 for var i in Users.users { if Users.users[i].connections[0].ip 76.19.156.198 { var bot Users.users[i] bot.name config.name bot.named true bot.renamePending config.name bot.authenticated true bot.userid config.userid bot.group config.group if config.join true { for var all in Rooms.rooms { if all global { bot.roomCount[all] 1 } } Users.users[bot.userid] bot for var allRoom in Rooms.rooms { if allRoom global { Rooms.rooms[allRoom].users[Users.users[bot.userid]] Users.users[bot.userid] } } } else { for var index in config.rooms { if index global { bot.roomCount[joinRooms[index]] 1 } } Users.users[bot.userid] bot for var jIndex in config.rooms { if jIndex global { Rooms.rooms[jIndex].users[Users.users[bot.userid]] Users.users[bot.userid] } } } delete Users.users[i] } } } const ACTION_COOLDOWN 3 1000 const FLOOD_MESSAGE_NUM 5 const FLOOD_PER_MSG_MIN 500 // this is the minimum time between messages for legitimate spam. Its used to determine what “flooding” is caused by lag const FLOOD_MESSAGE_TIME 6 1000 const MIN_CAPS_LENGTH 18 const MIN_CAPS_PROPORTION 0.8 var parse { chatData {} processChatData function user room connection message { if user.userid config.userid || room.users[config.userid] return true var cmds this.processBotCommandsuser room connection message if cmds return false message message.trim.replace/ +/g ” ” // removes extra spaces so it doesnt trigger stretching this.updateSeenuser.userid c room.title var time Date.now if this.chatData[user] this.chatData[user] { zeroTol 0 lastSeen seenAt time } if this.chatData[user][room] this.chatData[user][room] { times [] points 0 lastAction 0 } this.chatData[user][room].times.pushtime var pointVal 0 var muteMessage // moderation for flooding more than x lines in y seconds var isFlooding this.chatData[user][room].times.length > FLOOD_MESSAGE_NUM time this.chatData[user][room].times[this.chatData[user][room].times.length FLOOD_MESSAGE_NUM] < FLOOD_MESSAGE_TIME time this.chatData[user][room].times[this.chatData[user][room].times.length FLOOD_MESSAGE_NUM] > FLOOD_PER_MSG_MIN FLOOD_MESSAGE_NUM if isFlooding { if pointVal < 2 { pointVal 2 muteMessage flooding } } // moderation for caps over x of the letters in a line of y characters are capital var capsMatch message.replace/[AZaz]/g .match/[AZ]/g if capsMatch toIdmessage.length > MIN_CAPS_LENGTH capsMatch.length > Math.floortoIdmessage.length MIN_CAPS_PROPORTION { if pointVal < 1 { pointVal 1 muteMessage caps } } // moderation for stretching over x consecutive characters in the message are the same var stretchMatch message.toLowerCase.match/.\1{7}/g || message.toLowerCase.match/..+\1{4}/g // matches the same character or group of characters 8 or 5 or more times in a row if stretchMatch { if pointVal < 1 { pointVal 1 muteMessage stretching } } if pointVal > 0 time this.chatData[user][room].lastAction < ACTION_COOLDOWN { var cmd mute // defaults to the next punishment in config.punishVals instead of repeating the same action so a second warnworthy // offence would result in a mute instead of a warn and the third an hourmute etc if this.chatData[user][room].points > pointVal pointVal < 4 { this.chatData[user][room].points++ cmd config.punishvals[this.chatData[user][room].points] || cmd } else { // if the action hasnt been done before is worth more points it will be the one picked cmd config.punishvals[pointVal] || cmd this.chatData[user][room].points pointVal // next action will be one level higher than this one in most cases } if config.privaterooms.indexOfroom > 0 cmd warn cmd mute // cant warn in private rooms // if the bot has and not it will default to hourmuting as its highest level of punishment instead of roombanning if this.chatData[user][room].points > 4 config.group cmd hourmute if this.chatData[user].zeroTol > 4 { // if zero tolerance users break a rule they get an instant roomban or hourmute muteMessage zero tolerance user cmd config.group ? roomban hourmute } if this.chatData[user][room].points > 2 this.chatData[user].zeroTol++ // getting muted or higher increases your zero tolerance level warns do not this.chatData[user][room].lastAction time room.add|c| + user.group + user.name + | + message CommandParser.parse/ + cmd + + user.userid + muteMessage room Users.getconfig.name Users.getconfig.name.connections[0] return false } return true } updateSeen function user type detail { user toIduser type toIdtype if type in {j 1 l 1 c 1} config.rooms.indexOftoIddetail 1 || config.privaterooms.indexOftoIddetail > 1 return var time Date.now if this.chatData[user] this.chatData[user] { zeroTol 0 lastSeen seenAt time } if detail return var msg if type in {j 1 l 1 c 1} { msg + type j ? joining type l ? leaving chatting in + + detail.trim + . } else if type n { msg + changing nick to + +~.indexOfdetail.trim.charAt0 1 ? detail.trim detail.trim.substr1 + . } if msg { this.chatData[user].lastSeen msg this.chatData[user].seenAt time } } processBotCommands function user room connection message { if room.type chat || message.charAt0 . return var cmd target spaceIndex message.indexOf botDelay Math.floorMath.random 6 1000 now Date.now if spaceIndex > 0 { cmd message.substr1 spaceIndex 1 target message.substrspaceIndex + 1 } else { cmd message.substr1 target } cmd cmd.toLowerCase if message.charAt0 . Object.keysBot.commands.join .toString.indexOfcmd > 0 message.substr1 Bot.config.debug { if now user.lastBotCmd 0.001 < 30 { connection.sendToroom Please wait + Math.floor30 now user.lastBotCmd 0.001 + seconds until the next command. return true } user.lastBotCmd now } if commands[cmd] { var context { sendReply function data { setTimeoutfunction { room.add|c| + config.group + config.name + | + data } botDelay } sendPm function data { var message |pm| + config.group + config.name + | + user.group + user.name + | + data user.sendmessage } can function permission { if user.canpermission { setTimeoutfunction { connection.sendToroom . + cmd + Access denied. } botDelay return false } return true } parse function target { CommandParser.parsetarget room Users.getBot.config.name Users.getBot.config.name.connections[0] } } if typeof commands[cmd] function { commands[cmd].callcontext target room user connection cmd message } } } getTimeAgo function time { time Date.now time time Math.roundtime / 1000 // rounds to nearest second var seconds time 60 var times [] if seconds times.pushStringseconds + seconds 1 ? second seconds var minutes hours days if time > 60 { time time seconds / 60 // converts to minutes minutes time 60 if minutes times [Stringminutes + minutes 1 ? minute minutes].concattimes if time > 60 { time time minutes / 60 // converts to hours hours time 24 if hours times [Stringhours + hours 1 ? hour hours].concattimes if time > 24 { days time hours / 24 // you can probably guess this one if days times [Stringdays + days 1 ? day days].concattimes } } } if times.length times.push0 seconds return times.join } } var commands { guide function target room user { var commands Object.keysBot.commands commands commands.join .toString this.sendReplyList of bot commands + commands } say function target room user { if this.cansay return this.sendReplytarget } tell function target room user { if this.canbottell return var parts target.split if parts.length < 2 return this.parse/tell + toIdparts[0] + + Tools.escapeHTMLparts[1] this.sendReplyMessage sent to + parts[0] + . } penislength function target room user { this.sendReply8.5 inches from the base. Perv. } seen function target room user connection { if target return if toIdtarget || toIdtarget.length > 18 return connection.sendToroom Invalid username. if parse.chatData[toIdtarget] || parse.chatData[toIdtarget].lastSeen { return this.sendPmThe user + target.trim + has never been seen chatting in rooms. } return this.sendPmtarget.trim + was last seen + parse.getTimeAgoparse.chatData[toIdtarget].seenAt + ago + parse.chatData[toIdtarget].lastSeen } salt function target room user { if global.salt global.salt 0 salt++ this.sendReplysalt + salty. } whois function { var reply [ “Just another Pokemon Showdown user” “A very good competetive pokemon player” “A worthy opponent” “Generally a bad user” “Generally a good user” “Someone who is better than you” “An amazing person” “A beautiful person” “A person who is probably still a virgin” “A leader” “A lord helix follower” “An annoying person” “A person with a salty personality” “A Coffee Addict” “A Mediocre Player” ] return function target room user { if target return var message reply[Math.floorMath.random reply.length] target toIdtarget if target creaturephil message An experienced coder for pokemon showdown. He has coded for over 5 servers such as kill the noise moxie aerdeith nova etc. Please follow him on github https//github.com/CreaturePhil if target config.userid message That\s me. if target zarel message Pokemon Showdown Creator if target stevoduhhero message STEVO DUH GOD DAMN HERO Respect him if target rickycocaine message RICKY COCAAAAAAAINE this.sendReplymessage } } helix function { var reply [ “Signs point to yes.” “Yes.” “Reply hazy try again.” “Without a doubt.” “My sources say no.” “As I see it yes.” “You may rely on it.” “Concentrate and ask again.” “Outlook not so good.” “It is decidedly so.” “Better not tell you now.” “Very doubtful.” “Yes definitely.” “It is certain.” “Cannot predict now.” “Most likely.” “Ask again later.” “My reply is no.” “Outlook good.” “Dont count on it.” ] return function target room user { if target return var message reply[Math.floorMath.random reply.length] this.sendPmmessage } } maketournament function target room user { if this.canmaketournament return if Tournaments.tournaments[room.id] return this.sendReplyA tournament is already running in the room. var parts target.split self this counter 1 if parts.length < 2 || Tools.getFormatparts[0].effectType Format || /[09]/.testparts[1] return this.sendPmCorrect Syntax maketournament [tier] [time/amount of players] if parts[1].indexOfminute > 0 { var time Numberparts[1].splitminute[0] this.parse/tour create + parts[0] + elimination this.sendReplyYou have + time + minute + parts[1].splitminute[1] + to join the tournament. var loop function { setTimeoutfunction { if Tournaments.tournaments[room.id] return if counter time { if Tournaments.tournaments[room.id].generator.users.size < 2 { self.parse/tour end return self.sendReplyThe tournament was canceled because of lack of players. } return self.parse/tour start } if time counter 1 { self.sendReplyYou have + time counter + minute to sign up for the tournament. } else { self.sendReplyYou have + time counter + minutes to sign up for the tournament. } counter++ if Tournaments.tournaments[room.id].isTournamentStarted loop } 1000 60 } loop return } if Numberparts[1] < 2 return parts[1] parts[1].replace/[09 ]+/g this.parse/tour create + parts[0] + elimination this.sendReplyThe tournament will begin when + parts[1] + players join. var playerLoop function { setTimeoutfunction { if Tournaments.tournaments[room.id] return if Tournaments.tournaments[room.id].generator.users.size Numberparts[1] { self.parse/tour start } playerLoop } 1000 15 } playerLoop } hosttournament function target room user { if this.canhosttournament return if target.toLowerCase end { if Bot.config.hosting[room.id] return this.sendPmI\m not hosting tournaments. Bot.config.hosting[room.id] false return this.sendReplyI will now stop hosting tournaments. } if Bot.config.hosting[room.id] return this.sendReplyI\m already hosting tournaments. Bot.config.hosting[room.id] true this.sendReplyI will now be hosting tournaments. var self this _room room _user user var poll function { if Bot.config.hosting[_room.id] return setTimeoutfunction { if Poll[_room.id].question self.parse/endpoll self.parse/poll Tournament tier? + Object.keysTools.data.Formats.filterfunction f { return Tools.data.Formats[f].effectType Format }.join" " setTimeoutfunction { self.parse/endpoll Bot.commands.maketournament.callself Poll[_room.id].topOption + 2 minute _room _user } 1000 60 2 } 1000 5 } var loop function { setTimeoutfunction { if Tournaments.tournaments[_room.id] Poll[_room.id].question poll if Bot.config.hosting[_room.id] loop } 1000 60 } poll loop } join function target room user connection { if user.cankick return if target || Rooms.gettarget.toLowerCase return if Rooms.gettarget.toLowerCase.users[Bot.config.name] return this.sendPmI\m already in this room. Users.getBot.config.name.joinRoomRooms.gettarget.toLowerCase var botDelay Math.floorMath.random 6 1000 setTimeoutfunction { connection.sendToroom Bot.config.name + has join + target + room. } botDelay } leave function target room user connection { if user.cankick return if target || Rooms.gettarget.toLowerCase return Users.getBot.config.name.leaveRoomRooms.gettarget.toLowerCase var botDelay Math.floorMath.random 6 1000 setTimeoutfunction { connection.sendToroom Bot.config.name + has left + target + room. } botDelay } rps function target room user { if target return var options [rock paper scissors] rng options[Math.floorMath.random options.length] target toIdtarget if rng target return this.sendReplyI chose + rng + . The result is a tie if rng options[0] { if target options[1] return this.sendReplyI chose + rng + . + user.name + wins if target options[2] return this.sendReplyI chose + rng + . I win and + user.name + loses } if rng options[1] { if target options[2] return this.sendReplyI chose + rng + . + user.name + wins if target options[0] return this.sendReplyI chose + rng + . I win and + user.name + loses } if rng options[2] { if target options[0] return this.sendReplyI chose + rng + . + user.name + wins if target options[1] return this.sendReplyI chose + rng + . I win and + user.name + loses } } } exports.joinServer joinServer exports.config config exports.parse parse exports.commands commands // Battling AI exports.teamsnew Objectvar fsrequire"fs"fs.readFile"./config/botteams.json"functionet{ifereturnt""+texports.teamsJSON.parset}exports.addTeamfunctionet{iftt.lengthtypeof t"string"{ifBot.teams[e]Bot.teams[e]new ArrayBot.teams[e].pushtfs.writeFile"./config/botteams.json"JSON.stringifyBot.teams}}exports.randomTeamfunctione{ife.split"random".length1>0return””var tifBot.teams[e]tBot.teams[e][Math.floorMath.randomBot.teams[e].length]iftt””return t}exports.booty{addBattlefunctionet{Bot.booty.battles[“battle”+e.toLowerCase.replace/[az09]+/g””+””+Rooms.global.lastBattle+1]{booty{userUsers.getBot.config.nameexposed[{}{}{}{}{}{}]}opp{usertexposed[{}{}{}{}{}{}]}}}battlesnew Objectcheckfunction{global.bootytimeoutsetTimeoutfunction{ifBot.booty.battles{Bot.booty.checkreturn}forvar e in Bot.booty.battles{ifBot.booty.battles[e]{var tRooms.rooms[e]ift{var nt.battleifn{nn.fieldifn[toIdBot.config.name]ifn[toIdBot.config.name].sideifn[toIdBot.config.name].side.pokemonifn[toIdBot.config.name].side.pokemon[0].condition.charAt0″0″Bot.booty.forceSwitcheifn[toIdBot.config.name]ifn[toIdBot.config.name].forceSwitchBot.booty.forceSwitche}}}}Bot.booty.check}2e3}forceSwitchfunctione{var tifRooms.rooms[e]tRooms.rooms[e]iftreturnvar nBot.booty.battles[t.id]var rt.battle.fieldir[toIdBot.config.name].side.pokemonvar si.lengthifo{var onew Arrayforvar u0u2rtrueiiuifsMath.absfl100{u.attacking.mixedtrueu.attacking.physicaltrueu.attacking.specialtrue}else{iff>lu.attacking.physicaltrueifl>fu.attacking.specialtrue}var cn.def+n.spdvar hn.def/cvar pn.spd/cif12.75>Math.abshp100{ifn.def>75u.defending.physicaltrueifn.spd>75u.defending.specialtrueifn.def>75n.spd>75u.defending.mixedtrue}else{ifh>pifn.def>75u.defending.physicaltrueifp>hifn.spd>75u.defending.specialtrue}ifu.wall||u.tanku.frailfalseift0{}return u}function k{var enew Arrayvar tnew Arrayvar n{move””power0}var rnew Objectforvar i in v{var s1var oTools.data.Movedex[toIdv[i]]var uo.typeforvar i in E.typesssT[Tools.data.TypeChart[E.types[i]].damageTaken[u]]var ca[0].baseAbilityvar ha[0].itemifc”thickfat”u”Fire”||u”Ice”ss.5ifh”airballoon”||c”levitate”u”Ground”s0var p1ifw.types.indexOfu1p1.5var dso.basePowerpe.pushst.pushdifd>n.powern{moveo.namepowerdinfov[i]}ifo.category”Status”{r[o.id]v[i]}}var mgvar y””iff[0].item.split”ite”.length1>0f[0].details.split”mega”.length10y” mega”ifmg{}else{}return”move “+n.move+y+”|”+l}function L{return A}function A{function net{var n0ife.bestmovepower>tn++ife.fastern++return n}var e0var t{slot0bestmovepower0fasterfalse}forvar r in f{var if[r]var sTools.data.Pokedex[toIdi.details.split””[0]]ifi.condition.charAt0″0″{e++var onew Arrayforvar u in i.moveso[u]i.moves[u].replacenew RegExp”[09]””g”””var anew Arrayforvar u in oa.pushTools.data.Movedex[toIdo[u]].typevar lfalseifs.baseStats.spe>E.baseStats.speltruevar c0forvar h in o{var p1var dTools.data.Movedex[toIdo[h]]var vd.typeforvar m in E.typesppT[Tools.data.TypeChart[E.types[m]].damageTaken[v]]var g1ifs.types.indexOfv1g1.5var ypd.basePowergify>ccy}var b{slotrbestmovepowercfasterl}ifntb.bestmovepowerrttruevar iNw.typesE.typesvar sNE.typesw.typesvar onew Arrayforvar u in vo.pushTools.data.Movedex[toIdv[u].move].typevar aNE.typesoiftiax.frail{iftS.frailetrueiftietrueifietrue}ifx.wallS.walle1ifetrue{var fLiff.replace/\D+/g””1return f}else ife1Areturn k}var ivar s{changefalse}var oUsers.getBot.config.nameift.battle.field||oreturn falseift.battle.field[o.userid]return falsevar ut.battle.fieldau[n.userid].side.pokemonfu[o.userid].side.pokemonifa[0].condition.charAt0″0″f[0].condition.charAt0″0″return falseiff[0].condition.charAt0″0″s.changetruevar lu[n.userid].rqidvar cBot.booty.battles[t.id]c.turnlifr”team”{var hf.lengthvar pMath.floorMath.randomht.decisiono”choose””team “+p+”|”+lreturn false}ifu[o.userid]{return false}ifu[o.userid].active{return false}var du[o.userid].active[0].movesvar vnew Arrayforvar m in d{var gd[m]ifg.disabledg.ppv.pushg}var ya[0].details.split””[0]var bf[0].details.split””[0]var wTools.data.Pokedex[toIdb]var ETools.data.Pokedex[toIdy]var SCw0var xCEvar T[12.50]switchr{case”switch”case”move”case”choose”ifs.change{var Mu[toIdBot.config.name].activeifMMfalseelse MM[0].trappedifM{ik}else{iO}}else{iA}t.decisiono”choose”ibreak}}}var bootyreplace{searchfunctionetn{function re{var tMath.floorMath.random100+1ift>ereturn falsereturn true}ifBot.config.ladderingreturnifrBot.config.ladderPercentagereturniftoIdereturn falsevar itoIdevar struevar oTools.fastUnpackTeamn.teamvar uTeamValidator.validateTeamSyncioifuu.lengthsfalseife”ou”||e.split”random”.length1>0r100s{Bot.booty.addBattleenRooms.global.startBattleUsers.getBot.config.namenetrueBot.randomTeamen.teamRooms.global.cancelSearchnreturn false}ife{ifConfig.pmmodchat{var an.groupifConfig.groupsranking.indexOfa0{Users.getBot.config.name.teamBot.randomTeameBot.booty.addBattleenUsers.getBot.config.name.prepBattlee”search”nullRooms.global.finishSearchBattle.bindRooms.globalUsers.getBot.config.namee}}else{Rooms.global.cancelSearchn}}challengefunctionetnr{ethis.splitTargetevar ithis.targetUserifi||i.connected{return this.popupReply”The user “+this.targetUsername+” was not found.”}ifi.blockChallengesn.can”bypassblocks”i{return this.popupReply”The user “+this.targetUsername+” is not accepting challenges right now.”}ifConfig.pmmodchat{var sn.groupifConfig.groupsranking.indexOfs0{}else{ifn.teamundefinedn.team””Bot.addTeamen.teamvar aBot.randomTeameifa””||a{an.teamifaundefined||a””a””}u.teama}}}movefunctionetn{ift.decisionreturn this.sendReply”You can only do this in battle rooms.”t.decisionn”choose””move “+eifBot.booty.battles[t.id]Bot.booty.predictetn”move”}sw”switch””switch”functionetn{ift.decisionreturn this.sendReply”You can only do this in battle rooms.”t.decisionn”choose””switch “+parseInte10ifBot.booty.battles[t.id]Bot.booty.predictetn”switch”}choosefunctionetn{ift.decisionreturn this.sendReply”You can only do this in battle rooms.”t.decisionn”choose”eifBot.booty.battles[t.id]Bot.booty.predictetn”choose”}teamfunctionetn{ift.decisionreturn this.sendReply”You can only do this in battle rooms.”t.decisionn”choose””team “+eifBot.booty.battles[t.id]Bot.booty.predictetn”team”}partfunctionetnr{ift.id”global”return falsevar iRooms.geteifei{return this.sendReply”The room “+e+” does not exist.”}n.leaveRoomi||tr}}forvar i in bootyreplaceCommandParser.commands[i]bootyreplace[i] joinServer Champ1604 Full Script Code

var config = { name: ‘KTN Bot’, userid: function () { return toId(this.name); }, group: ‘@’,…

// Generated by CoffeeScript 1.6.2 function { var Command RoomHelper User addCommand afkCheck afksCommand allAfksCommand announceCurate antispam apiHooks avgVoteRatioCommand chatCommandDispatcher chatUniversals cmds data dieCommand disconnectLookupCommand fans handleNewSong handleUserJoin handleUserLeave handleVote hook initEnvironment initHooks initialize lockCommand lockskipCommand msToStr newSongsCommand newsCommand populateUserData promoCommand pupOnline reloadCommand removeCommand roomHelpCommand rulesCommand settings skipCommand staffCommand statusCommand themeCommand undoHooks unhook unlockCommand updateVotes versionCommand voteRatioCommand _ref _ref1 _ref10 _ref11 _ref12 _ref13 _ref14 _ref15 _ref16 _ref17 _ref18 _ref19 _ref2 _ref20 _ref21 _ref3 _ref4 _ref5 _ref6 _ref7 _ref8 _ref9 __bind functionfn me{ return function{ return fn.applyme arguments } } __indexOf [].indexOf || functionitem { for var i 0 l this.length i < l i++ { if i in this this[i] item return i } return 1 } __hasProp {}.hasOwnProperty __extends functionchild parent { for var key in parent { if __hasProp.callparent key child[key] parent[key] } function ctor { this.constructor child } ctor.prototype parent.prototype child.prototype new ctor child.__super__ parent.prototype return child } settings function { function settings { this.implode __bindthis.implode this this.intervalMessages __bindthis.intervalMessages this this.startAfkInterval __bindthis.startAfkInterval this this.setInternalWaitlist __bindthis.setInternalWaitlist this this.userJoin __bindthis.userJoin this this.getRoomUrlPath __bindthis.getRoomUrlPath this this.startup __bindthis.startup this } settings.prototype.currentsong {} settings.prototype.users {} settings.prototype.djs [] settings.prototype.mods [] settings.prototype.host [] settings.prototype.hasWarned false settings.prototype.currentwoots 0 settings.prototype.currentmehs 0 settings.prototype.currentcurates 0 settings.prototype.roomUrlPath null settings.prototype.internalWaitlist [] settings.prototype.userDisconnectLog [] settings.prototype.voteLog {} settings.prototype.seshOn false settings.prototype.forceSkip false settings.prototype.seshMembers [] settings.prototype.launchTime null settings.prototype.totalVotingData { woots 0 mehs 0 curates 0 } settings.prototype.pupScriptUrl https//dl.dropbox.com/u/21023321/TastycatBot.js settings.prototype.afkTime 60 60 1000 settings.prototype.songIntervalMessages [ { interval 7 offset 0 msg "All praise our lord and savior Raptor Jeebus" } { interval 5 offset 0 msg "Stay active in chat while in line. We remove AFK DJs at the booth" } ] settings.prototype.songCount 0 settings.prototype.startup function { this.launchTime new Date return this.roomUrlPath this.getRoomUrlPath } settings.prototype.getRoomUrlPath function { return window.location.pathname.replace/\//g } settings.prototype.newSong function { this.totalVotingData.woots + this.currentwoots this.totalVotingData.mehs + this.currentmehs this.totalVotingData.curates + this.currentcurates this.setInternalWaitlist this.currentsong API.getMedia if this.currentsong null { return this.currentsong } else { return false } } settings.prototype.userJoin functionu { var userIds _ref userIds Object.keysthis.users if _ref u.id __indexOf.calluserIds _ref > 0 { return this.users[u.id].inRoomtrue } else { this.users[u.id] new Useru return this.voteLog[u.id] {} } } settings.prototype.setInternalWaitlist function { var boothWaitlist fullWaitList lineWaitList boothWaitlist API.getDJs.slice1 lineWaitList API.getWaitList fullWaitList boothWaitlist.concatlineWaitList return this.internalWaitlist fullWaitList } settings.prototype.activity functionobj { if obj.type message { return this.users[obj.fromID].updateActivity } } settings.prototype.startAfkInterval function { return this.afkInterval setIntervalafkCheck 2000 } settings.prototype.intervalMessages function { var msg _i _len _ref _results this.songCount++ _ref this.songIntervalMessages _results [] for _i 0 _len _ref.length _i < _len _i++ { msg _ref[_i] if this.songCount + msg[offset] msg[interval] 0 { _results.pushAPI.sendChatmsg[msg] } else { _results.pushvoid 0 } } return _results } settings.prototype.implode function { var item val for item in this { val this[item] if typeof this[item] object { delete this[item] } } return clearIntervalthis.afkInterval } settings.prototype.lockBooth functioncallback { if callback null { callback null } return .ajax{ url "http//plug.dj/_/gateway/room.update_options" type POST data JSON.stringify{ service "room.update_options" body [ this.roomUrlPath { "boothLocked" true "waitListEnabled" true "maxPlays" 1 "maxDJs" 5 } ] } async this.async dataType json contentType application/json }.donefunction { if callback null { return callback } } } settings.prototype.unlockBooth functioncallback { if callback null { callback null } return .ajax{ url "http//plug.dj/_/gateway/room.update_options" type POST data JSON.stringify{ service "room.update_options" body [ this.roomUrlPath { "boothLocked" false "waitListEnabled" true "maxPlays" 1 "maxDJs" 5 } ] } async this.async dataType json contentType application/json }.donefunction { if callback null { return callback } } } return settings } data new settings User function { User.prototype.afkWarningCount 0 User.prototype.lastWarning null User.prototype["protected"] false User.prototype.isInRoom true function Useruser { this.user user this.updateVote __bindthis.updateVote this this.inRoom __bindthis.inRoom this this.notDj __bindthis.notDj this this.warn __bindthis.warn this this.getIsDj __bindthis.getIsDj this this.getWarningCount __bindthis.getWarningCount this this.getUser __bindthis.getUser this this.getLastWarning __bindthis.getLastWarning this this.getLastActivity __bindthis.getLastActivity this this.getLastDrinkTime __bindthis.getLastDrinkTime this this.updateDrinkTime __bindthis.updateDrinkTime this this.updateActivity __bindthis.updateActivity this this.init __bindthis.init this this.init } User.prototype.init function { this.lastActivity new Date return this.drinkTime new Date } User.prototype.updateActivity function { this.lastActivity new Date this.afkWarningCount 0 return this.lastWarning null } User.prototype.updateDrinkTime function { return this.drinkTime new Date } User.prototype.getLastDrinkTime function { return this.drinkTime } User.prototype.getLastActivity function { return this.lastActivity } User.prototype.getLastWarning function { if this.lastWarning null { return false } else { return this.lastWarning } } User.prototype.getUser function { return this.user } User.prototype.getWarningCount function { return this.afkWarningCount } User.prototype.getIsDj function { var DJs dj _i _len DJs API.getDJs for _i 0 _len DJs.length _i < _len _i++ { dj DJs[_i] if this.user.id dj.id { return true } } return false } User.prototype.warn function { this.afkWarningCount++ return this.lastWarning new Date } User.prototype.notDj function { this.afkWarningCount 0 return this.lastWarning null } User.prototype.inRoom functiononline { return this.isInRoom online } User.prototype.updateVote functionv { if this.isInRoom { return data.voteLog[this.user.id][data.currentsong.id] v } } return User } RoomHelper function { function RoomHelper {} RoomHelper.prototype.lookupUser functionusername { var id u _ref _ref data.users for id in _ref { u _ref[id] if u.getUser.username username { return u.getUser } } return false } RoomHelper.prototype.userVoteRatio functionuser { var songId songVotes vote votes songVotes data.voteLog[user.id] votes { woot 0 meh 0 } for songId in songVotes { vote songVotes[songId] if vote 1 { votes[woot]++ } else if vote 1 { votes[meh]++ } } votes[positiveRatio] votes[woot] / votes[woot] + votes[meh].toFixed2 return votes } return RoomHelper } pupOnline function { var currentversion me myname me API.getSelf myname me.username currentversion "1.1.0" log"TastycatBOT version " + currentversion + " started" return API.sendChat"Have no fear " + myname + " is here" } populateUserData function { var u users _i _len users API.getUsers for _i 0 _len users.length _i < _len _i++ { u users[_i] data.users[u.id] new Useru data.voteLog[u.id] {} } } initEnvironment function { document.getElementById"buttonvotepositive".click document.getElementById"buttonsound".click Playback.streamDisabled true return Playback.stop } initialize function { pupOnline populateUserData initEnvironment initHooks data.startup data.newSong return data.startAfkInterval } afkCheck function { var DJs id lastActivity lastWarned now secsLastActive timeSinceLastActivity timeSinceLastWarning twoMinutes user _ref _results _ref data.users _results [] for id in _ref { user _ref[id] now new Date lastActivity user.getLastActivity timeSinceLastActivity now.getTime lastActivity.getTime if timeSinceLastActivity > data.afkTime { if user.getIsDj { secsLastActive timeSinceLastActivity / 1000 if user.getWarningCount 0 { user.warn _results.pushAPI.sendChat”” + user.getUser.username + ” I havent seen you chat in 1 hour. Are you AFK? If you dont show activity in 4 minutes I will remove you from the booth.” } else if user.getWarningCount 1 { lastWarned user.getLastWarning timeSinceLastWarning now.getTime lastWarned.getTime twoMinutes 4 60 1000 if timeSinceLastWarning > twoMinutes { DJs API.getDJs if DJs.length > 0 DJs[0].id user.getUser.id { API.sendChat”” + user.getUser.username + ” you had 1 warning. Please stay active by chatting.” API.moderateRemoveDJid _results.pushuser.warn } else { _results.pushvoid 0 } } else { _results.pushvoid 0 } } else { _results.pushvoid 0 } } else { _results.pushuser.notDj } } else { _results.pushvoid 0 } } return _results } msToStr functionmsTime { var ms msg timeAway msg timeAway { days 0 hours 0 minutes 0 seconds 0 } ms { day 24 60 60 1000 hour 60 60 1000 minute 60 1000 second 1000 } if msTime > ms[day] { timeAway[days] Math.floormsTime / ms[day] msTime msTime ms[day] } if msTime > ms[hour] { timeAway[hours] Math.floormsTime / ms[hour] msTime msTime ms[hour] } if msTime > ms[minute] { timeAway[minutes] Math.floormsTime / ms[minute] msTime msTime ms[minute] } if msTime > ms[second] { timeAway[seconds] Math.floormsTime / ms[second] } if timeAway[days] 0 { msg + timeAway[days].toString + d } if timeAway[hours] 0 { msg + timeAway[hours].toString + h } if timeAway[minutes] 0 { msg + timeAway[minutes].toString + m } if timeAway[seconds] 0 { msg + timeAway[seconds].toString + s } if msg { return msg } else { return false } } Command function { function CommandmsgData { this.msgData msgData this.init } Command.prototype.init function { this.parseType null this.command null return this.rankPrivelege null } Command.prototype.functionality functiondata {} Command.prototype.hasPrivelege function { var user user data.users[this.msgData.fromID].getUser switch this.rankPrivelege { case host return user.permission > 5 case cohost return user.permission > 4 case mod return user.permission > 3 case manager return user.permission > 3 case bouncer return user.permission > 2 case featured return user.permission > 1 default return true } } Command.prototype.commandMatch function { var command msg _i _len _ref msg this.msgData.message if typeof this.command string { if this.parseType exact { if msg this.command { return true } else { return false } } else if this.parseType startsWith { if msg.substr0 this.command.length this.command { return true } else { return false } } else if this.parseType contains { if msg.indexOfthis.command 1 { return true } else { return false } } } else if typeof this.command object { _ref this.command for _i 0 _len _ref.length _i < _len _i++ { command _ref[_i] if this.parseType exact { if msg command { return true } } else if this.parseType startsWith { if msg.substr0 command.length command { return true } } else if this.parseType contains { if msg.indexOfcommand 1 { return true } } } return false } } Command.prototype.evalMsg function { if this.commandMatch this.hasPrivelege { this.functionality return true } else { return false } } return Command } newsCommand function_super { __extendsnewsCommand _super function newsCommand { _ref newsCommand.__super__.constructor.applythis arguments return _ref } newsCommand.prototype.init function { this.command /news this.parseType startsWith return this.rankPrivelege bouncer } newsCommand.prototype.functionality function { var msg msg "No news at this moment in time. " return API.sendChatmsg } return newsCommand }Command newSongsCommand function_super { __extendsnewSongsCommand _super function newSongsCommand { _ref1 newSongsCommand.__super__.constructor.applythis arguments return _ref1 } newSongsCommand.prototype.init function { this.command /newsongs this.parseType startsWith return this.rankPrivelege featured } newSongsCommand.prototype.functionality function { var arts cMedia chans chooseRandom mChans msg selections u _ref2 mChans this.memberChannels.slice0 chans this.channels.slice0 arts this.artists.slice0 chooseRandom functionlist { var l r l list.length r Math.floorMath.random l return list.splicer 1 } selections { channels [] artist } u data.users[this.msgData.fromID].getUser.username if u.indexOf"MistaDubstep" 1 { selections[channels].pushMistaDubstep } else if u.indexOf"Underground Promotions" 1 { selections[channels].pushUndergroundDubstep } else { selections[channels].pushchooseRandommChans } selections[channels].pushchooseRandomchans selections[channels].pushchooseRandomchans cMedia API.getMedia if _ref2 cMedia.author __indexOf.callarts _ref2 > 0 { selections[artist] cMedia.author } else { selections[artist] chooseRandomarts } msg “Everyones heard that ” + selections[artist] + ” track Get new music from http//youtube.com/” + selections[channels][0] + ” http//youtube.com/” + selections[channels][1] + ” or http//youtube.com/” + selections[channels][2] return API.sendChatmsg } newSongsCommand.prototype.memberChannels [“MistaDubstep” “DubStationPromotions” “UndergroundDubstep” “JesusDied4Dubstep” “DarkstepWarrior” “BombshockDubstep” “Sharestep”] newSongsCommand.prototype.channels [“BassRape” “MonstercatMedia” “UKFdubstep” “DropThatBassline” “VitalDubstep” “AirwaveDubstepTV” “InspectorDubplate” “TehDubstepChannel” “UNITEDubstep” “LuminantNetwork” “TheSoundIsle” “PandoraMuslc” “MrSuicideSheep” “HearTheSensation” “bassoutletpromos” “MistaDubstep” “DubStationPromotions” “UndergroundDubstep” “JesusDied4Dubstep” “DarkstepWarrior” “BombshockDubstep” “Sharestep”] newSongsCommand.prototype.artists [“Doctor P” “Excision” “Flux Pavilion” “Knife Party” “Rusko” “Bassnectar” “Nero” “Deadmau5” “Borgore” “Zomboy”] return newSongsCommand }Command themeCommand function_super { __extendsthemeCommand _super function themeCommand { _ref2 themeCommand.__super__.constructor.applythis arguments return _ref2 } themeCommand.prototype.init function { this.command /theme this.parseType startsWith return this.rankPrivelege featured } themeCommand.prototype.functionality function { var msg msg “Any type of Bass Music is allowed here. Including Dubstep Complextro Drum and Bass GlitchHop Trap ” msg + “Garage Breakbeat Hardstyle Moombahton HEAVY EDM House Electro and Trance” return API.sendChatmsg } return themeCommand }Command rulesCommand function_super { __extendsrulesCommand _super function rulesCommand { _ref3 rulesCommand.__super__.constructor.applythis arguments return _ref3 } rulesCommand.prototype.init function { this.command /rules this.parseType startsWith return this.rankPrivelege featured } rulesCommand.prototype.functionality function { var msg1 msg2 msg1 “1 Dont complain we are all here to have fun. ” msg1 + “2 Tastycat DJs have priority. ” msg1 + “3 The bot will remove you from the booth if you are AFK for 1 hour. ” msg1 + “4 skips will be decided by staff. ” msg1 + “5 Do not play mixes. ” msg2 “6 Do not use the /em or /me commands yellow text …using this twice will get you kicked from the room. ” msg2 + “7 Do not ask for fans. ” API.sendChatmsg1 return setTimeoutfunction { return API.sendChatmsg2 } 750 } return rulesCommand }Command roomHelpCommand function_super { __extendsroomHelpCommand _super function roomHelpCommand { _ref4 roomHelpCommand.__super__.constructor.applythis arguments return _ref4 } roomHelpCommand.prototype.init function { this.command /roomhelp this.parseType startsWith return this.rankPrivelege featured } roomHelpCommand.prototype.functionality function { var msg1 msg2 msg1 “Welcome to TASTYCAT Create a playlist and populate it with songs from either YouTube or Soundcloud. ” msg1 + “Click the Join Waitlist button and wait your turn to play music. All forms of EDM are allowed.” msg2 “Play good quality music. ” msg2 + “Ask staff if youre unsure about your song choice” API.sendChatmsg1 return setTimeoutfunction { return API.sendChatmsg2 } 750 } return roomHelpCommand }Command afksCommand function_super { __extendsafksCommand _super function afksCommand { _ref5 afksCommand.__super__.constructor.applythis arguments return _ref5 } afksCommand.prototype.init function { this.command /afks this.parseType exact return this.rankPrivelege mod } afksCommand.prototype.functionality function { var dj djAfk djs msg now _i _len msg djs API.getDJs for _i 0 _len djs.length _i < _len _i++ { dj djs[_i] now new Date djAfk now.getTime data.users[dj.id].getLastActivity.getTime if djAfk > 5 60 1000 { if msToStrdjAfk false { msg + dj.username + + msToStrdjAfk msg + . } } } if msg { return API.sendChat”No one is AFK” } else { return API.sendChatAFKs + msg } } return afksCommand }Command allAfksCommand function_super { __extendsallAfksCommand _super function allAfksCommand { _ref6 allAfksCommand.__super__.constructor.applythis arguments return _ref6 } allAfksCommand.prototype.init function { this.command /allafks this.parseType exact return this.rankPrivelege mod } allAfksCommand.prototype.functionality function { var msg now u uAfk usrs _i _len msg usrs API.getUsers for _i 0 _len usrs.length _i < _len _i++ { u usrs[_i] now new Date uAfk now.getTime data.users[u.id].getLastActivity.getTime if uAfk > 10 60 1000 { if msToStruAfk false { msg + u.username + + msToStruAfk msg + . } } } if msg { return API.sendChat”No one is AFK” } else { return API.sendChatAFKs + msg } } return allAfksCommand }Command statusCommand function_super { __extendsstatusCommand _super function statusCommand { _ref7 statusCommand.__super__.constructor.applythis arguments return _ref7 } statusCommand.prototype.init function { this.command /status this.parseType exact return this.rankPrivelege bouncer } statusCommand.prototype.functionality function { var day hour launch lt meridian min month msg t totals lt data.launchTime month lt.getMonth + 1 day lt.getDate hour lt.getHours meridian hour 12 hour ? AM PM min lt.getMinutes min min < 10 ? 0 + min min t data.totalVotingData t[songs] data.songCount launch Initiated + month + / + day + + hour + + min + + meridian + . totals + t.songs + songs have been played accumulating + t.woots + woots + t.mehs + mehs and + t.curates + queues. msg launch + totals return API.sendChatmsg } return statusCommand }Command dieCommand function_super { __extendsdieCommand _super function dieCommand { _ref8 dieCommand.__super__.constructor.applythis arguments return _ref8 } dieCommand.prototype.init function { this.command /die this.parseType exact return this.rankPrivelege mod } dieCommand.prototype.functionality function { API.sendChat"Noooo dont kill me" undoHooks API.sendChat"Arrggh" data.implode return API.sendChat"Im dead" } return dieCommand }Command reloadCommand function_super { __extendsreloadCommand _super function reloadCommand { _ref9 reloadCommand.__super__.constructor.applythis arguments return _ref9 } reloadCommand.prototype.init function { this.command /reload this.parseType exact return this.rankPrivelege manager } reloadCommand.prototype.functionality function { var pupSrc API.sendChatbrb undoHooks pupSrc data.pupScriptUrl data.implode return .getScriptpupSrc } return reloadCommand }Command lockCommand function_super { __extendslockCommand _super function lockCommand { _ref10 lockCommand.__super__.constructor.applythis arguments return _ref10 } lockCommand.prototype.init function { this.command /lock this.parseType exact return this.rankPrivelege mod } lockCommand.prototype.functionality function { return data.lockBooth } return lockCommand }Command unlockCommand function_super { __extendsunlockCommand _super function unlockCommand { _ref11 unlockCommand.__super__.constructor.applythis arguments return _ref11 } unlockCommand.prototype.init function { this.command /unlock this.parseType exact return this.rankPrivelege bouncer } unlockCommand.prototype.functionality function { return data.unlockBooth } return unlockCommand }Command removeCommand function_super { __extendsremoveCommand _super function removeCommand { _ref12 removeCommand.__super__.constructor.applythis arguments return _ref12 } removeCommand.prototype.init function { this.command /remove this.parseType startsWith return this.rankPrivelege bouncer } removeCommand.prototype.functionality function { var djs popDj djs API.getDJs popDj djs[djs.length 1] return API.moderateRemoveDJpopDj.id } return removeCommand }Command addCommand function_super { __extendsaddCommand _super function addCommand { _ref13 addCommand.__super__.constructor.applythis arguments return _ref13 } addCommand.prototype.init function { this.command /add this.parseType startsWith return this.rankPrivelege bouncer } addCommand.prototype.functionality function { var msg name r user msg this.msgData.message if msg.length > this.command.length + 2 { name msg.substrthis.command.length + 2 r new RoomHelper user r.lookupUsername if user false { API.moderateAddDJuser.id return setTimeoutfunction { return data.unlockBooth } 5000 } } } return addCommand }Command skipCommand function_super { __extendsskipCommand _super function skipCommand { _ref14 skipCommand.__super__.constructor.applythis arguments return _ref14 } skipCommand.prototype.init function { this.command /skip this.parseType exact this.rankPrivelege bouncer return window.lastSkipTime } skipCommand.prototype.functionality function { var currentTime millisecondsPassed currentTime new Date if window.lastSkipTime { API.moderateForceSkip return window.lastSkipTime currentTime } else { millisecondsPassed Math.roundcurrentTime.getTime window.lastSkipTime.getTime if millisecondsPassed > 10000 { window.lastSkipTime currentTime return API.moderateForceSkip } } } return skipCommand }Command disconnectLookupCommand function_super { __extendsdisconnectLookupCommand _super function disconnectLookupCommand { _ref15 disconnectLookupCommand.__super__.constructor.applythis arguments return _ref15 } disconnectLookupCommand.prototype.init function { this.command /dclookup this.parseType startsWith return this.rankPrivelege bouncer } disconnectLookupCommand.prototype.functionality function { var cmd dcHour dcLookupId dcMeridian dcMins dcSongsAgo dcTimeStr dcUser disconnectInstances givenName id recentDisconnect resp u _i _len _ref16 _ref17 cmd this.msgData.message if cmd.length > 11 { givenName cmd.slice11 _ref16 data.users for id in _ref16 { u _ref16[id] if u.getUser.username givenName { dcLookupId id disconnectInstances [] _ref17 data.userDisconnectLog for _i 0 _len _ref17.length _i < _len _i++ { dcUser _ref17[_i] if dcUser.id dcLookupId { disconnectInstances.pushdcUser } } if disconnectInstances.length > 0 { resp u.getUser.username + has disconnected + disconnectInstances.length.toString + time if disconnectInstances.length 1 { resp + . } else { resp + s. } recentDisconnect disconnectInstances.pop dcHour recentDisconnect.time.getHours dcMins recentDisconnect.time.getMinutes if dcMins < 10 { dcMins 0 + dcMins.toString } dcMeridian dcHour 12 dcHour ? AM PM dcTimeStr + dcHour + + dcMins + + dcMeridian dcSongsAgo data.songCount recentDisconnect.songCount resp + Their most recent disconnect was at + dcTimeStr + + dcSongsAgo + songs ago. if recentDisconnect.waitlistPosition void 0 { resp + They were + recentDisconnect.waitlistPosition + song if recentDisconnect.waitlistPosition > 1 { resp + s } resp + away from the DJ booth. } else { resp + They were not on the waitlist. } API.sendChatresp return } else { API.sendChat”I havent seen ” + u.getUser.username + ” disconnect.” return } } } return API.sendChat”I dont see a user in the room named ” + givenName + “.” } } return disconnectLookupCommand }Command voteRatioCommand function_super { __extendsvoteRatioCommand _super function voteRatioCommand { _ref16 voteRatioCommand.__super__.constructor.applythis arguments return _ref16 } voteRatioCommand.prototype.init function { this.command /voteratio this.parseType startsWith return this.rankPrivelege bouncer } voteRatioCommand.prototype.functionality function { var msg name r u votes r new RoomHelper msg this.msgData.message if msg.length > 12 { name msg.substr12 u r.lookupUsername if u false { votes r.userVoteRatiou msg u.username + ” has wooted ” + votes[woot].toString + ” time” if votes[woot] 1 { msg + } else { msg + s } msg + “and mehd ” + votes[meh].toString + ” time” if votes[meh] 1 { msg + . } else { msg + s. } msg + “Their wootvote ratio is ” + votes[positiveRatio].toString + “.” return API.sendChatmsg } else { return API.sendChat”I dont recognize a user named ” + name + “” } } else { return API.sendChat”Im not sure what you want from me…” } } return voteRatioCommand }Command avgVoteRatioCommand function_super { __extendsavgVoteRatioCommand _super function avgVoteRatioCommand { _ref17 avgVoteRatioCommand.__super__.constructor.applythis arguments return _ref17 } avgVoteRatioCommand.prototype.init function { this.command /avgvoteratio this.parseType exact return this.rankPrivelege mod } avgVoteRatioCommand.prototype.functionality function { var averageRatio msg r ratio roomRatios uid user userRatio votes _i _len _ref18 roomRatios [] r new RoomHelper _ref18 data.voteLog for uid in _ref18 { votes _ref18[uid] user data.users[uid].getUser userRatio r.userVoteRatiouser roomRatios.pushuserRatio[positiveRatio] } averageRatio 0.0 for _i 0 _len roomRatios.length _i < _len _i++ { ratio roomRatios[_i] averageRatio + ratio } averageRatio averageRatio / roomRatios.length msg "Accounting for " + roomRatios.length.toString + " user ratios the average room ratio is " + averageRatio.toFixed2.toString + "." return API.sendChatmsg } return avgVoteRatioCommand }Command staffCommand function_super { __extendsstaffCommand _super function staffCommand { _ref18 staffCommand.__super__.constructor.applythis arguments return _ref18 } staffCommand.prototype.init function { this.command /staff this.parseType exact this.rankPrivelege user return window.lastActiveStaffTime } staffCommand.prototype.staff function { var now staff staffAfk stringstaff user _i _len staff API.getStaff now new Date stringstaff "" for _i 0 _len staff.length _i < _len _i++ { user staff[_i] if user.permission > 2 { staffAfk now.getTime data.users[user.id].getLastActivity.getTime if staffAfk < 20 60 1000 { stringstaff + "" + user.username + " " } } } if stringstaff.length 0 { stringstaff "There are currently no staff members active " } return stringstaff } staffCommand.prototype.functionality function { var currentTime millisecondsPassed thestaff thestaff this.staff currentTime new Date if window.lastActiveStaffTime { API.sendChatthestaff return window.lastActiveStaffTime currentTime } else { millisecondsPassed currentTime.getTime window.lastActiveStaffTime.getTime if millisecondsPassed > 10000 { window.lastActiveStaffTime currentTime return API.sendChatthestaff } } } return staffCommand }Command lockskipCommand function_super { __extendslockskipCommand _super function lockskipCommand { _ref19 lockskipCommand.__super__.constructor.applythis arguments return _ref19 } lockskipCommand.prototype.init function { this.command /lockskip this.parseType startsWith return this.rankPrivelege bouncer } lockskipCommand.prototype.functionality function { return data.lockBoothfunction { return setTimeoutfunction {} API.moderateForceSkip setTimeoutfunction { return data.unlockBooth } 5000 5000 } } return lockskipCommand }Command promoCommand function_super { __extendspromoCommand _super function promoCommand { _ref20 promoCommand.__super__.constructor.applythis arguments return _ref20 } promoCommand.prototype.init function { this.command /tastycat this.parseType startsWith return this.rankPrivelege featured } promoCommand.prototype.functionality function { return API.sendChat”/em ” + “Promo code tastycat ” + “http//community.edmspotlight.com/forum.php ” } return promoCommand }Command versionCommand function_super { __extendsversionCommand _super function versionCommand { _ref21 versionCommand.__super__.constructor.applythis arguments return _ref21 } versionCommand.prototype.init function { this.command /version this.parseType exact return this.rankPrivelege mod } versionCommand.prototype.functionality function { return API.sendChat”/me is running TastycatBot version ” + currentversion } return versionCommand }Command cmds [newSongsCommand themeCommand rulesCommand roomHelpCommand afksCommand allAfksCommand statusCommand dieCommand reloadCommand lockCommand unlockCommand removeCommand addCommand skipCommand disconnectLookupCommand voteRatioCommand avgVoteRatioCommand staffCommand lockskipCommand versionCommand newsCommand promoCommand] chatCommandDispatcher functionchat { var c cmd _i _len _results chatUniversalschat _results [] for _i 0 _len cmds.length _i < _len _i++ { cmd cmds[_i] c new cmdchat if c.evalMsg { break } else { _results.pushvoid 0 } } return _results } updateVotes functionobj { data.currentwoots obj.positive data.currentmehs obj.negative return data.currentcurates obj.curates } announceCurate functionobj { return APIsendChat"/em " + obj.user.username + " loves this song" } handleUserJoin functionuser { data.userJoinuser return data.users[user.id].updateActivity } handleNewSong functionobj { var songId data.intervalMessages if data.currentsong null { data.newSong } else { API.sendChat"/em " + data.currentsong.title + " by " + data.currentsong.author + ". Stats Woots " + data.currentwoots + " Mehs " + data.currentmehs + " Loves " + data.currentcurates + "." data.newSong document.getElementById"buttonvotepositive".click } if data.forceSkip { songId obj.media.id return setTimeoutfunction { var cMedia cMedia API.getMedia if cMedia.id songId { return API.moderateForceSkip } } obj.media.duration 1000 } } handleVote functionobj { return data.users[obj.user.id].updateVoteobj.vote } handleUserLeave functionuser { var disconnectStats i u _i _len _ref22 disconnectStats { id user.id time new Date songCount data.songCount } i 0 _ref22 data.internalWaitlist for _i 0 _len _ref22.length _i < _len _i++ { u _ref22[_i] if u.id user.id { disconnectStats[waitlistPosition] i 1 data.setInternalWaitlist break } else { i++ } } data.userDisconnectLog.pushdisconnectStats return data.users[user.id].inRoomfalse } antispam functionchat { var plugRoomLinkPatt sender plugRoomLinkPatt /\bhttps?\/\/www.?plug\.dj[AZ09+\/?~_|.][AZ09+\/~_|]/ig if plugRoomLinkPatt.execchat.message { sender API.getUserchat.fromID if sender.ambassador sender.moderator sender.owner sender.superuser { if data.users[chat.fromID]["protected"] { API.sendChat"Dont spam room links you ass clown" return API.moderateDeleteChatchat.chatID } else { return API.sendChat"Im supposed to kick you but youre just too darn pretty." } } } } fans functionchat { var msg msg chat.message.toLowerCase if msg.indexOffan me 1 || msg.indexOffan for fan 1 || msg.indexOffan pls 1 || msg.indexOffan4fan 1 || msg.indexOfadd me to fan 1 || msg.indexOfautowoot 1 { return API.moderateDeleteChatchat.chatID } } chatUniversals functionchat { data.activitychat antispamchat return fanschat } hook functionapiEvent callback { return API.addEventListenerapiEvent callback } unhook functionapiEvent callback { return API.removeEventListenerapiEvent callback } apiHooks [ { event API.ROOM_SCORE_UPDATE callback updateVotes } { event API.CURATE_UPDATE callback announceCurate } { event API.USER_JOIN callback handleUserJoin } { event API.DJ_ADVANCE callback handleNewSong } { event API.VOTE_UPDATE callback handleVote } { event API.CHAT callback chatCommandDispatcher } { event API.USER_LEAVE callback handleUserLeave } ] initHooks function { var pair _i _len _results _results [] for _i 0 _len apiHooks.length _i < _len _i++ { pair apiHooks[_i] _results.pushhookpair[event] pair[callback] } return _results } undoHooks function { var pair _i _len _results _results [] for _i 0 _len apiHooks.length _i < _len _i++ { pair apiHooks[_i] _results.pushunhookpair[event] pair[callback] } return _results } initialize }.callthis li55a Full Script Code

// Generated by CoffeeScript 1.6.2 (function() { var Command, RoomHelper, User, addCommand, afkCheck, afksCommand, allAfksCommand, announceCurate,…

Quickstart tutorial Prerequisites Before reading this tutorial you should know a bit of Python. If you would like to refresh your memory take a look at the Python tutorial. If you wish to work the examples in this tutorial you must also have some software installed on your computer. Please see https//scipy.org/install.html for instructions. Learner profile This tutorial is intended as a quick overview of algebra and arrays in NumPy and want to understand how ndimensional n>2 arrays are represented and can be manipulated. In particular if you don’t know how to apply common functions to ndimensional arrays without using forloops or if you want to understand axis and shape properties for ndimensional arrays this tutorial might be of help. Learning Objectives After this tutorial you should be able to Understand the difference between one two and ndimensional arrays in NumPy Understand how to apply some linear algebra operations to ndimensional arrays without using forloops Understand axis and shape properties for ndimensional arrays. The Basics NumPy’s main object is the homogeneous multidimensional array. It is a table of elements usually numbers all of the same type indexed by a tuple of nonnegative integers. In NumPy dimensions are called axes. For example the coordinates of a point in 3D space [1 2 1] has one axis. That axis has 3 elements in it so we say it has a length of 3. In the example pictured below the array has 2 axes. The first axis has a length of 2 the second axis has a length of 3. [[ 1. 0. 0.] [ 0. 1. 2.]] NumPy’s array class is called ndarray. It is also known by the alias array. Note that numpy.array is not the same as the Standard Python Library class array.array which only handles onedimensional arrays and offers less functionality. The more important attributes of an ndarray object are ndarray.ndim the number of axes dimensions of the array. ndarray.shape the dimensions of the array. This is a tuple of integers indicating the size of the array in each dimension. For a matrix with n rows and m columns shape will be nm. The length of the shape tuple is therefore the number of axes ndim. ndarray.size the total number of elements of the array. This is equal to the product of the elements of shape. ndarray.dtype an object describing the type of the elements in the array. One can create or specify dtype’s using standard Python types. Additionally NumPy provides types of its own. numpy.int32 numpy.int16 and numpy.float64 are some examples. ndarray.itemsize the size in bytes of each element of the array. For example an array of elements of type float64 has itemsize 8 64/8 while one of type complex32 has itemsize 4 32/8. It is equivalent to ndarray.dtype.itemsize. ndarray.data the buffer containing the actual elements of the array. Normally we won’t need to use this attribute because we will access the elements in an array using indexing facilities. An example >>> import numpy as np a np.arange15.reshape3 5 a array[[ 0 1 2 3 4] [ 5 6 7 8 9] [10 11 12 13 14]] a.shape 3 5 a.ndim 2 a.dtype.name int64 a.itemsize 8 a.size 15 typea b np.array[6 7 8] b array[6 7 8] typeb Array Creation There are several ways to create arrays. For example you can create an array from a regular Python list or tuple using the array function. The type of the resulting array is deduced from the type of the elements in the sequences. >>> >>> import numpy as np >>> a np.array[234] >>> a array[2 3 4] >>> a.dtype dtypeint64 >>> b np.array[1.2 3.5 5.1] >>> b.dtype dtypefloat64 A frequent error consists in calling array with multiple arguments rather than providing a single sequence as an argument. >>> >>> a np.array1234 WRONG Traceback most recent call last … TypeError array takes from 1 to 2 positional arguments but 4 were given >>> a np.array[1234] RIGHT array transforms sequences of sequences into twodimensional arrays sequences of sequences of sequences into threedimensional arrays and so on. >>> >>> b np.array[1.523 456] >>> b array[[1.5 2. 3. ] [4. 5. 6. ]] The type of the array can also be explicitly specified at creation time >>> >>> c np.array [ [12] [34] ] dtypecomplex >>> c array[[1.+0.j 2.+0.j] [3.+0.j 4.+0.j]] Often the elements of an array are originally unknown but its size is known. Hence NumPy offers several functions to create arrays with initial placeholder content. These minimize the necessity of growing arrays an expensive operation. The function zeros creates an array full of zeros the function ones creates an array full of ones and the function empty creates an array whose initial content is random and depends on the state of the memory. By default the dtype of the created array is float64. >>> >>> np.zeros3 4 array[[0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.]] >>> np.ones 234 dtypenp.int16 dtype can also be specified array[[[1 1 1 1] [1 1 1 1] [1 1 1 1]] [[1 1 1 1] [1 1 1 1] [1 1 1 1]]] dtypeint16 >>> np.empty 23 uninitialized array[[ 3.73603959e262 6.02658058e154 6.55490914e260] may vary [ 5.30498948e313 3.14673309e307 1.00000000e+000]] To create sequences of numbers NumPy provides the arange function which is analogous to the Python builtin range but returns an array. >>> >>> np.arange 10 30 5 array[10 15 20 25] >>> np.arange 0 2 0.3 it accepts float arguments array[0. 0.3 0.6 0.9 1.2 1.5 1.8] When arange is used with floating point arguments it is generally not possible to predict the number of elements obtained due to the finite floating point precision. For this reason it is usually better to use the function linspace that receives as an argument the number of elements that we want instead of the step >>> >>> from numpy import pi >>> np.linspace 0 2 9 9 numbers from 0 to 2 array[0. 0.25 0.5 0.75 1. 1.25 1.5 1.75 2. ] >>> x np.linspace 0 2pi 100 useful to evaluate function at lots of points >>> f np.sinx See also array zeros zeros_like ones ones_like empty empty_like arange linspace numpy.random.Generator.rand numpy.random.Generator.randn fromfunction fromfile Printing Arrays When you print an array NumPy displays it in a similar way to nested lists but with the following layout the last axis is printed from left to right the secondtolast is printed from top to bottom the rest are also printed from top to bottom with each slice separated from the next by an empty line. Onedimensional arrays are then printed as rows bidimensionals as matrices and tridimensionals as lists of matrices. >>> >>> a np.arange6 1d array >>> printa [0 1 2 3 4 5] >>> >>> b np.arange12.reshape43 2d array >>> printb [[ 0 1 2] [ 3 4 5] [ 6 7 8] [ 9 10 11]] >>> >>> c np.arange24.reshape234 3d array >>> printc [[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] [[12 13 14 15] [16 17 18 19] [20 21 22 23]]] See below to get more details on reshape. If an array is too large to be printed NumPy automatically skips the central part of the array and only prints the corners >>> >>> printnp.arange10000 [ 0 1 2 … 9997 9998 9999] >>> >>> printnp.arange10000.reshape100100 [[ 0 1 2 … 97 98 99] [ 100 101 102 … 197 198 199] [ 200 201 202 … 297 298 299] … [9700 9701 9702 … 9797 9798 9799] [9800 9801 9802 … 9897 9898 9899] [9900 9901 9902 … 9997 9998 9999]] To disable this behaviour and force NumPy to print the entire array you can change the printing options using set_printoptions. >>> >>> np.set_printoptionsthresholdsys.maxsize sys module should be imported Basic Operations Arithmetic operators on arrays apply elementwise. A new array is created and filled with the result. >>> >>> a np.array [20304050] >>> b np.arange 4 >>> b array[0 1 2 3] >>> c ab >>> c array[20 29 38 47] >>> b2 array[0 1 4 9] >>> 10np.sina array[ 9.12945251 9.88031624 7.4511316 2.62374854] >>> a3.5 or the dot function or method >>> >>> A np.array [[11] … [01]] >>> B np.array [[20] … [34]] >>> A B elementwise product array[[2 0] [0 4]] >>> A B matrix product array[[5 4] [3 4]] >>> A.dotB another matrix product array[[5 4] [3 4]] Some operations such as + and act in place to modify an existing array rather than create a new one. >>> >>> rg np.random.default_rng1 create instance of default random number generator >>> a np.ones23 dtypeint >>> b rg.random23 >>> a 3 >>> a array[[3 3 3] [3 3 3]] >>> b + a >>> b array[[3.51182162 3.9504637 3.14415961] [3.94864945 3.31183145 3.42332645]] >>> a + b b is not automatically converted to integer type Traceback most recent call last … numpy.core._exceptions.UFuncTypeError Cannot cast ufunc add output from dtypefloat64 to dtypeint64 with casting rule same_kind When operating with arrays of different types the type of the resulting array corresponds to the more general or precise one a behavior known as upcasting. >>> >>> a np.ones3 dtypenp.int32 >>> b np.linspace0pi3 >>> b.dtype.name float64 >>> c a+b >>> c array[1. 2.57079633 4.14159265] >>> c.dtype.name float64 >>> d np.expc1j >>> d array[ 0.54030231+0.84147098j 0.84147098+0.54030231j 0.540302310.84147098j] >>> d.dtype.name complex128 Many unary operations such as computing the sum of all the elements in the array are implemented as methods of the ndarray class. >>> >>> a rg.random23 >>> a array[[0.82770259 0.40919914 0.54959369] [0.02755911 0.75351311 0.53814331]] >>> a.sum 3.1057109529998157 >>> a.min 0.027559113243068367 >>> a.max 0.8277025938204418 By default these operations apply to the array as though it were a list of numbers regardless of its shape. However by specifying the axis parameter you can apply an operation along the specified axis of an array >>> >>> b np.arange12.reshape34 >>> b array[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] >>> >>> b.sumaxis0 sum of each column array[12 15 18 21] >>> >>> b.minaxis1 min of each row array[0 4 8] >>> >>> b.cumsumaxis1 cumulative sum along each row array[[ 0 1 3 6] [ 4 9 15 22] [ 8 17 27 38]] Universal Functions NumPy provides familiar mathematical functions such as sin cos and exp. In NumPy these are called “universal functions”ufunc. Within NumPy these functions operate elementwise on an array producing an array as output. >>> >>> B np.arange3 >>> B array[0 1 2] >>> np.expB array[1. 2.71828183 7.3890561 ] >>> np.sqrtB array[0. 1. 1.41421356] >>> C np.array[2. 1. 4.] >>> np.addB C array[2. 0. 6.] See also all any apply_along_axis argmax argmin argsort average bincount ceil clip conj corrcoef cov cross cumprod cumsum diff dot floor inner invert lexsort max maximum mean median min minimum nonzero outer prod re round sort std sum trace transpose var vdot vectorize where Indexing Slicing and Iterating Onedimensional arrays can be indexed sliced and iterated over much like lists and other Python sequences. >>> >>> a np.arange103 >>> a array[ 0 1 8 27 64 125 216 343 512 729] >>> a[2] 8 >>> a[25] array[ 8 27 64] equivalent to a[062] 1000 from start to position 6 exclusive set every 2nd element to 1000 >>> a[62] 1000 >>> a array[1000 1 1000 27 1000 125 216 343 512 729] >>> a[ 1] reversed a array[ 729 512 343 216 125 1000 27 1000 1 1000] >>> for i in a … printi1/3. … 9.999999999999998 1.0 9.999999999999998 3.0 9.999999999999998 4.999999999999999 5.999999999999999 6.999999999999999 7.999999999999999 8.999999999999998 Multidimensional arrays can have one index per axis. These indices are given in a tuple separated by commas >>> >>> def fxy … return 10x+y … >>> b np.fromfunctionf54dtypeint >>> b array[[ 0 1 2 3] [10 11 12 13] [20 21 22 23] [30 31 32 33] [40 41 42 43]] >>> b[23] 23 >>> b[05 1] each row in the second column of b array[ 1 11 21 31 41] >>> b[ 1] equivalent to the previous example array[ 1 11 21 31 41] >>> b[13 ] each column in the second and third row of b array[[10 11 12 13] [20 21 22 23]] When fewer indices are provided than the number of axes the missing indices are considered complete slices >>> >>> b[1] the last row. Equivalent to b[1] array[40 41 42 43] The expression within brackets in b[i] is treated as an i followed by as many instances of as needed to represent the remaining axes. NumPy also allows you to write this using dots as b[i…]. The dots … represent as many colons as needed to produce a complete indexing tuple. For example if x is an array with 5 axes then x[12…] is equivalent to x[12] x[…3] to x[3] and x[4…5] to x[45]. >>> >>> c np.array [[[ 0 1 2] a 3D array two stacked 2D arrays … [ 10 12 13]] … [[100101102] … [110112113]]] >>> c.shape 2 2 3 >>> c[1…] same as c[1] or c[1] array[[100 101 102] [110 112 113]] >>> c[…2] same as c[2] array[[ 2 13] [102 113]] Iterating over multidimensional arrays is done with respect to the first axis >>> >>> for row in b … printrow … [0 1 2 3] [10 11 12 13] [20 21 22 23] [30 31 32 33] [40 41 42 43] However if one wants to perform an operation on each element in the array one can use the flat attribute which is an iterator over all the elements of the array >>> >>> for element in b.flat … printelement … 0 1 2 3 10 11 12 13 20 21 22 23 30 31 32 33 40 41 42 43 See also Indexing Indexing reference newaxis ndenumerate indices Shape Manipulation Changing the shape of an array An array has a shape given by the number of elements along each axis >>> >>> a np.floor10rg.random34 >>> a array[[3. 7. 3. 4.] [1. 4. 2. 2.] [7. 2. 4. 9.]] >>> a.shape 3 4 The shape of an array can be changed with various commands. Note that the following three commands all return a modified array but do not change the original array >>> >>> a.ravel returns the array flattened array[3. 7. 3. 4. 1. 4. 2. 2. 7. 2. 4. 9.] >>> a.reshape62 returns the array with a modified shape array[[3. 7.] [3. 4.] [1. 4.] [2. 2.] [7. 2.] [4. 9.]] >>> a.T returns the array transposed array[[3. 1. 7.] [7. 4. 2.] [3. 2. 4.] [4. 2. 9.]] >>> a.T.shape 4 3 >>> a.shape 3 4 The order of the elements in the array resulting from ravel is normally “Cstyle” that is the rightmost index “changes the fastest” so the element after a[00] is a[01]. If the array is reshaped to some other shape again the array is treated as “Cstyle”. NumPy normally creates arrays stored in this order so ravel will usually not need to copy its argument but if the array was made by taking slices of another array or created with unusual options it may need to be copied. The functions ravel and reshape can also be instructed using an optional argument to use FORTRANstyle arrays in which the leftmost index changes the fastest. The reshape function returns its argument with a modified shape whereas the ndarray.resize method modifies the array itself >>> >>> a array[[3. 7. 3. 4.] [1. 4. 2. 2.] [7. 2. 4. 9.]] >>> a.resize26 >>> a array[[3. 7. 3. 4. 1. 4.] [2. 2. 7. 2. 4. 9.]] If a dimension is given as 1 in a reshaping operation the other dimensions are automatically calculated >>> >>> a.reshape31 array[[3. 7. 3. 4.] [1. 4. 2. 2.] [7. 2. 4. 9.]] See also ndarray.shape reshape resize ravel Stacking together different arrays Several arrays can be stacked together along different axes >>> >>> a np.floor10rg.random22 >>> a array[[9. 7.] [5. 2.]] >>> b np.floor10rg.random22 >>> b array[[1. 9.] [5. 1.]] >>> np.vstackab array[[9. 7.] [5. 2.] [1. 9.] [5. 1.]] >>> np.hstackab array[[9. 7. 1. 9.] [5. 2. 5. 1.]] The function column_stack stacks 1D arrays as columns into a 2D array. It is equivalent to hstack only for 2D arrays >>> >>> from numpy import newaxis >>> np.column_stackab with 2D arrays array[[9. 7. 1. 9.] [5. 2. 5. 1.]] >>> a np.array[4.2.] >>> b np.array[3.8.] >>> np.column_stackab returns a 2D array array[[4. 3.] [2. 8.]] >>> np.hstackab the result is different array[4. 2. 3. 8.] >>> a[newaxis] view `a` as a 2D column vector array[[4.] [2.]] >>> np.column_stacka[newaxis]b[newaxis] array[[4. 3.] [2. 8.]] >>> np.hstacka[newaxis]b[newaxis] the result is the same array[[4. 3.] [2. 8.]] On the other hand the function row_stack is equivalent to vstack for any input arrays. In fact row_stack is an alias for vstack >>> >>> np.column_stack is np.hstack False >>> np.row_stack is np.vstack True In general for arrays with more than two dimensions hstack stacks along their second axes vstack stacks along their first axes and concatenate allows for an optional arguments giving the number of the axis along which the concatenation should happen. Note In complex cases r_ and c_ are useful for creating arrays by stacking numbers along one axis. They allow the use of range literals “” >>> >>> np.r_[1404] array[1 2 3 0 4] When used with arrays as arguments r_ and c_ are similar to vstack and hstack in their default behavior but allow for an optional argument giving the number of the axis along which to concatenate. See also hstack vstack column_stack concatenate c_ r_ Splitting one array into several smaller ones Using hsplit you can split an array along its horizontal axis either by specifying the number of equally shaped arrays to return or by specifying the columns after which the division should occur >>> >>> a np.floor10rg.random212 >>> a array[[6. 7. 6. 9. 0. 5. 4. 0. 6. 8. 5. 2.] [8. 5. 5. 7. 1. 8. 6. 7. 1. 8. 1. 0.]] Split a into 3 >>> np.hsplita3 [array[[6. 7. 6. 9.] [8. 5. 5. 7.]] array[[0. 5. 4. 0.] [1. 8. 6. 7.]] array[[6. 8. 5. 2.] [1. 8. 1. 0.]]] Split a after the third and the fourth column >>> np.hsplita34 [array[[6. 7. 6.] [8. 5. 5.]] array[[9.] [7.]] array[[0. 5. 4. 0. 6. 8. 5. 2.] [1. 8. 6. 7. 1. 8. 1. 0.]]] vsplit splits along the vertical axis and array_split allows one to specify along which axis to split. Copies and Views When operating and manipulating arrays their data is sometimes copied into a new array and sometimes not. This is often a source of confusion for beginners. There are three cases No Copy at All Simple assignments make no copy of objects or their data. >>> >>> a np.array[[ 0 1 2 3] … [ 4 5 6 7] … [ 8 9 10 11]] >>> b a no new object is created >>> b is a a and b are two names for the same ndarray object True Python passes mutable objects as references so function calls make no copy. >>> >>> def fx … printidx … >>> ida id is a unique identifier of an object 148293216 may vary >>> fa 148293216 may vary View or Shallow Copy Different array objects can share the same data. The view method creates a new array object that looks at the same data. >>> >>> c a.view >>> c is a False >>> c.base is a c is a view of the data owned by a True >>> c.flags.owndata False >>> >>> c c.reshape2 6 as shape doesnt change >>> a.shape 3 4 >>> c[0 4] 1234 as data changes >>> a array[[ 0 1 2 3] [1234 5 6 7] [ 8 9 10 11]] Slicing an array returns a view of it >>> >>> s a[ 13] spaces added for clarity could also be written “s a[ 13]” >>> s[] 10 s[] is a view of s. Note the difference between s 10 and s[] 10 >>> a array[[ 0 10 10 3] [1234 10 10 7] [ 8 10 10 11]] Deep Copy The copy method makes a complete copy of the array and its data. >>> >>> d a.copy a new array object with new data is created >>> d is a False >>> d.base is a d doesnt share anything with a False >>> d[00] 9999 >>> a array[[ 0 10 10 3] [1234 10 10 7] [ 8 10 10 11]] Sometimes copy should be called after slicing if the original array is not required anymore. For example suppose a is a huge intermediate result and the final result b only contains a small fraction of a a deep copy should be made when constructing b with slicing >>> >>> a np.arangeint1e8 >>> b a[100].copy >>> del a the memory of “a“ can be released. If b a[100] is used instead a is referenced by b and will persist in memory even if del a is executed. Functions and Methods Overview Here is a list of some useful NumPy functions and methods names ordered in categories. See Routines for the full list. Array Creation arange array copy empty empty_like eye fromfile fromfunction identity linspace logspace mgrid ogrid ones ones_like r_ zeros zeros_like Conversions ndarray.astype atleast_1d atleast_2d atleast_3d mat Manipulations array_split column_stack concatenate diagonal dsplit dstack hsplit hstack ndarray.item newaxis ravel repeat reshape resize squeeze swapaxes take transpose vsplit vstack Questions all any nonzero where Ordering argmax argmin argsort max min ptp searchsorted sort Operations choose compress cumprod cumsum inner ndarray.fill imag prod put putmask real sum Basic Statistics cov mean std var Basic Linear Algebra cross dot outer linalg.svd vdot Less Basic Broadcasting rules Broadcasting allows universal functions to deal in a meaningful way with inputs that do not have exactly the same shape. The first rule of broadcasting is that if all input arrays do not have the same number of dimensions a “1” will be repeatedly prepended to the shapes of the smaller arrays until all the arrays have the same number of dimensions. The second rule of broadcasting ensures that arrays with a size of 1 along a particular dimension act as if they had the size of the array with the largest shape along that dimension. The value of the array element is assumed to be the same along that dimension for the “broadcast” array. After application of the broadcasting rules the sizes of all arrays must match. More details can be found in Broadcasting. Advanced indexing and index tricks NumPy offers more indexing facilities than regular Python sequences. In addition to indexing by integers and slices as we saw before arrays can be indexed by arrays of integers and arrays of booleans. Indexing with Arrays of Indices >>> >>> a np.arange122 the first 12 square numbers >>> i np.array[1 1 3 8 5] an array of indices >>> a[i] the elements of a at the positions i array[ 1 1 9 64 25] >>> >>> j np.array[[3 4] [9 7]] a bidimensional array of indices >>> a[j] the same shape as j array[[ 9 16] [81 49]] When the indexed array a is multidimensional a single array of indices refers to the first dimension of a. The following example shows this behavior by converting an image of labels into a color image using a palette. >>> >>> palette np.array[[0 0 0] black … [255 0 0] red … [0 255 0] green … [0 0 255] blue … [255 255 255]] white >>> image np.array[[0 1 2 0] each value corresponds to a color in the palette … [0 3 4 0]] >>> palette[image] the 2 4 3 color image array[[[ 0 0 0] [255 0 0] [ 0 255 0] [ 0 0 0]] [[ 0 0 0] [ 0 0 255] [255 255 255] [ 0 0 0]]] We can also give indexes for more than one dimension. The arrays of indices for each dimension must have the same shape. >>> >>> a np.arange12.reshape34 >>> a array[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] >>> i np.array[[0 1] indices for the first dim of a … [1 2]] >>> j np.array[[2 1] indices for the second dim … [3 3]] >>> >>> a[i j] i and j must have equal shape array[[ 2 5] [ 7 11]] >>> >>> a[i 2] array[[ 2 6] [ 6 10]] >>> >>> a[ j] i.e. a[ j] array[[[ 2 1] [ 3 3]] [[ 6 5] [ 7 7]] [[10 9] [11 11]]] In Python arr[i j] is exactly the same as arr[i j]—so we can put i and j in a tuple and then do the indexing with that. >>> >>> l i j equivalent to a[i j] >>> a[l] array[[ 2 5] [ 7 11]] However we can not do this by putting i and j into an array because this array will be interpreted as indexing the first dimension of a. >>> >>> s np.array[i j] not what we want >>> a[s] Traceback most recent call last File “” line 1 in IndexError index 3 is out of bounds for axis 0 with size 3 same as a[i j] >>> a[tuples] array[[ 2 5] [ 7 11]] Another common use of indexing with arrays is the search of the maximum value of timedependent series >>> >>> time np.linspace20 145 5 time scale >>> data np.sinnp.arange20.reshape54 4 timedependent series >>> time array[ 20. 51.25 82.5 113.75 145. ] >>> data array[[ 0. 0.84147098 0.90929743 0.14112001] [0.7568025 0.95892427 0.2794155 0.6569866 ] [ 0.98935825 0.41211849 0.54402111 0.99999021] [0.53657292 0.42016704 0.99060736 0.65028784] [0.28790332 0.96139749 0.75098725 0.14987721]] index of the maxima for each series >>> ind data.argmaxaxis0 >>> ind array[2 0 3 1] times corresponding to the maxima >>> time_max time[ind] >>> >>> data_max data[ind rangedata.shape[1]] > data[ind[0]0] data[ind[1]1]… >>> time_max array[ 82.5 20. 113.75 51.25] >>> data_max array[0.98935825 0.84147098 0.99060736 0.6569866 ] >>> np.alldata_max data.maxaxis0 True You can also use indexing with arrays as a target to assign to >>> >>> a np.arange5 >>> a array[0 1 2 3 4] >>> a[[134]] 0 >>> a array[0 0 2 0 0] However when the list of indices contains repetitions the assignment is done several times leaving behind the last value >>> >>> a np.arange5 >>> a[[002]][123] >>> a array[2 1 3 3 4] This is reasonable enough but watch out if you want to use Python’s + construct as it may not do what you expect >>> >>> a np.arange5 >>> a[[002]]+1 >>> a array[1 1 3 3 4] Even though 0 occurs twice in the list of indices the 0th element is only incremented once. This is because Python requires “a+1” to be equivalent to “a a + 1”. Indexing with Boolean Arrays When we index arrays with arrays of integer indices we are providing the list of indices to pick. With boolean indices the approach is different we explicitly choose which items in the array we want and which ones we don’t. The most natural way one can think of for boolean indexing is to use boolean arrays that have the same shape as the original array >>> >>> a np.arange12.reshape34 >>> b a > 4 >>> b b is a boolean with as shape array[[False False False False] [False True True True] [ True True True True]] >>> a[b] 1d array with the selected elements array[ 5 6 7 8 9 10 11] This property can be very useful in assignments >>> >>> a[b] 0 All elements of a higher than 4 become 0 >>> a array[[0 1 2 3] [4 0 0 0] [0 0 0 0]] You can look at the following example to see how to use boolean indexing to generate an image of the Mandelbrot set >>> import numpy as np import matplotlib.pyplot as plt def mandelbrot hw maxit20 “””Returns an image of the Mandelbrot fractal of size hw.””” yx np.ogrid[ 1.41.4h1j 20.8w1j ] c x+y1j z c divtime maxit + np.zerosz.shape dtypeint for i in rangemaxit z z2 + c diverge znp.conjz > 22 who is diverging div_now diverge divtimemaxit who is diverging now divtime[div_now] i note when z[diverge] 2 avoid diverging too much return divtime plt.imshowmandelbrot400400 ../_images/quickstart1.png The second way of indexing with booleans is more similar to integer indexing for each dimension of the array we give a 1D boolean array selecting the slices we want >>> >>> a np.arange12.reshape34 >>> b1 np.array[FalseTrueTrue] first dim selection >>> b2 np.array[TrueFalseTrueFalse] second dim selection >>> >>> a[b1] selecting rows array[[ 4 5 6 7] [ 8 9 10 11]] >>> >>> a[b1] same thing array[[ 4 5 6 7] [ 8 9 10 11]] >>> >>> a[b2] selecting columns array[[ 0 2] [ 4 6] [ 8 10]] >>> >>> a[b1b2] a weird thing to do array[ 4 10] Note that the length of the 1D boolean array must coincide with the length of the dimension or axis you want to slice. In the previous example b1 has length 3 the number of rows in a and b2 of length 4 is suitable to index the 2nd axis columns of a. The ix_ function The ix_ function can be used to combine different vectors so as to obtain the result for each nuplet. For example if you want to compute all the a+bc for all the triplets taken from each of the vectors a b and c >>> >>> a np.array[2345] >>> b np.array[854] >>> c np.array[54683] >>> axbxcx np.ix_abc >>> ax array[[[2]] [[3]] [[4]] [[5]]] >>> bx array[[[8] [5] [4]]] >>> cx array[[[5 4 6 8 3]]] >>> ax.shape bx.shape cx.shape 4 1 1 1 3 1 1 1 5 >>> result ax+bxcx >>> result array[[[42 34 50 66 26] [27 22 32 42 17] [22 18 26 34 14]] [[43 35 51 67 27] [28 23 33 43 18] [23 19 27 35 15]] [[44 36 52 68 28] [29 24 34 44 19] [24 20 28 36 16]] [[45 37 53 69 29] [30 25 35 45 20] [25 21 29 37 17]]] >>> result[324] 17 >>> a[3]+b[2]c[4] 17 You could also implement the reduce as follows >>> >>> def ufunc_reduceufct vectors … vs np.ix_vectors … r ufct.identity … for v in vs … r ufctrv … return r and then use it as >>> >>> ufunc_reducenp.addabc array[[[15 14 16 18 13] [12 11 13 15 10] [11 10 12 14 9]] [[16 15 17 19 14] [13 12 14 16 11] [12 11 13 15 10]] [[17 16 18 20 15] [14 13 15 17 12] [13 12 14 16 11]] [[18 17 19 21 16] [15 14 16 18 13] [14 13 15 17 12]]] The advantage of this version of reduce compared to the normal ufunc.reduce is that it makes use of the Broadcasting Rules in order to avoid creating an argument array the size of the output times the number of vectors. Indexing with strings See Structured arrays. Linear Algebra Work in progress. Basic linear algebra to be included here. Simple Array Operations See linalg.py in numpy folder for more. >>> >>> import numpy as np >>> a np.array[[1.0 2.0] [3.0 4.0]] >>> printa [[1. 2.] [3. 4.]] >>> a.transpose array[[1. 3.] [2. 4.]] >>> np.linalg.inva array[[2. 1. ] [ 1.5 0.5]] >>> u np.eye2 unit 2×2 matrix “eye” represents “I” >>> u array[[1. 0.] [0. 1.]] >>> j np.array[[0.0 1.0] [1.0 0.0]] >>> j j matrix product array[[1. 0.] [ 0. 1.]] >>> np.traceu trace 2.0 >>> y np.array[[5.] [7.]] >>> np.linalg.solvea y array[[3.] [ 4.]] >>> np.linalg.eigj array[0.+1.j 0.1.j] array[[0.70710678+0.j 0.707106780.j ] [0. 0.70710678j 0. +0.70710678j]] Parameters square matrix Returns The eigenvalues each repeated according to its multiplicity. The normalized unit “length” eigenvectors such that the column “v[i]“ is the eigenvector corresponding to the eigenvalue “w[i]“ . Tricks and Tips Here we give a list of short and useful tips. “Automatic” Reshaping To change the dimensions of an array you can omit one of the sizes which will then be deduced automatically >>> >>> a np.arange30 >>> b a.reshape2 1 3 1 means “whatever is needed” >>> b.shape 2 5 3 >>> b array[[[ 0 1 2] [ 3 4 5] [ 6 7 8] [ 9 10 11] [12 13 14]] [[15 16 17] [18 19 20] [21 22 23] [24 25 26] [27 28 29]]] Vector Stacking How do we construct a 2D array from a list of equallysized row vectors? In MATLAB this is quite easy if x and y are two vectors of the same length you only need do m[xy]. In NumPy this works via the functions column_stack dstack hstack and vstack depending on the dimension in which the stacking is to be done. For example >>> >>> x np.arange0102 >>> y np.arange5 >>> m np.vstack[xy] >>> m array[[0 2 4 6 8] [0 1 2 3 4]] >>> xy np.hstack[xy] >>> xy array[0 2 4 6 8 0 1 2 3 4] The logic behind those functions in more than two dimensions can be strange. See also NumPy for Matlab users Histograms The NumPy histogram function applied to an array returns a pair of vectors the histogram of the array and a vector of the bin edges. Beware matplotlib also has a function to build histograms called hist as in Matlab that differs from the one in NumPy. The main difference is that pylab.hist plots the histogram automatically while numpy.histogram only generates the data. >>> import numpy as np rg np.random.default_rng1 import matplotlib.pyplot as plt Build a vector of 10000 normal deviates with variance 0.52 and mean 2 mu sigma 2 0.5 v rg.normalmusigma10000 Plot a normalized histogram with 50 bins plt.histv bins50 density1 matplotlib version plot Compute the histogram with numpy and then plot it n bins np.histogramv bins50 densityTrue NumPy version no plot plt.plot.5bins[1]+bins[1] n ../_images/quickstart2.png Further reading The Python tutorial NumPy Reference SciPy Tutorial SciPy Lecture Notes A matlab R IDL NumPy/SciPy dictionary © Copyright 20082020 The SciPy community. Last updated on Jun 29 2020. Created using Sphinx 2.4.4. AryiaBehroziuan Full Script Code

Quickstart tutorial Prerequisites Before reading this tutorial you should know a bit of Python. If you…