« first day (2456 days earlier)      last day (2485 days later) » 
00:00 - 19:0019:00 - 00:00

12:43 AM
0
Q: How to apply an API method iteratively in chunks of n of n word tokens

tumbleweedI am making requests to an API that process text. However, it seems that this API, is truncated to a limited number of string tokens (i.e. 1000). Therefore I can not just simply apply the API to a large text blob, since my text blob which I am working with super exceeds the 1000 character limit. ...

 
 
2 hours later…
wim
3:09 AM
@DSM That would be ExitStack, and there is a backport for 2.7
pip install contextlib2
 
 
4 hours later…
6:50 AM
Late night cbg
 
7:27 AM
Morning cbg
 
cbg'ning
 
cabbage
 
Maybe no mcve? stackoverflow.com/questions/44919204/… They do try, but it is becoming a mess.
So perhaps closure would encourage in to writing a better example, or not.
 
7:42 AM
anybody used pyramid_jwd? I can't do the config. it throws:
pyramid.exceptions.ConfigurationConflictError: Conflicting configuration actions
  For: <InterfaceClass pyramid.interfaces.IAuthenticationPolicy>
    Line 29 of file /home/khajvah/orimsa/orimsa/__init__.py:
        config.set_authentication_policy(ACLAuthorizationPolicy())
    Line 32 of file /home/khajvah/orimsa/orimsa/__init__.py:
        config.set_jwt_authentication_policy('secret')
 
8:20 AM
@davidism: possible Jinja2 random() bug, so far confirmed in 2.9.5: stackoverflow.com/questions/44965271/…
Confirmed in all 2.9 releases, 2.8 doesn't exhibit the behaviour ('randomly' picking the same element every single time from a list, in the same template rendering)
 
@BhargavRao hey
 
8:51 AM
@AndyK \o
 
