Thank you for very important and interesting presentation. My name is Irina Gerasimov. I am from Moscow Russian Academy of Sciences. I have two questions to the first presentation. The first one is about the social and economic factors of vulnerability. Could you say some more about what we mean, economic social factors, to fall in poverty and to change the statement of household? And the second one, if you have the task to estimate the dynamics of vulnerability in the big real, such as South Africa or South America and so on. But if each country has own level of poverty and the bottom lines of middle class, how to use your second approach? Thank you. Thank you very much. Then over there, the gentleman. My name is Niranjan. I work in the UN Regional Commission for Eastern Asia. Thank you for the excellent presentations. But my question is to Peter. First of all, the approach of defining vulnerability line and defining the middle class. This is something of my interest also, which you are doing in the Arab countries. So I liked the approach that you are proposing. But my question is, if you have a lower bound for middle class, which is the vulnerability line, what is the upper bound? Your former colleague specified $13 in PPP. But I didn't see that, so what is your response to that? My second question is specific to India. Since in my previous thesis, I was working on NSS data. You proposed this imputation method to calculate another condoms and expenditure for the households. But I think some years down the lane, Professor Diten had suggested, if we can use the grouped data, particularly because Indian households have very high fixed effects, which you have highlighted also, because of cultural expenses, maybe because of indebtedness, maybe because of seasonal migration. These are the factors which extremely affect Indian households' consumption. Now, if you impute, then I expect that the error variance may be high. But did you try with the grouping of households taking into account some common characteristics as you identified and calculating the mean expenditure for that and creating a panel to apply that method? Thank you. Thank you very much, and then we have a gentleman here. University of New South Wales. Another question for Peter. As you were introducing your talk, I was expecting what you would do would be to try to work out the probability of transition into poverty for people at the vulnerability line rather than the average for those above or those below it. Is there a reason why you didn't follow that strategy? I'm guessing there are practical reasons for implementation. Why didn't you do that? Thank you very much, and then we have a lady there a little bit further. First presenter. Let's mention for the Susanus data sources, you have calculated from 97 to 95 for the poverty. Actually, we have for panel data that from Susanus is 2002-2004 up to 2007 to panel data. My question is, are individuals in poverty data sources logical comparable among yours? That's my question. My assumption, you use the similar data sources from Susanus. If not, maybe my question will be disregarded. And for the second presenter for Davis, you calculate the log financial asset for per capita regression that stated the percentage of urban, the variable percentage of urban population, it was really small, 0.008. In this, in Aquilele, this is a very small coefficient. What is actually the purpose of this small coefficient in the analysis up in Aquilele? Thank you very much. Thank you very much. Let's stop here now for the time being and let's give our presenters a chance to make the first questions. Maybe would you, Jim, start and Peter can sort of put his comments together? Jim? Yeah, the idea about the percentage of urban population in financial assets regression is that it's an indicator of people, urban population has better access to financial institutions. So you would expect that with a more urbanized population, on average, access to financial institutions is easier and cheaper for that population. And so as an example of variables like that, that we tried in these different regressions, it turns out to be a significant variable, so we of course keep it in the regression. You're right, it's a pretty small coefficient, but you'd have to look into that a little bit further to find out, for example, what does a quantitatively, how large the impact is, it may be that it's quite small, but it is a theoretical reason for it being there and it's a significant variable, so we keep it. Thank you, Jim, and then Peter. Very cool, thanks very much for the questions. I'll try and answer, I'll try and move over. Thanks very much. I'll try and respond to at least some of these questions. Thanks very much. On the first, taking the last question first, the validation exercise that we reported on the Indonesian data based on the research that we had done in a separate paper was based on the Indonesian Family Life Survey, the IFLS rather than the Susanus, because we were interested in taking a true panel data set and then testing the method against the true panel data set. And in testing the method what we did is we treated the IFLS as though it was not a panel data set. So we took the panel subsample say from round one, we split that sample into two subsamples separately and then we implement the methodology across the two subsamples in such a way that we could treat them as though they're basically not panel data at all. We apply the methodology, we produce the transition probabilities and then we check against the true panel transition probabilities that are in the IFLS. So both the validation work using for Indonesia as well as the validation work for Vietnam was based using the actual panel data set but treating them as though they were not panel data, implementing the method as though they're not panel and then checking against the panel dimension of the work. So the Susanus data were not used in this exercise at all. I do have a separate study that's sort of ongoing at the moment with a colleague where we're going to try to implement the methodology using the Susanus data because it would then allow us to do some kind of panel type of analysis on a very much larger sample size in Indonesia if we could use the Susanus data for this purpose. But we want to probe and test that and validate that as well as we can before we do that in a large scale and that's kind of still ongoing at the moment. The question about calculating the probability at the vulnerability line, I think that's an interesting point. I can't say off the top of my head that we thought a whole lot about that. My quick reaction I think is that it will have posed some computational challenges, particularly sufficient sample sizes and so on at a particular point it's going to be much more difficult to do. Yeah, it would be like an additional level of fitting that would be going on but it's something that's worth thinking about and I'm grateful for the comment. The question of the upper bound on the vulnerability line, we sort of defined the middle class but we sort of let the middle classes range all the way up to the top income level. That's a very valid question and we did not really try to pursue that. We were really focusing on this vulnerability dimension and I think you'd have to use a very different line of reasoning, a different set of indicators as to try to find that line that delineates or separates the middle class from say the rich. I haven't really thought much about that. It's possibly that it wouldn't be based so much on a risk of falling into poverty criteria and it'd be some other criteria that we would want to use. I've called the middle class basically anyone that's above the vulnerability line but I acknowledge that that's probably not entirely satisfactory if you want to do a real focused analysis of the middle class and you want to also keep in mind the distinction between the middle class and those that could be considered as the rich in this society. So that's definitely not something that we've handled adequately in this particular paper. Fixed effects, I think it's very true that I think in India, as in many of these other data sets that we were looking at there is this very important fixed effect in the error term which means that our upper bound approach which assumes no correlation at all is clearly not satisfactory and that also motivates the work that we were trying to do where we tried to estimate this correlation coefficient, this parameter rho in the methodology and I didn't go into great detail here but what we do precisely is to work with cohorts and we use the cohort level information to estimate to produce an estimate of what this row parameter might be and we then plug that row parameter into the parametric version of the method to then generate the transition probabilities. So it's kind of a merging of these different strands. There's a long standing literature on producing pseudo panels based on cohort level analysis. We're trying to work with the unit record level analysis here but then we do draw on that cohort approach to estimate a particular parameter that we need for our purposes. So we're trying to integrate I guess to some extent these different strands of research. The first question on socio-economic patterns of vulnerability. I didn't go into that here but it is perfectly possible to calculate the vulnerable and identify the vulnerable population say or the chronically poor based on this methodology where you have these transition probabilities. You can focus on specific groups of the population and then you can look in the data at the characteristics of those populations and so you can look at the characteristics of the chronically poor and try to distinguish those from say the characteristics of those who are likely to be transitioning out of poverty or those who are more likely to be transitioning into poverty and to look at these interesting characteristics that might differ across these different groups. That's something that we've done and we've demonstrated that that's something that you certainly can do. You have to be careful in terms of how far you pursue it because of the cell sizes and the sample sizes and there is a whole error that's associated with prediction coming out of the imputation procedure that we're doing here and on top of that error comes the sampling error that comes from small cell sizes if you're looking at small numbers of observations. So you have to be careful and cautious in how far you take that kind of disaggregation for that kind of more disaggregated analysis but we certainly can, you know, show things about how the role of secondary education versus the primary school only, you know, how that is associated in a different way between those that are chronically poor and those who are more likely to be transitioning out of poverty over time. So there are opportunities to do that kind of work and I didn't manage to go into that in this presentation. I think that's my reply so far, thanks. Very good. Then the second round, I think we had a question over there and then a question here, so let's start with the lady at the back. Okay, my name is Prudence Maghejo from the Investor of the Witwatersrand in South Africa. Please can you put the mic a little bit closer? Okay, my name is Prudence Maghejo from the Investor of the Witwatersrand in South Africa and thank you for the very insightful presentation. My questions are directed to the first presenter, Peter. I'm not so sure about the role of time-varying characteristics in the predictions from round one to round two when we are in the synthetic panel. Can you please explain a little bit on that and also I'm wondering the role of unobservable characteristics. Is it going to be captured with the role parameter that you are talking about because I'm thinking maybe we may have similar characteristics which are time invariant but in terms of unobservables, how does your methodology deal with that? Thank you very much. Thank you very much and then we go here in the middle. Andrea Cornia, University of Florence. My question is addressed to Jim Davis. Is there any attempt to evaluate the Gini assets as well as the asset, the total wealth level and the wealth composition in relation to changes, large changes in interest rates? I think Tony, yesterday mentioned that quantitative easing interest rates are falling which means that everything has been equal, everybody will borrow and this is the intention and the value of housing goes up but the rents of bond holders goes down and so I think I'm puzzled by the fact that the values which are being presented, they are conditional on the level of interest rate and could one simulate changes in all these variables? Has it been done? I mean, in the US, if you take the value of assets before or after the housing bubble and after the housing crisis, it must be quite different. Thank you very much. We do have time. One, two other questions. Finn, in front. Okay, thank you very much. My name is Finn Taub. The first question I have for Peter, let me begin by first of all saying thank you very much for two brilliant presentations. They are fascinating. I mean, I'd like to convey my appreciation. The first sort of thought around Peter's presentation is just so where does that sort of leave those of us who spent a major part of our life doing panel work? I just kind of pondering about are we now becoming, if not superfluous, but we should then lower our level of effort? I was wondering whether you had a thought or a reflection around that. And Jim, you sort of, in your presentation, you sort of quietly mentioned would you attention or would you care? I was sort of wondering whether you could say or elaborate a little bit on that.  It's very professional, but I was just sort of wondering, could you reflect on some of the big decisions or some of the sort of really tricky points where you would say that mistakes are often made or that that due attention is not being paid? Thank you. Thank you very much. Any other questions? Please. Right, thanks. I've been a little bit. I'm from Norway. Could I ask, I think, Jim, what you have of your final slide there, the wealth GDP ratio, I mean, the difference between low-income countries two and four in high-income countries is quite significant. But it's always intriguing to ask, are there any countries that doesn't fit the pattern, any outlayers, in particular low-income countries which are significantly higher than the ratio of two and high-income countries that are significantly lower than four? And for Peter, I was wondering, I mean, the vulnerability historically could also be related to people who have been in the category of four people who have then moved to the vulnerable group and have a risk of falling back into poverty. Is there any analysis where you would actually also look at the history of those in the vulnerable group, whether they have always been just above the poverty line or whether they have actually been middle-class people going down into the vulnerable group or poor people who have actually moved out of poverty temporarily? Thank you very much. I think that now we have to go to the answer so that we can go and have some coffee in due time. Would Peter start? Sure, I think I'll try and go backwards again in order. On this question of the kind of work that's been done based on this approach and looking at more closely at the vulnerable and where they've come from and where they've gone and so on, so far in terms of my own research, I've been very much focused on the sort of methodological aspect of the feasibility and not so much on describing these patterns of vulnerability and so on, but that is something that's work that's underway and I might point you to a study that's very soon to come out of the Latin America region at the World Bank which is a study of chronic poverty which uses these methods to sort of identify who the chronically poor are given that in many countries we don't have panel data and we can't actually estimate this directly. They use these synthetic panels to try to identify who the chronically poor are and who those are that have managed to escape poverty and so on and then there's a fairly far wide-ranging analysis of circumstances and characteristics and history and so on of these groups. So that kind of work that looks more and really tries to tell the story of what comes out of these types of data is, I think, obviously the much more interesting part of this whole agenda. It's one that I've not, just for reasons of time, not been focusing on so much myself so I don't have a whole lot to say at this point but there is work that's underway and I think it's a fairly rich agenda which I think in some sense takes me to Finn's question about the future of panel data. I would really want to emphasize very, very strongly here that I see this work as by no means suggesting that we should stop collecting real panel data. I acknowledge that collecting panel data is a difficult thing to do. I remember being quite influenced when I was doing my graduate studies by a paper that Orly Aschenfelter, Angus Deaton and Gary Solon wrote. I think it was an LSMS working paper where they were just asking this question of whether the LSMS study at the World Bank should be getting into the business of collecting panel data or not and they were just highlighting how difficult it is and costly and complicated it is to do and I think that's also the reason why we see relatively few countries that are collecting panel data on a very large scale. Having said that, you know, there are efforts in the Indonesia Family Life Survey in Mexico. There's work underway. There are a number of countries where there's panel data being collected. The World Bank itself and the LSMS team has a very active program of collecting panel data in sub-Saharan Africa now and I think the insights that can come from those type of data are enormous, particularly when they're done well and the kind of insights that we can get from these synthetic panels that I'm describing here is really very limited. I'm describing, you know, a few things that we can possibly get some insights out of using these synthetic panels but it doesn't even scratch the surface of what we can do if we have real panel data. So it's more of a, you know, we're trying to be opportunistic. We have cross-sectional data in many countries. Let's try and get as much out of those cross-sectional data that we can but it's not really a substitution for collecting panel data in settings where that's a realistic option. At the same time we should just recognize it is difficult to do good panel data collection. Finally on the first question about the time invariant characteristics, let me try to very quickly give you the intuition of what the role is of these time invariant characteristics and why they need to be time invariant. You think about, so you have two surveys. You have a survey in say time zero and another survey in time period one and you're interested in the data for time period one. So you have all the households in that data set and you know what their income level is or their consumption level is in that time period one. But what you would like to know but you don't because you don't have panel data, you would like to know what their income was at time period zero. So that's your situation. You have the data on their income in time period one and you would love to know what their associated income was in period zero but you don't know that because you just have cross-section data. Our proposal is to then estimate a model in time period zero that relates consumption in time period zero to household characteristics in time period zero. And that's, we can easily do that with the data from time period zero. Now if the variables that we use in that model are time invariant then we can take the parameter estimate on that model estimated in time period zero and plug that in to the data for time period one because the X variable, the characteristic is not changing over time and that will then give us a reasonable basis in predicting what the consumption level was for a household in time period zero for each of those households in our data set in time period one. I hope that's clear and I'm very happy to talk perhaps afterwards over coffee to explain it better if I haven't done so but it's really to try to find that bridge between period one and period zero and using these explanatory variables these time invariant characteristics to produce that bridge, I guess with that bridge. Thank you very much and then Jim your last comments. Yes, very interesting questions from Andrea Cornia. It would be fantastic to be able to do a simulation on a global scale what the impact of changes in interest rates is on the distribution of wealth. As we saw a country like Japan where so much of personal financial assets are in the form of deposits, there would be much less impact than there would be in the United States where the value of their equities and their defined contribution pension plans would be very, you know, really quite sensitive to the interest rate. I think that realistically speaking the work needs to be done at the national level in some countries that have really good data and also have, you know, a body of macroeconomists who are used to performing simulations with dynamic general equilibrium models where they have heterogeneous individuals so there's actually a distribution of income. So I know that, you know, for example at my home institution there are guys that, you know, do work of that type. The US would be the natural place to do this because of the, because it has such really excellent wealth data. I think it would be a fascinating thing to do because, you know, there are forms of assets that are very sensitive to interest rates. It depends very much on what expectations are about the future, you know, which interest rate is the relevant one, what do you do about the risk adjustment, etc. So it would be very interesting to do but it hasn't been done and so there should be some PhD theses looking at that I would say. FinTARP is a question of what I was signaling about with due care. I think the largest thing is to make careful use of survey data. And so that means comparing the survey aggregates with the aggregates from the household balance sheets or other sources where people can get them making adjustments if necessary. Thinking about things like personal assets that may not be included at all in the surveys. So for some reason, which I don't quite understand in the English-speaking countries there has been a strong move towards including employer-based pensions and trying to do a better job of including them. So in Canada in the last couple of wealth surveys we have estimates of how much each household's employer-based pensions are worth and it's a really big chunk of wealth. Australia does the same thing. The UK has tried to do this in their last survey with kind of uneven results. So that would be another indication of where due care is required in this respect. If in a country like the UK there's a new survey they're trying to do something important and new well, you're going to have to look at that carefully and more carefully than say in a country where there's an established practice and they've taken a long time and people are quite confident about the quality of that stuff. So I'd say that's the major area that I think is tricky. The pension thing is especially tricky and this would be a point which is independent of whether you look at survey evidence or balance sheet evidence and the national accounts the value of our pensions is taken to be the value of the assets that are sitting in the fund that is supporting the pension. So if you have a defined benefit pension plan and you're working for the government or for some employer which is very unlikely to go bust and the markets go down as they did in 0708 how much has your pension wealth changed? Maybe it hasn't changed at all because you're not bearing the risk the government or your employer is bearing the risk completely opposite for defined contribution people So those are some tricky things and then finally oh yes, are there any outliers in wealth income ratios? I wish I had a sheet in front of me it's very dynamic we were seeing that just in the last few years the wealth income ratios in France, UK, the United States have been changing quite a bit in some countries they've been trending up in other countries they've recently done these fluctuations so it would even matter whether we were looking at year 2000 or year 2010, 2013 and then think about developing countries well, if you have a nascent miracle economy that's starting from a low wealth income ratio and they have a very high saving rate you might think well the thing in the numerator is going to go up really fast well the denominator is going up fast as well so it's a bit ambiguous of what's going to happen there and you can I'm thinking more in terms of models than I am in terms of facts I have to admit but in a slow growing traditional underdeveloped country you can have a high wealth income ratio and Raymond Goldsmith actually called attention to this and he said the wealth and the capital are not being used efficiently in these cases of stagnation and there were more of those cases back when he was writing them in art today so you can have a high wealth income ratio in a Southeast Asian country that's not growing very fast and it may be that when growth improves the wealth income ratio actually comes down and the other thing is again if we go back to developed countries it depends how much of your economic activities being run through the public sector versus the private sector so a country like the US like to try and do everything through the private sector in Scandinavia, Canada, Europe generally hospitals and colleges and universities and so on all these things are in the public sector but it is possible to locate those in the private sector as we look at the transition economies many of them had a rejection of doing things through the public sector and so over time they may end up as outliers on the wealth income ratio although that's not the case at the moment thank you very much Jim this ends our session we are running 10 minutes late but as we started a bit late so I took the privilege of extending the session a little bit thank you once again for Peter and Jim for presentations that definitely provided food for thought we don't live on good ideas only so let's go and have some coffee and next session we'll start at 11 thank you


