Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
motedek
Oct 9, 2012

cinci zoo sniper posted:

thread opinions on r pipes? phone posting so no decent example but it's basically replacing

a = 1
c = d(a)
e = f(c)

with

a = 1
e = a > d() > f()

the things about R that make this particularly good are 1) lots of interactive use, so you can just keep stacking piped operations until you get what you want 2) a large fraction of R code has the form
code:
 
df <- read.csv(whatever)
df2 <- do.thing(df)
df3 <- fix.rows(df2) 
which can be much cleaner as a pipeline using well-designed data frame functions (dplyr)

Adbot
ADBOT LOVES YOU

motedek
Oct 9, 2012
oops

cinci zoo sniper
Mar 15, 2013




yeah i do chain pipes for data processing. was just wondering if there are any conventions or something about this since loving up coding as much as i do i cant be sure about anything i stumble upon on my own

another operator i find cool is magrittr's %<>% so you can do stuff like
code:
df$col %<>% factor()
but i try to avoid it unless it really is some one off thing i cant throw coherently elsewhere. it also has an amusing abstract

quote:

The magrittr (to be pronounced with a sophisticated french accent)

Corla Plankun
May 8, 2007

improve the lives of everyone

cinci zoo sniper posted:

terrible programmer question of the evening:

in python, i have for loops that do things, and for some of them i've set

code:
print "."
so its not all dead all the time. during heavier tasks though it just dies and then shits out a wall of dots once done. that's just python, or anything i can do about it without something ridiculous like printing on a different thread?

if you're doing that as a primitive progress bar you should switch to tqdm: https://pypi.python.org/pypi/tqdm

it is way easier and conveys more info

HoboMan
Nov 4, 2010

tef posted:

this is literally what i said

to be fair tef, i do find your point gets lost in :words: pretty frequently

cinci zoo sniper
Mar 15, 2013




Corla Plankun posted:

if you're doing that as a primitive progress bar you should switch to tqdm: https://pypi.python.org/pypi/tqdm

it is way easier and conveys more info

this is much better, thanks! i use it as a large printing operation progress bar indeed, and they all are for loops at the base so the "implementation" will be a breeze

motedek
Oct 9, 2012

cinci zoo sniper posted:

yeah i do chain pipes for data processing. was just wondering if there are any conventions or something about this since loving up coding as much as i do i cant be sure about anything i stumble upon on my own

another operator i find cool is magrittr's %<>% so you can do stuff like
code:
df$col %<>% factor()
but i try to avoid it unless it really is some one off thing i cant throw coherently elsewhere. it also has an amusing abstract

the only convention we have is to try to factor out all the logic into nice clean functions so the actual pipe is just a series of functions. i didn't know about in-place mutation with magrittr.

cinci zoo sniper
Mar 15, 2013




onwards to other python questions. any one here with specifically bad python 2->3 migration ? ive been sitting on 2.7 for while on this computational project, and 3.x seemed meh, but it feels like its slowly getting there so i might consider porting it at a later stage

cinci zoo sniper
Mar 15, 2013




motedek posted:

the only convention we have is to try to factor out all the logic into nice clean functions so the actual pipe is just a series of functions. i didn't know about in-place mutation with magrittr.

then i'm up to speed, with singular function calls per line of pipe where possible

Workaday Wizard
Oct 23, 2009

by Pragmatica
is revulsion a normal reaction to seeing R code?

motedek
Oct 9, 2012
absolutely

gonadic io
Feb 16, 2011

>>=

Shinku ABOOKEN posted:

is revulsion a normal reaction to seeing R code?

What do you think it stands for?

It's entire premise is a free matlab, and matlab is poo poo sooo

fritz
Jul 26, 2003

gonadic io posted:

It's entire premise is a free matlab,

that's octave

quote:

and matlab is poo poo sooo


truth.

cinci zoo sniper
Mar 15, 2013




gonadic io posted:

What do you think it stands for?

It's entire premise is a free matlab, and matlab is poo poo sooo

it's a better s

Luigi Thirty
Apr 30, 2006

Emergency confection port.

tigerbrew emacs doesn't build on my imac for some reason and i'm mad

cinci zoo sniper
Mar 15, 2013




i just set up a virtual environment. in a virtual environment. please don't ask anything.

HoboMan
Nov 4, 2010

ok i am real stumped here: i have a sql stored procedure that takes 15 minutes to run if i call it, BUT if i just copy the guts out and run it as a freestanding query it comes back in less than a second (with the same data both times)

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

HoboMan posted:

ok i am real stumped here: i have a sql stored procedure that takes 15 minutes to run if i call it, BUT if i just copy the guts out and run it as a freestanding query it comes back in less than a second (with the same data both times)

mssql, right? check if the execution plans are the same.