9:33 AM
this regex hurts my eyes, my brain, and my faith in regex users: (["'])(?:(?=(\\?))\2.)*?\1
For those who don't get it, (?=(\\?))\2 is the same thing as just (\\?).
taken from an answer with score 185 by the way
 
cbg
@Rawing you so silly, that's not regex, that's an elaborate smiley face. Just tilt your head.
 
Andras... if that looks like a face to you, you may be living among orks or aliens
 
I can neither confirm nor deny that
 
9:49 AM
This is like one of those "my hobby" xkcd comics. "My Hobby: Sending unaware people regexes and pretending they're smileys"
 
black hat guy: "my hobby: posting smileys to the [regex] tag on SO"
 
10:15 AM
Cabbage!
 
cbg
 
10:42 AM
recbg
 
10:54 AM
cbg
 
cbg @AnttiHaapala
A wall of code that will not run as presented, but OP insists it is returning (wrong) results.
 
11:50 AM
cbg
(☞゚ヮ゚)☞ ☜(゚ヮ゚☜)
 
please don't ^
cbg
 
cbg
 
12:40 PM
cbg
 
@MartijnPieters coincidentally I just merged a fix for this on Wednesday.
Although I'm not sure why the behavior changed from 2.8.
 
12:53 PM
Hi Guys! I have a question: I wrote a class that contains helper methods that don't need to work with instance data. Would you remove these from the class and place them directly in this (or another) module?
 
Sometimes I do, sometimes I decorate them with staticmethod
 
I never learned python as much more than a scripting language so I dunno I'm afraid
and I don't really know how the whole class/module thing maps onto my main OOP background of Java
maybe I should learn this stuff for python
but I am scared of dynamic typing when it comes to this kind of thing!!
 
I definitely wouldn't just leave them as ordinary instance methods if you really never touch the self object at all. But whether you make them ordinary functions or keep them where they are and make them staticmethods/classmethods, is a decision with no objectively correct answer
If you do make them regular functions I'd be inclined to keep them in the same module that the class is in though
 
I have had such an unproductive week... combination of bad sleep and low motivation I think. do you guys have weeks like this? How do you bounce back?
 
I just wait it out. I'm convinced that my cycle of productivity and unproductivity is an emergent property of my brain chemistry that's completely beyond my control.
unrelated: sbnation.com/a/17776-football/chapter-1 looks interesting but the images are loading way too slow on my work machine. Posting this so I can find it later at home.
 
1:11 PM
That makes sense. Thanks!
I think I'm going to keep them in the same module, but switch them to regular functions.
 
1:44 PM
hi
 
cbg
 
cbg
 
2:18 PM
hissssssss
 
DSM
Snake-flavoured cabbage for all!
 
cbg
 
o/
 
snake?
aaah
python
 
2:21 PM
if you can't handle me at my cbgiest you don't deserve me at my hisssssssiest
proudly stolen from
I'm starting to realize how oatmeal just doesn't fill me up anymore
am I doing it wrong or something?
I'm just never satisfied after my bowl of oatmeal.
 
DSM
If you're tired of oatmeal, you're tired of life.
 
how do you make it? are you eating less oatmeal than you used to, or eating more the rest of the day, or doing more physical activity, or fatter or stronger than you used to be?
 
I never liked oatmeal, guess I never liked life either.
 
That's the thing. I'm not tired of oatmeal....my body just stays hungry.
I use the suggested serving size of 1/3 cup
I put raisins, natural peanut butter, blueberries
 
That's good idjaw, stay hungry and use it as motivation to strive to be better :D
 
2:24 PM
you don't understand.....my hunger is directly proportional to my anger
 
Oh you're a hangry eater?
 
exactly, friend...exactly
I'm a walking snickers commercial
 
use your anger to smash the state
 
DSM
Mix it up then. I'm on an eggs and turkey-bacon kick at the moment.
 
I'm more of a sad bored eater (I get sad or bored when I'm hungry too). When I'm sad or bored I eat, but then I get sad because I ate too much and is getting fat, then I eat more since I'm sad. until I overflow and reset the process a few weeks later :P
 
2:26 PM
@DSM that sounds good! and making eggs in the morning is really fast.
how many eggs do you usually make?
 
@DSM you have to wash the pan for fried eggs or do you make it boiled?
 
you could also add apples or pears or something to your breakfast, I find they can be good for plugging a gap with minimal effort
 
@LangeHaare OH! you made me realize I forgot! I chop up half a banana in there too
 
DSM
Two large eggs and a few slices of turkey bacon. 140 + 60~90 = 200-230 calories, and much more filling than the corresponding cereal equivalent.
 
do you have any carb with that? Or is that it?
 
DSM
2:28 PM
Typically no, but I alternate, so some days it's a more carb-heavy breakfast instead.
 
is it based off of your workout schedule?
 
DSM
Nope, just that even someone as naturally habit-forming as me can get bored. :-)
 
I've always been a yogurt for breakfast person. I started buying skyr recently, which has a really high protein content. I've found it does a really good job of holding me over till lunch.
 
that is quite a low calorie breakfast isn't it? if I eat that little in the morning I end up binging in the evening
 
It's 120kcal and ~16g protein.
 
2:31 PM
120k cal?!?!?! what does the 'k' mean here? 120,000 cal ?
 
DSM
When we say "calories" we almost always really mean kcal.
 
I meant @DSM's breakfast, but 120 is even less!
 
Yeah, what DSM said.
 
Oh... why is that ? time to google I suppose
 
only tic tacs have calories in them
@MooingRawr "because 1000 has a lot of digits and US people find metric units difficult"?
 
2:32 PM
A calorie is such a small measurement that it's nigh-useless in the context of food.
 
> The large calorie or kilogram calorie (symbol: Cal), also known as the food calorie and similar names,[2] is defined in terms of the kilogram rather than the gram. It is equal to 1000 small calories or 1 kilocalorie (symbol: kcal).
 
DSM
@LangeHaare: I'm at about 1500 kcal/day at the moment, so 250-300 is as high as I want to go for breakfast, which for me only comes about 4 hours before lunch, so it doesn't need to be that big anyhow.
 