Okay, hello everybody. Let's start with a very small example. So I have this tiny program. Only three lines seems pretty straightforward. But let's see if we can type check it using MyPy. So I guess first you need to install MyPy, just use to install MyPy. And now you need Python 3 to run MyPy. It's a Python 3 application, but you can use MyPy to type check also Python 2 code. Which we'll talk about later. And then the simplest way to type check and go, which is run MyPy, name of the file. And actually turns out that this program has an error. So reverse returns an iterator and you can't append to an iterator. So great, MyPy find a bug. Nice. So what exactly is MyPy? It is a static type checker. So static in this context means that it analyzes your code, like tries to understand some aspects of the code, but it doesn't actually run the code. So it has no idea like what is exactly happening at runtime. So it tries to find type errors, things like missing attribute, calling a function or method with a wrong number of arguments, or wrong name for a given argument, or wrong argument type, and things like that. And it needs a bit of help from the programmer. So you need to add type annotations to your code to actually have MyPy do useful type checking. So the type annotations are part of, like Python, that was mentioned briefly. And like Python 3.5 comes with a typing module in the standard library, which kind of we are going to use later on. So okay, now I'm just going to give you a very brief overview of how you like annotate your code. So I'm going into, there's like a large number of different kinds of types. You can use it's pretty flexible, but you can start it with just like a couple of basic things and then gradually kind of learn more stuff as you go on. So here's a slightly more complicated example. So here we have a user-defined class cat, which has, and this has type annotations. So here we have a Python 3 type annotation for the DunderInit method. So the argument color has type str. It just basically reference to the built-in str class object. And then also DunderInit doesn't return a value. So we have a return site. There's like arrow 9, which means that it doesn't return anything. Well, implicitly it returns 9, but we don't really mostly care about that. Another slightly interesting thing is like the self argument isn't annotated. MyPy is clever enough to figure out that the type of self is cat. So there's no need to kind of explicitly kind of add that sort of redundant information. And then the body seems kind of straightforward. There's actually something interesting going on there. So MyPy, by looking at the body of DunderInit, MyPy figures out oh, the class cat has an attribute called color. And also it does type inference. So it looks at the initializer, which is just an expression color. And the type of that is string. So it like infers at the type of the color attribute is also string. So you don't need to annotate that explicitly. And usually like you don't need to annotate variables, just functions. And then I mentioned the typing module. This is in the standard library and there's a back port for Python 3.4 if somebody is still using it on Python 2.7. And it is a bunch of like types and utilities that are very helpful. And almost all non-trivial code using annotations will use some of those. So in this case we import the types to iterable and sets. And we use them in the annotation for the function all colors. So the cat argument is an iterable over cats. So we use square brackets to kind of build more complex types out of like kind of simple types. And also there's return type use the square brackets to say this is like a concrete set object with string items. And actually if you run mypy against this program it finds another error, nice. Like we actually misspelled the color attribute. So obviously it should be written like that. And now it's green. And again mypy needs to know the type of cats to kind of know that the color attribute actually is misspelled because otherwise you have no idea of saying like what is supposed to be inside cats. Okay, another example. So in this case we just have like a task which is an empty list. And actually like mypy kind of complains if you write a type to this program because like it doesn't have enough information to decide what the type of the list item is. So you need to help mypy a little in this case. It's straightforward enough. So okay it just import another like type from typing and then we add a type annotation. So this is like variable type annotation which is what's added in Python 3.6 which is pretty nice. And you can also leave out the initializer if you just want to declare the type of a variable. So this kind of helps mypy a bit. But what if we actually are not sure what the item type is. Maybe there's some legacy code that nobody understands anymore. So in that case in general the type that you can't kind of figure out you can always fall back to any which means basically unknown something. So mypy kind of lets you put anything within that list. So it's kind of a cost. It can't type check as much but then it gives you more flexibility. So you can use this but you should use it too much. Okay I mentioned that like you can also type check Python 2. So these obviously you have to use a slightly different syntax. In this case this is also standardized for your type comments. You have different type comments for functions and variables. And the variable type comment is also useful in Python 3.5 which doesn't support the variable annotation syntax. And again like there's a back port for typing for Python 2.0 so you have to like pip install that and then you can basically do all the same stuff except with a slightly different syntax or quite different syntax. And if you type check my using mypy then you should use the dash-dashpy2 option to run mypy in Python 2.0 mode. And you also have Python 2.0 and 3.0 directly in code and just run mypy twice with different options. And note about Python 3.7 So Python 3.7 added some pretty cool stuff related to typing. So you should really consider creating to Python 3.7 if you're still using something else. In particular I like that from future import annotations thing which might not sound like much but actually makes life much easier. So it lets you have forward references in your types like these just like as you'd expect. So label is defined after the like label attribute. In Python 3.6 you have to use like string literal around the label in the annotation which is kind of ugly. So just jump straight to Python 3.7 and you can just forget about that problem. Okay, so now you have a general idea of how types work and what mypy is but should you use types? What's the point? The main thing that we've heard like over and over again from users and like other people giving talks about mypy it's just like type annotations make code much easier to understand because they act as machine checked, machine very write documentation and this is something particularly important for large scale basis if you have like a team of multiple programmers working in the same goto you can't expect everybody to understand everything and these types really make code understanding much easier and obviously types can find bugs early so basically you should run mypy like after like maybe each change you make not even trivial ones to make sure that you didn't have like typo something so because it's like the fast you find bugs the easier they are to fix because you just remember the code better so like few bugs in production which is obviously another big benefits. There's also like a slightly less obvious thing by increasing readability people are less likely to make mistakes by misunderstanding the code so like calling a function with say like wrong argument that just happens to run due to talk typing but it might produce something completely bogus so type checking kind of kind of catch those sorts of issues so again like few bugs thanks to typing and both of those kind of mean that you spend less time reading code less time like fixing and debugging issues in production which means like more productivity and more time to do actually useful work productive work and there are a couple of other big things that are kind of slightly less obvious is like ideas like by chairman or studio code can take advantage of type annotations and they can like give you better like code completion in pie trim like go to definition etc work better more reliably like especially if you have a large code base like the automatic type analyzers don't work that well but if you have type annotations then kind of it scales much better and works more reliably and also like types make refactoring easier so generally you can modify the signature function generally you just modify the annotation and then run my pie and it will show exactly which part of the code base needs to be updated not like you get some weird exception in your test or maybe in production because you forgot to update something so this is really like improves productivity and also it makes easier to refacture so that's your more likely to refacture code which means that your code is cleaner and you are less likely to introduce bugs so cleaner code is also less buggy code so all of these benefits are kind of they might be one to be obvious from the beginning but if you actually start using my types soon you'll be kind of getting the benefits okay another thing that my pie lets you do is gradual typing so most users as my pie I'd expect started with an existing code base without any type annotations the idea is that you can start with annotations and then start gradually add them until you reach like reasonable level of coverage you don't need to go like 300% but this is a great thing because it makes migrating easier but there are some issues you should be aware of so this is another like really tiny example we have like two modules A and B and B calls function F in A and obviously like well it will blow up add an int to a string so what if you run my pie actually my pie says like okay I can't see any problem why is this well the thing is my pie doesn't type check functions without annotations this is to make the gradual typing easier so if you have like huge numbers of legacy code then often my pie will generate some kind of warnings about things that it kind of can't figure out and you might get like hundreds of errors like types like everything in one so basically the idea is to gradually add annotation coverage which means like if you don't have annotations then there's not much my pie can do so basically okay let's add an annotation but again like what there's still no error well the thing is my pie still doesn't know what F returns because it doesn't have an annotation so it stills like F returns something maybe you can add it to string so now when you actually also annotate F my pie can find the error so basically it means like so if it's just an editing code you might need to like other code that the code interacts with to get like actually useful type checking results so if you have few annotations you get some checking but not that much if you have more annotations then more checking so that's kind of the thing to remember it kind of like and that's kind of something why can't my pie catch this error so this is really important thing to understand okay now I assume that you have some existing code that you'd like to migrate to static typing and you haven't used my pie before so no annotations so the first step by recommend is to try to get my pie to run against some code without adding any annotations other than the minimal ones to get kind of clean my pie run so again like as I said if you want to tweak things a bit maybe you do some like dynamic stuff that my pie doesn't quite understand or something else like you need to add some annotations so it takes a bit of work I'd recommend starting with maybe like 5,000 to 20,000 lines of code that's really like a reasonable size so if you have like million lines of code you shouldn't kind of try to get that all running under my pie so maybe like one or two days of effort and you should get like lead run for that then great then you're kind of doing well but things like how do you kind of pick that like 20,000 lines of code that's kind of can be a bit tricky so I'm going to spend some time talking about that so I guess the simplest thing is to any type check specific directories or specific files just like my pie and some paths which is great it works that's what you'd expect but obviously if you have like different directories you don't want to enumerate them explicitly so it doesn't really scale to like really large code phases and this is a slightly more general thing you can do is kind of similar so you can have like regular expressions or like a lot of patterns which kind of use to kind of pick up which files not to type check or maybe so basically you use a black list or certainly you can use a white list which are like have patterns which match the files that you want because in this case like we don't want to type check test code so we have this like slash test slash pardon so you probably wouldn't want to use exactly this but something similar might work for you but this kind of is more scalable than previous one it still kind of doesn't scale to like tens of hundreds of files probably okay this is what we use at draw box so we have like tens of thousands of files we don't want to maintain like manual lists we also have like black lists actually we probably use all of these in some capacity but we also have this like type comment kind of detection script which kind of looks for files with type comments and then we include all those files in the build so the moment you start underneath file it gets automatically picked up by the mypy build in Python 3 you might have a like regular expression which looks for like type annotations or import from the typing module or you can invent your own kind of marker so that way you can kind of pretty easily add new files to the build without having to modify some configuration file so you have to do a bit of scripting but it should be pretty straight forward again like this is a problem that maybe you don't have that like type annotation in a file because it doesn't have a function you forget to add the tag then you're kind of like problem big then mypy doesn't see that file so these are kind of tradeoffs you need to think about this carefully because it's kind of hard to change these like like six months into the project and if you have really lots of code then mypy does follow imports option which kind of decides like what should mypy do with files that are imported from the files you pass it on the command line but that are imported from those files but aren't included in the command line so skip means just like okay only type check these files on the command line there's also a silent option which kind of presents those files but it doesn't generate errors these kind of useful because otherwise you might get like large number of errors from mypy on your first run so this is like good thing to try okay next time I'm going to take something that's kind of directly related the previous topic but you'll hit it pretty quickly when you're like annotating any real code so mypy uses stub files to describe types in library modules there are stubs for the standard library and a bunch of third party packages mypy ships with stub so if you only use the standard library then some common third party modules it might just work but it seems mypy complains if you can't find a stub because then you can't type check your code and it doesn't want to silently kind of start ignoring stuff you can recognize stubs by the .py extension again this is like standard so what if you are using a third party library and it's missing a stub bundled with mypy so one thing is you can look for like an external maybe somebody has contributed a stub you can like google there's a recent Beb which lets you install stubs using pip install which is nice but unfortunately it's kind of new thing so there aren't that many stub packages available but if you write new stubs you should consider contributing it to the community next thing is you can just use a type ignore comment which means don't report any errors on this line so you get okay we don't ship with SQL alchemy stubs but it's not a big problem just like type ignore problem it makes kind of explicit that mypy can't type check your uses SQL alchemy but it can deal a lot of type checking for other stuff so this is like if you only have a few errors this is like a nice easy way to do it and it was for other kinds of like complains that you can't figure out just ignore it initially and then you can commit back to it later and see if you can fix it in a kind of more better way what if you have like a lot of like 15 bots to SQL alchemy in that case you can create a mypy.ini configuration file and you can just sell a mypy to ignore all the missing imports targeting these packages like maybe Bodo SQL alchemy and then those go away but if you import from something else you get an error so it's kind of like you kind of like accidentally like paper over like a large number of errors only those things that you don't want mypy to report okay now that you have a clean run from mypy then you have a way of running mypy which against some subset of your code base or all of your code base depending on the size you should like commit that script into your repo and have everybody in your team use that to run mypy because you want consistent results this is again should be pretty clear but it's important things to remember and once you have the script then you can run the script in CI to make sure that nobody will introduce additional errors accidentally or at least you will catch them pretty soon the fourth step is going back to the like the modules A and B you should add annotations to commonly imported library modules because otherwise like these modules are used all over the place and each time you call something in that module mypy thinks it's I don't know what it's any and it can't do much type checking with the result so pretty early on you should annotate a bunch of library functions and classes this will greatly increase the coverage and actually mypy will catch more errors pretty soon and then you should kind of talk to your team and kind of establish guidelines it's like if you edit a file annotations to the modified functions if you write any new functions you should annotate them so this way you'll gradually get more and more annotations in your code and this because when you're writing code you should understand what it's going so writing the annotations should be pretty straightforward so it's actually you'd have to write a doc string anyway so this actually saves time because annotations are more compact so you save some time and you get like more type checking coverage so it saves time so it's a win-win and then at some point you should probably look at your legacy code and try to start underlining that because it will kind of leak some like imprecise types to the other parts of your code base so you can do it manually it works pretty well, it's kind of boring but it's not that much work or there are tools like monkey type and pike annotate which let you collect types so for example you can run tests they can collect actual runtime types and then they can generate draft annotations to your code they aren't 100% correct but often like you just slightly manually tweak it then you can actually get a lot of code annotated without too much effort but again like you should give it a try they may work but sometimes they have some rough edges okay so maybe you've been adding a bunch of files to your build maybe you have like this means like mypy runs might be a bit slower because it's doing more work so it's useful but obviously faster is better so a couple of things pretty recent mypy features that can speed up mypy runs by maybe 10x or even more there's a mypy daemon which keeps like the program state in memory so that like the incremental builds it'll only have to like reprocess the modified files that's a really nice thing and it goes to something like remote caching to basically download like a recent snapshot of the mypy internal state so that you can then only have to do an incremental build on top of the most recent incremental state instead of like processing the inside code base every time you say switch to another branch so this is a summary of the steps we should kind of get you started then obviously there's more advanced topics and you just create the docs afterwards and see whether there's like other stuff you want to experiment with and finally I'll talk about a few mistakes beginners might make and I want to kind of avoid these the first mistake is like I'll just start with this single file which I'm working on and I annotated with mypy, I use mypy to type check it and then I get a good idea of how mypy works this is not true because I said that you need to annotate the library modules and other modules your code interacts with otherwise it might look like mypy doesn't check anything because you haven't annotated that much so this is not a good way to get started another mistake might be like oh we just like write annotations or new code that we've write so in like 12 months we have like a lot of our code annotated again like this misses all the legacy code that you probably have a lot of code that doesn't get changed in 12 months and that will never get annotated you should like annotate the legacy code as well outside the normal kind of coding workflow and then my mistake 3 is like oh we have this million lines let's type check everything and then you might get like I don't know 500,000 errors that you need to edit oh I'm not I give up it's too much work yeah you should start with like maybe 20,000 lines to go down then gradually increase it so there's no like big bang sort of integration which is pretty demoralising and if things go wrong then you wasted a lot of time so I think it starts simple and quickly I'm going to talk about our experiences of using MyPie at Dropbox so we've been using MyPie since pretty early days in MyPie yes since 2016 we currently have over 2 million annotated lines and pretty much all teams using Python use MyPie at Dropbox and this kind of like organic growth people just like see it's useful for them so they start using it we've kind of improved MyPie on the way so to get like basically more teams on the board and currently we are using MyPie daemon which I briefly mentioned and we get like incremental runs we get like telemetry from users typical incremental run takes about 2 seconds even if you have like millions of lines of code so you can it scales pretty well 6 months ago so this is really improved the other is a remote cache that I mentioned so that like it's also like when you start run MyPie for the first time it's also much faster and then we have a PyCharm MyPie plugin which is open source you should look it up if you use PyCharm it's really a kind of makes easy to run MyPie from PyCharm and kind of jump to the other it's really kind of simplifies the workload it's really smooth so that's all I had thank you everybody thank you Yuka can you raise your hand thank you great talk my question is about stub files supposing I got a bunch of C++ code that's exposed to Python do you know of any way of being able to generate those stub files from the C++ binary MyPie ships with a tool called stubgen and it can do some like runtime introspection of C extension modules and it will try to generate some draft files so you can give it a try the thing is it's kind of impossible to do that like 100% reliably so basically if it's simple enough it may work if not then it doesn't work so basically try it out just a quick question so does it support Python 2.7 at all Python 2.7 is fully supported as a type checking target so you can use the type comment syntax you just run MyPie-Pie2 that's actually what we use at drawbox so it's really like production quality as much as Python 3 but you can't run MyPie using Python 2.7 but that's no problem you can probably install MyPie3 will Guido be angry if Python becomes statically type language Guido is totally behind and he's actually working on MyPie so yeah it's not like Python is not becoming a silly type language this isn't totally optional so it's basically mostly for large projects and large code bases it's really helpful so this is just one tool in the tool box so use it if you think it's useful if you only have like small projects that you work on then probably it doesn't make sense to learn it it might still be useful but it might not be worth the kind of investment in kind of learning this stuff is there some fundamental problem with creating typesets for psychopg because it's like a very popular project and it still shows us cannot import stuff from psychopg2 do you know something about that? I'm not sure about this particular library it might be just nobody has kind of contributed them because if it's sometimes it's so simple to write the stubs yourself everybody writes their own set of stubs and then nobody contributes them back so I recommend trying it out there's a subgen utility it's not kind of well documented but it's there so I recommend trying it out often it's kind of straightforward until it's a really big library like Django then that's actually I wouldn't recommend starting out with that because it can take a lot of work do you have any metrics of what kind of quality improvements you get or how much do you speed up this is something it's really hard to have hard metrics but from draw books periodically somebody said oh we had an outage or some kind of production issue that would have been prevented even the code would have been type annotated so it definitely but things like if you prevent something then that's how do you know because it didn't happen but basically people we get feedback from users they're really happy so it's like a subjective thing but when working large code base we're pretty convinced that it's mostly a win once you get the initial some level of type-taking coverage then it gets really helpful but initially you have to do a bit of investment if you just added one single file it's not that helpful thank you we have time for the last good question how do you imagine some library a library wants to support multiple other dependencies and one of them we expect one something to some type and the other one and the updated one we expect another type how do you deal with such things can you repeat the question I didn't quite hear imagine that our library depends on some other library and from one version in that other library the type changed so if you have a third-party library and the signatures change so typesheet can only have one version at a time but we support like pip installable stop packages so you can have multiple versions of the stop package corresponding to different versions of the library and then you just pin the correct version of the stop package and you get type checking, correct type checking so that's probably the best option thanks I admire your courage to write such a huge library alone okay fantastic talk thank you Jukka, let's give a hand to Jukka