also make sure there isn't any type conversion fuckery. like maybe one parameter is an integer and you type it out as such in the query but the sproc treats it as a string (i've seen a report go from seconds to 2+ hours for that reason)

tef
May 30, 2004

-> some l-system crap ->

HoboMan posted:

to be fair tef, i do find your point gets lost in :words: pretty frequently

nerds: ugh you can't say that, what do you mean by that

nerds: ugh you write too many words


the only thing nerds want to read is cheap burns on tech they don't like and gloss over the moment they have to parse a text

AWWNAW
Dec 30, 2008

tef posted:

nerds: ugh you can't say that, what do you mean by that

nerds: ugh you write too many words


the only thing nerds want to read is cheap burns on tech they don't like and gloss over the moment they have to parse a text

it was a good post

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

cinci zoo sniper posted:

onwards to other python questions. any one here with specifically bad python 2->3 migration ? ive been sitting on 2.7 for while on this computational project, and 3.x seemed meh, but it feels like its slowly getting there so i might consider porting it at a later stage

Python 3 owns if for no other reason than the simplification and improvement of coroutines and generators to make them more chainable. you've posted a lot about workloads that are large datasets without I think a lot of internal relations. coroutines are really good for that because you can do the work piecemeal and lazily by structuring things with generators - think putting a 'yield value' in every for loop iteration and chaining them arbitrarily. and in 3.5 you can even make them async for IO bound workloads! neat.

that said 2to3 really runs into trouble with third party library calls, especially around string or bytestring handling because of the Unicode thing.

best advice is just say, I'm going to spend today running 2to3 on my code and going down the rabbit hole of what breaks. after spending a day on it you'll at least know how significant the breakage is and how much time you'll have to spend to fix it

JewKiller 3000
Nov 28, 2006

by Lowtax

tef posted:

nerds: ugh you can't say that, what do you mean by that

nerds: ugh you write too many words


the only thing nerds want to read is cheap burns on tech they don't like and gloss over the moment they have to parse a text

it's not the number of words, it's the tone of condescension, as though you're revealing deep truths instead of common knowledge in purple prose

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

JewKiller 3000 posted:

it's not the number of words, it's the tone of condescension, as though you're revealing deep truths instead of common knowledge in purple prose

distributed systems stuff isn't common knowledge, i learned poo poo and i spent four years workign with them

having a post of realtalk that cuts through jargon and trends is good

Luigi Thirty
Apr 30, 2006

Emergency confection port.

all right let's see if we can figure out how to read these wacky atari analog joyst--oh dammit



:mad:

well i've sussed out how to read if the stick is pressed up so far

HoboMan
Nov 4, 2010

tef posted:

nerds: ugh you can't say that, what do you mean by that

nerds: ugh you write too many words


the only thing nerds want to read is cheap burns on tech they don't like and gloss over the moment they have to parse a text


im just using regular expressions

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Luigi Thirty posted:

all right let's see if we can figure out how to read these wacky atari analog joyst--oh dammit



:mad:

well i've sussed out how to read if the stick is pressed up so far

As far as I can tell:

- You read one of the addresses that are mapped to an analog-to-digital channel. Presumably the one corresponding to the axis you want to read...
- Ignore the value because it's probably garbage
- You get an interrupt some time later, once the ADC has actually done the conversion.
- To get the real value you ___________ the ______ which _____

cinci zoo sniper
Mar 15, 2013




Phobeste posted:

Python 3 owns if for no other reason than the simplification and improvement of coroutines and generators to make them more chainable. you've posted a lot about workloads that are large datasets without I think a lot of internal relations. coroutines are really good for that because you can do the work piecemeal and lazily by structuring things with generators - think putting a 'yield value' in every for loop iteration and chaining them arbitrarily. and in 3.5 you can even make them async for IO bound workloads! neat.

that said 2to3 really runs into trouble with third party library calls, especially around string or bytestring handling because of the Unicode thing.

best advice is just say, I'm going to spend today running 2to3 on my code and going down the rabbit hole of what breaks. after spending a day on it you'll at least know how significant the breakage is and how much time you'll have to spend to fix it

while lot of async and coroutines stuff flies over my head on theoretical level, the last paragraph is more less what i'm thinking. i've got a couple dozen issues open atm, and one i get them done and make sure i'm aware how things work, i'll just roll with it and see if i can unfuck problems in a week or two. thankfully i don't have many 3rd party dependancies - its numpy/scipy core/matplotlib for almost everything, and some external i/o drivers

distortion park
Apr 25, 2011


tef posted:

nerds: ugh you can't say that, what do you mean by that

nerds: ugh you write too many words


the only thing nerds want to read is cheap burns on tech they don't like and gloss over the moment they have to parse a text