Yup, that's what I'm at as well.
I tend to eat super light for breakfast/lunch and then eat a big dinner when I get home from work. If I don't eat the big dinner, I'll snack all night.
 
DSM
So far so good, I've lost about 15 lbs over the past while, about 2-3 pounds per week, which is normal for me. Should be back to fighting trim by September.
 
Nice! That's awesome!
I'm down about 45 in the last 10 months or so.
 
2:34 PM
@DSM Ahh fair enough, I eat a lot more than that in a day
 
hair growth needs a lot of protein
 
DSM
Health tip: if you fall into and out of habits easily, don't let a sprained ankle be an excuse to stop going to the gym for a few months while not changing any of your other habits..
 
@MorganThrapp dude that's amazing. congrats
@DSM good job with the loss
 
@idjaw Thanks.
 
I need to shed 20 lbs
I'm having a hard time figuring out how to fit in the routine to get going
 
2:38 PM
Are you busy on the weekend? I started to wake up at 7 in the morning on Sat and Sun to go run for an hour... It's not much but it's a start...
 
@idjaw Pro tip, suddenly become single. You'll suddenly have a lot of extra time to spend on hitting the gym and obsessing over your calories.
 
DSM
My problem is that my intake/exercise routines are ordinarily pretty balanced. So if anything changes to break that equilibrium I don't react until it's too late. But now that I'm of A Certain Age I'm obviously going to have to take more direct control..
 
I went through a massive weight loss once and it was back when I was still at home and zero responsibility. All I did was work out
 
I am so mad at myself for writing such crap code last week that is making me suffer today
 
we all deal with past_self issues
it's the ongoing struggle
 
2:44 PM
If you ever get to the point where you look at old code and don't think "Wow, what idiot wrote that?", you've stopped improving and should be worried.
At least, that's what I tell myself to make me feel better about my terrible old code. :D
 
it's just the timeframe of it though, how was I so stupid just last week? normally takes me longer to learn enough to realise what an idiot I am/was
 
3:20 PM
According to pypinfo, jinja, the original very old version, not jinja2, had 10k downloads in the last month. Who the tomato is still using Jinja 1?!
 
whoever thinks that jinja2 is fundamentally broken
 
DSM
Someone who has it in a deps list somewhere but isn't actually using it? #wildguess
 
some company that has managers that refuses to listen to their developers and thinks the older version is stable and safe since they've heard that banks use 'legacy' systems without fully understanding what that means?
 
For reference, jinja2 was downloaded 4.5 million times last month.
I want to revive my crusade of deprecating the jinja2 name and moving versions back to the jinja name.
 
3:41 PM
in PyQt5 where is Qapplication and QSystemTrayIcon? it doesn't appear tobe in the same place it was in Pyqt4
nevermind I think I found it
 
4:00 PM
4.5 million.
wow
I'm realizing though (it is still a very large number), this number goes up with every download of jinja2, even if it is from the same domain multiple times in a given time frame right?
e.g. CI that does not use their own mirror.
 
Assuming your CI doesn't cache pip, then yes.
 
right. yeah.
 
That affects the number but not the scale or meaning of the number.
It just means if people didn't use it anymore it would see more than a 1x per project drop in downloads.
And yeah, the numbers are crazy.
github.com/ofek/pypinfo is really fun to play around with
 
is it possible to find out how many people download django 1.3 for example?
doesnt work with python 2 :(
 
^^
LOL
 
4:10 PM
but package installs without a problem
so sad a bit
 
lots of packages do that, no one checks in setup.py, and it's even harder in wheels
It is sort of weird that there's no metadata for that.
 
yeah, if an install ran unit tests while installing, I don't know how I would feel about that wait time
but, usually version support should be specified
and it is -> 3.5, 3.6 in the readme
 
Django was downloaded 1.6 million times, 1.3 was not listed.
 
i didnt say its not specified, it just installs without a problem using pip :)
 
would love to see the historical drop of that
 
4:13 PM
thanks @davidism
 