Everybody forced here rip in 2022 Bowman baseball sapphire 10 box number three Random team style you can always find these results at latent sports cards.com There's a link in chat currently Thanks for joining and good luck Boxes see some big stuff here. Alrighty Who looks great this year, man? Uh burn a bell Rockies first Bowman First Bowman auto brewers Felix Valerio Bay sapphire Solid hit brewers Robert Hassel Padres Marcelo Meyer You go Red Sox Khalil Watson base marlins Ace Watson Harry Ford mariners and Ronnie your cantero cubs first bowman Yonatan class a mariners first bowman Austin Hendry Yoshua Garcia Phillies first bowman and Victor Liza Raga Padres and I'll be martin mariners Jose Pastrano Cleveland first bowman Nick Gonzalez CJ Abrams Pete curl armstrong Alexander Ramirez junior San Quentin Cleveland first bowman Carlos Aguiar twins Anthony Rodriguez Giants first bowman Red Sox Nico Kovates Royals Luca Tres And Red Sox Adonai Raffaella. He is uh picking up some steam Raffaella is Climbing prospect rankings Red Sox organization debacks Alvin Guzman Jeter Downs Padres Ruby Ellen Halleis first bowman and Jay Allen Cartesia Harry Bertha Hernandez And an aqua blue jays Estevan Machado. It's a 55 on the first bowman. Good first box here Go blue jays and a Mackay backstrom Braves first bowman Tico Armstrong is going to be really good. He just one of those guys were like the hype got like out in front of him People were so hyped about him Got Brewers Yoruba first bowman Luciano Walker and Trey Sweeney Yankees Cubs Louise Verdugo Austin Martin twins Rangers Jose Rodriguez Shailin Palonco Radz Allen Serda Angels Denzer Guzman Torkelson and Blaise Jordan Oh, look at that color That is a red after this James Wood red Sapphire first bowman Padres Zayed Salinas Boom Three of ten San Diego That is sick Get that magged And right behind it is an Orioles first bowman auto daryl ornaise And reds michael triana. That's okay. Got Daria Lorenzo Astros first bowman Luis Rodriguez Jason Dominguez His last name is pig. That's good to know Eric. I'm glad I know that now I'm gonna impress people when I say that now. They're like, oh wow, I know so much.  I just Pay attention sometimes Mariners who we are Rodriguez Pacheco Bobby Whitt there he is And brailin minyay or minier for the reds Blue jays Esteven Machado South frailic Salinas base there for the Padres and Ian Lewis Marlins Brewers Jeremy Vargas Ray's Curtis Mead There we go base mead first bowman Soderstrom and Yankees Oswaldo Cabrera Let's keep it going Whoa, how do I get so out of focus there? Is that all now it's That was like when you're a kid you pick up your grandparents glasses and put them on and you're like gives you an instant headache Got brewers uh first bowman brannily brannily Yoraba there's a luciano and an aqua for the brewer south frailic to 55 Nice one brew crew and redsox and word olopez Austin martin pirates first bowman auto matt fraser A sapphire Yankees trace Sweeney And angels at your caro angels denser guzman Torkelson vertigo for the cubs first bowman shale and polonco blu raw james wood Padres Alan serda for the uh reds and jose rodriguez rangers Pacheco vene Dario Lorenzo houston blaze jordan redsox Salinas again for the Padres Jayrod mariners Jay dom Yankees and triana for the reds mckell triana solder strum machado for the blue jays frailic mignet presciato brewers first bowman jeremy vargas Ray's Curtis mead and bobby wit jr again All right three boxes in let's check our spots here Three to go guys on the dual case. That's awesome. That's it three to go Only six total spots for flawless football tonight left Um noir So just the bulls left in noir case 28 bulls and nets in 29 guys spots are feeling quick Persials have been full since before he went live Mets rubber domingas first bowman Couser adel amador reds christian roa Mitchell nice ray sapphire auto curtis mead Sick hit rays Get that mags for you.  Let's go Pad parasha for the royals That is a gorgeous card that magged for your royals uh missail gonzalez white sox first bowman and redolfo nolasko pirates got victor labrata mariners fidiel montero yankees dustin harris rangers and eddie's lennard dodgers Peyton wilson royals cassis lennon sosa white sox and will lagner houston Hernandez martinez ed Howard Pedro panetta. Oh, there's an averson artega for the giant's first bowman Benny montgomery nor have arrow white sox Miss Peyton wilson I said pad parasha That's what I said Royals god jackson choreo first bowman brewers green first bowman auto reds monster head matt mclean boom What a break That is huge Funny enough. I have not pulled A single matt mclean out of bowman hobby or jumbo That's huge Reds Who's got them neoya big congrats neoya beautiful matt mclean got compost for the tigers I mean, there's still five boxes after this one. So I'm sure you'll you'll hit some There's a deli crew deli crews for the reds now. Goodness gracious Uh, Ramos matos and auto lopez pirates or darryl lopez auto lopez is a current rookie for a different team auto lopez It's a different rookie Uh red sox brian bayo Miss sailor bena cleveland franal dewey first bowman and sugestay for the giants god braves luke waddell marlins brady allen avley rushman and darren baker dusty sun Walker davis john kenzie noel cleveland first bowman red sox edwardo lopez Brantlyn you're rob a first bowman. There's a red coming up This is getting crazy got marco luciano giants Got red reds j allen 2010.  What's going on here a third one pirates matt fraser This is fun you guys every break should be like this Ricio Rodriguez first bowman white sox missail ganzales And pirates were dolphin olasco Salas white sox elijah tatsis again Pirate uh not pirates philly. Simon was yachty dodgers eddies lennard Yankees fidel muntero rangers dustin harris Rockies robbie martin jr. And astros will wagner or vil Wagner is what uh I feel like saying every time I see his name quiten Cool quip. All right. What's gonna happen in this box now got royals payton wilson Casas, there's a lemon sosa for the white sox and pager panetta a's martinez Howard benny montgomery nor hey vera white sox first bowman Aguero Giants averson artega first bowman 13 and a half Frankie garoto compost pirates or frank Is it frankie or just frank? We got some orange coming up. You got kevin alcantara broovers first bowman is jackson choreo Orange first bowman for the reds Of course had to be the reds. I'm mckeltree on at a 50 Oh my god reds first bowman darro lopez pirates Yeah, there's a few decent names. We haven't seen yet Seeing a lot of the same runs here ramos matos cubs first bowman auto louise verdugo There you go sapphire base sugestay pirates first bowman Oh, okay. Got it frank. Yeah, I know I don't know. Sam's not here. So I don't know how many twin escragers we'll hit Uh cleveland fran al-dui first bowman reds elli delacruz adley and darren baker marlin's first bowman brady allen red sox brian bayo nacellar bina and red sox edward alo pez davis john kenzie noelle cleveland first bowman luke waddell braves And angeles edgar caro Yeah, wow God yoshua garcia philly's first bowman. Yeah, send me a picture that would send the mire and harry ford Classe first bowman for the mariners aqua first bowman auto padres rebiel on helis to 99 Good stuff for the padres abrams and victor lisaraga Welby marté jose pastrano nick genzales and carlos aggy are twins aggy are pico armstrong alexander ramires junior san quentin cleveland first bowman and rafaelo for the red sox on helis first bowman padres ante de rodriguez giant's first bowman cavadas for the red sox and trash for the royals d-backs alvin guzman Jeter downs brave as mackay backstrom j. Allen to get uh, diego cartaya caddy bertha hernandez orange first bowman brewers hendry mendez 12 of 50 Brewer's had a solid break too justice thompson for the reds He has alohandro pa for the break for the rays Yelqui cespidus and jose ramos dodgers All right, let me see what spots are like before we finish up this break here noir is sold out now dual cases down to two flawless football down to one and four less than uh less than 10 total spots tonight guys and gals So here we go sterling and tribute and then after that sterling and tribute The only breaks with spots left are flawless football tiered random cases That's it Warning uh burnabelle there warming burnabelle christian gonzalez ashrow's first bowman auto Nice one stroze got robert hassel marcello meyer cleol watson first bowman marlins harry ford mariners and ronnie or cantero cubs clausay for the mariners Hendrick garcia for the fillies first bowman leezer agapadres rockies warming burnabelle nongo marlins cleol watson again abrams akunia baity and aqua for the a's tyler sodar strum one of 55 carlos aggy arts wins first bowman giants diego rinconis fillies logan sterney redsox sedane raffaella and royals lucatres rubers hendry mendez blue jays martin jimenez orials darrell ornaise j alan cardinals joshua bayez blue jay samad taylor auto royals lucatres first bowman two autos in the pox nice hit royals royals do it crush to break before that macai backstrom braves In one last box. Good luck everybody. Thank you very much for filling these sapphire breaks up We've got one more 10 boxer after this We nearly sold out tonight. Persials have been full since before we went live at five eastern guys They're probably full Before I even showed up today.  Yeah, giant saverson artega christian hernandez or Elvis martinez nor have arrow white socks first bowman I don't know what it is, but it might be the car design, but this sapphire looks better than previous sapphires Brewer's jackson choreo first bowman Aguero, benny, montgomery. Yeah, right nick, right? Exactly tell the crews for the reds Elliot Ramos, Luis Matos, Roberto Campos, first bowman tigers, Urbina, Aldui for cleveland Dario Lopez pirates, andrian sugestay giants marlins brady allen red socks brian bayo Aqua marlins ian lewis first bowman of 55 There you go fish daren baker nationals davis cleveland junkenzie noel first bowman braves luke waddell and adley on the back What a recap we're about to see so this is um Autos and color right next time we'll do it. Okay Got uh autos here tyler wittaker astros royals lucatresh Astros christian Gonzalez aqua on helis for the Padres Cubs louis for dugot white socks benyman bailey pirates matt fraser Orioles daryl arnais Brewer's felix valerio And everything else is in a mag We had a red zeid salinas to 10 for the Padres Kurtis mead first bowman auto base sapphire rays Green first bowman auto reds matt mclean It's a 50 big hit reds red for the reds jay allen to of 10 red jose ramos dodgers four of 10 And pad parasha one of one royals patin wilson What a break Beautiful pad parasha that's gonna do it another one of those coming up next guys


