diff --git a/.gitignore b/.gitignore index 7c6571e..b288759 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ venv *.pyc +.env +.venv diff --git a/blurbs.py b/blurbs.py index b6a4532..a182cf8 100644 --- a/blurbs.py +++ b/blurbs.py @@ -2,39 +2,39 @@ def pick_blurb(row, col): -#This file returns the specific ds blurb needed for the results page + # This file returns the specific ds blurb needed for the results page - blurbs = [ #'Data Businessperson', 'Data Creative', 'Data Researcher', 'Data Engineer'] - [ #Programming - u"""You're a relatively rare breed -- a Data Businessperson who specializes in software development. How did you get here? Perhaps you started writing code, than realized your passion for entrepeneurship or consulting. You probably realized earlier than others around you the value of the data in your organization's relational databases, and the value of systems that extract and organize that data. Over the years, you've seen fads come and go, and aren't convinced this "Data Science" label is going to stick. Focus on your strengths -- leading teams that build systems and products that allow deep insights to be extracted from data. But you might spend some effort to broaden your knowledge of data visualization and statistics, so you can sell your work in an even more compelling way.""", - u"""Most Data Creatives can write programs, but that's your core skill. You live and breathe web services, databases, and Javascript. You've embraced the culture of Open Source, and may have contributed code (or data) yourself. But Data Science appeals to you, in its diversity of approaches and its enthusiastic embrace of exploration and problem-solving with data. Focus on your strengths -- building complete systems that integrate data, analytic components, and compelling visualizations. To broaden your appeal, and differentiate yourself from the software development masses, work with statistics and machine learning tools and techniques.""", - u"""Being a Data Researcher with core skills in Programming is an unusual combination and also a valuable one. You know that the key to solving problems efficiently and repeatably is to write code, and that an insight from data is most useful if it can be used as part of a software system. One-off solutions are for academics. You think about problems differently from Data Engineers, with a deeper level of domain expertise and a more scientific approach to problem solving. To focus on your strengths, make sure you're accomplished in the full technology stack, from databases to web-based front-end development. But by working on systems that integrate massive datasets and analytical components, and thinking creatively about how to solve problems with a statistical flavor, you'll have the unique combination of breadth and depth that gets results.""", - u"""Most Data Engineers can write code, but that's your core skill. You live and breathe databases and software development. You've embraced the culture of Open Source, and so the open, eclectic culture of Data Science appeals to you. You'd probably like to do more with Big Data and with the exploration of unstructured data sets. So focus on your strengths -- building complete systems that integrate massive datasets and analytical components. As an engineer pushing for smarter uses of data, you'll be a hero to the business side of things. To broaden your skills, consider working with some of the new Business Intelligence and Predictive Analytics as a Service tools, and learning best practices for data visualization and interpretation.""" - ], - [ #Stats, - u"""As a Data Businessperson who specializes in Statistics, you might be a quantitative marketer who uses survey research, data analysis, and visualization to help organizations better sell their products or services. Compared with other Data Scientists, you're probably more focused on the bottom line and the customer, and less focused on technology trends or the new buzzwords. But you're an important driving force behind organizational culture changes, pushing for data-driven decision making and thoughtful action. You're more likely than others in this field to be female, to have an MBA, to have managed employees or worked for yourself. Focus on your strengths -- communication about data and the value of data, asking the right questions, and being honest with the results. But it may be valuable to develop your programming skills and to learn more about the broader world of analytics, so that you can dive more deeply into problems on your own.""", - u"""As a Data Creative with core skills in Statistics, you can talk the talk as well as walk the walk. It's not enough to analyze the data with rigor, you have to be able to communicate the results, whether in person or via compelling visualizations. You may have some graduate work in a scientific field, a compelling background for working with organizational data. But your real skills were in getting stuff done using any tool that's handy, whether it's sucking data from web services, building a complex regression model, or quickly learning a new technique or new problem domain. Focus on those strengths -- modeling data from any source, thinking scientifically about problems, and effectively conveying to others what you find. But think about ways to integrate your results into processes or systems more effectively -- an insight that doesn't help others make decisions isn't very valuable.""", - u"""Many Data Researchers specialize in Statistics skills, and you're no exception. If you don't think of yourself as a Data Scientist, it's probably because you feel like the term is just a rebranding of "Applied Statistician." Regardless, you have the valuable skill to think scientifically about a broad range of problems, and to apply the tools of statistics and the scientific method to data of all sorts. You can solve complex problems, communicate the results effectively, and build complex models of the world an organization finds itself in. Focus on your strengths -- cutting edge analytical tools, especially those that work on very large or unstructured data, and your statistically sophisticated way of thinking about problems. But your effectiveness could be even stronger with more breadth, be it in machine learning approaches, or programming skills, or experience in business environments.""", - u"""As the rarest type of Data Engineer, with core skills in Statistics, you know that it's not enough to analyze the data, or build a toy model; you have to be able to put your insights into practice. Your educational background -- likely graduate work in a scientific field -- gives you the tools that you need to speak with authority about a problem, while your grounded experience gives you the broad set of tools of a Data Scientist, even if you may not care for the term. So focus on your core strengths of data analysis, visualization, and communication, while continuing to better understand your problem domain and how to better answer the most important questions. It never hurts to develop better programming or business skills either -- all the better for getting things done the right way.""" - ], - [ #Math/OR - u"""As a Data Businessperson with Math, Algorithms or Operations Research talents, you may be coming at Data Science from a different perspective than a lot of your peers -- you probably haven't embraced the new buzzwords. But you've as committed as anyone to the value of rigorous analysis around organizational data, and to the importance of making optimal use of that data. You're more likely to be female than many other types of Data Scientists, although it's definitely a male-dominated community. Focus on your strengths -- problem solving, thinking outside the box, working in teams to get amazing results. But it's worth keeping current in other areas -- consider learning more about Big Data technology, or picking up some new statistical techniques. """, - u"""Most Data Creatives have broad skillsets, but you specialized in the hard stuff -- Math or Algorithms or Operations Research. But perhaps you've pivoted away from an academic focus to solve organizational problems. As a Jack of All Trades, you may be focused on the value of Open Data, or the insights derivable from integrating data from multiple sources. But your background keeps you practical and rigorous, and that's a strength. Focus on your strengths -- problem solving and thinking about and optimizing complex systems. But keep your programming skills sharp. If you can build and demonstrate a complete system, from database to visualization, your sophisticated approach to the data becomes that much more unique and valuable.""", - u"""As a Data Researcher who specializes in Machine Learning or Big Data, you're almost the quintessential Data Scientist! In fact, of all the types of Data Scientist, you're the most likely to embrace the label. Your years of education, likely in Computer Science, give you an unparalleled ability to work creatively with the newest technologies and the biggest data. You can pull insights from data sets from Hadoop to Twitter and back again. Your weakness is probably on the business side, and you should probably develop both domain expertise and the "soft skills" of understanding business problems to maximize your value. But focus on your strengths -- working on the cutting-edge of machine learning and Big Data.""", - u"""You have a more quantitative background than most Data Engineers, with likely graduate work in Math or Computer Science or Operations Research. You may not consider yourself a Data Scientist, but you're as committed as anyone to the value of rigorous analysis around organizational data, and to the importance of making optimal use of that data. You are focused on building products that put your hard-won insights into use, making a real difference. To focus on your strengths, try learning more about different approaches to applying numerical tools to business problems, so you can work on a broader range of tasks. But keep your development and business skills broad enough that you can at least prototype and make the case for a full system on your own. """ - ], - [ #business - u"""Like many business men and women, your primary skill set is Business -- starting business initiatives, getting projects done, managing people, and constructing Powerpoints while never taking your eyes off of the bottom line. But, you don’t think like most MBAs. Your background, perhaps in Engineering, gives you an edge when building Data Science products. You've worked with data on a daily basis, possibly for several decades. But you're probably skeptical of the Data Scientist label. You prefer "Leader." Focus on your strengths -- telling stories with data, managing technical teams, building data-driven cultures, starting data businesses. But don't neglect your technical and data-related skills -- what sets you apart is your ability to work with and understand data yourself, not just manage others.""", - u"""Your top skills may be managing people and projects, but you identify as a Jack of All Trades, Hacker, or Artist. Perhaps you're the young turk in your organization, pulling creative data sources into decision-making, using your programming skills to subvert the usual channels. You may not call yourself a Data Scientist, but you've embraced the eclecticism and the new culture of data. If you haven't already, you may be thinking of starting a business or entering into consulting. That's a good idea, but focus on your strengths -- getting things done, finding creative solutions to problems, and working with smart people. If you want to broaden your skills, there are enormous opportunities to learn more about Big Data, Machine Learning, and Statistics, and to bring those skills into your daily work.""", - u"""A Data Researcher with core skills in Business? Did you sell out? No, you just realized that your years in academia made you extraordinarily qualified outside the Ivory Tower and making a bit more money is never a bad thing. You can solve complex problems, communicate complex results clearly, and build sophisticated models of the world in which an organization finds itself. Bringing a data-driven way of thinking to sclerotic organizations is a skill, a skill that you have, and you understand its worth. So focus on your strengths -- thinking creatively about data and systems, and using rigorous methods to solve business problems. And broaden your skill set by keeping familiar with the full set of data management and analysis tools available. You never know when you'll be asked to dive into a totally new type of problem.""", - u"""You may view yourself as a Data Engineer, but you now spend as much time worrying about people and budgets as you do about database design or systems integration. You're doubtless good at your job -- you probably have graduate work in engineering or business, or both. You seriously understand the effort required to build a data system for an enterprise and, with your technical background, you also understand the incredible opportunity afforded by big data and predictive analytics (which is why you're here). So focus on your strengths -- thinking through complex design problems, weighing pros and cons, and leading technical people. But keep up-to-date on the statistical and machine learning stuff -- you want to be able to integrate valuable new tools as soon as they become available.""" - ], - [ #ML/Big Data - u"""You're on the cutting edge of Data Businesspeople, diving into Big Data and its implications for organizations. You may have started a data-centric business, turning Terabytes into dollars and using the skills you learned in school as well as the practical expertise you've developed in the workplace. Compared with other Data Businesspeople, you're more likely to have embraced the Data Scientist label. Focus on your strengths -- working with Big Data and building analytical systems that deliver amazing value--but don't get lost in the code -- you need to be able to talk both business and math.""", - u"""As a Data Creative with Machine Learning and Big Data skills, you are the ultimate hacker. You understand the culture of Open Source, and may have contributed code (or data) yourself. You can pull data from anything -- a web service, a Hadoop cluster, or Twitter -- and build an amazing visualization or predictive tool. You may have done graduate work in a technical field, but you more likely identify as a Data Scientist than whatever's on your diploma. Focus on your strengths -- your ability to pick up any tool in the shed and bend it to your will, your ability to wow with your productivity, and your enthusiasm about data. But be open to other cultures around data -- statisticians, businesspeople, and engineers may bring valuable perspectives and collaborations.""", - u"""As a Data Researcher who specializes in Machine Learning or Big Data, you're almost the quintessential Data Scientist! In fact, of all the types of Data Scientist, you're the most likely to embrace the label. Your years of education, likely in Computer Science, give you an unparalleled ability to work creatively with the newest technologies and the biggest data. You can pull insights from data sets from Hadoop to Twitter and back again. Your weakness is probably on the business side, and you should probably develop both domain expertise and the "soft skills" of understanding business problems to maximize your value. But focus on your strengths -- working on the cutting-edge of machine learning and Big Data.""", - u"""As a Data Engineer with Machine Learning and Big Data skills, you're at the cutting edge of both technology and the culture around it. More than most other types of Data Scientist, you've embraced Open Source and the Big Data and Data Science buzzwords, and have skills to back it up. You have probably done graduate work, perhaps in an engineering field, and probably have worked with Terabyte-scale data sets. You're probably not a manager, and you're among the least likely type of Data Scientist to be female or to have started a business. To focus on your strengths, keep on the cutting edge of tools for managing enormous data sets. But to broaden your appeal, consider learning more ways of extracting insights, like text analytics or data visualization. """ - ] - ] + blurbs = [ #'Data Businessperson', 'Data Creative', 'Data Researcher', 'Data Engineer'] + [ # Programming + """You're a relatively rare breed -- a Data Businessperson who specializes in software development. How did you get here? Perhaps you started writing code, than realized your passion for entrepeneurship or consulting. You probably realized earlier than others around you the value of the data in your organization's relational databases, and the value of systems that extract and organize that data. Over the years, you've seen fads come and go, and aren't convinced this "Data Science" label is going to stick. Focus on your strengths -- leading teams that build systems and products that allow deep insights to be extracted from data. But you might spend some effort to broaden your knowledge of data visualization and statistics, so you can sell your work in an even more compelling way.""", + """Most Data Creatives can write programs, but that's your core skill. You live and breathe web services, databases, and Javascript. You've embraced the culture of Open Source, and may have contributed code (or data) yourself. But Data Science appeals to you, in its diversity of approaches and its enthusiastic embrace of exploration and problem-solving with data. Focus on your strengths -- building complete systems that integrate data, analytic components, and compelling visualizations. To broaden your appeal, and differentiate yourself from the software development masses, work with statistics and machine learning tools and techniques.""", + """Being a Data Researcher with core skills in Programming is an unusual combination and also a valuable one. You know that the key to solving problems efficiently and repeatably is to write code, and that an insight from data is most useful if it can be used as part of a software system. One-off solutions are for academics. You think about problems differently from Data Engineers, with a deeper level of domain expertise and a more scientific approach to problem solving. To focus on your strengths, make sure you're accomplished in the full technology stack, from databases to web-based front-end development. But by working on systems that integrate massive datasets and analytical components, and thinking creatively about how to solve problems with a statistical flavor, you'll have the unique combination of breadth and depth that gets results.""", + """Most Data Engineers can write code, but that's your core skill. You live and breathe databases and software development. You've embraced the culture of Open Source, and so the open, eclectic culture of Data Science appeals to you. You'd probably like to do more with Big Data and with the exploration of unstructured data sets. So focus on your strengths -- building complete systems that integrate massive datasets and analytical components. As an engineer pushing for smarter uses of data, you'll be a hero to the business side of things. To broaden your skills, consider working with some of the new Business Intelligence and Predictive Analytics as a Service tools, and learning best practices for data visualization and interpretation.""", + ], + [ # Stats, + """As a Data Businessperson who specializes in Statistics, you might be a quantitative marketer who uses survey research, data analysis, and visualization to help organizations better sell their products or services. Compared with other Data Scientists, you're probably more focused on the bottom line and the customer, and less focused on technology trends or the new buzzwords. But you're an important driving force behind organizational culture changes, pushing for data-driven decision making and thoughtful action. You're more likely than others in this field to be female, to have an MBA, to have managed employees or worked for yourself. Focus on your strengths -- communication about data and the value of data, asking the right questions, and being honest with the results. But it may be valuable to develop your programming skills and to learn more about the broader world of analytics, so that you can dive more deeply into problems on your own.""", + """As a Data Creative with core skills in Statistics, you can talk the talk as well as walk the walk. It's not enough to analyze the data with rigor, you have to be able to communicate the results, whether in person or via compelling visualizations. You may have some graduate work in a scientific field, a compelling background for working with organizational data. But your real skills were in getting stuff done using any tool that's handy, whether it's sucking data from web services, building a complex regression model, or quickly learning a new technique or new problem domain. Focus on those strengths -- modeling data from any source, thinking scientifically about problems, and effectively conveying to others what you find. But think about ways to integrate your results into processes or systems more effectively -- an insight that doesn't help others make decisions isn't very valuable.""", + """Many Data Researchers specialize in Statistics skills, and you're no exception. If you don't think of yourself as a Data Scientist, it's probably because you feel like the term is just a rebranding of "Applied Statistician." Regardless, you have the valuable skill to think scientifically about a broad range of problems, and to apply the tools of statistics and the scientific method to data of all sorts. You can solve complex problems, communicate the results effectively, and build complex models of the world an organization finds itself in. Focus on your strengths -- cutting edge analytical tools, especially those that work on very large or unstructured data, and your statistically sophisticated way of thinking about problems. But your effectiveness could be even stronger with more breadth, be it in machine learning approaches, or programming skills, or experience in business environments.""", + """As the rarest type of Data Engineer, with core skills in Statistics, you know that it's not enough to analyze the data, or build a toy model; you have to be able to put your insights into practice. Your educational background -- likely graduate work in a scientific field -- gives you the tools that you need to speak with authority about a problem, while your grounded experience gives you the broad set of tools of a Data Scientist, even if you may not care for the term. So focus on your core strengths of data analysis, visualization, and communication, while continuing to better understand your problem domain and how to better answer the most important questions. It never hurts to develop better programming or business skills either -- all the better for getting things done the right way.""", + ], + [ # Math/OR + """As a Data Businessperson with Math, Algorithms or Operations Research talents, you may be coming at Data Science from a different perspective than a lot of your peers -- you probably haven't embraced the new buzzwords. But you've as committed as anyone to the value of rigorous analysis around organizational data, and to the importance of making optimal use of that data. You're more likely to be female than many other types of Data Scientists, although it's definitely a male-dominated community. Focus on your strengths -- problem solving, thinking outside the box, working in teams to get amazing results. But it's worth keeping current in other areas -- consider learning more about Big Data technology, or picking up some new statistical techniques. """, + """Most Data Creatives have broad skillsets, but you specialized in the hard stuff -- Math or Algorithms or Operations Research. But perhaps you've pivoted away from an academic focus to solve organizational problems. As a Jack of All Trades, you may be focused on the value of Open Data, or the insights derivable from integrating data from multiple sources. But your background keeps you practical and rigorous, and that's a strength. Focus on your strengths -- problem solving and thinking about and optimizing complex systems. But keep your programming skills sharp. If you can build and demonstrate a complete system, from database to visualization, your sophisticated approach to the data becomes that much more unique and valuable.""", + """As a Data Researcher who specializes in Machine Learning or Big Data, you're almost the quintessential Data Scientist! In fact, of all the types of Data Scientist, you're the most likely to embrace the label. Your years of education, likely in Computer Science, give you an unparalleled ability to work creatively with the newest technologies and the biggest data. You can pull insights from data sets from Hadoop to Twitter and back again. Your weakness is probably on the business side, and you should probably develop both domain expertise and the "soft skills" of understanding business problems to maximize your value. But focus on your strengths -- working on the cutting-edge of machine learning and Big Data.""", + """You have a more quantitative background than most Data Engineers, with likely graduate work in Math or Computer Science or Operations Research. You may not consider yourself a Data Scientist, but you're as committed as anyone to the value of rigorous analysis around organizational data, and to the importance of making optimal use of that data. You are focused on building products that put your hard-won insights into use, making a real difference. To focus on your strengths, try learning more about different approaches to applying numerical tools to business problems, so you can work on a broader range of tasks. But keep your development and business skills broad enough that you can at least prototype and make the case for a full system on your own. """, + ], + [ # business + """Like many business men and women, your primary skill set is Business -- starting business initiatives, getting projects done, managing people, and constructing Powerpoints while never taking your eyes off of the bottom line. But, you don’t think like most MBAs. Your background, perhaps in Engineering, gives you an edge when building Data Science products. You've worked with data on a daily basis, possibly for several decades. But you're probably skeptical of the Data Scientist label. You prefer "Leader." Focus on your strengths -- telling stories with data, managing technical teams, building data-driven cultures, starting data businesses. But don't neglect your technical and data-related skills -- what sets you apart is your ability to work with and understand data yourself, not just manage others.""", + """Your top skills may be managing people and projects, but you identify as a Jack of All Trades, Hacker, or Artist. Perhaps you're the young turk in your organization, pulling creative data sources into decision-making, using your programming skills to subvert the usual channels. You may not call yourself a Data Scientist, but you've embraced the eclecticism and the new culture of data. If you haven't already, you may be thinking of starting a business or entering into consulting. That's a good idea, but focus on your strengths -- getting things done, finding creative solutions to problems, and working with smart people. If you want to broaden your skills, there are enormous opportunities to learn more about Big Data, Machine Learning, and Statistics, and to bring those skills into your daily work.""", + """A Data Researcher with core skills in Business? Did you sell out? No, you just realized that your years in academia made you extraordinarily qualified outside the Ivory Tower and making a bit more money is never a bad thing. You can solve complex problems, communicate complex results clearly, and build sophisticated models of the world in which an organization finds itself. Bringing a data-driven way of thinking to sclerotic organizations is a skill, a skill that you have, and you understand its worth. So focus on your strengths -- thinking creatively about data and systems, and using rigorous methods to solve business problems. And broaden your skill set by keeping familiar with the full set of data management and analysis tools available. You never know when you'll be asked to dive into a totally new type of problem.""", + """You may view yourself as a Data Engineer, but you now spend as much time worrying about people and budgets as you do about database design or systems integration. You're doubtless good at your job -- you probably have graduate work in engineering or business, or both. You seriously understand the effort required to build a data system for an enterprise and, with your technical background, you also understand the incredible opportunity afforded by big data and predictive analytics (which is why you're here). So focus on your strengths -- thinking through complex design problems, weighing pros and cons, and leading technical people. But keep up-to-date on the statistical and machine learning stuff -- you want to be able to integrate valuable new tools as soon as they become available.""", + ], + [ # ML/Big Data + """You're on the cutting edge of Data Businesspeople, diving into Big Data and its implications for organizations. You may have started a data-centric business, turning Terabytes into dollars and using the skills you learned in school as well as the practical expertise you've developed in the workplace. Compared with other Data Businesspeople, you're more likely to have embraced the Data Scientist label. Focus on your strengths -- working with Big Data and building analytical systems that deliver amazing value--but don't get lost in the code -- you need to be able to talk both business and math.""", + """As a Data Creative with Machine Learning and Big Data skills, you are the ultimate hacker. You understand the culture of Open Source, and may have contributed code (or data) yourself. You can pull data from anything -- a web service, a Hadoop cluster, or Twitter -- and build an amazing visualization or predictive tool. You may have done graduate work in a technical field, but you more likely identify as a Data Scientist than whatever's on your diploma. Focus on your strengths -- your ability to pick up any tool in the shed and bend it to your will, your ability to wow with your productivity, and your enthusiasm about data. But be open to other cultures around data -- statisticians, businesspeople, and engineers may bring valuable perspectives and collaborations.""", + """As a Data Researcher who specializes in Machine Learning or Big Data, you're almost the quintessential Data Scientist! In fact, of all the types of Data Scientist, you're the most likely to embrace the label. Your years of education, likely in Computer Science, give you an unparalleled ability to work creatively with the newest technologies and the biggest data. You can pull insights from data sets from Hadoop to Twitter and back again. Your weakness is probably on the business side, and you should probably develop both domain expertise and the "soft skills" of understanding business problems to maximize your value. But focus on your strengths -- working on the cutting-edge of machine learning and Big Data.""", + """As a Data Engineer with Machine Learning and Big Data skills, you're at the cutting edge of both technology and the culture around it. More than most other types of Data Scientist, you've embraced Open Source and the Big Data and Data Science buzzwords, and have skills to back it up. You have probably done graduate work, perhaps in an engineering field, and probably have worked with Terabyte-scale data sets. You're probably not a manager, and you're among the least likely type of Data Scientist to be female or to have started a business. To focus on your strengths, keep on the cutting edge of tools for managing enormous data sets. But to broaden your appeal, consider learning more ways of extracting insights, like text analytics or data visualization. """, + ], + ] - return(blurbs[row][col]) \ No newline at end of file + return blurbs[row][col] diff --git a/config.py b/config.py index 595daae..5ff3d1a 100644 --- a/config.py +++ b/config.py @@ -1,21 +1,25 @@ import os + class Config(object): - DEBUG = False - TESTING = False - SECRET_KEY = '\xb7Fr\xbd7TQ\x7f9]\xafr\xf0\xa9\xe70Q\xbcY\xe8\xe8\x00v\xa6' - CSRF_ENABLED = True - #DATABASE_URI = 'sqlite:////tmp/badges.db' - SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/badges.db' + DEBUG = False + TESTING = False + SECRET_KEY = "\xb7Fr\xbd7TQ\x7f9]\xafr\xf0\xa9\xe70Q\xbcY\xe8\xe8\x00v\xa6" + CSRF_ENABLED = True + # DATABASE_URI = 'sqlite:////tmp/badges.db' + SQLALCHEMY_DATABASE_URI = "sqlite:////tmp/badges.db" + class ProductionConfig(Config): - DEBUG = True - if 'DATABASE_URL' in os.environ.keys(): - DATABASE_URI = os.environ['DATABASE_URL'] - SQLALCHEMY_DATABASE_URI = os.environ['DATABASE_URL'] + DEBUG = True + if "DATABASE_URL" in list(os.environ.keys()): + DATABASE_URI = os.environ["DATABASE_URL"] + SQLALCHEMY_DATABASE_URI = os.environ["DATABASE_URL"] + class DevelopmentConfig(Config): - DEBUG = True + DEBUG = True + class TestingConfig(Config): - TESTING = True \ No newline at end of file + TESTING = True diff --git a/cosmoquiz_app.py b/cosmoquiz_app.py old mode 100644 new mode 100755 index 8b5ac0d..92e7aad --- a/cosmoquiz_app.py +++ b/cosmoquiz_app.py @@ -1,7 +1,18 @@ # all the imports -#from __future__ import with_statement -#from contextlib import closing -from flask import Flask, request, session, make_response, g, redirect, url_for, abort, render_template, flash +# from __future__ import with_statement +# from contextlib import closing +from flask import ( + Flask, + request, + session, + make_response, + g, + redirect, + url_for, + abort, + render_template, + flash, +) import random import os @@ -17,128 +28,147 @@ from datetime import datetime - # configuration -#DATABASE = '/tmp/badges.db' -#USERNAME = 'admin' -#PASSWORD = 'default' -#SERVER_NAME = 'http://www.dancesportlife.com/cosmoquiz/' -#ROOT_PATH = '/home5/dancespo/public_html/cosmoquiz/' -#DEBUG = True -#SECRET_KEY = '\xb7Fr\xbd7TQ\x7f9]\xafr\xf0\xa9\xe70Q\xbcY\xe8\xe8\x00v\xa6' -#CSRF_ENABLED = True +# DATABASE = '/tmp/badges.db' +# USERNAME = 'admin' +# PASSWORD = 'default' +# SERVER_NAME = 'http://www.dancesportlife.com/cosmoquiz/' +# ROOT_PATH = '/home5/dancespo/public_html/cosmoquiz/' +# DEBUG = True +# SECRET_KEY = '\xb7Fr\xbd7TQ\x7f9]\xafr\xf0\xa9\xe70Q\xbcY\xe8\xe8\x00v\xa6' +# CSRF_ENABLED = True # create application -app = Flask(__name__.split('.')[0]) +app = Flask(__name__.split(".")[0]) app.config.from_object(__name__) -#app.config.from_object('config.DevelopmentConfig') -app.config.from_object('config.ProductionConfig') - -#app.config.from_envvar('FLASKR_SETTINGS', silent=True) +# app.config.from_object('config.DevelopmentConfig') +app.config.from_object("config.ProductionConfig") -#app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL'] -#app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/badges.db' +# app.config.from_envvar('FLASKR_SETTINGS', silent=True) +# app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL'] +# app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/badges.db' -@app.route('/index') -@app.route('/') +@app.route("/index") +@app.route("/") def start(): - if ( ('results_computed' in session) and (session['results_computed']) ): - return (render_template('results.html', - blurb = blurbs.pick_blurb(session['skill_score_ndx_max'],session['self_id_score_ndx_max']), - skill=session['skill_label'], - skill_color = r.skill_colors(session['skill_score_ndx_max']), - selflabel=session['self_label'], - self_id_color = r.self_id_colors(session['self_id_score_ndx_max']) - )) - else: - session['user_id'] = str(random.randint(1, 999999)) - - if app.config['DEBUG']: - print(session['user_id']) - - return (render_template('index.html')) - -@app.route('/q1') + if ("results_computed" in session) and (session["results_computed"]): + return render_template( + "results.html", + blurb=blurbs.pick_blurb( + session["skill_score_ndx_max"], session["self_id_score_ndx_max"] + ), + skill=session["skill_label"], + skill_color=r.skill_colors(session["skill_score_ndx_max"]), + selflabel=session["self_label"], + self_id_color=r.self_id_colors(session["self_id_score_ndx_max"]), + ) + else: + session["user_id"] = str(random.randint(1, 999999)) + + if app.config["DEBUG"]: + print((session["user_id"])) + + return render_template("index.html") + + +@app.route("/q1") def q1(): - if app.config['DEBUG']: - print(session['user_id']) - return (render_template('question1.html')) - -@app.route('/q2', methods=['post']) + if app.config["DEBUG"]: + print((session["user_id"])) + return render_template("question1.html") + + +@app.route("/q2", methods=["post"]) def q2(): - data = request.form - q1 = data.getlist('id_name',type=float) - session['q1']= q1 - return (render_template('question2.html')) + data = request.form + q1 = data.getlist("id_name", type=float) + session["q1"] = q1 + return render_template("question2.html") -@app.route('/surveydetails') + +@app.route("/surveydetails") def surveydetails(): - return (render_template('surveydetails.html')) + return render_template("surveydetails.html") + -@app.route('/faq') +@app.route("/faq") def faq(): - return (render_template('faq.html')) + return render_template("faq.html") -@app.route('/results', methods=['post']) +@app.route("/results", methods=["post"]) def results(): - session['q2'] = [ float(request.form['scientist']), - float(request.form['engineer']), - float(request.form['bp']), - float(request.form['artist']), - float(request.form['researcher']), - float(request.form['stats']), - float(request.form['jack']), - float(request.form['leader']), - float(request.form['ent']), - float(request.form['dev']), - float(request.form['ds']) ] - - #Inserting database write instead of dump to file - result = Result(str(session['q1']).strip('[]'), str(session['q2']).strip('[]'), session['user_id'], datetime.utcnow(),str(request.remote_addr)) - - #UPDATE THIS! - db.session.add(result) - db.session.commit() - - #need to compute results to display, everything stored in session - r.compute_results(session, app.config['DEBUG']) - - session['results_computed'] = True - #need to return a block of text to - - if app.config['DEBUG']: - print "++++++++" - print session['skill_label'] - print session['self_label'] - print session.keys(), '\n' - print request.remote_addr - print datetime.utcnow() - - return (render_template('results.html', - blurb = blurbs.pick_blurb(session['skill_score_ndx_max'],session['self_id_score_ndx_max']), - skill=session['skill_label'], - skill_color = r.skill_colors(session['skill_score_ndx_max']), - selflabel=session['self_label'], - self_id_color = r.self_id_colors(session['self_id_score_ndx_max']) - )) - -@app.route('/reset') + session["q2"] = [ + float(request.form["scientist"]), + float(request.form["engineer"]), + float(request.form["bp"]), + float(request.form["artist"]), + float(request.form["researcher"]), + float(request.form["stats"]), + float(request.form["jack"]), + float(request.form["leader"]), + float(request.form["ent"]), + float(request.form["dev"]), + float(request.form["ds"]), + ] + + # Inserting database write instead of dump to file + result = Result( + str(session["q1"]).strip("[]"), + str(session["q2"]).strip("[]"), + session["user_id"], + datetime.utcnow(), + str(request.remote_addr), + ) + + # UPDATE THIS! + db.session.add(result) + db.session.commit() + + # need to compute results to display, everything stored in session + r.compute_results(session, app.config["DEBUG"]) + + session["results_computed"] = True + # need to return a block of text to + + if app.config["DEBUG"]: + print("++++++++") + print((session["skill_label"])) + print((session["self_label"])) + print((list(session.keys()), "\n")) + print((request.remote_addr)) + print((datetime.utcnow())) + + return render_template( + "results.html", + blurb=blurbs.pick_blurb( + session["skill_score_ndx_max"], session["self_id_score_ndx_max"] + ), + skill=session["skill_label"], + skill_color=r.skill_colors(session["skill_score_ndx_max"]), + selflabel=session["self_label"], + self_id_color=r.self_id_colors(session["self_id_score_ndx_max"]), + ) + + +@app.route("/reset") def reset(): - for key in session.keys(): - del(session[key]) + for key in list(session.keys()): + del session[key] + + session["results_computed"] = False - session['results_computed'] = False + if app.config["DEBUG"]: + print((list(session.keys()))) - if app.config['DEBUG']: - print session.keys() - - return (start()) + return start() -if __name__ == '__main__': - port = int(os.environ.get('PORT', 5000)) - app.run(host='0.0.0.0', port=port) +if __name__ == "__main__": + port = int(os.environ.get("PORT", 5000)) + db.create_all() + app.run(host="0.0.0.0", port=port) + diff --git a/models.py b/models.py index 6f46259..1ca1097 100644 --- a/models.py +++ b/models.py @@ -1,26 +1,27 @@ from flask_sqlalchemy import SQLAlchemy -#from flask.ext.sqlalchemy import SQLAlchemy + +# from flask.ext.sqlalchemy import SQLAlchemy # comment to make a change from cosmoquiz_app import app db = SQLAlchemy(app) -class Result(db.Model): - __tablename__ = 'results' - id = db.Column(db.Integer, primary_key=True) - session_id = db.Column(db.Integer) - q1 = db.Column(db.String) - q2 = db.Column(db.String) - email = db.Column(db.String) - date_added = db.Column(db.DateTime) - ip = db.Column(db.String) +class Result(db.Model): + __tablename__ = "results" + id = db.Column(db.Integer, primary_key=True) + session_id = db.Column(db.Integer) + q1 = db.Column(db.String) + q2 = db.Column(db.String) + email = db.Column(db.String) + date_added = db.Column(db.DateTime) + ip = db.Column(db.String) - def __init__(self, q1, q2, session_id, date_added, ip): - self.session_id = session_id - self.q1 = q1 - self.q2 = q2 - self.date_added = date_added - self.ip = ip + def __init__(self, q1, q2, session_id, date_added, ip): + self.session_id = session_id + self.q1 = q1 + self.q2 = q2 + self.date_added = date_added + self.ip = ip diff --git a/requirements.txt b/requirements.txt index 2bf0cd2..b9be127 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,21 @@ -Flask==0.9 -Flask-SQLAlchemy==0.16 -Jinja2==2.6 -SQLAlchemy==0.7.9 -Werkzeug==0.8.3 -ipython==2.1.0 -psycopg2==2.5.3 -wsgiref==0.1.2 +backcall==0.2.0 +Flask==2.0.1 +Flask-SQLAlchemy==2.1 +greenlet==1.1.0 +ipython==7.24.1 +itsdangerous==2.0.1 +jedi==0.18.0 +Jinja2==3.0.1 +MarkupSafe==2.0.1 +matplotlib-inline==0.1.2 +mypy-extensions==0.4.3 +parso==0.8.2 +pathspec==0.8.1 +pexpect==4.8.0 +psycopg2-binary==2.8.6 +ptyprocess==0.7.0 +Pygments==2.9.0 +SQLAlchemy==1.3.24 +traitlets==5.0.5 +wcwidth==0.2.5 +Werkzeug==2.0.1 diff --git a/results.py b/results.py index 2f29b31..394785d 100644 --- a/results.py +++ b/results.py @@ -1,130 +1,304 @@ +from functools import reduce + + def skill_colors(ndx=-1): - colors = ["orange", "green", "blue", "purple", "red"] - if ((ndx<0) | (ndx>len(colors))): - color = "black" - else: - color = colors[ndx] - return(color) + colors = ["orange", "green", "blue", "purple", "red"] + if (ndx < 0) | (ndx > len(colors)): + color = "black" + else: + color = colors[ndx] + return color + def self_id_colors(ndx=-1): - colors = ["#fdc592", "#b8f997", "#fba2c3", "#b3effe"] - if ((ndx<0) | (ndx>len(colors))): - color = "grey" - else: - color = colors[ndx] - return(color) + colors = ["#fdc592", "#b8f997", "#fba2c3", "#b3effe"] + if (ndx < 0) | (ndx > len(colors)): + color = "grey" + else: + color = colors[ndx] + return color def compute_results(session, DEBUG): - #Data Businessperson, Data Creative, Data Researcher, Data Engineer - # Rows: Scientist Engineer Business person Artist Researcher Statistician Jack of All Trades Leader Entrepeneur Developer Hacker - self_id_labels = ['Data Businessperson', 'Data Creative', 'Data Researcher', 'Data Engineer'] - nmf_self_id_coefs = [[0.009963015, 0.3716809758, 0.85740821, 0.167622008, 0.04800009, 0.1281892, 0.3267641, 0.6594510, 0.61200620, 0.24482807, 0.0000108286], - [0.129221047, 0.0026543565, 0.29647806, 0.850075527, 0.11137019, 0.2399181, 0.4589113, 0.1505755, 0.41604830, 0.34281471, 0.8454369306], - [0.792606674, 0.0001581727, 0.01934239, 0.182484734, 0.95225779, 0.7290859, 0.4426208, 0.2950846, 0.07824637, 0.06751748, 0.0095306879], - [0.506760298, 0.9637696274, 0.04407253, 0.003502658, 0.35405891, 0.2508140, 0.2702048, 0.2928380, 0.08595124, 0.76271333, 0.5897772478]] - - self_id_normalization = [6.474, 4.733, 5.592, 5.608] - - #Programming, Stats, Math/OR, Bus, ML/Big Data - #Rows: Algorithms Back.End.Programming Bayesian.Monte.Carlo.Statistics Big.and.Distributed.Data Business Classical.Statistics Data.Manipulation Front.End.Programming Graphical.Models Machine.Learning Math Optimization Product.Development Science Simulation Spatial.Statistics Stuctured.Data Surveys.and.Marketing Systems.Administration Temporal.Statistics Unstructured.Data Visualization - skill_labels = ['Programming', 'Stats', 'Math/OR', 'Business', 'ML/Big Data'] - nmf_rank_coefs = [[2.209891e-01, 7.037957e-01, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.667951e-01, 5.647743e-01, 2.220446e-16, 2.220446e-16, 2.179039e-01, 2.220446e-16, 2.220446e-16, 1.435995e-01, 2.220446e-16, 2.220446e-16, 4.951900e-01, 2.220446e-16, 5.684981e-01, 2.220446e-16, 2.220446e-16, 7.013570e-13], - [2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-16, 6.243905e-01, 3.798971e-01, 2.220446e-16, 2.220446e-16, 2.482207e-01, 1.455518e-01, 2.220446e-16, 2.220446e-16, 4.187207e-01, 1.375681e-01, 3.022789e-01, 2.220446e-16, 3.576539e-01, 2.220446e-16, 4.298513e-01, 2.220446e-16, 5.635239e-01], - [4.253356e-01, 2.220446e-16, 5.191935e-01, 2.220446e-16, 2.220446e-16, 4.322221e-01, 2.173335e-01, 2.220446e-16, 3.264821e-01, 3.112354e-01, 4.030644e-01, 4.938181e-01, 2.220446e-16, 3.439012e-01, 3.048536e-01, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.107039e-01, 2.220446e-16, 2.852953e-06], - [2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-16, 1.268313e+00, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.248777e-01, 2.220446e-16, 2.691779e-01, 2.220446e-16, 1.069837e+00, 1.046090e-13, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-16, 5.141404e-07], - [2.220446e-16, 2.220446e-16, 2.220446e-16, 5.283354e-01, 2.220446e-16, 2.220446e-16, 2.980927e-01, 2.220446e-16, 2.220446e-16, 3.119030e-01, 3.214431e-10, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-16, 2.220446e-16, 5.427035e-01, 2.220446e-16, 2.220446e-16, 2.220446e-16, 6.560886e-01, 4.377165e-01]] - - #No longer used - #skill_normalization = [32.971, 35.006, 44.13, 18.496, 28.937] - #skill_normalization = [58.5755, 63.1307, 65.8634, 57.1935, 52.6067] + # Data Businessperson, Data Creative, Data Researcher, Data Engineer + # Rows: Scientist Engineer Business person Artist Researcher Statistician Jack of All Trades Leader Entrepeneur Developer Hacker + self_id_labels = [ + "Data Businessperson", + "Data Creative", + "Data Researcher", + "Data Engineer", + ] + nmf_self_id_coefs = [ + [ + 0.009963015, + 0.3716809758, + 0.85740821, + 0.167622008, + 0.04800009, + 0.1281892, + 0.3267641, + 0.6594510, + 0.61200620, + 0.24482807, + 0.0000108286, + ], + [ + 0.129221047, + 0.0026543565, + 0.29647806, + 0.850075527, + 0.11137019, + 0.2399181, + 0.4589113, + 0.1505755, + 0.41604830, + 0.34281471, + 0.8454369306, + ], + [ + 0.792606674, + 0.0001581727, + 0.01934239, + 0.182484734, + 0.95225779, + 0.7290859, + 0.4426208, + 0.2950846, + 0.07824637, + 0.06751748, + 0.0095306879, + ], + [ + 0.506760298, + 0.9637696274, + 0.04407253, + 0.003502658, + 0.35405891, + 0.2508140, + 0.2702048, + 0.2928380, + 0.08595124, + 0.76271333, + 0.5897772478, + ], + ] - """ + self_id_normalization = [6.474, 4.733, 5.592, 5.608] + + # Programming, Stats, Math/OR, Bus, ML/Big Data + # Rows: Algorithms Back.End.Programming Bayesian.Monte.Carlo.Statistics Big.and.Distributed.Data Business Classical.Statistics Data.Manipulation Front.End.Programming Graphical.Models Machine.Learning Math Optimization Product.Development Science Simulation Spatial.Statistics Stuctured.Data Surveys.and.Marketing Systems.Administration Temporal.Statistics Unstructured.Data Visualization + skill_labels = ["Programming", "Stats", "Math/OR", "Business", "ML/Big Data"] + nmf_rank_coefs = [ + [ + 2.209891e-01, + 7.037957e-01, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.667951e-01, + 5.647743e-01, + 2.220446e-16, + 2.220446e-16, + 2.179039e-01, + 2.220446e-16, + 2.220446e-16, + 1.435995e-01, + 2.220446e-16, + 2.220446e-16, + 4.951900e-01, + 2.220446e-16, + 5.684981e-01, + 2.220446e-16, + 2.220446e-16, + 7.013570e-13, + ], + [ + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 6.243905e-01, + 3.798971e-01, + 2.220446e-16, + 2.220446e-16, + 2.482207e-01, + 1.455518e-01, + 2.220446e-16, + 2.220446e-16, + 4.187207e-01, + 1.375681e-01, + 3.022789e-01, + 2.220446e-16, + 3.576539e-01, + 2.220446e-16, + 4.298513e-01, + 2.220446e-16, + 5.635239e-01, + ], + [ + 4.253356e-01, + 2.220446e-16, + 5.191935e-01, + 2.220446e-16, + 2.220446e-16, + 4.322221e-01, + 2.173335e-01, + 2.220446e-16, + 3.264821e-01, + 3.112354e-01, + 4.030644e-01, + 4.938181e-01, + 2.220446e-16, + 3.439012e-01, + 3.048536e-01, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.107039e-01, + 2.220446e-16, + 2.852953e-06, + ], + [ + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 1.268313e00, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.248777e-01, + 2.220446e-16, + 2.691779e-01, + 2.220446e-16, + 1.069837e00, + 1.046090e-13, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 5.141404e-07, + ], + [ + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 5.283354e-01, + 2.220446e-16, + 2.220446e-16, + 2.980927e-01, + 2.220446e-16, + 2.220446e-16, + 3.119030e-01, + 3.214431e-10, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 5.427035e-01, + 2.220446e-16, + 2.220446e-16, + 2.220446e-16, + 6.560886e-01, + 4.377165e-01, + ], + ] + + # No longer used + # skill_normalization = [32.971, 35.006, 44.13, 18.496, 28.937] + # skill_normalization = [58.5755, 63.1307, 65.8634, 57.1935, 52.6067] + + """ skills =['Algorithms', 'Back-End Programming', 'Bayesian/Monte-Carlo Statistics', 'Big and Distributed Data', 'Business', 'Classical Statistics', 'Data Manipulation', 'Front-End Programming', 'Graphical Models', 'Machine Learning', 'Math', 'Optimization', 'Product', 'Science', 'Simulation', 'Spatial Statistics', 'Stuctured Data', 'Surveys and Marketing', 'Systems Administration', 'Temporal Statistics', 'Unstructured Data', 'Visualization'] """ - skills = [x for x in range(0,22)] + skills = [x for x in range(0, 22)] - q1 = session['q1'] - #q1 = q1.split(',') - #del(q1[-1]) + q1 = session["q1"] + # q1 = q1.split(',') + # del(q1[-1]) - skill_rank_vec = [] - for s in skills: - if s in q1: - rank = 21-q1.index(s) - else: - rank = 0 - print str(s) + '--->' + str(rank) - skill_rank_vec.append(rank) - - if DEBUG: - print "skill_rank_vec" - print skill_rank_vec + skill_rank_vec = [] + for s in skills: + if s in q1: + rank = 21 - q1.index(s) + else: + rank = 0 + print((str(s) + "--->" + str(rank))) + skill_rank_vec.append(rank) - skill_score = matmult(nmf_rank_coefs, skill_rank_vec) + if DEBUG: + print("skill_rank_vec") + print(skill_rank_vec) - sum = 0 - for num in skill_score: - sum += num + skill_score = matmult(nmf_rank_coefs, skill_rank_vec) - skill_norm = max([max(skill_score), 2*(sum/len(skill_score)) ]) + sum = 0 + for num in skill_score: + sum += num + skill_norm = max([max(skill_score), 2 * (sum / len(skill_score))]) - loop_ndx=0; - - for i in skill_score: - #skill_score[loop_ndx] = i/skill_normalization[loop_ndx] - skill_score[loop_ndx] = i/skill_norm - loop_ndx += 1 + loop_ndx = 0 - skill_score_ndx_max = skill_score.index(max(skill_score)) + for i in skill_score: + # skill_score[loop_ndx] = i/skill_normalization[loop_ndx] + skill_score[loop_ndx] = i / skill_norm + loop_ndx += 1 + skill_score_ndx_max = skill_score.index(max(skill_score)) - session['skill_score'] = skill_score - session['skill_score_ndx_max'] = skill_score_ndx_max + session["skill_score"] = skill_score + session["skill_score_ndx_max"] = skill_score_ndx_max - if DEBUG: - print "skill_score" - print skill_score - print "Max Skill_Score_ndx" - print skill_score_ndx_max + if DEBUG: + print("skill_score") + print(skill_score) + print("Max Skill_Score_ndx") + print(skill_score_ndx_max) - session['skill_label'] = skill_labels[skill_score_ndx_max] + session["skill_label"] = skill_labels[skill_score_ndx_max] - q2 = session['q2'] + q2 = session["q2"] - if DEBUG: - print "q2" - print q2 - self_id_score = matmult(nmf_self_id_coefs, q2) + if DEBUG: + print("q2") + print(q2) + self_id_score = matmult(nmf_self_id_coefs, q2) - loop_ndx = 0 - for i in self_id_score: - self_id_score[loop_ndx] = i/self_id_normalization[loop_ndx] - loop_ndx += 1 + loop_ndx = 0 + for i in self_id_score: + self_id_score[loop_ndx] = i / self_id_normalization[loop_ndx] + loop_ndx += 1 - self_id_score_ndx_max = self_id_score.index(max(self_id_score)) + self_id_score_ndx_max = self_id_score.index(max(self_id_score)) - session['self_id_score'] = self_id_score - session['self_id_score_ndx_max'] = self_id_score_ndx_max + session["self_id_score"] = self_id_score + session["self_id_score_ndx_max"] = self_id_score_ndx_max - if DEBUG: - print "Self ID Score" - print self_id_score - print "Max Self_ID_Score_ndx" - print self_id_score_ndx_max + if DEBUG: + print("Self ID Score") + print(self_id_score) + print("Max Self_ID_Score_ndx") + print(self_id_score_ndx_max) - session['self_label'] = self_id_labels[self_id_score_ndx_max] + session["self_label"] = self_id_labels[self_id_score_ndx_max] - return(session) + return session def matmult(m, v): - nrows = len(m) - w = [None] * nrows - for row in range(nrows): - w[row] = reduce(lambda x,y: x+y, map(lambda x,y: x*y, m[row], v)) - return w \ No newline at end of file + nrows = len(m) + w = [None] * nrows + for row in range(nrows): + w[row] = reduce(lambda x, y: x + y, list(map(lambda x, y: x * y, m[row], v))) + return w