Flask was 2.6 million times.
We also have more GitHub stars, the real popularity test.
But I happen to know Django is slightly beating Flask on Heroku deploys, so we've still got some work.
 
I started to see the number of company using Flask increase in the last year or two. Before it was dominated by Django in terms of Python web.
 
It makes sense, since Flask is a lot easier to spin up for quick APIs. Django has DRF though.
 
once again I tried to pass a list to subprocess.Popen and ended up shooting myself in the foot -.-'
 
Flask its easier to start with but it takes longer to build big app, especially then building nth app
 
4:17 PM
APIStar is pretty cool, but is based on Werkzeug, Click, and Jinja2, and skips Flask.
 
learnig process for django is longer
 
Rawing, in one of your latest answer, you used reduce for the life of me I thought it was in Itertools not functools
 
@marxin I agree, I really want to see a framework on top of Flask that doesn't go quite as far as Django in dictating things but makes it easier to spin up large apps.
There's Eve, for example, but it's a bit hard to understand that it's still a Flask app underneath, it expects everything to work its way.
 
hmm
 
I know a company that swapped from Flask to Django because they were growing 'too big'... sad to see them migrate but gotta do what you gotta do.
 
4:20 PM
@MooingRawr you'd never find a function that doesn't return an iterator in itertools
 
I like how Flask is perfect for hobby style sites
 
I see flask just as stripped out django
 
That's interesting, I did the exact opposite, Django to Flask, when a project got too big. Because Django was limiting in performance and building features.
 