Welcome to this brief introduction to Arena 3D and Cytoscape. Arena 3D, or Arena 3D Web as it's correctly called, is a tool for 3D network visualization of multi-layer networks such as this. In these networks you have multiple node types generally placed in separate layers, which makes multi-layer networks suitable for visualization of multi-omics data. However, one of the main challenges of making such visualizations is that Arena 3D requires quite a lot of data preparation before you can do the visualization and this typically requires scripting skills of the user. If you want to learn more about the Arena 3D tool, I've already covered that in an earlier presentation. Cytoscape, on the other hand, is a tool for 2D network visualization. It has a graphical user interface that allows you to import data and easily map these to visual properties such as colors. If you want to learn more about the Cytoscape platform, I've also covered that in an earlier presentation. Furthermore, Cytoscape has an ecosystem of hundreds of apps, which allow you to add all kinds of different functionality. One of these is the Cytoscape string app, which allows you to easily import string networks into Cytoscape. And it will therefore be really convenient if there was an easy way to take Cytoscape networks and pass them on to Arena 3D. And that is precisely what the new Arena 3D web app does. It's a Cytoscape app that you install from the App Store, which allows you to send networks from Cytoscape to Arena 3D. This allows you to build a network inside Cytoscape like the one you see on the left and send it to Arena 3D visualizing it the way you see on the right. The user interface of the app is very simple and mainly consists of this dialogue. The key thing you need to do in this dialogue is to define the layers. You do this by selecting a node column from the node tab in Cytoscape and each unique value from this column will become a separate layer in Arena 3D. Moreover, the app retains as many of the visual properties as possible from Cytoscape in Arena 3D. This means that you can import a network into Cytoscape, import your omics data, visualize the data on the network, for example by coloring the nodes and then do all of this within Cytoscape before passing it on to Arena 3D. The second half of the equation is the Arena 3D web API. This is what the app talks to. When you send a network from Cytoscape, it is received by Arena 3D web through its API. Afterwards, a default 3D layout is applied. However, you can use the web-based interface to adjust the 3D layout of the layers relative to each other and apply a 2D layout to each layer. That way you can create multi-layer network figures like the one shown here. This is all I have today about how you can visualize networks from Cytoscape in Arena 3D web. If you want to learn more about how to visualize networks in 3D, take a look at this presentation next. Thanks for your attention.


