natverse / nat

NeuroAnatomy Toolbox: An R package for the (3D) visualisation and analysis of biological image data, especially tracings of single neurons.
https://natverse.org/nat/
64 stars 28 forks source link

[add] print method for neuronlistz #468

Closed dokato closed 3 years ago

dokato commented 3 years ago

Addresses #466 .

I simplified so it doesn't call expensive contents.classes <- sapply(x, firstclass, USE.NAMES = F).

Artefact, we don't print the information about neuron types.

> nzmv
'neuronlistz' containing 3000 neurons objects and 'data.frame' with 1 vars [998 kB]

Benchmark on 3000 neurons:

# old
> system.time(print(nzmv))
'neuronlistz' containing 3000 'neuprintneuron' objects and 'data.frame' with 1 vars [998 kB]
   user  system elapsed 
 16.702   1.805  19.000 
# new
> system.time(print(nzmv))
'neuronlistz' containing 3000 neurons objects and 'data.frame' with 1 vars [998 kB]
   user  system elapsed 
  0.000   0.000   0.001 

Alternatively, we can add another rds that stores that info in zip? WDYT @jefferis ?

coveralls commented 3 years ago

Coverage Status

Coverage increased (+0.04%) to 81.425% when pulling 0bc9ef3b14aa44a10be80abe188c1a756b3422cd on dokato:printneuronlistz into 88507a819c2b4b4f16ada74a79560abc4d260fc5 on natverse:master.

jefferis commented 3 years ago

Thanks @dokato. This is good, but can you add the path to the zip file and its size on disk to the displayed information and make it clear that the currently printed size is just for the portion in memory?

dokato commented 3 years ago

Is message like this okay?

'neuronlistz' containing 3000 neurons objects and 'data.frame' with 1 vars.
Neurons loaded on demand from 'testz.zip' [93.1 MB]. Currently in memory: 998 kB.
jefferis commented 3 years ago

Thanks! How about:

'neuronlistz' containing 3000 neurons objects and 'data.frame' with 1 vars [998 kB in RAM].
Loaded on demand from '/x/y/z/testz.zip' [93.1 MB on disk].
dokato commented 3 years ago

Sure, done!

jefferis commented 3 years ago

Thanks again @dokato!