@Rawing which was why I was confused :(
 
guys swift is a pain to deal with
 
4:22 PM
@davidism regarding performance, any example?
 
I'm not sure on why the reason but when I was in University, my school used their service and it was Flask source code, but near the end of university, they announced they had signed majority of the university in my "state" and had swap to Django...
 
Templates and ORM are the big ones.
Now it supports Jinja, but the ORM is still mediocre compared to other options.
 
and what you use now? sqlalchemy?
 
Yeah. I think there used to be a Django extension that enabled SQLAlchemy next to Django's ORM, but it doesn't work with new versions.
 
@davidism Excellent use of Guido's time machine!
(fixing a bug before reporting is a typical Guido thing to do)
 
4:25 PM
is sqlalchemy really that faster than django orm? I thought that database call will be almost always a bottleneck anyway
 
Unfortunately I don't have full time machine privileges yet, the PR was in for a while.
@marxin it was a long time ago, but yes, in terms of the queries I had to build, it was both easier and faster in SQLAlchemy.
 
@MartijnPieters you never finished that story (or I might have missed it in the transcript) but what happen next? Did you research if butterflies have ears?
 
@MooingRawr we did, and butterflies do have ears. That they do was only discovered in 1912.
example of recent discoveries in this field: livescience.com/5814-butterfly-wing-ears-detect-birds.html
 
Wow... TIL.
 
Oh yes, seems very similar to how Lego ears work.
Our listening devices are actually the small round hat like object on the top of our heads. Granted, it is great for fitting hats on us, but its real purpose is for listening.
 
4:44 PM
cbg @everyone
 
cbg
well, this is the first user I see show up in chat with a hockey avatar
Welcome fan of the greatest sport ever.
 
cbg
 
so I was working on a huge sets of csv data time (seconds) vs some parameter like acceleration etc and ran into the occurance that cetain events over time like a rockets stage 1 separation occur at different times. so stage 1 sep could have occurred at 30 seconds here but in another mission it could have occurred at 45 seconds.
How would take the two sets of data and line them up according to the event occurance? So we can overlap the stage 1 sep on top of each other to see if they are "in family"
(also hockey IS the best sport. I play myself)
 
so you just want to line up that one event? You could take the time of that event as an offset and normalise all the other timings relative to that event?
 
yes
hmm......
could we get more specific?
 
4:55 PM
for each dataset, check the time of the stage 1 sep, call it t1, and make a new "normalised_time" field which is (normal_time - t1)
so normalised_time is the time relative to the stage 1 separation
then you can use that instead of the time field to do whatever other comparisons or whatever you're doing
 
5:07 PM
hmm....
Ok and they will align even if the points in the data set arent equidistant?
 
what do you even mean by "take the two sets of data and line them up"?
what does "lining up your data" entail?
 
like given x**2 and (x+6)**2
we see that they are exactly the same just offset
I want to line them on top of each other at a certain critical point
 
but in your case there's not just a single constant offset...right?
 
so say I make the critical points for both their mins
i dont know what you mean
 
What data type are we even talking about? I assume when you say "sets of data" you don't mean the built-in type set, because elements of a set are unordered anyway
 
5:09 PM
it will only take a single offset to line them up upon one point
 
x**2 and (x+6)**2 are identical except for a constant shift in x values
 
can you give us like a minimal example of what you have and a minimal example of what you want?
 
well it is going to be a csv of time vs something
 
what you're decribing might mean "both stuff start at t=0 but in the second case separation came 10 seconds later, so stage 1 is longer but everything else is identical"
 
(note not "time-series" but time in seconds)
 
DSM
5:11 PM
IIUC, figure out how to determine the critical points you want to align to (change in v, change in acc, change in jerk, whatever). Then transform each of your series so the corresponding series take the same duration for each region in your new T-like coordinate.
 
@LangeHaare I can show some code but I dont want to be pasting code here if that is against the rules
 
read the rules then
 
@AndrasDeak what do you mean by identical? what is identical?
@DSM the critical points are calculated so like if a gas valve drops from 100 to 0, then that is where an event occured so say it was at 76.98 seconds, then i would make that a crit point
 
I feel your problem as described is very vague. There are multiple ways to interpret it, with difficulty ranging from "trivial" to "OK, we need to think about this hard"
 
Well what else would you like to know? I will be more than happy to provide it. I apologize for poor descriptions
 
DSM
5:14 PM
Sure. Then map the time from 0->76.98 seconds to something canonical, say 0->1. Then if you have another critical point at 82 seconds, you map 76.98->82 to 1->2 or something.
 
@JulianRachman put it in a pastebin if it's longer than about 10 lines
 
@DSM I first read that as "naptime" and I was going to support that motion
 
Hmmm.. Then if I had another data set with a critical point 0->15, I would map the time, say 0 ->1 and then graph both? @DSM
 
this (highly voted, accepted) answer is useless now with the updated link dead etc? shall I flag it somehow? stackoverflow.com/a/925141/8131703
 
@LangeHaare I will just post it on my github
then link it
 
DSM
5:17 PM
@Julian: yeah, the idea is that if you want everything to align, you divide each series into sections, and then transform the times all in the same way. There's nothing special about 0-1, though, you could map the first section to 2-8.3 and the second to 8.3->1e4 or whatever you like.
 
@AndrasDeak I think he means he'll post the code he's asking about in this chat, not update the answer I linked to
 
oh crap, sorry, I completely misunderstood :D
excuse me
 
DSM
29 passed in 10.24 seconds <- time for lunch!
 
almost as good as maptime!
 
5:19 PM
grab me a snack
 
@DSM what if I want 0->4.5 to be 0->1 but 6.0->10 to be 1->2? Can I do that?
 
what's between 4.5 and 6.0?
ideally all your critical points should be individual normalized values
if there are 5 critical points -> spread them on range(1,6)
so yeah, I believe each segment should occupy a given segment
they don't have to have the same length, you can also define a typical length for each stage (if stage 1 is typically 30 seconds and stage 2 is typically 60, then stage 1 normalizes to 0->1, then stage 2 normalizes to 1->3)
then your plots won't be distorted too much in the typical case
but note that rescaling your times can introduce artifacts...so the question is what you want to do with the comparison
 
Well I mean there might not be an event between 4.5 to 6.0 so we leave it out
I was thinking maybe just look at +-10 seconds from the cirtical point
 
ah...I guess that works
 
5:23 PM
suggestion: don't from numpy import *
 
This is one of my alignment concepts but this only works for functions and not data
 
>>> len(globals())
6
>>> from numpy import *
>>> len(globals())
574
 
ya i know I just did that bc this example took me like 10 mins to do
 
OK:)
 