okay so now let's start the practical part and implementation of previously analyzed project so and we will use stn32 cube id tool for that so let me start my cube ibte so it is here and the first action is to start the project so new then stn32 project it will take a time it seems okay so now we can select our target just by entering the part number stn42 i mean the microcontroller on the top of the nuclear board stn32 l 476 rg and indeed here you can see the related comment of the associated board it is nuclear l 476 rg so let's highlight this microcontroller and then press next so next step is to add a project name stn32 l 476 atc let's say inter interrift and i select different than default location so maybe here and give me a moment please okay idc interlift it is here and let's say this sub folder of course you are free to select any sub folder for the project okay and finish so again we need to wait for the project creation okay so we have the project is opened now and let's start configuration of our project maybe the first step is to enable the debug lines so system core item and then sysperipherial and within debug selection let's select serial wire so here you can see pa14 pa14 lines to be active the lines are in green color okay then we need to add some debug output to our mcu application and the most maybe not the most but quite useful channel for that is the uart we have usert 2 or uart 2 so i'm selecting the asenhanos mode for usert 2 connected on nuclear board to the stlink debugger and one of the feature of the stlink debugger it is a virtual comport so we can redirect data from pins pa2 pa3 acting as a uart rx and tx uart 2 rx and tx to the virtual comport and this way we can observe data on the pc using any terminal let's keep the default parameters so 115 kilobits per second 8 bits character length without parity and one stop bit okay so we have debug pins for the debugger we have debug pins in order to redirect the printf output data stream then let's focus on the core activity of our application so the adc and configuration of the analog to digital converters yeah but it would be practical to select the particular pin of the nuclear board please remember we are going to use fast channels of the adc so let's see where are the fast channels in the datasheet so this is the datasheet here maybe i will magnify fast channels are pc0 pc1 pc2 pc3 and pa0 then we can go to the nuclear 64 description this is user manual 1724 you can also find this drawing this figure within the blister of the nuclear board let's say pa0 pa0 is here so let's use let's use pa0 pin for our application it is connected to pin number one of cn8 or it is connected to pin number 28 of cn7 so pa0 where is pa0 here it is here and it is indeed connected to the adc1 input 5 and adc2 input 5 because in order to perform the dual adc dual mode interleaved mode in particular we need to connect both adcs input to the same pin okay so adc1 let's select in 5 as a single-ended so pa0 pin is in green and adc2 in 5 single-ended okay so now pa0 is connected to the input 5 of adc1 and adc2 let's come back to the adc1 acting as a master adc so i can modify the screen a little bit okay so in 5 is activated let's start from the parameter setting tab and from the mode setting we want to configure the dual interleaved mode only here we want to have dma access so dma access enabled delay between two sampling phases it is three clock adc clock cycles clock press color that's the important point we want to connect we want to use the highest possible adc clock so synchronous clock mode divided by one but let's see what is the synchronous clock value so please switch to the clock configuration and we can see the system clock hclk is set to four megahertz while the maximum value it is 80 megahertz so let's change it just by entering here 80 megahertz and to automatically calculate the new settings okay so the new hclk and cclk clock value is set so we have msi as a input or base frequency for a pll unit here and 80 megahertz as a result okay then let's come back to the adc settings so we have 80 megahertz synchronous clock connected to the adc peripheral resolution 12 bits it is okay continuous conversion mode let's enable this because we need to or we want to continuously convert sample by sample as quick as possible then also we need to enable the dma continuous requests but it is currently impossible why because we need to configure the dma so let's add a channel and please remember we are going to use common data register so the data with is word the data size is instead of the half word the data size should be word and let's keep mode as a normal it is equivalent of single shot so the transfer stops when the buffer will be full the other option is a circular mode okay so let's come back to the parameter settings and enable dma continuous requests let's keep external trigger conversion source as a software and let's configure our rank so it is channel 5 but sampling time must be set to 6.5 adc clock cycles okay that's all regarding adc one and so it is our master so regarding adc two acting as a slave it is already set as dual interleaved mode dma access mode enabled delay between two sampling phases is three cycles synchronous clock is divided by one so that's okay continuous conversion enabled dma continuous request disabled because we don't have dma channel assigned to adc two we have common data register the only action on our side it is to configure the rank properly and we need the same sampling mode period so 6.5 clock cycles and that's all we can generate the source code okay and let's start our coding we are going to use printf function in order to send out to print out the user interface debug data the application so let's include the standard io file and as you remember when we are using kubemix to generate the source code it is good practice or i would say it is a must to put your user code between the code sections otherwise the the code will be deleted in case of regeneration of the source code so for the include the relevant section is here okay the next point it is to define the adc buffer size so the definition private define is here sorry and let's put here 20 why 20 because we want to acquire 40 samples we have interleaved mode so every transfer from the common data register means transfer of two adc's data register so in fact every item of the adc buffer consists of two results so we need to multiply 20 by 2 and then we get 40 items of the adc buffer okay we can save this then let's define the variables the user variables and the relevant section is here user code begin pv private variables so we have flag adc flag this flag will be active just after the end of dual conversion so just after the end of conversion of slave adc and this flag will be set within the dma and of transfer callback and the default value is of course reset then and it is volatile because it will be modified within interact callback the same for the variable i we need some index variable and we need the adc buffer okay the next point is to overwrite the default write function let's do it within the user code begin 0 section in fact this override of write underscore write function allows us to redirect the printf output data stream to the uart number two here okay next step it is important and it is practical hint for you that really first action when you are using adc on the top of stn32 microcontroller it is to calibrate the adc we have two adcs so we need to calibrate adc1 and adc2 we have single ended inputs for both then we can start our adc conversion and the api for that it is hull adc ex because ex means extended because this function is related to the l4 family the implementation of this function is related to l4 family multimode start multimode means that we are using more than one adc while the adc1 is a master adc so we need to point the master adc the buffer and the buffer size the next action is to enable the multi dma mode and configure this mode as a one shot here so the parameters are adc1 to 3 common it informs the function that we need we are using the common data register at 12 or 10 bits resolution then the next action it is to disable half transfer complete of dma interrupt this is quite practical hint for you when dma is active in hull library we have automatically enabled two interrupts dma transfer complete and dma hull transfer complete in our case we would like to increase the performance of our application and there is no need for half transfer complete dma from our application point of view we don't have dual buffer solution it is simple application so it makes sense to disable the enabled by default half transfer dma complete interrupt and this way save time increase the performance of application so the only interrupt from dma side we need it is the dma transfer complete okay and then we can add some welcome string like application started and that's all and this is all the activity before the main loop calibration of the adc start of dual mode or multi mode adc conversion configuration of the dma transfer so the n dma mode we are using single dma channel transferring data from common data register of adc in one shot mode some practical approach disable of half transfer complete dma interrupt in order to increase the application performance and then welcome string so let's implement main loop so i will copy all the main loop it is quite simple and it is good practice to put the main loop within the user code section number three as you can see it is between the brackets okay while one loop okay so what is behind if adc flag so it means when adc conversion is finished we are printing some separation string then we are printing out the adc buffer having in mind that lsb part of the world it is a master adc data register and msb part of the world it is a slave adc data register if you come back to the adc ex multi mode start dma api and this buffer adc buffer you can see that it is u in 32 type buffer so we have words in the buffer because of command data register so we are printing out the content of the adc buffer having in mind the organization of the command data register of adc then we are toggling the led and then we can reset back the adc flag and restart the dma multi mode adc conversion configure the mdma mode and disable the half transfer complete it seems i forgot to enable the gpio pin for the led so i can do it and this way i can show you how to regenerate the source code but before let's finish our main dot c modifications so here is the adc flag variable to be analyzed but we didn't modify this variable yet within the source code let's do it now and as i mentioned in the beginning this variable is modified within the callback so that i put i have just put the callback within the user code section number four this is the callback of the dma adc dma transfer complete and thanks to how dma transfer complete interrupt is linked to the adc conversion complete callback this is the power of the hardware abstraction layer and library so the only action here is to set the adc flag that's all okay so we can save and then let's come back to the our cuba mix and configure the relevant pin it is pa5 for the gpio before the led so i need to set gpio output and then regenerate the source code and thanks to the fact that i have put all my source code within the related source code sections i can still see my source code after regeneration so this is for example the callback just edit this is the main loop here and the user code section one more comment here so here you can see the alternative solution for the app of line so you can use ll api in order to configure the multimode dma or you can just write directly to the register using the related data structure but let's keep the low layer library this is equivalent so let's try to build our application okay and now we can start the back session and in the meantime i will open the terminal once again let's start the back session okay so application just build it then we can start the back session it is just finished download verified successfully so we can close the debug session because we are going to use terminal only in order to debug our application so this is terra term let's modify the settings starting from the font size to maximize the window and then let's change the serial port border to 115 okay okay we need to establish a connection first looking for the sd microelectronics virtual comport label here yeah so it is working now but it seems we need to maximize the size of the window in order to see all the buffer so that's it was the reason for the for for the separation string here just to separate following acquisitions okay so we can see some noise external noise voltage i will try to start the signal generator now this is the application to control the signal generation on my side so it is sinus output signal 500 kilohertz so the period is two microseconds amplitude is 1.5 volts offset is 1.5 volts so we have signal starting from zero up to three volts so let's start and see the terminal output so something has changed maybe let's stop the session and copy the data to the scratchpad so control c and now let's open the excel at paste data to the excel okay and then we can try to insert the chart okay and we see very nice sinus chart so it is working it is working i'm going to come back for a moment to the slides and show you the analyze of this sinus chart because this is exactly the same here as you remember the output data rate or something data rate the equivalent one for the interleaved mode it is eight mega samples per second what means 16 samples for two microseconds because for eight mega samples per second we have 125 nanoseconds per sample if we would divide the period of the 500 kilohertz which is two microseconds by the sampling period we will get 16 samples for the period so here we have 16 samples and just one period of the signal so thank you for your attention