I said it was a good post! I do think it sounds too much time attacking queues as direct substitutes for request response, rather than considering their drawbacks when used in a more suitable architecture. Replayability is a really powerful testing mechanism (although that's not the only use) and most persistent queues make it super easy. It's possible to do almost the same with some (most?) databases but is much harder to get right.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

tef posted:

the only thing nerds want to read is cheap burns on tech they don't like and gloss over the moment they have to parse a text

welcome to yospos

AggressivelyStupid
Jan 9, 2012

cinci zoo sniper posted:

while lot of async and coroutines stuff flies over my head on theoretical level, the last paragraph is more less what i'm thinking. i've got a couple dozen issues open atm, and one i get them done and make sure i'm aware how things work, i'll just roll with it and see if i can unfuck problems in a week or two. thankfully i don't have many 3rd party dependancies - its numpy/scipy core/matplotlib for almost everything, and some external i/o drivers

i think scipy supports 3.x out of the box so good news there

Zemyla
Aug 6, 2008

I'll take her off your hands. Pleasure doing business with you!

Luigi Thirty posted:

all right let's see if we can figure out how to read these wacky atari analog joyst--oh dammit



:mad:

well i've sussed out how to read if the stick is pressed up so far

What exactly did you find that's so faded, and can you get another copy?

cinci zoo sniper
Mar 15, 2013




AggressivelyStupid posted:

i think scipy supports 3.x out of the box so good news there

yeah they did sometime in mid 3.x push an update introducing python 3 compatibility for the stack.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Zemyla posted:

What exactly did you find that's so faded, and can you get another copy?

a scanned copy of the Atari System 1 Hardware & Operating System Description from a filing cabinet in Ireland someone raided when atari closed

I don't think I can get another copy, no

MAME to the rescue though! this is a digital joystick so if I can rig up something that reads the input port the way it expects it'll work

code:
READ16_MEMBER(atarisy1_state::joystick_r)
{
	int newval = 0xff;
	static const char *const portnames[] = { "IN0", "IN1" };

	/* digital joystick type */
	if (m_joystick_type == 1)
		newval = (ioport("IN0")->read() & (0x80 >> offset)) ? 0xf0 : 0x00;

	/* Hall-effect analog joystick */
	else if (m_joystick_type == 2)
		newval = ioport(portnames[offset & 1])->read();

	/* Road Blasters gas pedal */
	else if (m_joystick_type == 3)
		newval = ioport("IN1")->read();

	/* the A4 bit enables/disables joystick IRQs */
	m_joystick_int_enable = ((offset >> 3) & 1) ^ 1;

	/* clear any existing interrupt and set a timer for a new one */
	m_joystick_int = 0;
	m_joystick_timer->adjust(attotime::from_usec(50), newval);
	update_interrupts();

	return m_joystick_value;
}


WRITE16_MEMBER(atarisy1_state::joystick_w)
{
	/* the A4 bit enables/disables joystick IRQs */
	m_joystick_int_enable = ((offset >> 3) & 1) ^ 1;
}
:hmm:

spiritual bypass
Feb 19, 2008

Grimey Drawer
emacs update: this is pretty cool and im probably not going to renew my jetbrains subscription at this rate

fritz
Jul 26, 2003

Phobeste posted:

Python 3 owns if for no other reason than the simplification and improvement of coroutines and generators to make them more chainable. you've posted a lot about workloads that are large datasets without I think a lot of internal relations. coroutines are really good for that because you can do the work piecemeal and lazily by structuring things with generators - think putting a 'yield value' in every for loop iteration and chaining them arbitrarily. and in 3.5 you can even make them async for IO bound workloads! neat.

that said 2to3 really runs into trouble with third party library calls, especially around string or bytestring handling because of the Unicode thing.

best advice is just say, I'm going to spend today running 2to3 on my code and going down the rabbit hole of what breaks. after spending a day on it you'll at least know how significant the breakage is and how much time you'll have to spend to fix it

i bit the bullet a while ago and moved to 3, most of my work's in a repl and i majorly dislike some of the changes like "map no longer returns a list" b/c it messes with my muscle memory pretty terrilbe

tef
May 30, 2004

-> some l-system crap ->

Wheany posted:

welcome to yospos

i;m home

tef
May 30, 2004

-> some l-system crap ->

JewKiller 3000 posted:

it's not the number of words, it's the tone of condescension, as though you're revealing deep truths instead of common knowledge in purple prose

sorry i don't write like jeff atwood

tef
May 30, 2004

-> some l-system crap ->
it's a tersely written long read apparently

i can only assume americans expect smaller words and more encouragement

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

tef posted:

it's a tersely written long read apparently

i can only assume americans expect smaller words and more encouragement

it was a good post

this is also a good post

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->
it made hacker news

people then said 'he's wrong' because 'brokers do work at the edge' and 'everyone knows pubsub is not how you build work assignment'

well, everyone except the ampq vendors

  • Locked thread