5:24 PM
@JulianRachman if it works for functions it should work for data...
 
this is another approach but with a defined domain for both
 
we're talking about a linear transformation of your x (t) values
 
ya but the scripts only accept equal domain distance and equidistant x values
i do like @DSM 's idea and would like to see an example or something
Im interested....
 
after a linear transformation your t values will still be equidistant
 
sorry hang on
 
5:26 PM
what "the scripts"?
 
the two files I sent you
 
okay?
 
garlic
 
what we're talking about is simply this: intead of x use (x-x.min())/(x.max()-x.min())
 
5:29 PM
sure
 
well, plus the shift using the critical point x value
davidism's right that I still have no idea what your problem really is, so perhaps you should reconsider and try to pinpoint exactly what you need specific help with
 
@JulianRachman Explain your problem clearly. See minimal, complete, and verifiable example. Or consider taking the time to write a full question since it seems you're having trouble communicating your issue in chat.
 
Ok well let me reframe
 
@LangeHaare are you planning to update the broken link?
 
also suprisingly at least @DSM understood
 
5:31 PM
that is indeed surprising
 
I have 2 sets of rocket data that are (say for now) acceleration vs time that contain non-equidistant points and do not necessarily have the same domain
do you follow so far?
 
Stop. We've heard the story. What is your specific question? "How do I align the data?" already has an answer: normalize each of your times.
 
Ok could you direct me to some examples or specific techniques?
 
@AndrasDeak sure, will do
 
@JulianRachman you mean like all the explanations they've both given you? No, we cannot do more than that.
 
5:36 PM
Well I understand what the normalization is doing but could I get directed to techniques, what functions to use, etc
 
7 mins ago, by Andras Deak
what we're talking about is simply this: intead of x use (x-x.min())/(x.max()-x.min())
Sounds pretty straightforward. If it's not, then you need to ask a specific question about a specific problem you're having.
 
ok then I will go into a more specific example. The python scripts I linked both only work with data that contains equidistant points, however the data I have does not have equidistant points. How should I fix my scripts to accommodate this?
 
@LangeHaare thanks
@JulianRachman first find the point that breaks if your data is not equidistant
@LangeHaare actually, I noticed you have <2k rep
let me know if you already submitted the edit, I'll aprove it
otherwise I can change it without a need for review
 
Ok i think it is because for the domain I have been calling linspace and arange
 
that is quite possible
in your case the domain is the data itself...so no need to linspace and arange, right?
 
5:43 PM
And instead of my code thinking in terms of my data, it thinks in terms of "points."
yes
 
do try to implement what we discussed with your real data
 
I think the definition of "specific" may not be specific enough :-)
 
and let us know if you run into further specific problems
 
cbg!
 
cbg
 
5:44 PM
well like for what I linked above it thinks in points so if I have a domain -20 to 20 with 1000 points in between and I call t1[20]
 
you don't have to explain it to me, just try to solve it first
 
@AndrasDeak submitted the edit, sorry I just submitted it and then read your message immediately afterwards!
 
@JulianRachman that was a warning. Do work on your own. Ask when you have a specific problem while doing that work, after you've thought about it for more than a couple minutes.
 
@LangeHaare nah, I should've thought of that earlier:) Contributions are good for SO!
 
"Can I get tips on the care and maintenance of my houseplant?"
"Please be specific. Is it a fern or a cactus, or something else? Care and maintenance will vary depending on your answer"
"Allow me to be more specific. My houseplant is three years old. It is sixteen inches tall. I named it 'Carl'. I bought it at Steve's Plants on 33d and Market Ave from a man named Emilio."
"That is not enough detail."
"Do you need Emilio's last name too? I can dig that up if necessary"
13
 
5:46 PM
I apologize I am just suprised that someone that wants advice get kicked meaning I am getting put on the same level as trolls, spammers, etc.
 