Hello, and welcome back here to the channel. I'm evil rabbit and we are in a vdc lobby on ESda long beach for something a little different So one of my streamers that I watched who plays call of duty does what's called spectating warzone solos So I decided let's do a new series here Let's hop into a set of Corsa and spectate random drivers And we could do that with this whole box cab situation that I have going on so we get some cool views So make sure you guys follow me and also should meet all just found the description box below and let's get to it Kill lateral so we're first taking up at kill lateral so he is chasing down so we're gonna spectate him for a little bit We could change up cameras and things like that with this nice hard Initiation kind of a little bit far back with switch to track cam here Kind of trying to suck up the door a little shallow, but he's still there that 180 definitely looks amazing Trying to chase down that the lead e92 so like I said, it's definitely a very cool idea of doing this If you guys want to see more spectating random lobbies Let me know down in the comment section down below because I would enjoy doing this getting to see other people drive and Stuff like that. It's definitely fun. Now. We're on fly box hard initiation by fly box go track camera getting chased down and This dude is on a solid lead run in that s14. Oh, yeah, this guy's the Definitely the sweat in the lobby so far. So we're gonna take a look at it from a chase cam So we are walking the box cam style where I have chase cab track cams I have the box cam style as well as spine camera. I'm not too sure what spine camera is Or supply camera, but we're gonna we're gonna watch it. Oh, I think it's just tracks there All right, so we're gonna go back to track camera See him initiate in trying to follow in. Oh And then you know, it's like it was hard into the wall I want to watch him get a good solid run because he seemed like he was definitely one of the Better drivers to the far we're gonna watch a bunch of other drivers So we do have a safe preset for the chase camera in here and we are on This man fly box looks like he's got one of the I think it was TSK about to chase him down Hard full week initiation by fly box all too much sauce So we're gonna switch it up to it looks like D.M. DSM shock Trying to chase down that e92 So it's like a different style of video But something that I feel is very fun to do jump into random lobbies and watch random drivers It was TSF TSF kid drifter So we got DSM shock that we are watching now if it's butchers anyways names I do apologize. So if you guys are watching this and you guys see and I'm spectating you and I butcher your name. I do apologize people keep hitting me. I feel my wheel twitching So it looks like DSM shock is waiting for somebody. Oh, it looks like he's gonna take a lead run. All right He's gonna take a roll-through lead with that E are with a a 90 behind him Japanese driver vs. American driver hard flick initiation.  So let's see who else we got in the lobby We're gonna rotate through cars here Looks like we got a geo among us Geo among us Jew among us we among us All right, we'll take it we'll pull up the track cam actually we're gonna go with box cam style for this one See if we can't get a cool cinematic style of Geo among us looks like initiating hard in Nice on that clip really deep into that wall got this other S14 right in his door That's deep and shook and looks we got the 180 behind and a very solid run by Geo among us All right among us that was a I'll give you that that was a very solid lead run For you my guy. So let's see if we can't get another good Maybe a chase run from him. So like I said, you guys want to see more styles of this random Spectating of random a set of course the lobbies. Let me know down in the comment section down below It's definitely something fun that I feel I would enjoy doing and bringing a full series for it Looks like we are gonna get a chance to get a chase run from Geo among us. Maybe not. Oh Yeah, we will get against killer all Later all definitely was a solid armor. We're spectating him. So let's see what we can get against Geo among us in the chase Nice and tight on him. Both of them come away deep in the zone Oh wall tap for Geo among us and he just right turqued it into the wall. Oh Rip to that man's car That was unfortunate. So let's see what other cars we got to spectate In this lobby, we have not spectated Cotty the cross yet So we got Cotty the cross here Want to try this spline camera? We can get a chance.  All right. Oh I think I think that man just DC'd Or the lobby didn't reset. I think that man just DC'd or the lobby did reset. Oh Rip the lobby had connection issues Go figure we will back once we connect back to the lobby. So we are gonna get a chance to watch Cotty the cross chased down Geo among us. Go figure we tried to do this Spectating we had a connection issue. It looked like the server did reset. So Kind of cross try to initiate in behind Geo among us Kind of cutting that inside clip Geo among us almost writing it off But kind of the cross definitely able to hold a little bit trying to work that FDR Seven up to the door that s14 Definitely a very solid run. So we got a lot of cars coming back into the lobby So we got Geo among us to try and catch some people that we didn't we're gonna take a look at the lead from Cotty the cross So like I said spectating random Tandems and random Lobbies here to set a course that definitely something fun. All right Hard flick kind of missing that zone nice About made in that zone. All right cross all and into the wall. He goes Unfortunate that man just ripped it into the wall. So we got frowned side, but he's in the M2 this time So let's see if we can't maybe get a good solid chase and you have to it gets Script X we didn't watch script X. We will take a look at the script X in this run. Oh Oh Yep He dead. He's definitely dead. Let's try and find script X here spectate script X here before we add this spec first spectating video. Oh, we do also have Kid Drifter and Madonna We got to find a script X though Nope, that's not script X. That's not script X. That's me. We're not running One problem about trying to find There it is. There's script X in the A90 Supra nice hard flicks from script X Really deep in that zone. Oh a little hesitation on there But nice and smooth on that inner clip. So definitely gonna see him go against somebody.  It's fine. He was run our solo run. We'll watch it We'll watch it from the box cam style It's trying to back up in the camera. He saw the cameras there. Oh, he's gonna grab DSM shook on his back bumper box cam style here to finish this episode off So make sure you guys follow me and also to meet all the sponsors bucks below spectating oh script X into a wall on Turn one So if you guys liked this spectating a set of course up random attendance Let me know down in the comments section down below because I'm actually enjoying watching this and watching to get people And seeing how everybody drives. So we are going to get another Looks like lead run from script X. Hopefully he can Put this one together and not smack it hard into the wall Little bit of a late hesitation on initiation, but probably a little check for the wall hit. Oh Script X shutting her down So that's gonna do it here for this episode here on a set of course up And a big thank you for you guys coming back and watching and all these guys driving here in this random lobby They have no idea that I'm watching which I think makes this the best So make sure you follow me and all social media all it's found in the description box below as always I thank you guys for coming back and watching. I'm evil rabbit. I'll see you guys on the track