@LangeHaare good job fixing up the post
 
Note that nobody in my little imaginary play is a bad guy. There is merely a communication gap between two well-meaning participants.
 
@JulianRachman You're being what's called a help vampire. Read this before continuing: skidmore.edu/~pdwyer/e/eoc/help_vampire.htm
 
@AndrasDeak thanks, it was a bit of a mess!
 
Well I again apologize. I will leave and find help else where.
 
5:48 PM
does anyone know how to reverse the quad function to solve for t while knowing the output of it? Thanks.
t = math.atan(3.05*math.tan(5*math.pi/18)/2.23)
Dx = lambda t: -3.05 * np.sin(t);
Dy = lambda t: 2.23 * np.cos(t);
quad(lambda t: np.sqrt(Dx(t)**2 + Dy(t)**2), 0, t)
 
@JulianRachman "Go be a help vampire elsewhere", while solving our immediate problem, is not a very healthy outlook. Maybe try thinking about the feedback you've gotten instead.
 
@FairlyFactual "reverse the quad function" how?
 
it's starting all over again
 
long Friday
 
like you have the answer (in this case ~2.53). Is there any way to take that and put it back through the thing to solve for t?
 
5:50 PM
Oh no I have I have nothing against your decision. I just thought if I came with some work I have done and some questions they would get answered in a more thorough way. Again I apologize and I tried.
 
sounds like more of a math problem anyway, not anything specific to numpy
 
or does the module not allow for that?
 
No, imperative programming doesn't work like that.
 
Quad integrates a function numerically over a range. "reverse that" how?
 
5:52 PM
anyway, I concur, "no"
 
In general, not all functions are reversible. consider the function def f(x): return x%2. f(3) gives 1 and f(111) gives 1. If you have some unknown value q and you only know that f(q) gives 1, that is not enough information to return the complete value of q.
 
the problem here that this is not even a function
 
q could be 3 or 111 or 12345678910348745298475098274350298745 or any odd integer
 
Also, Python can't reverse it for you even if it was reversible, you have to write the reverse function.
 
it's as if you were trying to solve for x in def foo(*args): x=3
 
5:53 PM
ok
 
in other words: what would be the "t" that this "reverse" should give you in the above example? I'm genuinely curious
ah, I think I know
 
TIL - flute player in episode VI is named Droopy McCool
that is one of the greatest names ever
 
DSM
You can use functions in scipy.optimize to do the inversion. For example:
In [56]: t
Out[56]: 1.0205053551951384

In [57]: def func(x): return np.sqrt(Dx(x)**2 + Dy(x)**2)

In [58]: quad(func, 0, t)
Out[58]: (2.531419526553662, 2.8104402433655884e-14)

In [59]: q = quad(func, 0, t)[0]

In [60]: from scipy.optimize import minimize

In [61]: minimize(lambda x: abs(quad(func, 0, x)[0] - q), 1).x
Out[61]: array([ 1.02050535])
 
since i know the 3.05 and 2.23, I was thinking that the thing i would solve for would be the angle measure
 
@FairlyFactual take a look at scipy.optimize.fsolve for instance
it won't be cheap though
oh, DSM'ed
 
5:59 PM
oh thanks
i think what DSM wrote is what I need thanks!
 
and by "won't be cheap" I mean "you need to numerically integrate a function for each step of the minimization procedure"
 
that amazing feeling when you are looking for the logic that you need to extract to a new application and realize you were looking in the wrong application.
 
DSM
What Andras said about the performance. You can sometimes speed things up by constructing an interpolator on the inverse function and using that, if precision isn't always the most important thing.
 
When I said "can't" I should have qualified that as "can't efficiently".
 
6:02 PM
yeah, +1 for an interpolator
 
There's no convenient f.reverse() for arbitrary functions named f, certainly
 
incidentally, there was a post on code golf meta the other day about reversible languages: codegolf.meta.stackexchange.com/questions/13194/…
 
00:00 - 19:0019:00 - 00:00

« first day (2456 days earlier)      last day (2485 days later) »